mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Fix test array spacing
This commit is contained in:
parent
37d719ed67
commit
a553adb232
@ -25,7 +25,7 @@ class ArgTest extends TestCase
|
||||
sort($b);
|
||||
',
|
||||
'assertions' => [
|
||||
'$a' => 'array{b:int, a:int}',
|
||||
'$a' => 'array{b: int, a: int}',
|
||||
'$b' => 'array<int, int>',
|
||||
],
|
||||
],
|
||||
|
@ -64,7 +64,7 @@ class ArrayAssignmentTest extends TestCase
|
||||
$out[] = [4];
|
||||
}',
|
||||
'assertions' => [
|
||||
'$out' => 'non-empty-array<int, array{0:int}>',
|
||||
'$out' => 'non-empty-array<int, array{0: int}>',
|
||||
],
|
||||
],
|
||||
'generic2dArrayCreationAddedInIf' => [
|
||||
@ -200,8 +200,8 @@ class ArrayAssignmentTest extends TestCase
|
||||
$bat[$text] = $bar[$i];
|
||||
}',
|
||||
'assertions' => [
|
||||
'$foo' => 'array{0:string, 1:string, 2:string}',
|
||||
'$bar' => 'array{0:int, 1:int, 2:int}',
|
||||
'$foo' => 'array{0: string, 1: string, 2: string}',
|
||||
'$bar' => 'array{0: int, 1: int, 2: int}',
|
||||
'$bat' => 'array<string, int>',
|
||||
],
|
||||
],
|
||||
@ -210,7 +210,7 @@ class ArrayAssignmentTest extends TestCase
|
||||
$foo = [];
|
||||
$foo["bar"] = "hello";',
|
||||
'assertions' => [
|
||||
'$foo' => 'array{bar:string}',
|
||||
'$foo' => 'array{bar: string}',
|
||||
'$foo[\'bar\']' => 'string',
|
||||
],
|
||||
],
|
||||
@ -219,7 +219,7 @@ class ArrayAssignmentTest extends TestCase
|
||||
$foo = [];
|
||||
$foo["bar"]["baz"] = "hello";',
|
||||
'assertions' => [
|
||||
'$foo' => 'array{bar:array{baz:string}}',
|
||||
'$foo' => 'array{bar: array{baz: string}}',
|
||||
'$foo[\'bar\'][\'baz\']' => 'string',
|
||||
],
|
||||
],
|
||||
@ -228,7 +228,7 @@ class ArrayAssignmentTest extends TestCase
|
||||
$foo = [];
|
||||
$foo["bar"]["baz"]["bat"] = "hello";',
|
||||
'assertions' => [
|
||||
'$foo' => 'array{bar:array{baz:array{bat:string}}}',
|
||||
'$foo' => 'array{bar: array{baz: array{bat: string}}}',
|
||||
'$foo[\'bar\'][\'baz\'][\'bat\']' => 'string',
|
||||
],
|
||||
],
|
||||
@ -237,7 +237,7 @@ class ArrayAssignmentTest extends TestCase
|
||||
$foo = [];
|
||||
$foo["bar"]["baz"]["bat"]["bap"] = "hello";',
|
||||
'assertions' => [
|
||||
'$foo' => 'array{bar:array{baz:array{bat:array{bap:string}}}}',
|
||||
'$foo' => 'array{bar: array{baz: array{bat: array{bap: string}}}}',
|
||||
'$foo[\'bar\'][\'baz\'][\'bat\'][\'bap\']' => 'string',
|
||||
],
|
||||
],
|
||||
@ -246,7 +246,7 @@ class ArrayAssignmentTest extends TestCase
|
||||
$foo = ["bar" => []];
|
||||
$foo["bar"]["baz"] = "hello";',
|
||||
'assertions' => [
|
||||
'$foo' => 'array{bar:array{baz:string}}',
|
||||
'$foo' => 'array{bar: array{baz: string}}',
|
||||
'$foo[\'bar\'][\'baz\']' => 'string',
|
||||
],
|
||||
],
|
||||
@ -255,7 +255,7 @@ class ArrayAssignmentTest extends TestCase
|
||||
$foo = ["bar" => []];
|
||||
$foo["bar"]["baz"]["bat"] = "hello";',
|
||||
'assertions' => [
|
||||
'$foo' => 'array{bar:array{baz:array{bat:string}}}',
|
||||
'$foo' => 'array{bar: array{baz: array{bat: string}}}',
|
||||
],
|
||||
],
|
||||
'conflictingTypesWithNoAssignment' => [
|
||||
@ -265,7 +265,7 @@ class ArrayAssignmentTest extends TestCase
|
||||
"baz" => [1]
|
||||
];',
|
||||
'assertions' => [
|
||||
'$foo' => 'array{bar:array{a:string}, baz:array{0:int}}',
|
||||
'$foo' => 'array{bar: array{a: string}, baz: array{0: int}}',
|
||||
],
|
||||
],
|
||||
'implicitObjectLikeCreation' => [
|
||||
@ -275,7 +275,7 @@ class ArrayAssignmentTest extends TestCase
|
||||
];
|
||||
$foo["baz"] = "a";',
|
||||
'assertions' => [
|
||||
'$foo' => 'array{bar:int, baz:string}',
|
||||
'$foo' => 'array{bar: int, baz: string}',
|
||||
],
|
||||
],
|
||||
'conflictingTypesWithAssignment' => [
|
||||
@ -286,7 +286,7 @@ class ArrayAssignmentTest extends TestCase
|
||||
];
|
||||
$foo["bar"]["bam"]["baz"] = "hello";',
|
||||
'assertions' => [
|
||||
'$foo' => 'array{bar:array{a:string, bam:array{baz:string}}, baz:array{0:int}}',
|
||||
'$foo' => 'array{bar: array{a: string, bam: array{baz: string}}, baz: array{0: int}}',
|
||||
],
|
||||
],
|
||||
'conflictingTypesWithAssignment2' => [
|
||||
@ -296,7 +296,7 @@ class ArrayAssignmentTest extends TestCase
|
||||
$foo["b"][] = "goodbye";
|
||||
$bar = $foo["a"];',
|
||||
'assertions' => [
|
||||
'$foo' => 'array{a:string, b:array<int, string>}',
|
||||
'$foo' => 'array{a: string, b: array<int, string>}',
|
||||
'$foo[\'a\']' => 'string',
|
||||
'$foo[\'b\']' => 'array<int, string>',
|
||||
'$bar' => 'string',
|
||||
@ -308,7 +308,7 @@ class ArrayAssignmentTest extends TestCase
|
||||
$foo["a"] = "hello";
|
||||
$foo["b"]["c"]["d"] = "goodbye";',
|
||||
'assertions' => [
|
||||
'$foo' => 'array{a:string, b:array{c:array{d:string}}}',
|
||||
'$foo' => 'array{a: string, b: array{c: array{d: string}}}',
|
||||
],
|
||||
],
|
||||
'nestedObjectLikeAssignment' => [
|
||||
@ -317,7 +317,7 @@ class ArrayAssignmentTest extends TestCase
|
||||
$foo["a"]["b"] = "hello";
|
||||
$foo["a"]["c"] = 1;',
|
||||
'assertions' => [
|
||||
'$foo' => 'array{a:array{b:string, c:int}}',
|
||||
'$foo' => 'array{a: array{b: string, c: int}}',
|
||||
],
|
||||
],
|
||||
'conditionalObjectLikeAssignment' => [
|
||||
@ -330,7 +330,7 @@ class ArrayAssignmentTest extends TestCase
|
||||
$foo["b"] = 2;
|
||||
}',
|
||||
'assertions' => [
|
||||
'$foo' => 'array{a:string, b:int}',
|
||||
'$foo' => 'array{a: string, b: int}',
|
||||
],
|
||||
],
|
||||
'arrayKey' => [
|
||||
@ -368,8 +368,8 @@ class ArrayAssignmentTest extends TestCase
|
||||
$c = [];
|
||||
$c[$b][$b][] = "bam";',
|
||||
'assertions' => [
|
||||
'$a' => 'array{boop:array<int, string>}',
|
||||
'$c' => 'array{boop:array<string, array<int, string>>}',
|
||||
'$a' => 'array{boop: array<int, string>}',
|
||||
'$c' => 'array{boop: array<string, array<int, string>>}',
|
||||
],
|
||||
],
|
||||
'assignExplicitValueToGeneric' => [
|
||||
@ -388,8 +388,8 @@ class ArrayAssignmentTest extends TestCase
|
||||
|
||||
$b = [] + ["bar"];',
|
||||
'assertions' => [
|
||||
'$a' => 'array{0:string}',
|
||||
'$b' => 'array{0:string}',
|
||||
'$a' => 'array{0: string}',
|
||||
'$b' => 'array{0: string}',
|
||||
],
|
||||
],
|
||||
'additionDifferentType' => [
|
||||
@ -399,8 +399,8 @@ class ArrayAssignmentTest extends TestCase
|
||||
|
||||
$b = ["bar"] + [1];',
|
||||
'assertions' => [
|
||||
'$a' => 'array{0:string}',
|
||||
'$b' => 'array{0:string}',
|
||||
'$a' => 'array{0: string}',
|
||||
'$b' => 'array{0: string}',
|
||||
],
|
||||
],
|
||||
'present1dArrayTypeWithVarKeys' => [
|
||||
@ -444,7 +444,7 @@ class ArrayAssignmentTest extends TestCase
|
||||
$foo["a"] = 1;
|
||||
$foo += ["b" => [2, 3]];',
|
||||
'assertions' => [
|
||||
'$foo' => 'array{a:int, b:array{0:int, 1:int}}',
|
||||
'$foo' => 'array{a: int, b: array{0: int, 1: int}}',
|
||||
],
|
||||
],
|
||||
'nestedObjectLikeArrayAddition' => [
|
||||
@ -453,7 +453,7 @@ class ArrayAssignmentTest extends TestCase
|
||||
$foo["root"]["a"] = 1;
|
||||
$foo["root"] += ["b" => [2, 3]];',
|
||||
'assertions' => [
|
||||
'$foo' => 'array{root:array{a:int, b:array{0:int, 1:int}}}',
|
||||
'$foo' => 'array{root: array{a: int, b: array{0: int, 1: int}}}',
|
||||
],
|
||||
],
|
||||
'updateStringIntKey1' => [
|
||||
@ -463,7 +463,7 @@ class ArrayAssignmentTest extends TestCase
|
||||
$a["a"] = 5;
|
||||
$a[0] = 3;',
|
||||
'assertions' => [
|
||||
'$a' => 'array{a:int, 0:int}',
|
||||
'$a' => 'array{a: int, 0: int}',
|
||||
],
|
||||
],
|
||||
'updateStringIntKey2' => [
|
||||
@ -475,7 +475,7 @@ class ArrayAssignmentTest extends TestCase
|
||||
$b[$string] = 5;
|
||||
$b[0] = 3;',
|
||||
'assertions' => [
|
||||
'$b' => 'array{c:int, 0:int}',
|
||||
'$b' => 'array{c: int, 0: int}',
|
||||
],
|
||||
],
|
||||
'updateStringIntKey3' => [
|
||||
@ -487,7 +487,7 @@ class ArrayAssignmentTest extends TestCase
|
||||
$c[0] = 3;
|
||||
$c[$string] = 5;',
|
||||
'assertions' => [
|
||||
'$c' => 'array{0:int, c:int}',
|
||||
'$c' => 'array{0: int, c: int}',
|
||||
],
|
||||
],
|
||||
'updateStringIntKey4' => [
|
||||
@ -525,7 +525,7 @@ class ArrayAssignmentTest extends TestCase
|
||||
$a[0]["a"] = 5;
|
||||
$a[0][0] = 3;',
|
||||
'assertions' => [
|
||||
'$a' => 'array{0:array{a:int, 0:int}}',
|
||||
'$a' => 'array{0: array{a: int, 0: int}}',
|
||||
],
|
||||
],
|
||||
'updateStringIntKeyWithIntRoot' => [
|
||||
@ -553,10 +553,10 @@ class ArrayAssignmentTest extends TestCase
|
||||
$e[0][$int] = 3;
|
||||
$e[0][$string] = 5;',
|
||||
'assertions' => [
|
||||
'$b' => 'array{0:array<string|int, int>}',
|
||||
'$c' => 'array{0:array<int|string, int>}',
|
||||
'$d' => 'array{0:array<int|string, int>}',
|
||||
'$e' => 'array{0:array<string|int, int>}',
|
||||
'$b' => 'array{0: array<string|int, int>}',
|
||||
'$c' => 'array{0: array<int|string, int>}',
|
||||
'$d' => 'array{0: array<int|string, int>}',
|
||||
'$e' => 'array{0: array<string|int, int>}',
|
||||
],
|
||||
],
|
||||
'updateStringIntKeyWithObjectLikeRootAndNumberOffset' => [
|
||||
@ -569,7 +569,7 @@ class ArrayAssignmentTest extends TestCase
|
||||
$a["root"]["a"] = 5;
|
||||
$a["root"][0] = 3;',
|
||||
'assertions' => [
|
||||
'$a' => 'array{root:array{a:int, 0:int}}',
|
||||
'$a' => 'array{root: array{a: int, 0: int}}',
|
||||
],
|
||||
],
|
||||
'updateStringIntKeyWithObjectLikeRoot' => [
|
||||
@ -597,10 +597,10 @@ class ArrayAssignmentTest extends TestCase
|
||||
$e["root"][$int] = 3;
|
||||
$e["root"][$string] = 5;',
|
||||
'assertions' => [
|
||||
'$b' => 'array{root:array<string|int, int>}',
|
||||
'$c' => 'array{root:array<int|string, int>}',
|
||||
'$d' => 'array{root:array<int|string, int>}',
|
||||
'$e' => 'array{root:array<string|int, int>}',
|
||||
'$b' => 'array{root: array<string|int, int>}',
|
||||
'$c' => 'array{root: array<int|string, int>}',
|
||||
'$d' => 'array{root: array<int|string, int>}',
|
||||
'$e' => 'array{root: array<string|int, int>}',
|
||||
],
|
||||
],
|
||||
'mixedArrayAssignmentWithStringKeys' => [
|
||||
@ -654,9 +654,9 @@ class ArrayAssignmentTest extends TestCase
|
||||
$a["d"]["e"] = 5;',
|
||||
'assertions' => [
|
||||
'$a[\'b\']' => 'int',
|
||||
'$a[\'d\']' => 'array{e:int}',
|
||||
'$a[\'d\']' => 'array{e: int}',
|
||||
'$a[\'d\'][\'e\']' => 'int',
|
||||
'$a' => 'array{b:int, d:array{e:int}}',
|
||||
'$a' => 'array{b: int, d: array{e: int}}',
|
||||
],
|
||||
],
|
||||
'changeObjectLikeTypeInIf' => [
|
||||
@ -675,8 +675,8 @@ class ArrayAssignmentTest extends TestCase
|
||||
|
||||
$a["b"]["e"] = "d";',
|
||||
'assertions' => [
|
||||
'$a' => 'array{b:array{e:string}}',
|
||||
'$a[\'b\']' => 'array{e:string}',
|
||||
'$a' => 'array{b: array{e: string}}',
|
||||
'$a[\'b\']' => 'array{e: string}',
|
||||
'$a[\'b\'][\'e\']' => 'string',
|
||||
],
|
||||
],
|
||||
@ -783,7 +783,7 @@ class ArrayAssignmentTest extends TestCase
|
||||
$a = null;
|
||||
$a[0][] = 1;',
|
||||
'assertions' => [
|
||||
'$a' => 'array{0:array<int, int>}',
|
||||
'$a' => 'array{0: array<int, int>}',
|
||||
],
|
||||
'error_levels' => ['PossiblyNullArrayAssignment'],
|
||||
],
|
||||
@ -819,7 +819,7 @@ class ArrayAssignmentTest extends TestCase
|
||||
$a_values = array_values($a);
|
||||
$a_keys = array_keys($a);',
|
||||
'assertions' => [
|
||||
'$a' => 'array{0:string, 1:int}',
|
||||
'$a' => 'array{0: string, 1: int}',
|
||||
'$a_values' => 'array<int, string|int>',
|
||||
'$a_keys' => 'array<int, int>',
|
||||
],
|
||||
@ -829,7 +829,7 @@ class ArrayAssignmentTest extends TestCase
|
||||
$b = ["hello", 5];
|
||||
$b[0] = 3;',
|
||||
'assertions' => [
|
||||
'$b' => 'array{0:int, 1:int}',
|
||||
'$b' => 'array{0: int, 1: int}',
|
||||
],
|
||||
],
|
||||
'changeIntOffsetKeyValuesAfterCopy' => [
|
||||
@ -838,8 +838,8 @@ class ArrayAssignmentTest extends TestCase
|
||||
$c = $b;
|
||||
$c[0] = 3;',
|
||||
'assertions' => [
|
||||
'$b' => 'array{0:string, 1:int}',
|
||||
'$c' => 'array{0:int, 1:int}',
|
||||
'$b' => 'array{0: string, 1: int}',
|
||||
'$c' => 'array{0: int, 1: int}',
|
||||
],
|
||||
],
|
||||
'mergeIntOffsetValues' => [
|
||||
@ -847,8 +847,8 @@ class ArrayAssignmentTest extends TestCase
|
||||
$d = array_merge(["hello", 5], []);
|
||||
$e = array_merge(["hello", 5], ["hello again"]);',
|
||||
'assertions' => [
|
||||
'$d' => 'array{0:string, 1:int}',
|
||||
'$e' => 'array{0:string, 1:int, 2:string}',
|
||||
'$d' => 'array{0: string, 1: int}',
|
||||
'$e' => 'array{0: string, 1: int, 2: string}',
|
||||
],
|
||||
],
|
||||
'addIntOffsetToEmptyArray' => [
|
||||
@ -856,7 +856,7 @@ class ArrayAssignmentTest extends TestCase
|
||||
$f = [];
|
||||
$f[0] = "hello";',
|
||||
'assertions' => [
|
||||
'$f' => 'array{0:string}',
|
||||
'$f' => 'array{0: string}',
|
||||
],
|
||||
],
|
||||
'assignArrayOrSetNull' => [
|
||||
@ -1029,7 +1029,7 @@ class ArrayAssignmentTest extends TestCase
|
||||
$a = (array) (rand(0, 1) ? [1 => "one"] : 0);
|
||||
$b = (array) null;',
|
||||
'assertions' => [
|
||||
'$a' => 'array{1?:string, 0?:int}',
|
||||
'$a' => 'array{1?: string, 0?: int}',
|
||||
'$b' => 'array<empty, empty>',
|
||||
],
|
||||
],
|
||||
|
@ -175,12 +175,12 @@ class CallableTest extends TestCase
|
||||
$e = array_map([$a_instance, "bar"], ["one", "two"]);
|
||||
$f = array_map("baz", ["one", "two"]);',
|
||||
'assertions' => [
|
||||
'$a' => 'array{0:string, 1:string}',
|
||||
'$b' => 'array{0:string, 1:string}',
|
||||
'$c' => 'array{0:string, 1:string}',
|
||||
'$d' => 'array{0:string, 1:string}',
|
||||
'$e' => 'array{0:string, 1:string}',
|
||||
'$f' => 'array{0:string, 1:string}',
|
||||
'$a' => 'array{0: string, 1: string}',
|
||||
'$b' => 'array{0: string, 1: string}',
|
||||
'$c' => 'array{0: string, 1: string}',
|
||||
'$d' => 'array{0: string, 1: string}',
|
||||
'$e' => 'array{0: string, 1: string}',
|
||||
'$f' => 'array{0: string, 1: string}',
|
||||
],
|
||||
],
|
||||
'arrayMapClosureVar' => [
|
||||
@ -188,7 +188,7 @@ class CallableTest extends TestCase
|
||||
$mirror = function(int $i) : int { return $i; };
|
||||
$a = array_map($mirror, [1, 2, 3]);',
|
||||
'assertions' => [
|
||||
'$a' => 'array{0:int, 1:int, 2:int}',
|
||||
'$a' => 'array{0: int, 1: int, 2: int}',
|
||||
],
|
||||
],
|
||||
'arrayCallableMethod' => [
|
||||
|
@ -223,7 +223,7 @@ class FunctionCallTest extends TestCase
|
||||
'<?php
|
||||
$d = array_merge(["a", "b", "c"], [1, 2, 3]);',
|
||||
'assertions' => [
|
||||
'$d' => 'array{0:string, 1:string, 2:string, 3:int, 4:int, 5:int}',
|
||||
'$d' => 'array{0: string, 1: string, 2: string, 3: int, 4: int, 5: int}',
|
||||
],
|
||||
],
|
||||
'arrayReverseDontPreserveKey' => [
|
||||
@ -579,7 +579,7 @@ class FunctionCallTest extends TestCase
|
||||
|
||||
foo($a3);',
|
||||
'assertions' => [
|
||||
'$a3' => 'array{hi:int, bye:int}',
|
||||
'$a3' => 'array{hi: int, bye: int}',
|
||||
],
|
||||
],
|
||||
'arrayRand' => [
|
||||
@ -591,10 +591,10 @@ class FunctionCallTest extends TestCase
|
||||
$e = array_rand($more_vars);',
|
||||
|
||||
'assertions' => [
|
||||
'$vars' => 'array{x:string, y:string}',
|
||||
'$vars' => 'array{x: string, y: string}',
|
||||
'$c' => 'string',
|
||||
'$d' => 'string',
|
||||
'$more_vars' => 'array{0:string, 1:string}',
|
||||
'$more_vars' => 'array{0: string, 1: string}',
|
||||
'$e' => 'int',
|
||||
],
|
||||
],
|
||||
@ -608,7 +608,7 @@ class FunctionCallTest extends TestCase
|
||||
$f = array_rand($vars, $b);',
|
||||
|
||||
'assertions' => [
|
||||
'$vars' => 'array{x:string, y:string}',
|
||||
'$vars' => 'array{x: string, y: string}',
|
||||
'$c' => 'string',
|
||||
'$e' => 'array<int, string>',
|
||||
'$f' => 'array<int, string>|string',
|
||||
@ -1216,8 +1216,8 @@ class FunctionCallTest extends TestCase
|
||||
array_splice($d, -1, 1);',
|
||||
'assertions' => [
|
||||
'$a' => 'non-empty-array<int, string|int>',
|
||||
'$b' => 'array{0:string, 1:string, 2:string}',
|
||||
'$c' => 'array{0:int, 1:int, 2:int}',
|
||||
'$b' => 'array{0: string, 1: string, 2: string}',
|
||||
'$c' => 'array{0: int, 1: int, 2: int}',
|
||||
],
|
||||
],
|
||||
'arraySpliceOtherType' => [
|
||||
@ -1225,7 +1225,7 @@ class FunctionCallTest extends TestCase
|
||||
$d = [["red"], ["green"], ["blue"]];
|
||||
array_splice($d, -1, 1, "foo");',
|
||||
'assertions' => [
|
||||
'$d' => 'array<int, array{0:string}|string>',
|
||||
'$d' => 'array<int, array{0: string}|string>',
|
||||
],
|
||||
],
|
||||
'ksortPreserveShape' => [
|
||||
@ -1589,9 +1589,9 @@ class FunctionCallTest extends TestCase
|
||||
$d = hrtime(false);',
|
||||
'assertions' => [
|
||||
'$a' => 'int',
|
||||
'$b' => 'array{0:int, 1:int}',
|
||||
'$c' => 'array{0:int, 1:int}|int',
|
||||
'$d' => 'array{0:int, 1:int}',
|
||||
'$b' => 'array{0: int, 1: int}',
|
||||
'$c' => 'array{0: int, 1: int}|int',
|
||||
'$d' => 'array{0: int, 1: int}',
|
||||
],
|
||||
],
|
||||
'PHP73-hrtimeCanBeFloat' => [
|
||||
|
@ -102,7 +102,7 @@ class Php56Test extends TestCase
|
||||
$a = [[1, 2]];
|
||||
$b = array_merge([], ...$a);',
|
||||
'assertions' => [
|
||||
'$b' => 'array{0:int, 1:int}',
|
||||
'$b' => 'array{0: int, 1: int}',
|
||||
],
|
||||
],
|
||||
'preserveTypesWhenUnpacking' => [
|
||||
|
@ -323,31 +323,31 @@ class TypeCombinationTest extends TestCase
|
||||
],
|
||||
],
|
||||
'combineObjectType1' => [
|
||||
'array{a?:int, b?:string}',
|
||||
'array{a?: int, b?: string}',
|
||||
[
|
||||
'array{a:int}',
|
||||
'array{b:string}',
|
||||
'array{a: int}',
|
||||
'array{b: string}',
|
||||
],
|
||||
],
|
||||
'combineObjectType2' => [
|
||||
'array{a:int|string, b?:string}',
|
||||
'array{a: int|string, b?: string}',
|
||||
[
|
||||
'array{a:int}',
|
||||
'array{a:string,b:string}',
|
||||
'array{a: int}',
|
||||
'array{a: string,b: string}',
|
||||
],
|
||||
],
|
||||
'combineObjectTypeWithIntKeyedArray' => [
|
||||
'array<int|string, string|int>',
|
||||
[
|
||||
'array{a:int}',
|
||||
'array{a: int}',
|
||||
'array<int, string>',
|
||||
],
|
||||
],
|
||||
'combineNestedObjectTypeWithObjectLikeIntKeyedArray' => [
|
||||
'array{a:array<int|string, string|int>}',
|
||||
'array{a: array<int|string, string|int>}',
|
||||
[
|
||||
'array{a:array{a:int}}',
|
||||
'array{a:array<int, string>}',
|
||||
'array{a: array{a: int}}',
|
||||
'array{a: array<int, string>}',
|
||||
],
|
||||
],
|
||||
'combineIntKeyedObjectTypeWithNestedIntKeyedArray' => [
|
||||
@ -360,22 +360,22 @@ class TypeCombinationTest extends TestCase
|
||||
'combineNestedObjectTypeWithNestedIntKeyedArray' => [
|
||||
'array<int|string, array<int|string, string|int>>',
|
||||
[
|
||||
'array{a:array{a:int}}',
|
||||
'array{a: array{a: int}}',
|
||||
'array<int, array<int, string>>',
|
||||
],
|
||||
],
|
||||
'combinePossiblyUndefinedKeys' => [
|
||||
'array{a:bool, b?:mixed, d?:mixed}',
|
||||
'array{a: bool, b?: mixed, d?: mixed}',
|
||||
[
|
||||
'array{a:false, b:mixed}',
|
||||
'array{a:true, d:mixed}',
|
||||
'array{a:true, d:mixed}',
|
||||
'array{a: false, b: mixed}',
|
||||
'array{a: true, d: mixed}',
|
||||
'array{a: true, d: mixed}',
|
||||
],
|
||||
],
|
||||
'combinePossiblyUndefinedKeysAndString' => [
|
||||
'array{a:string, b?:int}|string',
|
||||
'array{a: string, b?: int}|string',
|
||||
[
|
||||
'array{a:string, b?:int}',
|
||||
'array{a: string, b?: int}',
|
||||
'string',
|
||||
],
|
||||
],
|
||||
@ -425,7 +425,7 @@ class TypeCombinationTest extends TestCase
|
||||
'array<string, int>',
|
||||
[
|
||||
'array<"a"|"b"|"c", 1|2|3>',
|
||||
'array{a:1|2, b:2|3, c:1|3}',
|
||||
'array{a: 1|2, b: 2|3, c: 1|3}',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
@ -251,8 +251,8 @@ class TypeParseTest extends TestCase
|
||||
public function testPhpDocObjectLikeArray()
|
||||
{
|
||||
$this->assertSame(
|
||||
'array<array-key, array{b:bool, d:string}>',
|
||||
(string) Type::parseString('array{b:bool,d:string}[]')
|
||||
'array<array-key, array{b: bool, d: string}>',
|
||||
(string) Type::parseString('array{b: bool, d: string}[]')
|
||||
);
|
||||
}
|
||||
|
||||
@ -321,7 +321,7 @@ class TypeParseTest extends TestCase
|
||||
*/
|
||||
public function testObjectLikeWithSimpleArgs()
|
||||
{
|
||||
$this->assertSame('array{a:int, b:string}', (string) Type::parseString('array{a:int, b:string}'));
|
||||
$this->assertSame('array{a: int, b: string}', (string) Type:: parseString('array{a: int, b: string}'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -330,7 +330,7 @@ class TypeParseTest extends TestCase
|
||||
public function testObjectLikeWithoutClosingBracket()
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\TypeParseTreeException::class);
|
||||
Type::parseString('array{a:int, b:string');
|
||||
Type::parseString('array{a: int, b: string');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -347,8 +347,8 @@ class TypeParseTest extends TestCase
|
||||
public function testObjectLikeWithUnionArgs()
|
||||
{
|
||||
$this->assertSame(
|
||||
'array{a:int|string, b:string}',
|
||||
(string) Type::parseString('array{a:int|string, b:string}')
|
||||
'array{a: int|string, b: string}',
|
||||
(string) Type::parseString('array{a: int|string, b: string}')
|
||||
);
|
||||
}
|
||||
|
||||
@ -358,8 +358,8 @@ class TypeParseTest extends TestCase
|
||||
public function testObjectLikeWithGenericArgs()
|
||||
{
|
||||
$this->assertSame(
|
||||
'array{a:array<int, string|int>, b:string}',
|
||||
(string) Type::parseString('array{a:array<int, string|int>, b:string}')
|
||||
'array{a: array<int, string|int>, b: string}',
|
||||
(string) Type::parseString('array{a: array<int, string|int>, b: string}')
|
||||
);
|
||||
}
|
||||
|
||||
@ -369,7 +369,7 @@ class TypeParseTest extends TestCase
|
||||
public function testObjectLikeWithIntKeysAndUnionArgs()
|
||||
{
|
||||
$this->assertSame(
|
||||
'array{0:null|stdClass}',
|
||||
'array{0: null|stdClass}',
|
||||
(string)Type::parseString('array{stdClass|null}')
|
||||
);
|
||||
}
|
||||
@ -380,12 +380,12 @@ class TypeParseTest extends TestCase
|
||||
public function testObjectLikeWithIntKeysAndGenericArgs()
|
||||
{
|
||||
$this->assertSame(
|
||||
'array{0:array<array-key, mixed>}',
|
||||
'array{0: array<array-key, mixed>}',
|
||||
(string)Type::parseString('array{array}')
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
'array{0:array<int, string>}',
|
||||
'array{0: array<int, string>}',
|
||||
(string)Type::parseString('array{array<int, string>}')
|
||||
);
|
||||
}
|
||||
@ -396,8 +396,8 @@ class TypeParseTest extends TestCase
|
||||
public function testObjectLikeOptional()
|
||||
{
|
||||
$this->assertSame(
|
||||
'array{a:int, b?:int}',
|
||||
(string)Type::parseString('array{a:int, b?:int}')
|
||||
'array{a: int, b?: int}',
|
||||
(string)Type::parseString('array{a: int, b?: int}')
|
||||
);
|
||||
}
|
||||
|
||||
@ -842,7 +842,7 @@ class TypeParseTest extends TestCase
|
||||
*/
|
||||
public function testVeryLargeType()
|
||||
{
|
||||
$very_large_type = 'array{a:Closure():(array<mixed, mixed>|null), b?:Closure():array<mixed, mixed>, c?:Closure():array<mixed, mixed>, d?:Closure():array<mixed, mixed>, e?:Closure():(array{f:null|string, g:null|string, h:null|string, i:string, j:mixed, k:mixed, l:mixed, m:mixed, n:bool, o?:array{0:string}}|null), p?:Closure():(array{f:null|string, g:null|string, h:null|string, q:string, i:string, j:mixed, k:mixed, l:mixed, m:mixed, n:bool, o?:array{0:string}}|null), r?:Closure():(array<mixed, mixed>|null), s:array<mixed, mixed>}|null';
|
||||
$very_large_type = 'array{a: Closure():(array<mixed, mixed>|null), b?: Closure():array<mixed, mixed>, c?: Closure():array<mixed, mixed>, d?: Closure():array<mixed, mixed>, e?: Closure():(array{f: null|string, g: null|string, h: null|string, i: string, j: mixed, k: mixed, l: mixed, m: mixed, n: bool, o?: array{0: string}}|null), p?: Closure():(array{f: null|string, g: null|string, h: null|string, q: string, i: string, j: mixed, k: mixed, l: mixed, m: mixed, n: bool, o?: array{0: string}}|null), r?: Closure():(array<mixed, mixed>|null), s: array<mixed, mixed>}|null';
|
||||
|
||||
$this->assertSame(
|
||||
$very_large_type,
|
||||
|
@ -244,12 +244,12 @@ class TypeReconciliationTest extends TestCase
|
||||
'unionContainsWithstring' => ['string', 'string|false'],
|
||||
'unionContainsWithFalse' => ['false', 'string|false'],
|
||||
'objectLikeTypeWithPossiblyUndefinedToGeneric' => [
|
||||
'array{0:array{a:string}, 1:array{c:string, e:string}}',
|
||||
'array{0: array{a: string}, 1: array{c: string, e: string}}',
|
||||
'array<int, array<string, string>>',
|
||||
],
|
||||
'objectLikeTypeWithPossiblyUndefinedToEmpty' => [
|
||||
'array<empty, empty>',
|
||||
'array{a?:string, b?:string}',
|
||||
'array{a?: string, b?: string}',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user