11<?php
22
3+ use Phpfastcache \Helper \TestHelper ;
4+
35chdir (__DIR__ . '/../../ ' );
6+ require_once __DIR__ . '/../../vendor/autoload.php ' ;
7+ $ testHelper = new TestHelper ('PHP Lexer ' );
8+
49
510/**
611 * @author Khoa Bui (khoaofgod) <[email protected] > http://www.phpfastcache.com 712 * @author Georges.L (Geolim4) <[email protected] > 813 */
914
10- function read_dir ($ dir , $ ext = null )
15+ function phpfastcache_read_dir ($ dir , $ ext = null )
1116{
1217 $ list = [];
1318 $ dir .= '/ ' ;
@@ -20,7 +25,7 @@ function read_dir($dir, $ext = null)
2025 }
2126 $ name = $ dir . $ name ;
2227 if (is_dir ($ name )) {
23- $ list = array_merge ($ list , read_dir ($ name , $ ext ));
28+ $ list = array_merge ($ list , phpfastcache_read_dir ($ name , $ ext ));
2429 } elseif (is_file ($ name )) {
2530 if (!is_null ($ ext ) && substr (strrchr ($ name , '. ' ), 1 ) != $ ext ) {
2631 continue ;
@@ -32,29 +37,18 @@ function read_dir($dir, $ext = null)
3237 return $ list ;
3338}
3439
35- $ list = read_dir ('./lib ' , 'php ' );
40+ $ list = phpfastcache_read_dir ('./lib ' , 'php ' );
3641
37- $ exit = 0 ;
38- foreach ($ list as $ file ) {
42+ foreach (array_map ('realpath ' , $ list ) as $ file ) {
3943 $ output = '' ;
40- /**
41- * @todo Make the exclusions much cleaner
42- */
43- if (strpos ($ file , '/vendor/composer ' ) === false && strpos ($ file , '/bin/stubs ' ) === false ) {
44- exec ((defined ('HHVM_VERSION ' ) ? 'hhvm ' : 'php ' ) . ' -l " ' . realpath ($ file ) . '" ' , $ output , $ status );
45- } else {
46- echo '[SKIP] ' . $ file ;
47- echo "\n" ;
48- continue ;
49- }
44+ \exec (($ testHelper ->isHHVM () ? 'hhvm ' : 'php ' ) . ' -l " ' . $ file . '" ' , $ output , $ status );
45+
46+ $ output = trim (implode ("\n" , $ output ));
5047
5148 if ($ status !== 0 ) {
52- $ exit = $ status ;
53- echo '[FAIL] ' ;
49+ $ testHelper ->printFailText ($ output ?: "Syntax error found in {$ file }" );
5450 } else {
55- echo ' [PASS] ' ;
51+ $ testHelper -> printPassText ( $ output ?: " No syntax errors detected in { $ file }" ) ;
5652 }
57- echo ' ' . implode ("\n" , $ output );
58- echo "\n" ;
5953}
60- exit ( $ exit );
54+ $ testHelper -> terminateTest ( );
0 commit comments