> On Sep 5, 2016, at 02:38, Nicolas Grekas <nicolas.gre...@gmail.com> wrote:
> 
> Hello,
> 
> It looks like we miss a way to check by reflection if a function/method has
> strict types enabled or not.
> 
> We'd need to do this in Symfony to generate a file with concatenated
> classes, but split "declare_strict=1" classes out so that they don't break
> (because there is no way to create a single file that contains both strict
> and non-strict classes unfortunately also).
> 
> Would it be possible to expose some flavor of ZEND_ACC_STRICT_TYPES to
> userland?

Strict types are only enforced from the CALL site. A library author cannot 
dictate that their code be called using strict types or not, only the file 
actually calling the library methods can. Though, regardless, the type hints do 
ensure that the value received is of the type specified, you just won't know if 
it was coerced or not.

Just like when you import a namespaced class and alias it, the alias only works 
in the file the "use " statement is in.

Therefore, you cannot actually author strict or non-strict classes period, 
unless they are only called in the file in which they are defined.

This means you cannot reflect on it, unless we start doing reflection on source 
code files themselves.

 - Davey

Reply via email to