Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Return type self is not an internal type while code generation #161

Open
namlier opened this issue Oct 10, 2018 · 2 comments
Open

Return type self is not an internal type while code generation #161

namlier opened this issue Oct 10, 2018 · 2 comments
Labels

Comments

@namlier
Copy link

namlier commented Oct 10, 2018

Is it right behavior that TypeGenerator does not think self type is an internal type?
Because of that my code generation causes wrong return type in resulting file.
public function foo(): self
turns on
public function foo(): \self
It thinks self is a class.
Zend\Code\Generator\TypeGenerator:36
private static $internalPhpTypes = ['void', 'int', 'float', 'string', 'bool', 'array', 'callable', 'iterable'];

@Ocramius
Copy link
Member

@mastiuhin-olexandr self is an alias for "this class". Passing self to the TypeGenerator is incorrect, as self has no meaning without its surrounding context.

I'd rather say that it should be rejected completely, and an exception should be thrown.

@weierophinney
Copy link
Member

This repository has been closed and moved to laminas/laminas-code; a new issue has been opened at laminas/laminas-code#4.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants