Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4c0f978

Browse files
Fix build on PHP 7.4
1 parent a670a59 commit 4c0f978

File tree

3 files changed

+29
-17
lines changed

3 files changed

+29
-17
lines changed

‎tests/Rules/Classes/RequireParentConstructCallRuleTest.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace PHPStan\Rules\Classes;
44

5+
use const PHP_VERSION_ID;
6+
57
class RequireParentConstructCallRuleTest extends \PHPStan\Testing\RuleTestCase
68
{
79

@@ -21,21 +23,17 @@ public function testCallToParentConstructor(): void
2123
'BCallToParentConstructor::__construct() does not call parent constructor from ACallToParentConstructor.',
2224
51,
2325
],
24-
[
25-
'CCallToParentConstructor::__construct() calls parent constructor but does not extend any class.',
26-
61,
27-
],
2826
[
2927
'FCallToParentConstructor::__construct() does not call parent constructor from DCallToParentConstructor.',
30-
86,
28+
76,
3129
],
3230
[
3331
'BarSoapClient::__construct() does not call parent constructor from SoapClient.',
34-
129,
32+
119,
3533
],
3634
[
3735
'StaticCallOnAVariable::__construct() does not call parent constructor from FooCallToParentConstructor.',
38-
140,
36+
130,
3937
],
4038
]);
4139
}
@@ -45,4 +43,17 @@ public function testCheckInTraits(): void
4543
$this->analyse([__DIR__ . '/data/call-to-parent-constructor-in-trait.php'], []);
4644
}
4745

46+
public function testCallsParentButHasNotParent(): void
47+
{
48+
if (PHP_VERSION_ID >= 70400) {
49+
self::markTestSkipped('This test does not support PHP 7.4 or higher.');
50+
}
51+
$this->analyse([__DIR__ . '/data/call-to-parent-constructor-php-lt-74.php'], [
52+
[
53+
'CCallToParentConstructor::__construct() calls parent constructor but does not extend any class.',
54+
6,
55+
],
56+
]);
57+
}
58+
4859
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
class CCallToParentConstructor
4+
{
5+
6+
public function __construct()
7+
{
8+
parent::__construct();
9+
}
10+
11+
}

‎tests/Rules/Classes/data/call-to-parent-constructor.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,6 @@ public function __construct()
5555

5656
}
5757

58-
class CCallToParentConstructor
59-
{
60-
61-
public function __construct()
62-
{
63-
parent::__construct();
64-
}
65-
66-
}
67-
6858
class DCallToParentConstructor
6959
{
7060

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /