On Monday March 16 at 9:33 am Thomas Punt wrote:
Strictly speaking (pun intended), this is not true. A library can easily expose a
facade that enforces a user of that library (who is in weak mode) to have to write
in strict mode [1]. Once more, this can be done unintentionally [2] because of the
caller-deciding semantics. These examples can be further extended into wrapper
classes, nested library dependencies, etc.Sure, you could argue that this could easily be turned off by simply removing the
top declare() statement of that library, but modifying the library in itself introduces
complications - especially when using dependency managers like Composer.[1] https://gist.github.com/tpunt/4830d18d47e2df021c2f
[2] https://gist.github.com/tpunt/eecfed2495bdccb73632
This is a bug in the library. It declares strict mode but passes a value it
does not know to be an integer to a method requiring an integer. It can
be fixed by simply adding an int type declaration to the constructor or
test method.
Thanks,
Theodore
On Monday March 16 at 9:33 am Thomas Punt wrote:
Strictly speaking (pun intended), this is not true. A library can easily expose a
facade that enforces a user of that library (who is in weak mode) to have to write
in strict mode [1]. Once more, this can be done unintentionally [2] because of the
caller-deciding semantics. These examples can be further extended into wrapper
classes, nested library dependencies, etc.Sure, you could argue that this could easily be turned off by simply removing the
top declare() statement of that library, but modifying the library in itself introduces
complications - especially when using dependency managers like Composer.[1] https://gist.github.com/tpunt/4830d18d47e2df021c2f
[2] https://gist.github.com/tpunt/eecfed2495bdccb73632This is a bug in the library. It declares strict mode but passes a value it
does not know to be an integer to a method requiring an integer. It can
be fixed by simply adding an int type declaration to the constructor or
test method.
Indeed if you enable strict mode you definitely should type-hint all the
things or validate your inputs. That's a fairly obvious requirement IMO.
Cheers
Hey,
This is a bug in the library. It declares strict mode but passes a value it
does not know to be an integer to a method requiring an integer. It can
be fixed by simply adding an int type declaration to the constructor or
test method.
The second example is certainly a programmer error, but the first
example could be could considered design by intention to enforce
users to pass in the correct argument types.
Thanks,
Theodore
-Tom
This is a bug in the library. It declares strict mode but passes a value it
does not know to be an integer to a method requiring an integer. It can
be fixed by simply adding an int type declaration to the constructor or
test method.
It actually highlights a problem. Anything that says 'int $i' and rejects "1" as a value is defective PHP. You may not like that (I don't), but 20 years of legacy carry a certain weight.
K
--
Kristian Köhntopp http://google.com/+KristianKohntopp