Not detecting ?-> Nullsafe operator incompatibility with PHP 7.1 and PHP 5.6
galexla opened this issue · comments
Nullsafe operator appeared in PHP 8.0. I created a PHP 8.0 file kva.php to test PHPCompatibility:
`<?php
$session = new stdClass();
$session->user = new stdClass();
$session->user->address = new stdClass();
$session->user->address->country = 'kva';
echo $session?->user?->address?->country . PHP_EOL;`
Then run
vendor/bin/phpcs -psvw --standard=PHPCompatibility --runtime-set testVersion 5.6 "./src"
And it showed:
Registering sniffs in the PHPCompatibility standard... DONE (117 sniffs registered) Creating file list... DONE (1 files in queue) Changing into directory xxxx Processing kva.php [PHP => 72 tokens in 10 lines]... DONE in 18ms (0 errors, 0 warnings) Time: 112ms; Memory: 8MB
The same result if I print "testVersion 7.1"
But the code successfully runs here https://laravelplayground.com/#/?php=8
Result of
vendor/bin/phpcs --version
is
PHP_CodeSniffer version 3.7.1 (stable) by Squiz (http://www.squiz.net)
Running file kva.php under php 7.1 results in:
PHP Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR) in xxxxxx/kva.php on line 8