= $count || '(' !== $tokens[ $j ] ) { continue; } ++$j; while ( $j < $count && is_array( $tokens[ $j ] ) && T_WHITESPACE === $tokens[ $j ][0] ) { ++$j; } if ( $j < $count && is_array( $tokens[ $j ] ) && T_CONSTANT_ENCAPSED_STRING === $tokens[ $j ][0] ) { if ( in_array( trim( $tokens[ $j ][1], "'\"" ), $guards, true ) ) { $found = true; break; } } } if ( ! $found ) { printf( "::error file=%s,line=1::No guard against direct access. Add: if ( ! defined( 'ABSPATH' ) ) { exit; }\n", $path ); ++$problems; } } // The floor, for the same reason every other check in this kit has one: "every // shipped file is guarded" is also what zero shipped files prints. if ( $checked < $min ) { fwrite( STDERR, sprintf( "Only %d shipped PHP file(s) were examined, expected at least %d. The file list is wrong, so this check proved nothing.\n", $checked, $min ) ); exit( 1 ); } if ( $problems > 0 ) { printf( "\n%d of %d shipped PHP files have no guard against direct access.\n", $problems, $checked ); exit( 1 ); } printf( " %d shipped PHP files parsed, every one guards against direct access\n", $checked ); exit( 0 );