Skip to content

Commit 7affe5d

Browse files
Merge branch '5.4' into 6.0
* 5.4: (21 commits) 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 [Process] Fix Process::getEnv() when setEnv() hasn't been called before ...
2 parents 3ee4816 + 9d186e1 commit 7affe5d

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

Node/BinaryNode.php

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

5454
$compiler
55-
->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(); } })(')
55+
->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(); } })(')
5656
->compile($this->nodes['right'])
5757
->raw(', ')
5858
->compile($this->nodes['left'])
@@ -173,13 +173,13 @@ public function toArray()
173173
return ['(', $this->nodes['left'], ' '.$this->attributes['operator'].' ', $this->nodes['right'], ')'];
174174
}
175175

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

Tests/Node/BinaryNodeTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ public function getEvaluateData()
6666
[[1, 2, 3], new BinaryNode('..', new ConstantNode(1), new ConstantNode(3))],
6767

6868
[1, new BinaryNode('matches', new ConstantNode('abc'), new ConstantNode('/^[a-z]+$/'))],
69+
[0, new BinaryNode('matches', new ConstantNode(''), new ConstantNode('/^[a-z]+$/'))],
70+
[0, new BinaryNode('matches', new ConstantNode(null), new ConstantNode('/^[a-z]+$/'))],
6971
];
7072
}
7173

@@ -114,7 +116,7 @@ public function getCompileData()
114116

115117
['range(1, 3)', new BinaryNode('..', new ConstantNode(1), new ConstantNode(3))],
116118

117-
['(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]+$/'))],
119+
['(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]+$/'))],
118120
];
119121
}
120122

0 commit comments

Comments
 (0)