Skip to content

Null Parameter Deprecation Notices #51147

@aldobarr

Description

@aldobarr

Laravel Version

10.48.8

PHP Version

8.2.16

Database Driver & Version

No response

Description

UrlGenerator has the following deprecation notices:

  1. PHP Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /src/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php on line 570
  2. PHP Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /src/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php on line 633

Steps To Reproduce

This can be easily replicated with a unit test such as:

<?php

declare(strict_types=1);

namespace Tests\Unit\Actions;

use Illuminate\Testing\TestResponse;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;

class UrlTest extends TestCase
{
    #[Test]
    public function url_deprecation_test(): void
    {
        $redirect = redirect('/');
        $response = new TestResponse(response($redirect));
        $response->assertLocation('/');
    }
}

Here, assertLocation will pass a null value as $path and trigger the deprecation notices.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions