Skip to content

chore: refactor to declare more types#771

Draft
phil-davis wants to merge 1 commit into
sabre-io:masterfrom
phil-davis:declare-more-types
Draft

chore: refactor to declare more types#771
phil-davis wants to merge 1 commit into
sabre-io:masterfrom
phil-davis:declare-more-types

Conversation

@phil-davis

@phil-davis phil-davis commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Trying some changes to type declarations now that PHP 8.2 is the minimum.

I thought that it might be easy to remove lots of ReturnTypeWillChange.
But it turns out to not always be simple. See a few comments below.

@codecov

codecov Bot commented Jun 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.66%. Comparing base (55cb62c) to head (77f9657).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master     #771   +/-   ##
=========================================
  Coverage     98.66%   98.66%           
  Complexity     1757     1757           
=========================================
  Files            71       71           
  Lines          5163     5164    +1     
=========================================
+ Hits           5094     5095    +1     
  Misses           69       69           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread lib/Node.php
*/
#[\ReturnTypeWillChange]
public function offsetExists($offset): bool
public function offsetExists(mixed $offset): bool

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These don't look so good. The PHPdoc used to say that $offset is an int
But the parent ArrayAccess::offsetExists(mixed $offset): boolallows anything as parameter 1. So we can't writepublic function offsetExists(int $offset): bool`
So we seem to lose something here, the PHPdoc type hint goes, but we can't preserve it in the actual parameter type declaration.

Comment on lines -33 to +35
$param->addValue(1);
$param->addValue('1');

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

IMO addValue was supposed to always expect to be passed a string.
In this PR I enforced that. But this test was passing int literals to addValue

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.

1 participant