-
-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,7 +27,7 @@ class Opcache | |
| */ | ||
| public function getStatus() : array | ||
| { | ||
| if ($this->status ??= opcache_get_status(true)) { | ||
| if ($this->status = $this->status ?: opcache_get_status(true)) { | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. status is not nullable. |
||
| return $this->status; | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -135,7 +135,7 @@ protected function canGenerate(string $path, bool $overwrite) : bool | |
| } | ||
|
|
||
| // If there is a condition, call it. | ||
| if ($this->condition) { | ||
| if (is_callable($this->condition)) { | ||
| return (bool) call_user_func($this->condition); | ||
| } | ||
|
|
||
|
|
@@ -146,17 +146,17 @@ protected function canGenerate(string $path, bool $overwrite) : bool | |
| * Writes the preloader script file into the specified path. | ||
| * | ||
| * @param string $path | ||
| * @return false|int | ||
| * @return true | ||
| * | ||
| * @codeCoverageIgnore | ||
| */ | ||
| protected function performWrite(string $path) | ||
| { | ||
| 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]."); | ||
| } | ||
|
Comment on lines
155
to
157
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Put the unhappy path in the conditional. |
||
|
|
||
| throw new RuntimeException("Preloader couldn't write the script to [$path]."); | ||
| return true; | ||
| } | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ class PreloaderCompiler | |
| * | ||
| * @var false|string | ||
| */ | ||
| public string $contents; | ||
| public $contents; | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| /** | ||
| * Configuration array. | ||
|
|
@@ -67,7 +67,7 @@ class PreloaderCompiler | |
| * | ||
| * @return string|string[] | ||
| */ | ||
| public function compile() : string | ||
| public function compile() | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| { | ||
| $replacing = array_merge($this->preloaderConfig, $this->opcacheConfig, [ | ||
| '@output' => $this->scriptRealPath(), | ||
|
|
@@ -80,7 +80,7 @@ public function compile() : string | |
| ? 'require_once $file' : 'opcache_compile_file($file)', | ||
| ]); | ||
|
|
||
| return str_replace(array_keys($replacing), $replacing, $this->contents); | ||
| return str_replace(array_keys($replacing), $replacing, $this->contents ?: []); | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
|
|
||
| /** | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
$conditionproperty could be uninitialized.