Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.
This repository was 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

@namlier

Description

@namlier

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'];

Activity

Ocramius

Ocramius commented on Oct 15, 2018

@Ocramius
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

weierophinney commented on Dec 31, 2019

@weierophinney
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 join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @weierophinney@Ocramius@namlier

        Issue actions

          Return type self is not an internal type while code generation · Issue #161 · zendframework/zend-code