Skip to content

Commit

Permalink
Fix build on PHP 7.4
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Feb 14, 2020
1 parent a670a59 commit caf5ad7
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
25 changes: 18 additions & 7 deletions tests/Rules/Classes/RequireParentConstructCallRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace PHPStan\Rules\Classes;

use const PHP_VERSION_ID;

class RequireParentConstructCallRuleTest extends \PHPStan\Testing\RuleTestCase
{

Expand All @@ -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,
],
]);
}
Expand All @@ -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) {
$this->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,
],
]);
}

}
11 changes: 11 additions & 0 deletions tests/Rules/Classes/data/call-to-parent-constructor-php-lt-74.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

class CCallToParentConstructor
{

public function __construct()
{
parent::__construct();
}

}
10 changes: 0 additions & 10 deletions tests/Rules/Classes/data/call-to-parent-constructor.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,6 @@ public function __construct()

}

class CCallToParentConstructor
{

public function __construct()
{
parent::__construct();
}

}

class DCallToParentConstructor
{

Expand Down

0 comments on commit caf5ad7

Please sign in to comment.