Skip to content

Exception message is not on point for unary operator #9920

Closed as not planned
Closed as not planned
@mvorisek

Description

@mvorisek

Description

The following code:

var_dump(- '3');
$v = 'x';
var_dump(- $v);
var_dump(- 'x');

https://3v4l.org/tokuW

it seems the exception message does not expect unary operator, as for 1 + 'x' it makes much more sense and the operator is displayed correctly

Resulted in this output:

int(-3)

Fatal error: Uncaught TypeError: Unsupported operand types: string * int in /in/tokuW:5
Stack trace:
#0 {main}
  thrown in /in/tokuW on line 5

But I expected this output instead:

int(-3)
1x meaningful exception (or 2x warning)

PHP Version

PHP 8.0+

Operating System

any

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions