Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected PropertyNotSetInConstructor #2923

Closed
mjnbock opened this issue Mar 6, 2020 · 1 comment
Closed

Unexpected PropertyNotSetInConstructor #2923

mjnbock opened this issue Mar 6, 2020 · 1 comment
Labels

Comments

@mjnbock
Copy link

mjnbock commented Mar 6, 2020

// PropertyNotSetInConstructor FooBarBaz::$val
class FooBarBaz extends BarBaz{
    public function __construct() { parent::__construct('val'); }
}

class BarBaz extends Baz
{
    /** @var string */
    protected $val;
    //private $val; // no issue found

    public function __construct(string $val='')
    {
        $this->val = $val;
        if (true)
            parent::__construct();

        // no issue found without if:
        //parent::__construct();

        // no issue found without calling parent constructor at all
    }
}

class Baz {
    public function __construct() { }
}

This seems to unexpectedly trigger PropertyNotSetInConstructor,
despite the property being set by the parent constructor.

@muglug muglug added the bug label Mar 6, 2020
@muglug muglug closed this as completed in a2a5071 Mar 6, 2020
@muglug
Copy link
Collaborator

muglug commented Mar 6, 2020

Yeah, looks like this was caused by a hacky fix for #1309 – the tests for that still appear to work when I removed the "fix" conditional

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

No branches or pull requests

2 participants