plugin-php icon indicating copy to clipboard operation
plugin-php copied to clipboard

Case build-in classes

Open alexander-akait opened this issue 7 years ago • 1 comments

Ref: http://php.net/manual/en/reserved.classes.php In php allowed use any case of build-in class:

$exception = new Exception('Message');
$exception = new EXCEPTION('Message');
$exception = new eXcEpTiOn('Message');

Always return exception build-in class. Should we prettify class names? Also don't forget about namespaces.

  1. File without namespace - new Exception() === new \Exception();.
  2. File with namespace - new Exception !== new \Exception.

In theory we can do it:

  1. If namespace exists only correct new \Exception();
  2. If namespace doesn't exists correct and new Exception() and new \Exception();

alexander-akait avatar Mar 11 '18 18:03 alexander-akait

I think there is too much complexity to do this here. To fix this the parser would have to be aware of all built-in classes and be able to resolve the namespaces correctly, which is impossible in some situations currently as only single files are parsed.

As cool as it would be, I don't think this is the right tool for that job.

cseufert avatar Jul 15 '21 10:07 cseufert