Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work on php 5.6 #85

Closed
dotboris opened this issue May 9, 2019 · 2 comments · Fixed by #86
Closed

Does not work on php 5.6 #85

dotboris opened this issue May 9, 2019 · 2 comments · Fixed by #86
Labels

Comments

@dotboris
Copy link

dotboris commented May 9, 2019

This module claims to support php 5.4 and up but when I run the latest version on php 5.6 it fails with a syntax error.

$ php --version
PHP 5.6.39 (cli) (built: Dec  7 2018 08:27:47)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
    with Xdebug v2.5.5, Copyright (c) 2002-2017, by Derick Rethans
$ composer show sirbrillig/phpcs-variable-analysis
name     : sirbrillig/phpcs-variable-analysis
descrip. : A PHPCS sniff to detect problems with variables.
keywords :
versions : * v2.6.2
type     : phpcodesniffer-standard
license  : BSD 2-Clause "Simplified" License (BSD-2-Clause) (OSI approved) https://spdx.org/licenses/BSD-2-Clause.html#licenseText
source   : [git] https://github.com/sirbrillig/phpcs-variable-analysis.git a31046c32e95cff4062856a3eb78770dd1bc1e48
dist     : [zip] https://api.github.com/repos/sirbrillig/phpcs-variable-analysis/zipball/a31046c32e95cff4062856a3eb78770dd1bc1e48 a31046c32e95cff4062856a3eb78770dd1bc1e48
path     : /.../vendor/sirbrillig/phpcs-variable-analysis
names    : sirbrillig/phpcs-variable-analysis

autoload
psr-4
VariableAnalysis\ => VariableAnalysis/

requires
php >=5.4.0

requires (dev)
dealerdirect/phpcodesniffer-composer-installer ^0.4.4
limedeck/phpunit-detailed-printer ^3.1
phpunit/phpunit ^6.5
sirbrillig/phpcs-import-detection ^1.1
squizlabs/php_codesniffer ^3.1
$ composer lint
> phpcs
PHP Parse error:  syntax error, unexpected '?' in /.../vendor/sirbrillig/phpcs-variable-analysis/VariableAnalysis/Sniffs/CodeAnalysis/VariableAnalysisSniff.php on line 1062
PHP Stack trace:
PHP   1. {main}() /.../vendor/squizlabs/php_codesniffer/bin/phpcs:0
PHP   2. PHP_CodeSniffer\Runner->runPHPCS() /.../vendor/squizlabs/php_codesniffer/bin/phpcs:18
PHP   3. PHP_CodeSniffer\Runner->init() /.../vendor/squizlabs/php_codesniffer/src/Runner.php:70
PHP   4. PHP_CodeSniffer\Ruleset->__construct() /.../vendor/squizlabs/php_codesniffer/src/Runner.php:332
PHP   5. PHP_CodeSniffer\Ruleset->registerSniffs() /.../vendor/squizlabs/php_codesniffer/src/Ruleset.php:216
PHP   6. PHP_CodeSniffer\Autoload::loadFile() /.../vendor/squizlabs/php_codesniffer/src/Ruleset.php:1146

Parse error: syntax error, unexpected '?' in /.../vendor/sirbrillig/phpcs-variable-analysis/VariableAnalysis/Sniffs/CodeAnalysis/VariableAnalysisSniff.php on line 1062

Call Stack:
    0.0024     230080   1. {main}() /.../vendor/squizlabs/php_codesniffer/bin/phpcs:0
    0.0061     709800   2. PHP_CodeSniffer\Runner->runPHPCS() /.../vendor/squizlabs/php_codesniffer/bin/phpcs:18
    0.0176    1318656   3. PHP_CodeSniffer\Runner->init() /.../vendor/squizlabs/php_codesniffer/src/Runner.php:70
    0.0221    1685624   4. PHP_CodeSniffer\Ruleset->__construct() /.../vendor/squizlabs/php_codesniffer/src/Runner.php:332
    0.0326    1731848   5. PHP_CodeSniffer\Ruleset->registerSniffs() /.../vendor/squizlabs/php_codesniffer/src/Ruleset.php:216
    0.0594    4048304   6. PHP_CodeSniffer\Autoload::loadFile() /.../vendor/squizlabs/php_codesniffer/src/Ruleset.php:1146

Script phpcs handling the lint event returned with error code 255

I think that the issue comes from https://github.com/sirbrillig/phpcs-variable-analysis/blob/master/VariableAnalysis/Sniffs/CodeAnalysis/VariableAnalysisSniff.php#L1062 which uses the ?? syntax. I think that this is a new syntax that only showed up in php 7+

@sirbrillig
Copy link
Owner

Oops! Thank you for noticing that. I've had this issue before.

@sirbrillig
Copy link
Owner

I updated the automated tests so hopefully this will be noticed next time it happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants