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

Add --php-version to psalm? #1191

Closed
TysonAndre opened this issue Jan 9, 2019 · 0 comments
Closed

Add --php-version to psalm? #1191

TysonAndre opened this issue Jan 9, 2019 · 0 comments

Comments

@TysonAndre
Copy link
Contributor

A common type of bug would be using features from newer PHP versions when the project needs to support older versions.

Obviously there's other ways to detect this, such as providing a plugin to run php --no-php-ini --syntax-check < file_or_tmpfile.php, or doing that with a separate tool

A reasonable default would be the php version used to run psalm (or guess from composer.json). For backwards compatibility, I'd assume 7.3 would be the most similar

Examples:

  • Nullable types/void in PHP 7.1, object in php 7.2, etc
  • Psalm does not warn about extra trailing commas in function calls (e.g. if running with PHP 7.1). Those became valid in PHP 7.3. (I'd assume PHP-Parser provides this)
<?php
call_user_func(/** @return void */function () {
    $other = 'x';
    var_export(is_string(
        $other,  // Psalm doesn't warn about trailing commas
    ));
    var_export(is_string($missing));  // Psalm correctly warns about this
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants