Skip to content

PHP 8.1: Passing null to non-nullable parameters of built-in functions is deprecated #41643

@selfsimilar

Description

@selfsimilar
  • Laravel Version: 9.3..1
  • PHP Version: 8.1.x
  • Database Driver & Version:

Description:

See Migrating from PHP 8.0.x to PHP 8.1.x - Deprecated Features

A PHP warning is emitted when trim() is passed a null. trim() is used extensively throughout the framework,
but specifically in src/Illuminate/View/Compilers/Concerns/CompilesStacks.php the framework sets $id to null
as part of default behavior when processing a standard Blade pushOnce directive. There may be other instances
in the framework where this happens, but I have only triggered this particular instance.

Steps To Reproduce:

This was discovered by running tlint in a repository where the pushOnce directive was used.

Recommendation

Replace null with the empty string '' when setting a default 'empty' value that will be passed on to trim().

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