Skip to content

chore(ci): add failOnDeprecation to PHPunit config - #344

Merged
phil-davis merged 2 commits into
sabre-io:masterfrom
phil-davis:failOnDeprecation
Aug 26, 2026
Merged

chore(ci): add failOnDeprecation to PHPunit config#344
phil-davis merged 2 commits into
sabre-io:masterfrom
phil-davis:failOnDeprecation

Conversation

@phil-davis

Copy link
Copy Markdown
Contributor

phpunit on PHP 8.4 and later was reporting a deprecation:

$ composer phpunit
PHPUnit 11.5.56 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.4.24
Configuration: /home/phil/git/sabre-io/xml/tests/phpunit.xml

.....D.........................................................  63 / 116 ( 54%)
.....................................................           116 / 116 (100%)

Time: 00:00.036, Memory: 10.00 MB

1 test triggered 1 PHP deprecation:

1) /home/phil/git/sabre-io/xml/lib/Deserializer/functions.php:361
Calling ReflectionMethod::__construct() with 1 argument is deprecated, use ReflectionMethod::createFromMethodName() instead

Triggered by:

* Sabre\Xml\Deserializer\FunctionCallerTest::testDeserializeFunctionCallerWithDifferentTypesOfCallable
  /home/phil/git/sabre-io/xml/tests/Sabre/Xml/Deserializer/FunctionCallerTest.php:65

OK, but there were issues!
Tests: 116, Assertions: 150, Deprecations: 1.

I think that we may as well get phpunit to fail in this case, and we can easily sort out the needed code change now, rather than waiting until we are forced to do it (when PHP 9 happens, probably)

@phil-davis
phil-davis requested a review from staabm August 26, 2026 05:23
@codecov

codecov Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.45%. Comparing base (782f532) to head (901a903).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #344      +/-   ##
============================================
+ Coverage     96.44%   96.45%   +0.01%     
  Complexity      118      118              
============================================
  Files            13       13              
  Lines           478      480       +2     
============================================
+ Hits            461      463       +2     
  Misses           17       17              

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

@phil-davis

Copy link
Copy Markdown
Contributor Author
Note: Using configuration file /home/runner/work/xml/xml/phpstan.neon.
  0/39 [░░░░░░░░░░░░░░░░░░░░░░░░░░░░]   0%
 39/39 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

Error: Call to an undefined static method ReflectionMethod::createFromMethodName().
 ------ ------------------------------------------- 
  Line   lib/Deserializer/functions.php             
 ------ ------------------------------------------- 
  362    Call to an undefined static method         
         ReflectionMethod::createFromMethodName().  
         🪪  staticMethod.notFound                  
 ------ ------------------------------------------- 


 [ERROR] Found 1 error                                                          

Script phpstan analyse handling the phpstan event returned with error code 1

I thought that phpstan was smart enough to realise that code inside an if statement like:

        if (PHP_VERSION_ID >= 80400) {
            $ref = \ReflectionMethod::createFromMethodName($func);
        } else {
            $ref = new \ReflectionMethod($func);
        }

is only for PHP 8.4 and up, and that createFromMethodName exists in those versions.

Looks like I have to work around that.

Signed-off-by: Phillip Davis <phil@jankaritech.com>
@staabm

staabm commented Aug 26, 2026

Copy link
Copy Markdown
Member

I opened phpstan/phpstan#15109

We should baseline/ignore the issue for now

Signed-off-by: Phillip Davis <phil@jankaritech.com>
@phil-davis
phil-davis merged commit 28a027d into sabre-io:master Aug 26, 2026
6 checks passed
@phil-davis
phil-davis deleted the failOnDeprecation branch August 26, 2026 07:48
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