Index: trunk/phase3/maintenance/syntaxChecker.php |
— | — | @@ -38,20 +38,12 @@ |
39 | 39 | } |
40 | 40 | |
41 | 41 | public function execute() { |
42 | | - if( !function_exists( 'parsekit_compile_file' ) ) { |
43 | | - $this->error( 'Requires PHP with parsekit', true ); |
44 | | - } |
45 | | - |
46 | 42 | $this->output( "Building file list..." ); |
47 | 43 | $this->buildFileList(); |
48 | 44 | $this->output( "done.\n" ); |
49 | 45 | |
50 | 46 | $this->output( "Checking syntax (this can take a really long time)...\n\n" ); |
51 | | - foreach( $this->mFiles as $f ) { |
52 | | - $this->checkFile( $f ); |
53 | | - } |
54 | | - $this->output( "\nDone! " . count( $this->mFiles ) . " files checked, " . |
55 | | - count( $this->mFailures ) . " failures found" ); |
| 47 | + $res = $this->checkSyntax(); |
56 | 48 | } |
57 | 49 | |
58 | 50 | /** |
— | — | @@ -88,33 +80,19 @@ |
89 | 81 | } |
90 | 82 | |
91 | 83 | /** |
92 | | - * Check a file for syntax errors. Shamelessly stolen |
93 | | - * from tools/lint.php by TimStarling |
94 | | - * |
95 | | - * @param $file String Path to a file to check for syntax errors |
| 84 | + * Check the files for syntax errors |
96 | 85 | * @return boolean |
97 | 86 | */ |
98 | | - private function checkFile( $file ) { |
99 | | - static $okErrors = array( |
100 | | - 'Redefining already defined constructor', |
101 | | - 'Assigning the return value of new by reference is deprecated', |
102 | | - ); |
103 | | - $errors = array(); |
104 | | - parsekit_compile_file( $file, $errors, PARSEKIT_SIMPLE ); |
105 | | - $ret = true; |
106 | | - if ( $errors ) { |
107 | | - foreach ( $errors as $error ) { |
108 | | - foreach ( $okErrors as $okError ) { |
109 | | - if ( substr( $error['errstr'], 0, strlen( $okError ) ) == $okError ) { |
110 | | - continue 2; |
111 | | - } |
112 | | - } |
113 | | - $ret = false; |
114 | | - $this->output( "Error in $file line {$error['lineno']}: {$error['errstr']}\n" ); |
| 87 | + private function checkSyntax() { |
| 88 | + foreach( $this->mFiles as $f ) { |
| 89 | + $res = exec( 'php -l ' . $f ); |
| 90 | + if( strpos( $res, 'No syntax errors detected' ) === false ) { |
| 91 | + $this->mFailures[] = $f; |
| 92 | + $this->error( $res . "\n" ); |
115 | 93 | } |
116 | | - $this->mFailures[ $file ] = $errors; |
117 | 94 | } |
118 | | - return $ret; |
| 95 | + $this->output( count($this->mFiles) . " files checked, " |
| 96 | + . count($this->mFailures) . " failures\n" ); |
119 | 97 | } |
120 | 98 | } |
121 | 99 | |
Property changes on: trunk/phase3/RELEASE-NOTES |
___________________________________________________________________ |
Name: svn:mergeinfo |
122 | 100 | + /branches/REL1_15/phase3/RELEASE-NOTES:51646 |