Skip to content

Commit

Permalink
more invalid tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kkmuffme committed Mar 12, 2024
1 parent 4436c1a commit 2344c1b
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 6 deletions.
4 changes: 4 additions & 0 deletions tests/ArrayFunctionCallTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2988,13 +2988,17 @@ function merger(array $a, array $b) : array {
array_merge(...$map);
',
'error_message' => 'NamedArgumentNotAllowed',
'ignored_issues' => [],
'php_version' => '8.1',
],
'arrayMergeRecursiveNoNamed' => [
'code' => '<?php
$map = ["a" => []];
array_merge_recursive(...$map);
',
'error_message' => 'NamedArgumentNotAllowed',
'ignored_issues' => [],
'php_version' => '8.1',
],
'arrayUniquePreservesEmptyInput' => [
'code' => '<?php
Expand Down
12 changes: 12 additions & 0 deletions tests/AttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ public function __construct(
public string $name = "",
) {}
}',
'assertions' => [],
'ignored_issues' => [],
'php_version' => '8.0',
],
'functionAttributeExists' => [
'code' => '<?php
Expand Down Expand Up @@ -145,6 +148,9 @@ public function __construct(array $methods = []) {
#[Route(methods: ["GET"])]
class HealthController
{}',
'assertions' => [],
'ignored_issues' => [],
'php_version' => '8.0',
],
'allowsRepeatableFlag' => [
'code' => '<?php
Expand All @@ -168,6 +174,9 @@ public function __construct(string $_className)
#[Foo(_className: Baz::class)]
class Baz {}',
'assertions' => [],
'ignored_issues' => [],
'php_version' => '8.0',
],
'allowsClassStringFromDifferentNamespace' => [
'code' => '<?php
Expand Down Expand Up @@ -203,6 +212,9 @@ class Bar implements FoobarInterface {}
class Baz {}
}
',
'assertions' => [],
'ignored_issues' => [],
'php_version' => '8.0',
],
'returnTypeWillChange7.1' => [
'code' => '<?php
Expand Down
2 changes: 1 addition & 1 deletion tests/CallableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function __invoke(Closure ...$_fn): int
'$a' => 'int',
],
'ignored_issues' => [],
'php_version' => '7.4',
'php_version' => '8.0',
],
'inferArgFromClassContextInGenericContext' => [
'code' => '<?php
Expand Down
4 changes: 4 additions & 0 deletions tests/CoreStubsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -447,12 +447,16 @@ public function providerInvalidCodeParse(): iterable
json_decode("true", depth: -1);
',
'error_message' => 'InvalidArgument',
'ignored_issues' => [],
'php_version' => '8.0',
];
yield 'json_encode invalid depth' => [
'code' => '<?php
json_encode([], depth: 439877348953739);
',
'error_message' => 'InvalidArgument',
'ignored_issues' => [],
'php_version' => '8.0',
];
yield 'str_contains literal haystack' => [
'code' => '<?php
Expand Down
4 changes: 2 additions & 2 deletions tests/IntRangeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -668,8 +668,8 @@ function getInt(): int{return 0;}
$i = max($b, $c, $d);
$j = max($d, $e);
$k = max($e, 40);
$l = min($a, ...[$b, $c], $d);
$m = max(...[$a, ...[$b, $c]], $d);
$l = min($a, $d, ...[$b, $c]);
$m = max($d, ...[$a, ...[$b, $c]]);
',
'assertions' => [
'$f===' => 'int<min, -16>',
Expand Down
4 changes: 3 additions & 1 deletion tests/Template/ClassTemplateCovarianceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,9 @@ public function __construct(...$a) {
*/
public function add($a) : Collection
{
return new Collection(...$this->arr, $a);
$data = $this->arr;
$data[] = $a;
return new Collection(...$data);
}
}
Expand Down
2 changes: 2 additions & 0 deletions tests/UnusedCodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1737,6 +1737,8 @@ function baz(): string
return $f;
}',
'error_message' => 'UnusedFunctionCall',
'ignored_issues' => [],
'php_version' => '8.0',
],
'propertyWrittenButNotRead' => [
'code' => '<?php
Expand Down
7 changes: 5 additions & 2 deletions tests/UnusedVariableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2228,8 +2228,11 @@ function f(): array {
'funcGetArgs' => [
'code' => '<?php
function validate(bool $b, bool $c) : void {
/** @psalm-suppress MixedArgument */
print_r(...func_get_args());
$args = func_get_args();
if ($args !== array()) {
/** @psalm-suppress MixedArgument */
print_r(...$args);
}
}',
],
'nullCoalesce' => [
Expand Down

0 comments on commit 2344c1b

Please sign in to comment.