Php.ini settings for absolute maximum strictness

For MySQL I’ve got:


sql-mode="STRICT_ALL_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ZERO_DATE,NO_ZERO_IN_DATE,NO_AUTO_CREATE_USER"

which AFAIK sets MySQL to it’s absolutely maximum possible strictness. What settings should I have in my php.ini file to set PHP to its absolutely maximum possible strictness?

I have mine set at error_reporting( -1 ); which I believe is the maximum setting,

Edit:
Just checked the online manual:

// Report all PHP errors
error_reporting(-1);

I was thinking more on the lines of things like where you don’t specify what type of variable a variable is (eg string, integer, etc) that it would force you to always specify what type of variable it is

You can’t do that in php.ini, but if you want check you’re using the correct types of variables the first thing to do is to declare(strict_types=1); in all your files, and you can do additional checking using phpstan. I would recommend to start with level 1 and work your way up to level 7.
I’ve been using phpstan for a few months now and it’s caught a lot of tiny mistakes already.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.