-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
Description
Bug report
Simple example:
<?php
class HelloWorld
{
public private(set) \DateTimeImmutable $createdAt {
get {
return $this->createdAt ??= new \DateTimeImmutable();
}
}
}Actual sandbox false-positive:
Class HelloWorld has an uninitialized property $createdAt. Give it default value or assign it in the constructor.
Actual PHPStan 2.1.3 false-positive:
Property HelloWorld::$createdAt is not writable
Actual PHPStan, in principle, considers any properties where setters are absent to be read-only, although this is not the case.
Code snippet that reproduces the problem
https://phpstan.org/r/70b0264c-11e8-4c22-94ad-f6cfaff44092
Expected output
- All OK
Did PHPStan help you today? Did it make you happy in any way?
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels