Skip to content

Commit fc2992e

Browse files
committed
Fix php8.2 deprecation: strpos():
- Passing null to parameter laravel#1 ($haystack) of type string is deprecated
1 parent 0fc5528 commit fc2992e

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/Illuminate/Routing/UrlGenerator.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,10 @@ public function formatParameters($parameters)
608608
*/
609609
protected function extractQueryString($path)
610610
{
611-
if (($queryPosition = strpos($path, '?')) !== false) {
611+
if (
612+
$path !== null
613+
&& ($queryPosition = strpos($path, '?')) !== false
614+
) {
612615
return [
613616
substr($path, 0, $queryPosition),
614617
substr($path, $queryPosition),

tests/Routing/RoutingUrlGeneratorTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public function testQueryGeneration()
5656
$this->assertSame('http://www.foo.com/foo/bar', $url->query('foo/bar?baz=boom', ['baz' => null]));
5757
$this->assertSame('https://www.foo.com/foo/bar/baz?foo=bar&zal=bee', $url->query('foo/bar?foo=bar', ['zal' => 'bee'], ['baz'], true));
5858
$this->assertSame('http://www.foo.com/foo/bar?baz[0]=boom&baz[1]=bam&baz[2]=bim', urldecode($url->query('foo/bar', ['baz' => ['boom', 'bam', 'bim']])));
59+
$this->assertSame('http://www.foo.com', urldecode($url->query(null)));
5960
}
6061

6162
public function testAssetGeneration()

0 commit comments

Comments
 (0)