Skip to content

Deprecation: Passing null to strlen is deprecated #233

Closed
@Patrick-Beuks

Description

@Patrick-Beuks

Since PHP 8.0 passing null to strlen is deprecated.

This can for example happen in ReferenceBag#L357 where null is passed to ParserBase#L29 when git fails to execute show-ref (happened when doing hasBranch on an empty repo)

There are 12 instances of strlen used. All but one of them in parsers and one in StringHelper#L36 as a fallback for mb_strlen. Some of these usages can also always be expected to be a string.

There are two ways that come into mind to fix these problems:

1: Check the input if it is null
2: Add stricter types to input parameters and change logic to not pass null to functions that expect a string.

If there is a preferred method let me know and I can look into making a PR for this.

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