From baecd3ea2e7b42840c1fa88f301b655f5f9d4242 Mon Sep 17 00:00:00 2001 From: Yuta Nagamiya Date: Sun, 21 Mar 2021 00:32:32 +0900 Subject: [PATCH 1/3] Update dependencies --- composer.json | 2 +- composer.lock | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index cca140a..e02c095 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ ], "require": { "php": "^7.3|^8.0", - "ngmy/typed-array": "^0.6.0" + "ngmy/typed-array": "^0.8.0" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index 3c89142..24c3434 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "8d72452ca285dffd14b375d9b5c729f0", + "content-hash": "66253266947ae0e3c0d9562c9406f21c", "packages": [ { "name": "ngmy/typed-array", - "version": "0.6.0", + "version": "0.8.0", "source": { "type": "git", "url": "https://github.com/ngmy/php-typed-array.git", - "reference": "a7fb1b469b33f875c8198eb3a55de73673750eee" + "reference": "edc2ba905657f8b7373ad8f08c9011fa524389ad" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ngmy/php-typed-array/zipball/a7fb1b469b33f875c8198eb3a55de73673750eee", - "reference": "a7fb1b469b33f875c8198eb3a55de73673750eee", + "url": "https://api.github.com/repos/ngmy/php-typed-array/zipball/edc2ba905657f8b7373ad8f08c9011fa524389ad", + "reference": "edc2ba905657f8b7373ad8f08c9011fa524389ad", "shasum": "" }, "require": { @@ -50,7 +50,7 @@ ], "support": { "issues": "https://github.com/ngmy/php-typed-array/issues", - "source": "https://github.com/ngmy/php-typed-array/tree/0.6.0" + "source": "https://github.com/ngmy/php-typed-array/tree/0.8.0" }, "funding": [ { @@ -62,7 +62,7 @@ "type": "github" } ], - "time": "2021-03-18T12:09:44+00:00" + "time": "2021-03-20T15:20:15+00:00" } ], "packages-dev": [], From 2bada64e7e47fa6efc5f996c6061a5d1508e33e5 Mon Sep 17 00:00:00 2001 From: Yuta Nagamiya Date: Sun, 21 Mar 2021 00:32:55 +0900 Subject: [PATCH 2/3] Create coc-settings.json Add coc-diagnostic configuration for using PHPStan on Docker. --- .vim/coc-settings.json | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .vim/coc-settings.json diff --git a/.vim/coc-settings.json b/.vim/coc-settings.json new file mode 100644 index 0000000..6ca861e --- /dev/null +++ b/.vim/coc-settings.json @@ -0,0 +1,26 @@ +{ + "diagnostic-languageserver.filetypes": { + "php": ["phpstan"] + }, + "diagnostic-languageserver.linters": { + "phpstan": { + "command": "docker", + "debounce": 100, + "rootPatterns": [ "composer.json", "composer.lock", "vendor", ".git" ], + "args": [ "exec", "laradock-php-enum_workspace_1", "composer", "findbugs", "--", "--error-format", "raw", "--no-progress" ], + "offsetLine": 0, + "offsetColumn": 0, + "sourceName": "phpstan", + "formatLines": 1, + "formatPattern": [ + "^/var/www/([^:]+):(\\d+):(.*)(\\r|\\n)*$", + { + "sourceName": 1, + "sourceNameFilter": true, + "line": 2, + "message": 3 + } + ] + } + } +} From 32d8cce294cd1f18db0f68289a6359a8e04a328b Mon Sep 17 00:00:00 2001 From: Yuta Nagamiya Date: Sun, 21 Mar 2021 00:33:35 +0900 Subject: [PATCH 3/3] Change list to array A list type is not supported by coc-phpls. --- docs/api/classes/Ngmy-Enum-Enum.html | 70 ++++++--- docs/api/classes/Ngmy-Enum-EnumSet.html | 6 +- .../classes/Ngmy-TypedArray-TypedArray.html | 140 +++++++++++++----- docs/api/js/searchIndex.js | 9 +- src/Enum.php | 14 +- src/EnumSet.php | 4 +- tests/EnumMapTest.php | 15 +- tests/EnumTest.php | 10 +- 8 files changed, 190 insertions(+), 78 deletions(-) diff --git a/docs/api/classes/Ngmy-Enum-Enum.html b/docs/api/classes/Ngmy-Enum-Enum.html index 22473d8..174c5f2 100644 --- a/docs/api/classes/Ngmy-Enum-Enum.html +++ b/docs/api/classes/Ngmy-Enum-Enum.html @@ -118,7 +118,7 @@

$names -  : array<string, list<string|int, string>> +  : array<string, array<int, string>>
@@ -188,7 +188,7 @@

values() -  : list<string|int, static> +  : array<int, static>
Returns all constants of this enum type.
@@ -278,7 +278,7 @@

private - static array<string, list<string|int, string>> + static array<string, array<int, string>> $names = [] @@ -322,14 +322,14 @@

Returns the enum constant of the specified name.

public - final static __callStatic(string $name, list<string|int, mixed> $arguments) : static + final static __callStatic(string $name, array<int, mixed> $arguments) : static
@@ -344,7 +344,7 @@

Parameters
$arguments - : list<string|int, mixed> + : array<int, mixed>
@@ -353,6 +353,21 @@
Parameters
+
+ Tags + +
+
+
+ phpstan-param +
+
+ +

list $arguments

+
+ +
+
Return values
static @@ -374,7 +389,7 @@

@@ -425,7 +440,7 @@

Returns the name of this enum constant, as contained in the declaration.

@@ -459,7 +474,7 @@

@@ -491,7 +506,7 @@

Returns true if the specified object is equal to this enum constant.

@@ -535,7 +550,7 @@

Returns the hash code for this enum constant

@@ -569,7 +584,7 @@

Returns the name of this enum constant, exactly as declared in its enum declaration.

@@ -603,7 +618,7 @@

Returns the ordinal of this enum constant.

@@ -638,7 +653,7 @@

Returns the enum constant of the specified name.

@@ -682,22 +697,37 @@

Returns all constants of this enum type.

public - final static values() : list<string|int, static> + final static values() : array<int, static>
+

+ Tags + +
+
+
+ phpstan-return +
+
+ +

list

+
+ +
+
Return values
- list<string|int, static> + array<int, static>
@@ -716,7 +746,7 @@

@@ -749,7 +779,7 @@

@@ -791,7 +821,7 @@

diff --git a/docs/api/classes/Ngmy-Enum-EnumSet.html b/docs/api/classes/Ngmy-Enum-EnumSet.html index 838e097..13aa8e8 100644 --- a/docs/api/classes/Ngmy-Enum-EnumSet.html +++ b/docs/api/classes/Ngmy-Enum-EnumSet.html @@ -292,7 +292,7 @@

toArray() -  : list<string|int, Enum> +  : array<int, Enum>
Gets the enum set of values as a plain array.
@@ -1120,7 +1120,7 @@

public - toArray() : list<string|int, Enum> + toArray() : array<int, Enum>
@@ -1143,7 +1143,7 @@

Return values
- list<string|int, Enum> + array<int, Enum>
diff --git a/docs/api/classes/Ngmy-TypedArray-TypedArray.html b/docs/api/classes/Ngmy-TypedArray-TypedArray.html index 33ed250..7107afb 100644 --- a/docs/api/classes/Ngmy-TypedArray-TypedArray.html +++ b/docs/api/classes/Ngmy-TypedArray-TypedArray.html @@ -254,7 +254,7 @@

 : array<int|string, mixed> -
+
The hash map of key's hash codes and keys.
$keyType @@ -275,7 +275,7 @@

 : array<int|string, mixed>

-
+
The hash map of key's hash codes and values.
$valueType @@ -506,6 +506,13 @@

 : int|string|null

+
+ +
+ keyExists() + +  : bool +
@@ -673,17 +680,19 @@

- +

The hash map of key's hash codes and keys.

+ private array<int|string, mixed> $keys = [] -
+

This is only used when the key type is the object, class, interface, or trait type.

+

@@ -796,10 +805,11 @@

- +

The hash map of key's hash codes and values.

+ private array<int|string, mixed> @@ -892,7 +902,7 @@

@@ -940,7 +950,7 @@

@@ -997,7 +1007,7 @@

Determines if the typed array is empty or not.

@@ -1031,7 +1041,7 @@

Creates a new instance of the typed array.

@@ -1065,7 +1075,7 @@

@@ -1124,7 +1134,7 @@

@@ -1192,7 +1202,7 @@

@@ -1277,7 +1287,7 @@

@@ -1336,7 +1346,7 @@

Gets the typed array of values as a plain array.

@@ -1385,7 +1395,7 @@

Returns a new instance of the typed array with the array type value.

@@ -1434,7 +1444,7 @@

Returns a new instance of the typed array with the bool type key.

@@ -1483,7 +1493,7 @@

Returns a new instance of the typed array with the bool type value.

@@ -1532,7 +1542,7 @@

Returns a new instance of the typed array with the specified class type key.

@@ -1621,7 +1631,7 @@

Returns a new instance of the typed array with the specified class type value.

@@ -1698,7 +1708,7 @@

Returns a new instance of the typed array with the float type key.

@@ -1747,7 +1757,7 @@

Returns a new instance of the typed array with the float type value.

@@ -1796,7 +1806,7 @@

Returns a new instance of the typed array with the class type key that implements the specified interface.

@@ -1885,7 +1895,7 @@

Returns a new instance of the typed array with the class type value that implements the specified interface.

@@ -1962,7 +1972,7 @@

Returns a new instance of the typed array with the int type key.

@@ -2011,7 +2021,7 @@

Returns a new instance of the typed array with the int type value.

@@ -2060,7 +2070,7 @@

Returns a new instance of the typed array with the mixed type key.

@@ -2109,7 +2119,7 @@

Returns a new instance of the typed array with the mixed type value.

@@ -2158,7 +2168,7 @@

Returns a new instance of the typed array with the object type key.

@@ -2219,7 +2229,7 @@

Returns a new instance of the typed array with the object type value.

@@ -2268,7 +2278,7 @@

Returns a new instance of the typed array with the resource type key.

@@ -2317,7 +2327,7 @@

Returns a new instance of the typed array with the resource type value.

@@ -2366,7 +2376,7 @@

Returns a new instance of the typed array with the string type key.

@@ -2415,7 +2425,7 @@

Returns a new instance of the typed array with the string type value.

@@ -2464,7 +2474,7 @@

Returns a new instance of the typed array with the class type key that uses the specified trait.

@@ -2535,7 +2545,7 @@

Returns a new instance of the typed array with the class type value that uses the specified trait.

@@ -2594,7 +2604,7 @@

@@ -2657,7 +2667,7 @@

@@ -2687,6 +2697,58 @@

Return values
+ +
+

+ keyExists() + +

+ + + + + private + keyExists(mixed $key, int|string|null $keyHashCode) : bool + +
+ +
Parameters
+
+
+ $key + : mixed +
+
+
+ +
+
+ $keyHashCode + : int|string|null +
+
+
+ +
+
+ + + +
Return values
+ bool + — +
+ +
diff --git a/docs/api/js/searchIndex.js b/docs/api/js/searchIndex.js index 9d37cd2..1dcb497 100644 --- a/docs/api/js/searchIndex.js +++ b/docs/api/js/searchIndex.js @@ -445,6 +445,11 @@ Search.appendIndex( "name": "getKeyHashCode", "summary": "", "url": "classes/Ngmy-TypedArray-TypedArray.html#method_getKeyHashCode" + }, { + "fqsen": "\\Ngmy\\TypedArray\\TypedArray\u003A\u003AkeyExists\u0028\u0029", + "name": "keyExists", + "summary": "", + "url": "classes/Ngmy-TypedArray-TypedArray.html#method_keyExists" }, { "fqsen": "\\Ngmy\\TypedArray\\TypedArray\u003A\u003AKEY_TYPES", "name": "KEY_TYPES", @@ -488,12 +493,12 @@ Search.appendIndex( }, { "fqsen": "\\Ngmy\\TypedArray\\TypedArray\u003A\u003A\u0024keys", "name": "keys", - "summary": "", + "summary": "The\u0020hash\u0020map\u0020of\u0020key\u0027s\u0020hash\u0020codes\u0020and\u0020keys.", "url": "classes/Ngmy-TypedArray-TypedArray.html#property_keys" }, { "fqsen": "\\Ngmy\\TypedArray\\TypedArray\u003A\u003A\u0024values", "name": "values", - "summary": "", + "summary": "The\u0020hash\u0020map\u0020of\u0020key\u0027s\u0020hash\u0020codes\u0020and\u0020values.", "url": "classes/Ngmy-TypedArray-TypedArray.html#property_values" }, { "fqsen": "\\", diff --git a/src/Enum.php b/src/Enum.php index de5a49e..097db9c 100644 --- a/src/Enum.php +++ b/src/Enum.php @@ -12,7 +12,7 @@ abstract class Enum { /** - * @var array> + * @var array> * @phpstan-var array> */ private static $names = []; @@ -23,8 +23,10 @@ abstract class Enum /** * Returns the enum constant of the specified name. * - * @param list $arguments + * @param array $arguments * @return static + * + * @phpstan-param list $arguments */ final public static function __callStatic(string $name, array $arguments): self { @@ -44,7 +46,9 @@ final public static function valueOf(string $name): self /** * Returns all constants of this enum type. * - * @return list + * @return array + * + * @phpstan-return list */ final public static function values(): array { @@ -56,8 +60,10 @@ final public static function values(): array /** * Returns names of all constants of this enum type. * - * @return list + * @return array * @internal + * + * @phpstan-return list */ final public static function names(): array { diff --git a/src/EnumSet.php b/src/EnumSet.php index 527c58e..46dd16e 100644 --- a/src/EnumSet.php +++ b/src/EnumSet.php @@ -147,14 +147,14 @@ public function isEmpty(): bool /** * Gets the enum set of values as a plain array. * - * @return list + * @return array * * @phpstan-return list */ public function toArray(): array { /** - * @var list + * @var array * @phpstan-var list */ $array = $this->enumMap->toArray(); diff --git a/tests/EnumMapTest.php b/tests/EnumMapTest.php index c83534e..2235420 100644 --- a/tests/EnumMapTest.php +++ b/tests/EnumMapTest.php @@ -70,8 +70,10 @@ public function isEmptyProvider(): array } /** - * @param list $enums + * @param array $enums * @dataProvider isEmptyProvider + * + * @phpstan-param list $enums */ public function testIsEmpty(array $enums, bool $expected): void { @@ -94,8 +96,10 @@ public function countProvider(): array } /** - * @param list $enums + * @param array $enums * @dataProvider countProvider + * + * @phpstan-param list $enums */ public function testCount(array $enums, int $expected): void { @@ -231,10 +235,13 @@ public function dataProvider(): array * TODO: Split this test into several smaller tests * * @param EnumMap $enumMap - * @param list $keys - * @param list $values + * @param array $keys + * @param array $values * @param array|Exception $expected * @dataProvider dataProvider + * + * @phpstan-param list $keys + * @phpstan-param list $values */ public function test(EnumMap $enumMap, array $keys, array $values, $expected): void { diff --git a/tests/EnumTest.php b/tests/EnumTest.php index 0d9d7ed..05e5046 100644 --- a/tests/EnumTest.php +++ b/tests/EnumTest.php @@ -86,10 +86,11 @@ public function valuesProvider(): array } /** - * @param Exception|list $expected + * @param Exception|array $expected * @dataProvider valuesProvider * - * @phpstan-param class-string $class + * @phpstan-param class-string $class + * @phpstan-param Exception|list $expected */ public function testValues(string $class, $expected): void { @@ -129,12 +130,13 @@ public function namesProvider(): array } /** - * @param Exception|list $expected + * @param Exception|array $expected * @dataProvider namesProvider * @runInSeparateProcess * @preserveGlobalState disabled * - * @phpstan-param class-string $class + * @phpstan-param class-string $class + * @phpstan-param Exception|list $expected */ public function testNames(string $class, $expected): void {