diff --git a/composer.json b/composer.json index cab86d9..a7d8041 100644 --- a/composer.json +++ b/composer.json @@ -6,6 +6,7 @@ "symfony/translation": "~2.3", "symfony/config": "~2.3", "swiftmailer/swiftmailer": "~5.0", - "guzzle/guzzle": "~3.7" + "guzzle/guzzle": "~3.7", + "nikic/php-parser": "~0.9" } } diff --git a/composer.lock b/composer.lock index e76dd3f..02726c7 100644 --- a/composer.lock +++ b/composer.lock @@ -3,7 +3,7 @@ "This file locks the dependencies of your project to a known state", "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" ], - "hash": "e9bc445899f0e8b6c7b1a68e3106d576", + "hash": "ac3725b9d9d876fb79ca80e454872995", "packages": [ { "name": "guzzle/guzzle", @@ -97,6 +97,50 @@ ], "time": "2013-10-02 20:47:00" }, + { + "name": "nikic/php-parser", + "version": "v0.9.4", + "source": { + "type": "git", + "url": "https://github.com/nikic/PHP-Parser.git", + "reference": "1e5e280ae88a27effa2ae4aa2bd088494ed8594f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/1e5e280ae88a27effa2ae4aa2bd088494ed8594f", + "reference": "1e5e280ae88a27effa2ae4aa2bd088494ed8594f", + "shasum": "" + }, + "require": { + "php": ">=5.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.9-dev" + } + }, + "autoload": { + "psr-0": { + "PHPParser": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Nikita Popov" + } + ], + "description": "A PHP parser written in PHP", + "keywords": [ + "parser", + "php" + ], + "time": "2013-08-25 17:11:40" + }, { "name": "pimple/pimple", "version": "v1.0.2", @@ -821,16 +865,16 @@ }, { "name": "twig/twig", - "version": "v1.14.0", + "version": "v1.14.1", "source": { "type": "git", "url": "https://github.com/fabpot/Twig.git", - "reference": "224fc55635d544a2ec8edb3592be18db5a093f59" + "reference": "8873d7593ad7c120004f177c0fd01459b383c9cb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/fabpot/Twig/zipball/224fc55635d544a2ec8edb3592be18db5a093f59", - "reference": "224fc55635d544a2ec8edb3592be18db5a093f59", + "url": "https://api.github.com/repos/fabpot/Twig/zipball/8873d7593ad7c120004f177c0fd01459b383c9cb", + "reference": "8873d7593ad7c120004f177c0fd01459b383c9cb", "shasum": "" }, "require": { @@ -866,7 +910,7 @@ "keywords": [ "templating" ], - "time": "2013-10-03 06:41:20" + "time": "2013-10-15 19:17:38" } ], "packages-dev": [ diff --git a/extract_strings.php b/extract_strings.php new file mode 100644 index 0000000..5cce9c1 --- /dev/null +++ b/extract_strings.php @@ -0,0 +1,26 @@ +name == 'trans') { + echo $node->args[0]->value->value."\n"; + } + } + } +} + +$file = file_get_contents('index.php'); + +$parser = new PHPParser_Parser(new PHPParser_Lexer); +$traverser = new PHPParser_NodeTraverser; +$traverser->addVisitor(new MyNodeVisitor); + +try { + $stmts = $parser->parse($file); + $stmts = $traverser->traverse($stmts); +} catch (PHPParser_Error $e) { + echo 'Parse Error: ', $e->getMessage(); +}