PHP 7 compatibility inspection missing

Answered

Hi everybody,

I'm working on the last version of PhpStorm and have to make a project written in PHP5, compatible with PHP7.

I'm aware that PhpStorm provides an inspection called "PHP7 Compatibility". Unfortunately, when I select Code > Run Inspection by Name, I can't find any inspection named like so.

Do anyone knows how to fix it?

Thank you

11 comments
Avatar
Vladimir Luchansky
Comment actions Permalink

Hello,

There's "Language Level" inspection as well as some others in PHP | General like "Deprecated" and "Disabled extension stubs" that may help you to find extensions that are not used anymore but still present in the project code.

1
Comment actions Permalink

Same issue here.   I find various specialised inspection tools using with ALT+CTRL+SHIFT+I but i cant find any global "PHP 7 Compatibility Inspection"

https://blog.jetbrains.com/phpstorm/2015/11/get-your-code-php-7-ready-with-phpstorm-10/ seems to be outdated or is there another way to reach that feature ?

1
Comment actions Permalink

Well, this is a 2015 blog post, we don't update older posts when something changes.

Googling the topic is supposed to bring you here, and that's what it did apparently.

0
Comment actions Permalink

Ok. Well ... about that post, maybe you could add a link to some updated documentation about that topic (where please ?) or add an "OBSOLETE" tag.

I could find several specialized compatibility scans in updated PhpStorm but none refering to that more global « migrate to PHP7 » issue. Hence my question still is : what is the way to reach that feature now ? 

0
Comment actions Permalink

See the latest comment in that post: this inspection is merged into PHP | General | Language Level inspection. Just set appropriate language level at File | Settings | Languages & Frameworks | PHP & PhpStorm would report all the PHP-language-level errors

It was also decided to drop the "PHP 7 Compatibility Inspection": https://youtrack.jetbrains.com/issue/WI-29071#focus=streamItem-27-3108359-0-0

0
Comment actions Permalink

Thank you.

0
Comment actions Permalink

I'm looking to scan our repo for upgrade from PHP 5 to 7, and am not finding a way to do this yet. I merely overheard someone say they did it in PHPStorm. So far a Google search brings me to an outdated 2015 and 2017 post that don't work anymore, and I'm unclear from this thread what does without having to go through every file to view what needs to be updated, nevermind figuring out composer and vendor in our frameworks.

Is there still something that will scan all files in the repo (at least ignoring vendor, unless it will consider composer.json) to provide a list or tree of found issues? 

I'm using PHPStorm version 2021.1.4.

Opening Preferences > PHP shows no General option.

Language Level appears to be an option in Preferences > PHP, not a full view of settings.

I have no Settings option in File:

Language Level Inspection seems to just be a bunch of checkmark settings, not an option to scan the repo to provide a list of version difference errors or warnings:

What's the updated way of doing this?

Should I make a new post for this? I don't mean to keep digging up old information or a long thread, but I'm trying to find what people are talking about, and the interface seems to have changed a lot even from late 2019.

0
Comment actions Permalink

Hi there,

Language Level appears to be an option in Preferences > PHP, not a full view of settings.

Yes, as of 2021.1 the "PHP" settings node has been moved from "Languages & Frameworks" and now is at the very top.

I have no Settings option in File:

"File | Settings" is for Windows/ Linux; for Mac it's "PhpStorm | Preferences".

Is there still something that will scan all files in the repo (at least ignoring vendor, unless it will consider composer.json) to provide a list or tree of found issues?

Still the same "Code | Inspect Code..." to run the whole thing or "Code | Run Inspection by Name..." and choose "Language Level" there if you wish to run that particular inspection only.

https://www.jetbrains.com/help/phpstorm/running-inspections.html#run-inspections-manually

2
Comment actions Permalink

OK thank you.

Note that Code > Run Inspection by Name does not show a list of things to choose from, I have to start typing to get a list of options.

0
Comment actions Permalink

OK I ran "Code > Run Inspection by Name", searched for and chose 'Language Level', ran it for the whole project, for *.php files using PHP 7.3 and 7.4, and the response was:

`No suspicious code found. 445 files processed in 'Project 'my-project''.`

I'm not sure this is working properly 🤔

I know this project written for PHP 5.6 will run on PHP 7.3 but not PHP 7.4, I don't understand why it says "no suspicious code found", nor what's meant by "suspicious", your documentation link doesn't even mention that word. The current file I'm looking at has 4 warnings, which should have shown in the manual global inspection that I ran.

0
Comment actions Permalink

It looks to me that Language Level inspection works other way around: reports newer features as unavailable if PHP is set to an older version (e.g. reports PHP 8 features (i.e. named arguments) if current PHP level is 7.x or lower).

Other inspections can catch some "migrating PHP to a newer version" issues, e.g. "Inspections | PHP | General | Element is not available in configured PHP version" will report deprecated in that PHP version functions. I guess you better run the whole thing (Code | Inspect Code..) first, see what issues it reports, then create a new profile and include only desired inspections there...

P.S. Php Inspections (EA Extended) plugin provides a bunch of such inspections: "Inspections | PHP | Php Inspections (EA Extended) | Language level migration"

 

 

1

Please sign in to leave a comment.