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 @@ -125,6 +125,10 @@ public function enterNode(Node $node): ?Node
}
}

if ($node instanceof Node\Arg && $node->name !== null) {
$this->require(self::PHP_8_0, 'named arguments', $node);
}

$this->checkStandaloneType($node);
$this->checkMixedType($node);

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

namespace Bug14596;

Expand Down
2 changes: 1 addition & 1 deletion tests/PHPStan/Analyser/data/bug-9428.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php declare(strict_types = 1);
<?php declare(strict_types = 1); // lint >= 8.0

namespace Bug9428;

Expand Down
2 changes: 1 addition & 1 deletion tests/PHPStan/Analyser/data/discussion-7124.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php declare(strict_types = 1);
<?php declare(strict_types = 1); // lint >= 8.0

namespace Discussion7124;

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

namespace Bug4510;

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

namespace Bug5262;

Expand Down
7 changes: 7 additions & 0 deletions tests/PHPStan/Build/RequiredPhpVersionCommentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ public static function dataDetectedVersion(): iterable
yield 'nullable union type' => ['<?php function foo(A|null $x) {}', 80000];
yield 'intersection type' => ['<?php function foo(A&B $x) {}', 80100];
yield 'first-class callable' => ['<?php strlen(...);', 80100];
yield 'named argument in function call' => ['<?php str_repeat(string: "a", times: 2);', 80000];
yield 'named argument in method call' => ['<?php $foo->bar(baz: 1);', 80000];
yield 'named argument in nullsafe method call' => ['<?php $foo?->bar(baz: 1);', 80000];
yield 'named argument in static call' => ['<?php Foo::bar(baz: 1);', 80000];
yield 'named argument in new' => ['<?php new Foo(bar: 1);', 80000];
yield 'named argument in attribute' => ['<?php #[Foo(bar: 1)] class C {}', 80000];
yield 'positional argument only' => ['<?php str_repeat("a", 2);', null];
yield 'readonly class' => ['<?php readonly class Foo {}', 80200];
yield 'standalone null type' => ['<?php function foo(): null { return null; }', 80200];
yield 'standalone false type' => ['<?php function foo(): false { return false; }', 80200];
Expand Down
2 changes: 1 addition & 1 deletion tests/PHPStan/Rules/Classes/data/class-attributes.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php // lint >= 8.0

namespace ClassAttributes;

Expand Down
12 changes: 6 additions & 6 deletions tests/PHPStan/Rules/Functions/CallCallablesRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,27 +391,27 @@ public function testBug4510(): void
$this->analyse([__DIR__ . '/../../Analyser/nsrt/bug-4510.php'], [
[
'Trying to invoke array{$this(Bug4510\HelloWorld), string} but it might not be a callable.',
16,
17,
],
[
'Trying to invoke array{Bug4510\HelloWorld, string} but it might not be a callable.',
27,
28,
],
[
"Trying to invoke array{'Bug4510\\\HelloWorld', string} but it might not be a callable.",
46,
47,
],
[
'Trying to invoke array{Bug4510\HelloWorld, string} but it might not be a callable.',
90,
91,
],
[
'Trying to invoke array{Bug4510\HelloWorld, string} but it might not be a callable.',
118,
119,
],
[
'Trying to invoke array{Bug4510\HelloWorld, string} but it might not be a callable.',
133,
134,
],
]);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/PHPStan/Rules/Functions/data/array_values_list.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php // lint >= 8.0

/** @var list<int> $list */
$list = [1, 2, 3];
Expand Down
2 changes: 1 addition & 1 deletion tests/PHPStan/Rules/Functions/data/bug-11418.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php // lint >= 8.0

namespace Bug11418;

Expand Down
2 changes: 1 addition & 1 deletion tests/PHPStan/Rules/Functions/data/bug-13719.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php declare(strict_types = 1);
<?php declare(strict_types = 1); // lint >= 8.0

namespace Bug13719;

Expand Down
2 changes: 1 addition & 1 deletion tests/PHPStan/Rules/Functions/data/bug-8046.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php declare(strict_types = 1);
<?php declare(strict_types = 1); // lint >= 8.0

namespace Bug8046;

Expand Down
2 changes: 1 addition & 1 deletion tests/PHPStan/Rules/Functions/data/bug-9823.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php declare(strict_types=1);
<?php declare(strict_types=1); // lint >= 8.0

namespace Bug9823;

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

namespace CallablesNamedArguments;

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

namespace ConstantParameterCheck;

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

namespace FunctionCallStatementNoSideEffectsPhp8;

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

namespace ImplodeNamedParameters;

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

namespace FunctionNamedArgumentsAfterUnpacking;

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

namespace FunctionNamedArguments;

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

namespace Bug14596Methods;

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

namespace Bug5898;

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

namespace Bug7434;

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

namespace ConstantParameterCheckMethods;

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

namespace DisallowNamedArgumentsInPhpVersionScope;

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

namespace DisallowNamedArguments;

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

namespace NamedArgumentsMethod;

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

namespace StaticMethodNamedArguments;

Expand Down
Loading