Skip to content

Commit 7625990

Browse files
authored
Update extractor.rst
Make the example work out-of-the-box.
1 parent 85b126a commit 7625990

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

components/extractor.rst

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,16 @@ When the extractor is downloaded you may use it by doing the following:
1717

1818
.. code-block:: php
1919
20+
<?php
21+
2022
require "vendor/autoload.php";
2123
2224
use Translation\Extractor\Visitor\Php\Symfony as Visitor;
25+
use Translation\Extractor\FileExtractor\PHPFileExtractor;
26+
use Translation\Extractor\Extractor;
2327
2428
// Create extractor for PHP files
25-
$fileExtractor = new PHPFileExtractor()
29+
$fileExtractor = new PHPFileExtractor();
2630
2731
// Add visitors
2832
$fileExtractor->addVisitor(new Visitor\ContainerAwareTrans());
@@ -32,16 +36,17 @@ When the extractor is downloaded you may use it by doing the following:
3236
3337
// Add the file extractor to Extractor
3438
$extractor = new Extractor();
35-
$extractor->addFileExtractor($this->getPHPFileExtractor());
39+
$extractor->addFileExtractor($fileExtractor);
3640
37-
//Start extracting files
41+
// Start extracting files
3842
$sourceCollection = $extractor->extractFromDirectory('/foo/bar');
3943
4044
// Print the result
4145
foreach ($sourceCollection as $source) {
42-
echo sprintf('Key "%s" found in %s at line %d', $source->getMessage(), $source->getPath(), $source->getLine());
46+
echo sprintf('Key "%s" found in %s at line %d', $source->getMessage(), $source->getPath(), $source->getLine());
4347
}
4448
49+
4550
Architecture
4651
------------
4752

0 commit comments

Comments
 (0)