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

Persistent typed property must not be accessed before initialization #286

janfejtek opened this issue Apr 8, 2021 · 0 comments


Copy link

Version: 3.1.2

Bug Description

When using non-nullable typed property marked as @persistent Error Typed property must not be accessed before initialization is thrown
This can be fixed by using nullable public ?int $id = null but I think that clearly marking variable as required for presenter is better for code readability.

Error occurs here:

$params[$name] = $this->$name;

Steps To Reproduce

class SomePresenter extends Presenter {
        /** @persistent */
        public int $id;
        public function actionSomething()

Possible Solution

Throw something like BadRequestException Missing parameter $id required by SomePresenter for typed properties
Do not throw error and skip all unitialized (or null) persistent values just by isset check

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

No branches or pull requests

1 participant