-
-
Notifications
You must be signed in to change notification settings - Fork 25
Fix problems reported by PHPStan #60
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
base: master
Are you sure you want to change the base?
Conversation
| * If this Preloader should run | ||
| * | ||
| * @var callable | ||
| * @var callable|null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$condition property could be uninitialized.
| public function getStatus() : array | ||
| { | ||
| if ($this->status ??= opcache_get_status(true)) { | ||
| if ($this->status = $this->status ?: opcache_get_status(true)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
status is not nullable.
| { | ||
| if (file_put_contents($path, $this->prepareCompiler($path)->compile(), LOCK_EX)) { | ||
| return true; | ||
| if (file_put_contents($path, $this->prepareCompiler($path)->compile(), LOCK_EX) === false) { | ||
| throw new RuntimeException("Preloader couldn't write the script to [$path]."); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put the unhappy path in the conditional.
| * @var false|string | ||
| */ | ||
| public string $contents; | ||
| public $contents; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$contents could be false.
| * @return string|string[] | ||
| */ | ||
| public function compile() : string | ||
| public function compile() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
compile() can return an array.
| ]); | ||
|
|
||
| return str_replace(array_keys($replacing), $replacing, $this->contents); | ||
| return str_replace(array_keys($replacing), $replacing, $this->contents ?: []); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$contents could be false.
Please be gentle with me. I am very bad at arguing.
In
writeToand inperformWrite"return-false world" and exception world (OOP) collide 💥Please thrown an exception, do not return a boolean.
OR! :) https://phpstan.org/r/d87dbd47-070a-4cd7-a85c-0a44067e5fdd