[php-src] Issue #10985: PHP parser: operator precedence of `instanceof` vs `::` is weird
| From: | mikkorantalainen | Date: | Fri, 31 Mar 2023 14:43:33 +0000 |
| Subject: | [php-src] Issue #10985: PHP parser: operator precedence of `instanceof` vs `::` is weird | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-244070@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/10985
Author: mikkorantalainen
### Description
The following code:
```php
<?php
$c = new stdClass();
assert($c instanceof (stdClass::class));
assert($c instanceof stdClass::class);
echo "OK";
```
Resulted in this output:
```
Parse error: syntax error, unexpected token "class", expecting variable or "$"
in /path/to/test.php on line 4
[Process exited with code 255.]
```
But I expected this output instead:
```
OK
```
The code without extra parenthesis should do the same thing. It makes zero sense to have operator
instanceof precedence higher than ::.
### PHP Version
PHP 8.0.28
### Operating System
_No response_