Closed homersimpsons closed 4 years ago
Hmm, need to evaluate this: in practice, self
is an alias to the current class, but it is problematic to use when generating inheritances.
Specifically, self
on a generated inheritance tree in parameters will lead to a crash (by design), which is why I didn't include self
nor its less known sibling static
in ReflectionType
on purpose.
Since zendframework/zend-code
is built to generate code, and that code will never adhere to personal quality standards expected by humans, I'd rather say that self
should not be used in this component, and instead the alias should be resolved to the target symbol.
I agree here with @Ocramius, this is not going to be addressed.
We can use some Coding Standard rules to replace current class name with self
.
Add
self
as a PHP Internal Type (#161)Why is the new feature needed? What purpose does it serve?
As per https://www.php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration
self
is a PHP valid type.Currently adding self will add a
\
(backslash) prefix leading to an undefined\self
class.How will users use the new feature?
Users will now be able to declare
self
as a Method return Type.Add tests for the new feature.
Test written to test this as a MethodGenerator return type. Test written to test this in TypeGenerator tests.
CHANGELOG.md
entry for the new feature.