Skip to content
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

Merged
merged 9 commits into from
Aug 29, 2022
Merged

PHP min version 7.4 #97

merged 9 commits into from
Aug 29, 2022

Conversation

phil-davis
Copy link
Contributor

@phil-davis phil-davis commented Aug 24, 2022

Drop PHP below 7.1

Add type declarations.

Increase phpstan level to 6.

Also run the tests with PHP 8.2 in CI.

@phil-davis phil-davis self-assigned this Aug 24, 2022
@codecov
Copy link

codecov bot commented Aug 24, 2022

Codecov Report

Merging #97 (933b5a6) into master (2a7bd1b) will decrease coverage by 0.03%.
The diff coverage is 100.00%.

@@             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              
Impacted Files Coverage Δ
lib/Loop/functions.php 100.00% <ø> (ø)
lib/Promise/functions.php 100.00% <ø> (ø)
lib/EmitterTrait.php 100.00% <100.00%> (ø)
lib/Loop/Loop.php 100.00% <100.00%> (ø)
lib/Promise.php 100.00% <100.00%> (ø)
lib/WildcardEmitterTrait.php 100.00% <100.00%> (ø)
lib/coroutine.php 96.77% <0.00%> (-0.45%) ⬇️
... and 3 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

.github/workflows/ci.yml Outdated Show resolved Hide resolved
@phil-davis phil-davis requested a review from staabm August 24, 2022 16:44
@phil-davis phil-davis marked this pull request as ready for review August 24, 2022 16:47
lib/Promise/functions.php Outdated Show resolved Hide resolved
@phil-davis
Copy link
Contributor Author

@staabm any other review comments?

lib/EmitterInterface.php Outdated Show resolved Hide resolved
lib/Promise/functions.php Outdated Show resolved Hide resolved
Comment on lines +6 to +12
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which lines were affected?

Copy link
Contributor Author

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.  
 ------ --------------------------------- 

Copy link
Member

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

Copy link
Contributor Author

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?

Copy link
Member

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

Copy link
Contributor Author

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?

Copy link
Contributor Author

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.

@phil-davis phil-davis merged commit 3937405 into sabre-io:master Aug 29, 2022
@phil-davis phil-davis deleted the php-7.4 branch August 29, 2022 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants