Skip to content

Undefined offset in PSR12.Functions.ReturnTypeDeclaration when checking function return type inside ternary #2975

@martin-heralecky

Description

@martin-heralecky
<?php return (!$a ? [ new class { public function b(): c {} } ] : []);

This code, when run against PSR12.Functions.ReturnTypeDeclaration.SpaceBeforeReturnType, throws Undefined offset: -1 in .../vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Sniffs/Functions/ReturnTypeDeclarationSniff.php on line 89 error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions