Hello Bishop,

 

For your first example I do not know what will be the best way but assume 
something like:

 

God::create(God::chicken);

 

In cases when you are giving strings to PHP (like in example with 
$_REQUEST[‘animal’]) all should work as is

 

Idea of nameof (at least in my understanding) is to reduce string usage and 
replace them with “strongly” typed “pointers” which can give us feedback while 
script is processed (like when you misstyped method name php will give you 
fatal error).

 

You are right – tools like ag <https://github.com/ggreer/the_silver_searcher>  
--php "'God'" will do the work, but when it comes to rename method – there 
might be troubles, for example if I have code like:

 

class God { public function chicken() {} }

$data = $_REQUEST[‘chicken’];

calluser_func(God::class, ‘chicken’);

 

you cannot just rename word “chicken” in your code.

 

Also while you are typing God::chi| - you can get autocomplete, which will help 
you write less code and make less mistakes

 

Reply via email to