First, if I am replying to the wrong thing I apologize; this method of commenting on SitePoint is uber confusing…
Anyway, regarding the strictification not causing any harm because it is optional, I respectfully disagree. Few if any PHP coders are in full control of their entire codebase. In most cases developers would be foolish to control their entire codebase as modern frameworks make much better starting points for most projects.
So saying that optional means no harm is ignoring the use in frameworks and the fact that zealous well-intentioned framework developers will likely begin to add strictness to their framework in ways that are detrimental to flexibility. In some cases adding strictness means painting a developer into a corner that without strictness would not exist. And why this is of concern is that it is hard for the developer who adds strictness to envision the use-cases where strictness will cause problems and thus they will think they are doing the best thing.
I ran a business that revolved around Visual Basic back when more than 50% of worldwide developers used VB. Microsoft released a stricter Visual Basic as VB.NET, and since then we’ve seen usage plummet to a rounding error. Just sayin…
It sounds like you didn’t dive too deep into the suggested implementation - the strictness would be activated by the code calling it, not the code defining it. So even if a lib in its entirety uses strict mode, if we call it from a non-strict part of code, all is well, strictness is ignored. There would be no painting of anyone into a corner this way.
I thought I had dived deep – I usually try to do so before commenting – but I looked again and could not find reference to that. Can you point me to it, please?
Or better, what’s the syntax the caller would use require strictness vs. not require it?
BTW, I work with WordPress and using hooks I can still see where strictness could cause problems because my return value on a hook my then get returned to a function call that (needlessly) requires strictness.
I had a written reference somewhere, but cannot find it right now. In the meanwhile, please see this, it’s discussed in detail here if I remember correctly.
If you declare strict mode in a file, then everything that ends up executing as a result of that file will respect strict rules. If you don’t, then it’s weak, even if the third party code you’re using is fully written in strict mode.