~ubuntu-branches/ubuntu/vivid/php-parser/vivid

« back to all changes in this revision

Viewing changes to .pc/0003-Update-help-to-match-command-in-PATH.patch/bin/php-parse.php

  • Committer: Package Import Robot
  • Author(s): David Prévot, nikic, David Prévot
  • Date: 2014-10-16 22:04:02 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20141016220402-kbqssv91y2t8ouk3
Tags: 1.0.1-1
[ nikic ]
* Disallow new without a class name
* Fix var_dump truncation with xdebug in php-parse.php
* Add ability to pass code directly to php-parse.php
* Release version 1.0.1

[ David Prévot ]
* Improve manual page generation

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/php5
2
2
<?php
3
3
 
4
 
require 'PhpParser/Autoloader.php';
5
 
PhpParser\Autoloader::register();
 
4
require 'PhpParser/bootstrap.php';
6
5
 
7
6
ini_set('xdebug.max_nesting_level', 2000);
8
7
 
9
 
/* The fancy var_dump function provided by XDebug will cut off the output way too
10
 
 * early to be of use. */
11
 
ini_set('xdebug.overload_var_dump', 0);
 
8
// Disable XDebug var_dump() output truncation
 
9
ini_set('xdebug.var_display_max_children', -1);
 
10
ini_set('xdebug.var_display_max_data', -1);
 
11
ini_set('xdebug.var_display_max_depth', -1);
12
12
 
13
13
list($operations, $files) = parseArgs($argv);
14
14
 
30
30
$traverser->addVisitor(new PhpParser\NodeVisitor\NameResolver);
31
31
 
32
32
foreach ($files as $file) {
33
 
    if (!file_exists($file)) {
34
 
        die("File $file does not exist.\n");
 
33
    if (strpos($file, '<?php') === 0) {
 
34
        $code = $file;
 
35
        echo "====> Code $code\n";
 
36
    } else {
 
37
        if (!file_exists($file)) {
 
38
            die("File $file does not exist.\n");
 
39
        }
 
40
 
 
41
        $code = file_get_contents($file);
 
42
        echo "====> File $file:\n";
35
43
    }
36
44
 
37
 
    echo "====> File $file:\n";
38
 
 
39
 
    $code = file_get_contents($file);
40
45
    try {
41
46
        $stmts = $parser->parse($code);
42
47
    } catch (PhpParser\Error $e) {
70
75
 
71
76
    php php-parse.php [operations] file1.php [file2.php ...]
72
77
 
 
78
The file arguments can also be replaced with a code string:
 
79
 
 
80
    php php-parse.php [operations] "<?php code"
 
81
 
73
82
Operations is a list of the following options (--dump by default):
74
83
 
75
84
    --dump           -d  Dump nodes using NodeDumper