PhpStorm showing code error for PHP method - phpstorm

I am curious as to why the following syntax is rejected by my PhpStorm editor:
PhpStorm version: 2016.1.2

Nullable parameters/return types (?User from your example) is a PHP 7.1 feature.
PHP Language Level must be set to 7.1 in PhpStorm settings for this project (although right now it does not produce an error if language is set below 7.1 -- see WI-32136 ticket).
Support for nullable types was added in PhpStorm 2016.2.2 (which is newer than your 2016.1.x)
Conclusion: upgrade your PhpStorm to the latest version (which is 2017.2.1 at this moment). At very least you need to have PhpStorm 2016.2.2 for this particular syntax to be supported 9not showing an error).

Related

PHP Language level missing latest (version 7.3 is the highest)

I'm trying to setup Xdebug and while doing that I'm trying to ensure that all PHP-versions and setup of that is exactly right.
I've matched the PHP-version on the server (7.4), by installing and linking the right PHP-version using Brew (I'm on a Mac).
So in a terminal, if I write php --version I get: version: 7.4.14:
I've set the CLI-interpreter in PhpStorm to point to that same PHP-executable:
But in spite of this, I can only set PHP version 7.3 to be the highest language level:
Solution attempts:
All these things have been found in random cracks and articles. None of them worked.
Invalidated Cached and restarted PhpStorm ( File >> Invalidate Cache and restart ).
Uncheck 'Synchronize IDE Settings with composer.json' in Settings >> Languages & Frameworks >> PHP >> Composer. I had to first insert a path to remove it. But it didn't do anything anyway.
Tried to see if there was any upgrades to the "PHP Latest"-plugin, but I couldn't see any pending updates (v. 0.4).
Overarching question
How do I get the latest version in the PHP Language Level field (to also get better code hints)?
My version was this: 2018.2.3 - Build #PS-182.4323.68 built September 13, 2018
You need to upgrade your IDE. Latest stable version is 2020.3.1.
Partial PHP 7.4 support is present since PhpStorm 2019.2 version.
Proper PHP 7.4 support was added in PhpStorm 2019.3.
Initial/partial PHP 8 support was added in PhpStorm 2020.2.
Current 2020.3 version has more complete PHP 8 support.

Can SonarLint be run on JDK 5,6, or 7?

I am trying to install SonarLint for Eclipse Ganymede (3.4.2) - and our project is very old, so we're using JDK 1.5 here. So is it possible to run SonarLint for JDK 5?
First of all, JDK 5 is so old, I can't really be certain of anything...
But here are some key factors that are important to understand:
Java code is analyzed by the Java analyzer (known today as "SonarJava"). SonarLint is a plugin in Eclipse (and other IDEs) that executes the SonarJava, and uses the results from it to annotate the code you are editing.
The JDK version that the SonarJava itself requires to run, is not the same thing as the JDK version of the source code it is able to analyze (= the subject of the analysis). For example, SonarJava may not run at all on JDK 7, but able to analyze code that is written in JDK 6.
If you use SonarLint in standalone mode, it uses its embedded version of the SonarJava, you cannot use another version. If you use SonarLint in connected mode, it uses SonarJava installed in the SonarQube to which you are connected. Here you have some freedom of choice in the version of the SonarJava, but not unlimited, because SonarLint may not be compatible with all versions of SonarJava, for example recent versions require a certain minimum version.
As per the product news, the current version of SonarLint requires Java 8 and more recent Eclipse than Juno. But you may be able to find an older version of SonarLint that can run in an older Eclipse, and support a version of SonarJava that is able to run on your JDK, and analyze code written for your target JDK version.
Based on the above points, you can dig into the older releases of SonarLint and find something suitable. These links should be useful in your search:
Product news of SonarLint for Eclipse. These also include links to the detailed release notes, which usually contain information about the version of embedded SonarJava
Releases of SonarLint for Eclipse
Homepage of SonarJava

IDE's Java runtime (1.8u111) is outdated - this may cause stability issues. Please update to 1.8.0u112 or newer while opening PhpStorm in Ubuntu 16.10

I recently updated PhpStorm to latest version 2017.1 and I get following message while starting PhpStorm
IDE's Java runtime (1.8u111) is outdated - this may cause stability
issues. Please update to 1.8.0u112 or newer
Start the IDE, use Help | Find Action (Ctrl+Shift+A or Cmd+Shift+A on Mac), type "Switch IDE Boot JDK", press Enter.
But If you don't have the latest JDK, download it from:
Download latest JAVA JDK here
And then select the "IDE BOOT JDK" like Tall Liou told.

Checkstyle throwsindent property not available

My checkstyle indentation module does not have "throwsIndent" property. Is there any alternative available for this property?
Checkstyle doc where "throwsIndent" is present -
http://checkstyle.sourceforge.net/config_misc.html
The throwsIndent property of the Indentation check was added with Checkstyle 5.7, which is the latest version at the time of this writing. As far as I know, there is no workaround for this property for Checkstyle versions prior to 5.7.
So your best bet is to upgrade your Checkstyle version. If you are using Eclipse, you can upgrade to the latest version of the Eclipse-CS plugin, which will also include the newest Checkstyle. The same is true for CheckStyle-IDEA, the Checkstyle plugin for IntelliJ IDEA.

Razor Engine on Mono 3.2.x with Fast CGI - target specific .net?

My site works on mono 2.10 and I'm nearly done on a brand new server upgrading to mono 3.2.x.
It works using XSP4, the ServiceStack Razor views render correctly. (And it fixes a lot of artefacts in 2.10)
When I set the site to use nginx + Fast CGI (4) however I get a HttpCompileException, caused by:
The predefined type `System.Collections.Generic.IReadOnlyList' is defined multiple times. Using definition from `mscorlib.dll'
Remember this works fine with xsp4 so I think it needs some setting to tie it to one .Net instance, maybe it's confused between .net 4.0 and .net 4.5? Any suggestions on how I can force it to use only one of these?
Note: I installed from git using latest (3.2.7), as the 3.2.5 release would crash. I'm using a clean Amazon EC2 Ubuntu 12.04 64bit. It didn't have mono on it before, and when I tried 3.2.5 it was another now deleted instance.
This is largely the same error as: RazorEngine on Mono - TemplateCompilationException thrown
But I had no other version installed. The build process added others which have since been deleted to no effect. All instances of mscorlib are here:
/usr/lib/mono/2.0/mscorlib.dll
/usr/lib/mono/4.5/mscorlib.dll
/usr/lib/mono/4.0/mscorlib.dll
I found out what the problem is and was able to solve it.
The culprit are these files:
https://github.com/mono/xsp/tree/master/src/Mono.WebServer.FastCgi/Compatibility
For some reason, they added these compaibility classes that are compiled to a NET 4.0 target (which does not have the IReadOnlyList class), but when we run the fastcgi-mono-server4, it runs under the 4.5 runtime, which do have a IReadOnlyList class and therefore generates the Razor HttpCompile error.
The solution was adding these 2 parameters -d:NET_4_5 -sdk:4.5 to the Makefile.in of the FastCGI source project:
#NET_4_0_TRUE# $(DMCS) -d:NET_2_0 -d:NET_4_0 -d:NET_4_5 -sdk:4.5 $(MCSFLAGS) $(references4) /out:$# \
Then I recompiled and reinstalled with ./configure, make, make install and the Razor compile error was gone for good.
If you don't want to go through all this trouble, I'd recommend sticking to the latest released version of the xsp project, which didn't have these Compatibility classes.