From 4c0f97818480edca5d8c48e64d17c1a2de3acd6c Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Fri, 14 Feb 2020 15:13:12 +0100 Subject: [PATCH] Fix build on PHP 7.4 --- .../RequireParentConstructCallRuleTest.php | 25 +++++++++++++------ .../call-to-parent-constructor-php-lt-74.php | 11 ++++++++ .../data/call-to-parent-constructor.php | 10 -------- 3 files changed, 29 insertions(+), 17 deletions(-) create mode 100644 tests/Rules/Classes/data/call-to-parent-constructor-php-lt-74.php diff --git a/tests/Rules/Classes/RequireParentConstructCallRuleTest.php b/tests/Rules/Classes/RequireParentConstructCallRuleTest.php index c184464f..a390d998 100644 --- a/tests/Rules/Classes/RequireParentConstructCallRuleTest.php +++ b/tests/Rules/Classes/RequireParentConstructCallRuleTest.php @@ -2,6 +2,8 @@ namespace PHPStan\Rules\Classes; +use const PHP_VERSION_ID; + class RequireParentConstructCallRuleTest extends \PHPStan\Testing\RuleTestCase { @@ -21,21 +23,17 @@ public function testCallToParentConstructor(): void 'BCallToParentConstructor::__construct() does not call parent constructor from ACallToParentConstructor.', 51, ], - [ - 'CCallToParentConstructor::__construct() calls parent constructor but does not extend any class.', - 61, - ], [ 'FCallToParentConstructor::__construct() does not call parent constructor from DCallToParentConstructor.', - 86, + 76, ], [ 'BarSoapClient::__construct() does not call parent constructor from SoapClient.', - 129, + 119, ], [ 'StaticCallOnAVariable::__construct() does not call parent constructor from FooCallToParentConstructor.', - 140, + 130, ], ]); } @@ -45,4 +43,17 @@ public function testCheckInTraits(): void $this->analyse([__DIR__ . '/data/call-to-parent-constructor-in-trait.php'], []); } + public function testCallsParentButHasNotParent(): void + { + if (PHP_VERSION_ID >= 70400) { + self::markTestSkipped('This test does not support PHP 7.4 or higher.'); + } + $this->analyse([__DIR__ . '/data/call-to-parent-constructor-php-lt-74.php'], [ + [ + 'CCallToParentConstructor::__construct() calls parent constructor but does not extend any class.', + 6, + ], + ]); + } + } diff --git a/tests/Rules/Classes/data/call-to-parent-constructor-php-lt-74.php b/tests/Rules/Classes/data/call-to-parent-constructor-php-lt-74.php new file mode 100644 index 00000000..1efa1203 --- /dev/null +++ b/tests/Rules/Classes/data/call-to-parent-constructor-php-lt-74.php @@ -0,0 +1,11 @@ +