Skip to content

strval(mixed) errors since version 1.10.15 #9295

@mickverm

Description

@mickverm

Bug report

In version 1.10.15, PHPStan's handling of strval() changed (see phpstan/phpstan-src#2354)

Since then, the following does not work any longer on level 9:

$value = strval(constant('SECRET'));
Parameter #1 $value of function strval expects bool|float|int|resource|string|null, mixed given.

The following was never allowed:

$value = (string) constant('SECRET');
Cannot cast mixed to string.

This is now the only solution/fix, is this intended behavior?

/** @var string $value */
$value = constant('SECRET');

https://phpstan.org/r/32f21004-4041-4ef8-a83b-b53bd29f08c4

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