Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions build/PHPStan/Build/RequiredPhpVersionVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ public function enterNode(Node $node): ?Node
$this->require(self::PHP_8_1, 'readonly properties', $node);
}

if ($node instanceof Node\Param && $node->flags !== 0) {
$this->require(self::PHP_8_0, 'promoted properties', $node);
}

if ($node instanceof Node\Param && ($node->flags & Modifiers::READONLY) !== 0) {
$this->require(self::PHP_8_1, 'readonly promoted properties', $node);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/PHPStan/Analyser/data/bug-7116.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php declare(strict_types = 1);

<?php // lint >= 8.0
declare(strict_types = 1);
namespace Bug7116;

#[\Attribute(\Attribute::TARGET_CLASS)]
Expand Down
2 changes: 1 addition & 1 deletion tests/PHPStan/Analyser/nsrt/assert-constructor.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php // lint >= 8.0

namespace AssertConstructor;

Expand Down
2 changes: 1 addition & 1 deletion tests/PHPStan/Analyser/nsrt/assert-this.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php // lint >= 8.0

namespace AssertThis;

Expand Down
4 changes: 2 additions & 2 deletions tests/PHPStan/Analyser/nsrt/bug-13851.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php declare(strict_types=1);

<?php // lint >= 8.0
declare(strict_types=1);
namespace Bug13851;

use function PHPStan\Testing\assertType;
Expand Down
2 changes: 1 addition & 1 deletion tests/PHPStan/Analyser/nsrt/bug-14645.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php // lint >= 8.0

namespace Bug14645;

Expand Down
4 changes: 2 additions & 2 deletions tests/PHPStan/Analyser/nsrt/bug-6633.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php declare(strict_types = 1);

<?php // lint >= 8.0
declare(strict_types = 1);
namespace Bug6633;

use function PHPStan\Testing\assertType;
Expand Down
2 changes: 1 addition & 1 deletion tests/PHPStan/Analyser/nsrt/bug-8008.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php // lint >= 8.0

namespace Bug8008;

Expand Down
2 changes: 1 addition & 1 deletion tests/PHPStan/Analyser/nsrt/bug-9455.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php // lint >= 8.0

namespace Bug9455;

Expand Down
4 changes: 4 additions & 0 deletions tests/PHPStan/Build/RequiredPhpVersionCommentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ public static function dataDetectedVersion(): iterable
yield 'mixed property type' => ['<?php class Foo { public mixed $x; }', 80000];
yield 'enum' => ['<?php enum Foo { case A; }', 80100];
yield 'readonly property' => ['<?php class Foo { public readonly int $x; }', 80100];
yield 'promoted property' => ['<?php class Foo { public function __construct(public int $x) {} }', 80000];
yield 'promoted property protected' => ['<?php class Foo { public function __construct(protected int $x) {} }', 80000];
yield 'promoted property private' => ['<?php class Foo { public function __construct(private int $x) {} }', 80000];
yield 'non-promoted parameter' => ['<?php class Foo { public function __construct(int $x) {} }', null];
yield 'readonly promoted property' => ['<?php class Foo { public function __construct(public readonly int $x) {} }', 80100];
yield 'union type' => ['<?php function foo(A|B $x) {}', 80000];
yield 'union return type' => ['<?php function foo(): A|B {}', 80000];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php // lint >= 8.0

namespace InstantiationPromotedProperties;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php // lint >= 8.0

namespace InvalidPromotedProperties;

Expand Down
4 changes: 2 additions & 2 deletions tests/PHPStan/Rules/Functions/data/bug-10298.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php declare(strict_types = 1);

<?php // lint >= 8.0
declare(strict_types = 1);
namespace Bug10298;

#[\Attribute(\Attribute::TARGET_PROPERTY)]
Expand Down
2 changes: 1 addition & 1 deletion tests/PHPStan/Rules/Functions/data/bug-10732.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php // lint >= 8.0

namespace Bug10732;

Expand Down
4 changes: 2 additions & 2 deletions tests/PHPStan/Rules/Functions/data/bug-12317.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php declare(strict_types = 1);

<?php // lint >= 8.0
declare(strict_types = 1);
namespace Bug12317;

class Uuid {
Expand Down
2 changes: 1 addition & 1 deletion tests/PHPStan/Rules/Functions/data/bug-12499.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php // lint >= 8.0

namespace Bug12499;

Expand Down
4 changes: 2 additions & 2 deletions tests/PHPStan/Rules/Functions/data/bug-6633.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php declare(strict_types = 1);

<?php // lint >= 8.0
declare(strict_types = 1);
namespace Bug6633\Rule;

class CreateServiceSolrData
Expand Down
2 changes: 1 addition & 1 deletion tests/PHPStan/Rules/Functions/data/param-attributes.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php // lint >= 8.0

namespace ParamAttributes;

Expand Down
4 changes: 2 additions & 2 deletions tests/PHPStan/Rules/Methods/data/bug-11067.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php declare(strict_types = 1);

<?php // lint >= 8.0
declare(strict_types = 1);
namespace Bug11067;

interface BuilderInterface
Expand Down
2 changes: 1 addition & 1 deletion tests/PHPStan/Rules/Methods/data/bug-13511.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php // lint >= 8.0

namespace Bug13511;

Expand Down
2 changes: 1 addition & 1 deletion tests/PHPStan/Rules/Methods/data/bug-13993.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php // lint >= 8.0

namespace Bug13993;

Expand Down
2 changes: 1 addition & 1 deletion tests/PHPStan/Rules/Methods/data/bug-6353.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php // lint >= 8.0

namespace Bug6353;

Expand Down
4 changes: 2 additions & 2 deletions tests/PHPStan/Rules/Methods/data/bug-7662.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php declare(strict_types = 1);

<?php // lint >= 8.0
declare(strict_types = 1);
namespace Bug7662;

class Foo {
Expand Down
2 changes: 1 addition & 1 deletion tests/PHPStan/Rules/Methods/data/bug-9494.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php // lint >= 8.0

namespace Bug9494;

Expand Down
2 changes: 1 addition & 1 deletion tests/PHPStan/Rules/Methods/data/bug-9766.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php // lint >= 8.0

namespace Bug9766;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php // lint >= 8.0

namespace ReflectionClassIssue8679;

Expand Down
Loading