Re: STH and the 3 RFCs

From: Date: Mon, 16 Mar 2015 20:06:34 +0000
Subject: Re: STH and the 3 RFCs
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-85086@lists.php.net to get a copy of this message
> On 17 Mar 2015, at 1:33 am, Thomas Punt <tpunt@hotmail.co.uk> wrote: > > Hey David, >> A library written in weak or strict mode will have no bearing on its public API. > > 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 > > -Tom No, your example would blow up regardless of the caller being in strict mode or weak mode. The calls made in the library are strict, and will always fail with bad input. All you've shown is that poor code will blow up with poor input validation. If you had: <?php declare(strict_types=1); require 'library.php'; (new LibraryFacade)->test('1'); It would still error just as before. Cheers, David

« previous php.internals (#85086) next »