Skip to content

Commit 4d64023

Browse files
Merge branch '6.0' into 6.1
* 6.0: (22 commits) Add missing license header Add missing license header [Workflow] Catch error when trying to get an uninitialized marking Add missing license header Allow usage of Provider domains if possible Use reference date in reverse transform Fixes #40997 Fix env resolution in lock configuration Fix Symfony not working on SMB share #45990 [Messenger] DoctrineTransportFactory works with notify and decorated PostgreSQL driver [Cache] make LockRegistry use static properties instead of static variables fix: return-path has higher priority for envelope address than from address (fixes #41322) [HttpClient] Fix sending content-length when streaming the body [Console] Header with column max width is now well wrap with separator Fix use_cookies framework session configuration [FrameworkBundle] [Command] Fix `debug:router --no-interaction` error … [Intl] Update the ICU data to 71.1 - 5.4 [Intl] Update the ICU data to 71.1 - 4.4 Add tests to messenger connection get for OraclePlatform [RateLimiter] Adding default empty value [DependencyInjection] Add TaggedIteratorArgument unit tests ...
2 parents bc4c517 + 7affe5d commit 4d64023

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

Node/BinaryNode.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function compile(Compiler $compiler)
5555
}
5656

5757
$compiler
58-
->raw('(static function ($regexp, $str) { set_error_handler(function ($t, $m) use ($regexp, $str) { throw new \Symfony\Component\ExpressionLanguage\SyntaxError(sprintf(\'Regexp "%s" passed to "matches" is not valid\', $regexp).substr($m, 12)); }); try { return preg_match($regexp, $str); } finally { restore_error_handler(); } })(')
58+
->raw('(static function ($regexp, $str) { set_error_handler(function ($t, $m) use ($regexp, $str) { throw new \Symfony\Component\ExpressionLanguage\SyntaxError(sprintf(\'Regexp "%s" passed to "matches" is not valid\', $regexp).substr($m, 12)); }); try { return preg_match($regexp, (string) $str); } finally { restore_error_handler(); } })(')
5959
->compile($this->nodes['right'])
6060
->raw(', ')
6161
->compile($this->nodes['left'])
@@ -176,13 +176,13 @@ public function toArray()
176176
return ['(', $this->nodes['left'], ' '.$this->attributes['operator'].' ', $this->nodes['right'], ')'];
177177
}
178178

179-
private function evaluateMatches(string $regexp, string $str): int
179+
private function evaluateMatches(string $regexp, ?string $str): int
180180
{
181181
set_error_handler(function ($t, $m) use ($regexp) {
182182
throw new SyntaxError(sprintf('Regexp "%s" passed to "matches" is not valid', $regexp).substr($m, 12));
183183
});
184184
try {
185-
return preg_match($regexp, $str);
185+
return preg_match($regexp, (string) $str);
186186
} finally {
187187
restore_error_handler();
188188
}

Tests/Node/BinaryNodeTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ public function getEvaluateData()
7070
[true, new BinaryNode('ends with', new ConstantNode('abc'), new ConstantNode('c'))],
7171
[false, new BinaryNode('ends with', new ConstantNode('abc'), new ConstantNode('b'))],
7272
[1, new BinaryNode('matches', new ConstantNode('abc'), new ConstantNode('/^[a-z]+$/'))],
73+
[0, new BinaryNode('matches', new ConstantNode(''), new ConstantNode('/^[a-z]+$/'))],
74+
[0, new BinaryNode('matches', new ConstantNode(null), new ConstantNode('/^[a-z]+$/'))],
7375
];
7476
}
7577

@@ -118,9 +120,10 @@ public function getCompileData()
118120

119121
['range(1, 3)', new BinaryNode('..', new ConstantNode(1), new ConstantNode(3))],
120122

123+
['(static function ($regexp, $str) { set_error_handler(function ($t, $m) use ($regexp, $str) { throw new \Symfony\Component\ExpressionLanguage\SyntaxError(sprintf(\'Regexp "%s" passed to "matches" is not valid\', $regexp).substr($m, 12)); }); try { return preg_match($regexp, (string) $str); } finally { restore_error_handler(); } })("/^[a-z]+\$/", "abc")', new BinaryNode('matches', new ConstantNode('abc'), new ConstantNode('/^[a-z]+$/'))],
124+
121125
['str_starts_with("abc", "a")', new BinaryNode('starts with', new ConstantNode('abc'), new ConstantNode('a'))],
122126
['str_ends_with("abc", "a")', new BinaryNode('ends with', new ConstantNode('abc'), new ConstantNode('a'))],
123-
['(static function ($regexp, $str) { set_error_handler(function ($t, $m) use ($regexp, $str) { throw new \Symfony\Component\ExpressionLanguage\SyntaxError(sprintf(\'Regexp "%s" passed to "matches" is not valid\', $regexp).substr($m, 12)); }); try { return preg_match($regexp, $str); } finally { restore_error_handler(); } })("/^[a-z]+\$/", "abc")', new BinaryNode('matches', new ConstantNode('abc'), new ConstantNode('/^[a-z]+$/'))],
124127
];
125128
}
126129

0 commit comments

Comments
 (0)