[php-src] Issue #13083: Test script outputs incorrect difference empty blank lines

From: Date: Sat, 06 Jan 2024 14:34:43 +0000
Subject: [php-src] Issue #13083: Test script outputs incorrect difference empty blank lines
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-246185@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/13083 Author: jorgsowa ### Description The script run-test.php calculates the wrong lines of difference for the given test. ```php --TEST-- Test preg_grep() function : error conditions - bad regular expressions --FILE-- <?php $values = [ 'abcdef', //Regex without delimiter '/[a-zA-Z]', //Regex without closing delimiter '[a-zA-Z]/', //Regex without opening delimiter '/[a-zA-Z]/F', [ '[a-z]', //Array of Regexes '[A-Z]', '[0-9]', ], '/[a-zA-Z]/', //Regex string ]; $array = [123, 'abc', 'test']; foreach ($values as $value) { try { var_dump(preg_grep($value, $array)); } catch (TypeError $e) { echo $e->getMessage(), "\n"; } } $value = new stdclass(); //Object try { var_dump(preg_grep($value, $array)); } catch (TypeError $e) { echo $e->getMessage(), "\n"; } ?> --EXPECTF-- Warning: preg_grep(): Delimiter must not be alphanumeric, backslash, or NUL in %spreg_grep_error1.php on line %d bool(false) Warning: preg_grep(): No ending delimiter '/' found in %spreg_grep_error1.php on line %d bool(false) Warning: preg_grep(): Unknown modifier '/' in %spreg_grep_error1.php on line %d bool(false) Warning: preg_grep(): Unknown modifier 'F' in %spreg_grep_error1.php on line %d bool(false) preg_grep(): Argument #1 ($pattern) must be of type string, array given array(2) { [1]=> string(3) "abc" [2]=> string(4) "test" } preg_grep(): Argument #1 ($pattern) must be of type string, stdClass given ``` Resulted in this output: ``` Warning: preg_grep(): Delimiter must not be alphanumeric, backslash, or NUL byte in %spreg_grep_error1.php on line %d bool(false) 004- 005- Warning: preg_grep(): No ending delimiter '/' found in %spreg_grep_error1.php on line %d 006- bool(false) 007- 008- Warning: preg_grep(): Unknown modifier '/' in %spreg_grep_error1.php on line %d 009- bool(false) 010- 011- Warning: preg_grep(): Unknown modifier 'F' in %spreg_grep_error1.php on line %d 012- bool(false) 013- preg_grep(): Argument #1 ($pattern) must be of type string, array given 014- Warning: preg_grep(): No ending delimiter '/' found in %spreg_grep_error1.php on line %d bool(false) -- ``` But I expected this output instead: ``` Warning: preg_grep(): Delimiter must not be alphanumeric, backslash, or NUL byte in %spreg_grep_error1.php on line %d bool(false) 004- Warning: preg_grep(): No ending delimiter '/' found in %spreg_grep_error1.php on line %d bool(false) -- Warning: preg_grep(): Unknown modifier 'F' in %spreg_grep_error1.php on line %d bool(false) preg_grep(): Argument #1 ($pattern) must be of type string, array given 014- Warning: preg_grep(): No ending delimiter '/' found in %spreg_grep_error1.php on line %d bool(false) -- ``` ### PHP Version PHP 8.3 ### Operating System _No response_

« previous php.bugs (#246185) next »