@@ -30,9 +30,9 @@ public function __construct($fullpath, $basedir)
3030class Analyzer
3131{
3232 const PHP = "php " ;
33-
33+
3434 private $ parser ;
35-
35+
3636 public function __construct ()
3737 {
3838 $ astparser = (new \PhpParser \ParserFactory )->createForNewestSupportedVersion ();
@@ -48,8 +48,8 @@ public function getFilesOfDir($context, $dir, $initialDir, &$files)
4848 if ($ filesanddirs !== false ) {
4949 foreach ($ filesanddirs as $ filedir ) {
5050 if ($ filedir !== '. ' && $ filedir !== ".. " ) {
51- $ folderorfile = $ dir. DIRECTORY_SEPARATOR . $ filedir ;
52-
51+ $ folderorfile = $ dir . DIRECTORY_SEPARATOR . $ filedir ;
52+
5353 if (is_dir ($ folderorfile )) {
5454 $ this ->getFilesOfDir ($ context , $ folderorfile , $ initialDir , $ files );
5555 } else {
@@ -87,7 +87,7 @@ public function parsePhp($context)
8787 }
8888 }
8989 } catch (\Exception $ e ) {
90- Utils::printWarning ($ context , Lang::PARSER_ERROR . $ e ->getMessage ());
90+ Utils::printWarning ($ context , Lang::PARSER_ERROR . $ e ->getMessage ());
9191 }
9292 }
9393
@@ -106,7 +106,7 @@ public function transformPhp($context, $script)
106106
107107 unset($ traverser );
108108 unset($ transformvisitor );
109-
109+
110110 /*
111111 $dumper = new \PHPCfg\Printer\Text();
112112 echo $dumper->printScript($script);
@@ -118,10 +118,10 @@ public function runFunctionAnalysis($context, $myFunc, $updatemyfile = true)
118118 {
119119 if (!is_null ($ myFunc ) && !$ myFunc ->isVisited ()) {
120120 $ myFunc ->setIsVisited (true );
121-
121+
122122 $ myFunc ->getMyCode ()->setStart (0 );
123123 $ myFunc ->getMyCode ()->setEnd (count ($ myFunc ->getMyCode ()->getCodes ()));
124-
124+
125125 $ visitoranalyzer = new \progpilot \Analysis \VisitorAnalysis ;
126126
127127 if ($ updatemyfile ) {
@@ -151,13 +151,13 @@ public function runFunctionAnalysis($context, $myFunc, $updatemyfile = true)
151151 // throw main function missing
152152 }
153153 }
154-
154+
155155 public function visitDataFlow ($ context )
156156 {
157157 // analyze
158158 if (!is_null ($ context )) {
159159 $ visitordataflow = new \progpilot \Dataflow \VisitorDataflow ();
160-
160+
161161 $ fileNameHash = hash ("sha256 " , $ context ->getCurrentMyfile ()->getName ());
162162 foreach ($ context ->getTmpFunctions () as $ myFunc ) {
163163 if (!is_null ($ myFunc )) {
@@ -175,7 +175,7 @@ public function visitDataFlow($context)
175175 $ context ->clearTmpFunctions ();
176176 }
177177 }
178-
178+
179179 public function computeDataFlowPhp ($ context )
180180 {
181181 // free memory
@@ -190,27 +190,29 @@ public function computeDataFlowPhp($context)
190190 $ script = $ this ->parsePhp ($ context );
191191
192192 $ this ->transformPhp ($ context , $ script );
193-
193+
194194 $ this ->visitDataFlow ($ context );
195195 }
196-
196+
197197 public function computeDataFlow ($ context )
198198 {
199199 $ filename = $ context ->inputs ->getFile ();
200200
201201 if (!file_exists ($ filename ) && is_null ($ context ->inputs ->getCode ())) {
202202 Utils::printWarning (
203203 $ context ,
204- Lang::FILE_DOESNT_EXIST . " ( " . Utils::encodeCharacters ($ filename ). ") "
204+ Lang::FILE_DOESNT_EXIST . " ( " . Utils::encodeCharacters ($ filename ) . ") "
205205 );
206206 } elseif (is_null ($ filename ) && is_null ($ context ->inputs ->getCode ())) {
207207 Utils::printWarning ($ context , Lang::FILE_AND_CODE_ARE_NULL );
208208 } else {
209- if (is_null ($ context ->inputs ->getCode ())
210- && @filesize ($ filename ) > $ context ->getMaxFileSize ()) {
209+ if (
210+ is_null ($ context ->inputs ->getCode ())
211+ && @filesize ($ filename ) > $ context ->getMaxFileSize ()
212+ ) {
211213 Utils::printWarning (
212214 $ context ,
213- Lang::MAX_SIZE_EXCEEDED . " ( " . Utils::encodeCharacters ($ filename ). ") "
215+ Lang::MAX_SIZE_EXCEEDED . " ( " . Utils::encodeCharacters ($ filename ) . ") "
214216 );
215217 } else {
216218 if (!$ context ->isFileDataAnalyzed ($ filename )) {
@@ -219,16 +221,18 @@ public function computeDataFlow($context)
219221 }
220222 }
221223 }
222-
224+
223225 public static function getTypeOfLanguage ($ lookfor , $ content )
224226 {
225227 if ($ lookfor === Analyzer::PHP && !empty ($ content )) {
226- if (strpos ($ content , "<? " ) !== false
227- || strpos ($ content , "<?php " ) !== false ) {
228+ if (
229+ strpos ($ content , "<? " ) !== false
230+ || strpos ($ content , "<?php " ) !== false
231+ ) {
228232 return true ;
229233 }
230234 }
231-
235+
232236 return false ;
233237 }
234238
@@ -251,7 +255,7 @@ public function getNamespace($context, $file)
251255 $ traverser ->traverse ($ script );
252256 }
253257 } catch (\Exception $ e ) {
254- Utils::printWarning ($ context , Lang::PARSER_ERROR . $ e ->getMessage ());
258+ Utils::printWarning ($ context , Lang::PARSER_ERROR . $ e ->getMessage ());
255259 }
256260 }
257261
@@ -319,7 +323,7 @@ public function runAnalysisOfCurrentMyFile($context)
319323 $ context ->resetCallStack ();
320324 }
321325 }
322-
326+
323327 public function run ($ context , $ cmdFiles = null )
324328 {
325329 $ currentMemoryLimit = ini_get ("memory_limit " );
@@ -331,7 +335,7 @@ public function run($context, $cmdFiles = null)
331335 if ($ bytes < $ context ->getMaxMemory ()) {
332336 $ ret = ini_set ('memory_limit ' , $ context ->getMaxMemory ());
333337 if (!$ ret ) {
334- Utils::printWarning ($ context , Lang::CANNOT_SET_MEMORY . $ context ->getMaxMemory ());
338+ Utils::printWarning ($ context , Lang::CANNOT_SET_MEMORY . $ context ->getMaxMemory ());
335339 }
336340 }
337341
@@ -358,8 +362,10 @@ public function run($context, $cmdFiles = null)
358362 $ this ->getFilesOfDir ($ context , $ cmdFile , $ cmdFile , $ files );
359363 } else {
360364 $ cmdFileA = new FileAnalysis ($ cmdFile , dirname ($ cmdFile ));
361- if (!in_array ($ cmdFileA , $ files , true )
362- && !$ context ->inputs ->isExcludedFile ($ cmdFile )) {
365+ if (
366+ !in_array ($ cmdFileA , $ files , true )
367+ && !$ context ->inputs ->isExcludedFile ($ cmdFile )
368+ ) {
363369 $ files [] = $ cmdFileA ;
364370 }
365371 }
@@ -373,8 +379,10 @@ public function run($context, $cmdFiles = null)
373379 $ this ->getFilesOfDir ($ context , $ includedFile , $ includedFile , $ files );
374380 } else {
375381 $ cmdFileA = new FileAnalysis ($ includedFile , dirname ($ includedFile ));
376- if (!in_array ($ cmdFileA , $ files , true )
377- && !$ context ->inputs ->isExcludedFile ($ includedFile )) {
382+ if (
383+ !in_array ($ cmdFileA , $ files , true )
384+ && !$ context ->inputs ->isExcludedFile ($ includedFile )
385+ ) {
378386 $ files [] = $ cmdFileA ;
379387 }
380388 }
@@ -387,8 +395,10 @@ public function run($context, $cmdFiles = null)
387395 if ($ context ->inputs ->getFile () !== null ) {
388396 $ file = \progpilot \Inputs \MyInputsInternalApi::resolvePath ($ context ->inputs ->getFile ());
389397 $ cmdFileA = new FileAnalysis ($ file , dirname ($ file ));
390- if (!in_array ($ cmdFileA , $ files , true )
391- && !$ context ->inputs ->isExcludedFile ($ file )) {
398+ if (
399+ !in_array ($ cmdFileA , $ files , true )
400+ && !$ context ->inputs ->isExcludedFile ($ file )
401+ ) {
392402 $ files [] = $ cmdFileA ;
393403 }
394404 }
@@ -408,9 +418,9 @@ public function run($context, $cmdFiles = null)
408418 foreach ($ files as $ file ) {
409419 if (is_file ($ file ->fullpath )) {
410420 if ($ context ->isDebugMode ()) {
411- echo "progpilot analyze : " . Utils::encodeCharacters ($ file ->fullpath ). "\n" ;
421+ echo "progpilot analyze : " . Utils::encodeCharacters ($ file ->fullpath ) . "\n" ;
412422 }
413-
423+
414424 $ context ->outputs ->setCountAnalyzedFiles (
415425 $ context ->outputs ->getCountAnalyzedFiles () + 1
416426 );
0 commit comments