rfc:class_name_scalars

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
rfc:class_name_scalars [2012/09/11 20:09] – [Use case] edited real world use cases ralphschindlerrfc:class_name_scalars [2012/09/11 20:18] – [Real World Usage Scenarios] udpated ralphschindler
Line 71: Line 71:
 </code> </code>
  
 +4. General PHP Usage:
 +
 +<code php>
 +
 +use MyVendor\SomeComponent\TargetNs as T;
 +
 +// reflection
 +$r = new ReflectionClass(T\Foo::class); // instead of new ReflectionClass('MyVendor\SomeComponent\TargetNs\Foo');
 +
 +// class_exists, also applies to any php function that takes a class name (is_subclass_of, get_class_methods, etc)
 +if (class_exists(T\Foo::class, true)) {} // instead of class_exists('MyVendor\SomeComponent\TargetNs\Foo')
 +
 +</code>
 ===== Choice of syntax ===== ===== Choice of syntax =====
  
rfc/class_name_scalars.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1