Fix problems reported by PHPStan#60
Open
szepeviktor wants to merge 1 commit intoDarkGhostHunter:masterfrom
Open
Fix problems reported by PHPStan#60szepeviktor wants to merge 1 commit intoDarkGhostHunter:masterfrom
szepeviktor wants to merge 1 commit intoDarkGhostHunter:masterfrom
Conversation
szepeviktor
commented
Aug 5, 2023
| * If this Preloader should run | ||
| * | ||
| * @var callable | ||
| * @var callable|null |
Author
There was a problem hiding this comment.
$condition property could be uninitialized.
szepeviktor
commented
Aug 5, 2023
| public function getStatus() : array | ||
| { | ||
| if ($this->status ??= opcache_get_status(true)) { | ||
| if ($this->status = $this->status ?: opcache_get_status(true)) { |
szepeviktor
commented
Aug 5, 2023
Comment on lines
155
to
157
| { | ||
| 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]."); | ||
| } |
Author
There was a problem hiding this comment.
Put the unhappy path in the conditional.
szepeviktor
commented
Aug 5, 2023
| * @var false|string | ||
| */ | ||
| public string $contents; | ||
| public $contents; |
szepeviktor
commented
Aug 5, 2023
| * @return string|string[] | ||
| */ | ||
| public function compile() : string | ||
| public function compile() |
Author
There was a problem hiding this comment.
compile() can return an array.
szepeviktor
commented
Aug 5, 2023
| ]); | ||
|
|
||
| return str_replace(array_keys($replacing), $replacing, $this->contents); | ||
| return str_replace(array_keys($replacing), $replacing, $this->contents ?: []); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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