Hi guys,
Got issue on my last php-cs-fixer run. On my method, I need to return an object, if that object is not found, it's a null (cause if we are going deeper into the code notion, Object -> pointer -> null if nothing).
As I come from C / C ++ development, it's for me a best practice to handle that way.
But the script rewrite my return null to return..
I'm just asking why this is hardcoded that way ? The type returned is different, it should not touch this.
Thanks :)
Hi,
It is not hardcoded so you can fix this :)
The reason is that the SF doesn't like return null; until recently since the void type has added to PHP7.1.
To stop PHP-CS-Fixer from replacing return null; with return; don't use the empty_return fixer (called simplified_null_return on master), either by removing in your configuration file (or add -empty_return to the fixers list), or use something like --fixers=-empty_return if you run the app from the command line.
@SpacePossum Yeah I exaggerated on the "hardcoded" term =D
Alright, thanks for the tips :) Gonna use this now.
Most helpful comment
@SpacePossum Yeah I exaggerated on the "hardcoded" term =D
Alright, thanks for the tips :) Gonna use this now.