You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<?php/** * @psalm-immutable */class Some
{
// it was a `?string $locale` in pastprivatestring$locale;
publicfunction__construct(
string$locale,
) {
$this->locale = $locale;
}
publicfunction__wakeup(): void
{
// it was a `?string $locale` in pastif (false === isset($this->locale)) {
$this->locale = '';
}
}
}
Psalm output (using commit [37cc4fd](https://github.com/vimeo/psalm/commit/37cc4fd)):
ERROR: [RedundantPropertyInitializationCheck](https://psalm.dev/261) - 20:13 - Property $this->locale with type string should already be set in the constructor
ERROR: [InaccessibleProperty](https://psalm.dev/054) - 21:13 - Some::$locale is marked readonly
What's the proper way to handle it?
Suppress both issues or psalm may allow such a checks and updates for magic method like a __wakeup?
As of #10180 (comment) - the current issue requests for a feature in Psalm - don't emit such errors for code like above in the __wakeup.
The text was updated successfully, but these errors were encountered:
<?php/** * @psalm-immutable */class Some
{
// it was a `?string $locale` in pastprivatestring$locale;
publicfunction__construct(
string$locale,
) {
$this->locale = $locale;
}
publicfunction__wakeup(): void
{
// it was a `?string $locale` in pastif (false === isset($this->locale)) {
$this->locale = '';
}
}
}
Psalm output (using commit 37cc4fd):
ERROR: RedundantPropertyInitializationCheck - 20:13 - Property $this->locale with type string should already be set in the constructor
ERROR: InaccessibleProperty - 21:13 - Some::$locale is marked readonly
Discussed in #10180
Originally posted by andrew-demb September 5, 2023
https://psalm.dev/r/0b9d93cacf
What's the proper way to handle it?
Suppress both issues or psalm may allow such a checks and updates for magic method like a
__wakeup
?As of #10180 (comment) - the current issue requests for a feature in Psalm - don't emit such errors for code like above in the
__wakeup
.The text was updated successfully, but these errors were encountered: