1010 * the LICENSE file that was distributed with this source code.
1111 */
1212
13- require __DIR__ . '/../../vendor/codeigniter4/codeigniter4/system/Test/bootstrap .php ' ;
13+ require __DIR__ . '/../../vendor/codeigniter4/codeigniter4/system/util_bootstrap .php ' ;
1414
1515use CodeIgniter \CLI \CLI ;
1616use Translations \Tests \AbstractTranslationTestCase ;
1717
18- if (! isset ($ argv [1 ])) {
18+ if (! isset ($ argv [1 ]) || ! is_string ( $ argv [ 1 ]) ) {
1919 CLI ::error ('No GitHub Event provided. ' , 'light_gray ' , 'red ' );
2020
2121 exit (1 );
2222}
2323
24- $ event = ( string ) $ argv [1 ];
24+ $ event = $ argv [1 ];
2525
2626if (! in_array ($ event , ['--pull-request ' , '--push ' ], true )) {
2727 CLI ::error ('Invalid GitHub Event provided. ' , 'light_gray ' , 'red ' );
@@ -35,8 +35,14 @@ if ($event === '--pull-request') {
3535 $ files = shell_exec ('git diff --name-only --diff-filter=ACMRTUXB HEAD~..HEAD ' );
3636}
3737
38- $ isCIAffected = str_contains ((string ) $ files , '.github/scripts/continuous-integration ' );
39- $ isBuildAffected = str_contains ((string ) $ files , '.github/workflows/build.yml ' );
38+ if (! is_string ($ files )) {
39+ CLI ::error ('Unable to retrieve the list of changed files. ' , 'light_gray ' , 'red ' );
40+
41+ exit (1 );
42+ }
43+
44+ $ isCIAffected = str_contains ($ files , '.github/scripts/continuous-integration ' );
45+ $ isBuildAffected = str_contains ($ files , '.github/workflows/build.yml ' );
4046$ isTestAffected = preg_match ('/tests\/Language\/(.+)Test(?:|Case)\.php/ ' , $ files ) === 1 ;
4147
4248$ files = str_replace (["\r\n" , "\r" ], "\n" , $ files );
@@ -66,7 +72,7 @@ $failed = [];
6672
6773$ phpunit = 'vendor/bin/phpunit ' ;
6874
69- if (CLI :: isWindows ()) {
75+ if (is_windows ()) {
7076 $ phpunit = strtr ($ phpunit , '/ ' , '\\' );
7177}
7278
@@ -87,14 +93,14 @@ if ($count > 0 && $count < count(AbstractTranslationTestCase::$locales)) {
8793 foreach ($ locales as $ locale ) {
8894 $ class = array_search ($ locale , AbstractTranslationTestCase::$ locales , true );
8995
90- if ($ class === false ) {
96+ if (! is_string ( $ class) ) {
9197 CLI ::error (sprintf ('The locale "%s" has no corresponding test case yet. ' , $ locale ), 'light_gray ' , 'red ' );
9298 CLI ::error ('You can read on the Contributing Guide for details on adding test cases. ' , 'light_gray ' , 'red ' );
9399
94100 exit (1 );
95101 }
96102
97- $ class = preg_replace ('/^Translations \\\\Tests \\\\(.+)$/u ' , '$1 ' , ( string ) $ class );
103+ $ class = preg_replace ('/^Translations \\\\Tests \\\\(.+)$/u ' , '$1 ' , $ class );
98104
99105 CLI ::write ("Executing vendor/bin/phpunit --color=always --filter {$ class }\n" , 'black ' , 'yellow ' );
100106 passthru ("{$ phpunit } --color=always --filter {$ class }" , $ return );
@@ -137,7 +143,7 @@ if ($count > 0 && $count < count(AbstractTranslationTestCase::$locales)) {
137143
138144 foreach ($ reasons as [$ reason , $ explanation ]) {
139145 if ($ reason ) {
140- CLI ::write (' Reason: ' . $ explanation . " \n" , 'black ' , 'yellow ' );
146+ CLI ::write (" Reason: { $ explanation} \n" , 'black ' , 'yellow ' );
141147 break ;
142148 }
143149 }
0 commit comments