-
Notifications
You must be signed in to change notification settings - Fork 21
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
PHP min version 7.4 #97
Conversation
Codecov Report
@@ Coverage Diff @@
## master #97 +/- ##
============================================
- Coverage 99.74% 99.71% -0.04%
+ Complexity 110 109 -1
============================================
Files 7 7
Lines 397 349 -48
============================================
- Hits 396 348 -48
Misses 1 1
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@staabm any other review comments? |
message: "#^If condition is always true.$#" | ||
count: 1 | ||
path: lib/Loop/Loop.php | ||
- | ||
message: "#^Left side of && is always true.$#" | ||
count: 1 | ||
path: lib/Loop/Loop.php |
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.
which lines were affected?
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.
------ ------------------------------
Line lib/Loop/Loop.php
------ ------------------------------
72 If condition is always true.
178 Left side of && is always 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.
seems legit, thx for the hint
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.
public function setInterval(callable $cb, float $timeout): array
{
$keepGoing = true;
$f = null;
$f = function () use ($cb, &$f, $timeout, &$keepGoing) {
if ($keepGoing) {
$cb();
$this->setTimeout($f, $timeout);
}
};
$this->setTimeout($f, $timeout);
// Really the only thing that matters is returning the $keepGoing
// boolean value.
//
// We need to pack it in an array to allow returning by reference.
// Because I'm worried people will be confused by using a boolean as a
// sort of identifier, I added an extra string.
return ['I\'m an implementation detail', &$keepGoing];
}
I guess that $cb
can modify the value at the address &$keepGoing
- but phpstan
has no way to really know that?
Maybe I should add a phpstan "ignore line" tag with a comment?
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.
phpstan has some open problems regarding references. I think its not worth the effort
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.
public function run(): void
{
$this->running = true;
do {
$hasEvents = $this->tick(true);
} while ($this->running && $hasEvents);
$this->running = false;
}
$this->running
is "always true" inside the loop. It gets set to false
in the stop()
method. I guess that there is some way for stop()
to happen? And phpstan has no way understand that?
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.
phpstan has some open problems regarding references. I think its not worth the effort
yeh, I will just leave it in the ignored-errors list. A later phpstan release might come along and "magically" not report this any more.
Drop PHP below 7.1
Add type declarations.
Increase phpstan level to 6.
Also run the tests with PHP 8.2 in CI.