From afef96e2c6dc7abfad5923a2e4a12a2e1b481c11 Mon Sep 17 00:00:00 2001
From: Yuta Nagamiya
Date: Tue, 30 Mar 2021 22:50:17 +0900
Subject: [PATCH 01/19] Update tools
---
.phive/phars.xml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/.phive/phars.xml b/.phive/phars.xml
index 54f64a1..853e8b0 100644
--- a/.phive/phars.xml
+++ b/.phive/phars.xml
@@ -1,10 +1,10 @@
-
+
-
-
+
+
From 7eb704f88b8d0cbf32990f079d055295d526ff1e Mon Sep 17 00:00:00 2001
From: Yuta Nagamiya
Date: Tue, 30 Mar 2021 22:50:51 +0900
Subject: [PATCH 02/19] Install Psalm
---
.phive/phars.xml | 1 +
1 file changed, 1 insertion(+)
diff --git a/.phive/phars.xml b/.phive/phars.xml
index 853e8b0..acda6c4 100644
--- a/.phive/phars.xml
+++ b/.phive/phars.xml
@@ -7,4 +7,5 @@
+
From e422729b946322f1daf1f32b8db08e474195e74c Mon Sep 17 00:00:00 2001
From: Yuta Nagamiya
Date: Tue, 30 Mar 2021 22:51:11 +0900
Subject: [PATCH 03/19] Create psalm.xml.dist
---
psalm.xml.dist | 15 +++++++++++++++
1 file changed, 15 insertions(+)
create mode 100644 psalm.xml.dist
diff --git a/psalm.xml.dist b/psalm.xml.dist
new file mode 100644
index 0000000..3240886
--- /dev/null
+++ b/psalm.xml.dist
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
From cf65e53c73f448d8ad5c2dc0a651cbc1261e8928 Mon Sep 17 00:00:00 2001
From: Yuta Nagamiya
Date: Tue, 30 Mar 2021 22:52:13 +0900
Subject: [PATCH 04/19] Update dependencies
---
composer.json | 2 +-
composer.lock | 18 +++++++-----------
2 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/composer.json b/composer.json
index e02c095..0707c2c 100644
--- a/composer.json
+++ b/composer.json
@@ -20,7 +20,7 @@
],
"require": {
"php": "^7.3|^8.0",
- "ngmy/typed-array": "^0.8.0"
+ "ngmy/typed-array": "^0.9.0"
},
"autoload": {
"psr-4": {
diff --git a/composer.lock b/composer.lock
index 24c3434..be1a53b 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": "66253266947ae0e3c0d9562c9406f21c",
+ "content-hash": "242e07387a353272851cb3d7246270c5",
"packages": [
{
"name": "ngmy/typed-array",
- "version": "0.8.0",
+ "version": "0.9.0",
"source": {
"type": "git",
"url": "https://github.com/ngmy/php-typed-array.git",
- "reference": "edc2ba905657f8b7373ad8f08c9011fa524389ad"
+ "reference": "c55688a86db5f83141623d25a32f9a80dbfab5b8"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/ngmy/php-typed-array/zipball/edc2ba905657f8b7373ad8f08c9011fa524389ad",
- "reference": "edc2ba905657f8b7373ad8f08c9011fa524389ad",
+ "url": "https://api.github.com/repos/ngmy/php-typed-array/zipball/c55688a86db5f83141623d25a32f9a80dbfab5b8",
+ "reference": "c55688a86db5f83141623d25a32f9a80dbfab5b8",
"shasum": ""
},
"require": {
@@ -48,10 +48,6 @@
"array",
"type"
],
- "support": {
- "issues": "https://github.com/ngmy/php-typed-array/issues",
- "source": "https://github.com/ngmy/php-typed-array/tree/0.8.0"
- },
"funding": [
{
"url": "https://flattr.com/@ngmy",
@@ -62,7 +58,7 @@
"type": "github"
}
],
- "time": "2021-03-20T15:20:15+00:00"
+ "time": "2021-03-30T11:23:06+00:00"
}
],
"packages-dev": [],
@@ -75,5 +71,5 @@
"php": "^7.3|^8.0"
},
"platform-dev": [],
- "plugin-api-version": "2.0.0"
+ "plugin-api-version": "1.1.0"
}
From 152fa7895df77faea5cb7558cdf089a0166edcde Mon Sep 17 00:00:00 2001
From: Yuta Nagamiya
Date: Tue, 30 Mar 2021 22:54:54 +0900
Subject: [PATCH 05/19] Update coc-settings.json
---
.vim/coc-settings.json | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/.vim/coc-settings.json b/.vim/coc-settings.json
index df73b46..c183557 100644
--- a/.vim/coc-settings.json
+++ b/.vim/coc-settings.json
@@ -1,10 +1,13 @@
{
"diagnostic-languageserver.linters": {
- "ngmy.laradock.composer.lint": {
- "args": ["exec", "-u", "laradock", "laradock-ngmy-php-enum_workspace_1", "composer", "lint", "--", "--report=emacs"]
+ "ngmy.laradock.phive.phpcs": {
+ "args": ["exec", "-u", "laradock", "laradock-ngmy-php-enum_workspace_1", "php", "tools/phpcs", "--report=emacs"]
},
- "ngmy.laradock.composer.findbugs": {
- "args": ["exec", "-u", "laradock", "laradock-ngmy-php-enum_workspace_1", "composer", "findbugs", "--", "--error-format", "raw", "--no-progress"]
+ "ngmy.laradock.phive.phpstan": {
+ "args": ["exec", "-u", "laradock", "laradock-ngmy-php-enum_workspace_1", "php", "tools/phpstan", "analyse", "--error-format", "raw", "--no-progress"]
+ },
+ "ngmy.laradock.phive.psalm": {
+ "args": ["exec", "-u", "laradock", "laradock-ngmy-php-enum_workspace_1", "php", "tools/psalm", "--output-format=emacs", "--no-progress", "--no-cache"]
}
}
}
From 19f9604af4df34ae07b670caea03d0e2a58b8ac4 Mon Sep 17 00:00:00 2001
From: Yuta Nagamiya
Date: Tue, 30 Mar 2021 22:57:42 +0900
Subject: [PATCH 06/19] Update Composer scripts
---
composer.json | 38 +++++++++++++++++++++++++++++---------
1 file changed, 29 insertions(+), 9 deletions(-)
diff --git a/composer.json b/composer.json
index 0707c2c..c2da3d1 100644
--- a/composer.json
+++ b/composer.json
@@ -39,20 +39,40 @@
"prefer-stable": true,
"scripts": {
"test": [
- "@php tools/phpunit --colors=always"
+ "@phpunit"
],
"lint": [
- "@php tools/phpcs"
- ],
- "findbugs": [
- "@php tools/phpstan analyse --ansi"
+ "@phpcs",
+ "@phpstan",
+ "@psalm"
],
"fmt": [
- "@php tools/phpcbf | exit 0",
- "@php tools/php-cs-fixer fix --ansi"
+ "@phpcbf",
+ "@php-cs-fixer"
+ ],
+ "doc": [
+ "@phpdoc"
+ ],
+ "php-cs-fixer": [
+ "tools/php-cs-fixer fix --ansi"
+ ],
+ "phpcbf": [
+ "tools/phpcbf"
+ ],
+ "phpcs": [
+ "tools/phpcs"
+ ],
+ "phpdoc": [
+ "tools/phpDocumentor --force"
+ ],
+ "phpstan": [
+ "tools/phpstan analyse --ansi"
+ ],
+ "phpunit": [
+ "tools/phpunit --colors=always"
],
- "docs": [
- "@php tools/phpDocumentor --force"
+ "psalm": [
+ "[ \"${PSALM_SHEPHERD:-0}\" = '0' ] && tools/psalm --no-cache || tools/psalm --no-cache --shepherd"
]
}
}
From 02df29e8e4cd03cc8e14e7237c875157c9100ca3 Mon Sep 17 00:00:00 2001
From: Yuta Nagamiya
Date: Tue, 30 Mar 2021 22:58:50 +0900
Subject: [PATCH 07/19] Update the GitHub Actions workflow
---
.github/workflows/php.yml | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml
index 71ab83c..d4cdbb6 100644
--- a/.github/workflows/php.yml
+++ b/.github/workflows/php.yml
@@ -80,12 +80,17 @@ jobs:
name: tools
path: tools
+ - name: Set tools as an executable
+ run: find tools -type f -print0 | xargs -0 chmod +x
+
- name: Run lint
+ env:
+ PSALM_SHEPHERD: 1
+ # TODO: Remove it when psalm no longer tries to create a cache directory
+ # https://github.com/vimeo/psalm/issues/4267
+ XDG_CACHE_HOME: /tmp
run: composer lint
- - name: Run bug analysis
- run: composer findbugs
-
- name: Run unit tests
env:
XDEBUG_MODE: coverage
From cac20de8d2c884279cb143e9962a14610462527a Mon Sep 17 00:00:00 2001
From: Yuta Nagamiya
Date: Tue, 30 Mar 2021 23:02:22 +0900
Subject: [PATCH 08/19] Add Shepherd badges
---
README.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/README.md b/README.md
index 780e3e3..8d98af6 100644
--- a/README.md
+++ b/README.md
@@ -7,6 +7,8 @@
[](https://github.com/ngmy/php-typed-array/actions/workflows/php.yml)
[](https://coveralls.io/github/ngmy/php-enum?branch=master)
[](https://github.com/phpstan/phpstan)
+[](https://shepherd.dev/github/ngmy/php-typed-array)
+[](https://shepherd.dev/github/ngmy/php-typed-array)
PHP Enum is the enumeration type for PHP.
From c0cb0a8292bbe6658230822eb7214e74f40ee700 Mon Sep 17 00:00:00 2001
From: Yuta Nagamiya
Date: Tue, 30 Mar 2021 23:02:54 +0900
Subject: [PATCH 09/19] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 8d98af6..fd35f6d 100644
--- a/README.md
+++ b/README.md
@@ -14,7 +14,7 @@ PHP Enum is the enumeration type for PHP.
- Interface like the enum type of Java
- Also provides the enum map and set like Java
-- Supports the static analysis like PHPStan. Please see [examples](docs/examples)
+- Supports the static analysis like PHPStan and Psalm. Please see [examples](docs/examples)
```php
/**
From 98bafb8cf17f0b0be5c63193b62ac019f076f0e1 Mon Sep 17 00:00:00 2001
From: Yuta Nagamiya
Date: Fri, 2 Apr 2021 00:01:15 +0900
Subject: [PATCH 10/19] Fix the PHPStan error
---
src/EnumMap.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/EnumMap.php b/src/EnumMap.php
index 3bec45f..96ef7f5 100644
--- a/src/EnumMap.php
+++ b/src/EnumMap.php
@@ -183,6 +183,7 @@ public function withInterfaceValue(string $interface): self
* @return EnumMap
*
* @phpstan-param class-string $trait
+ * @phpstan-return EnumMap
*/
public function withTraitValue(string $trait): self
{
From 686bed59fa185a965e60b05e33d69e49fefc86eb Mon Sep 17 00:00:00 2001
From: Yuta Nagamiya
Date: Fri, 2 Apr 2021 00:07:39 +0900
Subject: [PATCH 11/19] Fix the Composer script for Psalm
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index c2da3d1..c4f57d0 100644
--- a/composer.json
+++ b/composer.json
@@ -72,7 +72,7 @@
"tools/phpunit --colors=always"
],
"psalm": [
- "[ \"${PSALM_SHEPHERD:-0}\" = '0' ] && tools/psalm --no-cache || tools/psalm --no-cache --shepherd"
+ "if [ \"${PSALM_SHEPHERD:-0}\" = '0' ]; then tools/psalm --no-cache; else tools/psalm --no-cache --shepherd; fi"
]
}
}
From 6ce6e8b15feb0ffbb91731d49707b23aea9a5692 Mon Sep 17 00:00:00 2001
From: Yuta Nagamiya
Date: Sat, 3 Apr 2021 19:57:29 +0900
Subject: [PATCH 12/19] Update Laradock
---
.laradock/env-development | 37 +++++++++++++++++++++++++++++++------
laradock | 2 +-
2 files changed, 32 insertions(+), 7 deletions(-)
diff --git a/.laradock/env-development b/.laradock/env-development
index accb120..77495cc 100644
--- a/.laradock/env-development
+++ b/.laradock/env-development
@@ -100,6 +100,7 @@ SHELL_OH_MY_ZSH_ALIASES=false
WORKSPACE_BASE_IMAGE_TAG_PREFIX=latest
WORKSPACE_COMPOSER_GLOBAL_INSTALL=true
+WORKSPACE_COMPOSER_VERSION=2
WORKSPACE_COMPOSER_AUTH=false
WORKSPACE_COMPOSER_REPO_PACKAGIST=
WORKSPACE_NVM_NODEJS_ORG_MIRROR=
@@ -122,6 +123,7 @@ WORKSPACE_INSTALL_WORKSPACE_SSH=false
WORKSPACE_INSTALL_SUBVERSION=false
WORKSPACE_INSTALL_BZ2=false
WORKSPACE_INSTALL_GMP=false
+WORKSPACE_INSTALL_GNUPG=false
WORKSPACE_INSTALL_XDEBUG=true
WORKSPACE_INSTALL_PCOV=false
WORKSPACE_INSTALL_PHPDBG=false
@@ -137,7 +139,7 @@ WORKSPACE_INSTALL_CASSANDRA=false
WORKSPACE_INSTALL_GEARMAN=false
WORKSPACE_INSTALL_MSSQL=false
WORKSPACE_INSTALL_DRUSH=false
-WORKSPACE_DRUSH_VERSION=8.1.17
+WORKSPACE_DRUSH_VERSION=8.4.6
WORKSPACE_INSTALL_DRUPAL_CONSOLE=false
WORKSPACE_INSTALL_WP_CLI=false
WORKSPACE_INSTALL_AEROSPIKE=false
@@ -146,7 +148,7 @@ WORKSPACE_INSTALL_V8JS=false
WORKSPACE_INSTALL_LARAVEL_ENVOY=false
WORKSPACE_INSTALL_LARAVEL_INSTALLER=false
WORKSPACE_INSTALL_DEPLOYER=false
-WORKSPACE_INSTALL_PRESTISSIMO=true
+WORKSPACE_INSTALL_PRESTISSIMO=false
WORKSPACE_INSTALL_LINUXBREW=false
WORKSPACE_INSTALL_MC=false
WORKSPACE_INSTALL_SYMFONY=false
@@ -156,6 +158,7 @@ WORKSPACE_INSTALL_POWERLINE=false
WORKSPACE_INSTALL_SUPERVISOR=false
WORKSPACE_INSTALL_IMAGE_OPTIMIZERS=false
WORKSPACE_INSTALL_IMAGEMAGICK=false
+WORKSPACE_IMAGEMAGICK_VERSION=latest
WORKSPACE_INSTALL_TERRAFORM=false
WORKSPACE_INSTALL_DUSK_DEPS=false
WORKSPACE_INSTALL_PG_CLIENT=false
@@ -164,7 +167,7 @@ WORKSPACE_INSTALL_SWOOLE=false
WORKSPACE_INSTALL_TAINT=false
WORKSPACE_INSTALL_LIBPNG=false
WORKSPACE_INSTALL_GRAPHVIZ=false
-WORKSPACE_INSTALL_IONCUBE=false
+WORKSPACE_INSTALL_IONCUBE=false # PHP 8.0 is not supported yet. Reference: https://forum.ioncube.com/viewtopic.php?t=4592
WORKSPACE_INSTALL_MYSQL_CLIENT=false
WORKSPACE_INSTALL_PING=false
WORKSPACE_INSTALL_SSHPASS=false
@@ -184,7 +187,7 @@ WORKSPACE_INSTALL_AUDIOWAVEFORM=false
WORKSPACE_INSTALL_WKHTMLTOPDF=false
WORKSPACE_INSTALL_GNU_PARALLEL=false
WORKSPACE_INSTALL_AST=true
-WORKSPACE_AST_VERSION=1.0.3
+WORKSPACE_AST_VERSION=1.0.10
WORKSPACE_BROWSERSYNC_HOST_PORT=3000
WORKSPACE_BROWSERSYNC_UI_HOST_PORT=3001
WORKSPACE_VUE_CLI_SERVE_HOST_PORT=8080
@@ -194,6 +197,7 @@ WORKSPACE_INSTALL_GIT_PROMPT=false
WORKSPACE_INSTALL_DOCKER_CLIENT=false
WORKSPACE_INSTALL_LNAV=false
WORKSPACE_INSTALL_PROTOC=false
+WORKSPACE_INSTALL_PHPDECIMAL=false
WORKSPACE_PROTOC_VERSION=latest
### PHP_FPM ###############################################
@@ -203,12 +207,14 @@ PHP_FPM_INSTALL_BCMATH=true
PHP_FPM_INSTALL_MYSQLI=true
PHP_FPM_INSTALL_INTL=true
PHP_FPM_INSTALL_IMAGEMAGICK=true
+PHP_FPM_IMAGEMAGICK_VERSION=latest
PHP_FPM_INSTALL_OPCACHE=true
PHP_FPM_INSTALL_IMAGE_OPTIMIZERS=true
PHP_FPM_INSTALL_PHPREDIS=true
PHP_FPM_INSTALL_MEMCACHED=false
PHP_FPM_INSTALL_BZ2=false
PHP_FPM_INSTALL_GMP=false
+PHP_FPM_INSTALL_GNUPG=false
PHP_FPM_INSTALL_XDEBUG=false
PHP_FPM_INSTALL_PCOV=false
PHP_FPM_INSTALL_XHPROF=false
@@ -237,7 +243,7 @@ PHP_FPM_INSTALL_POSTGIS=false
PHP_FPM_INSTALL_PCNTL=false
PHP_FPM_INSTALL_CALENDAR=false
PHP_FPM_INSTALL_FAKETIME=false
-PHP_FPM_INSTALL_IONCUBE=false
+PHP_FPM_INSTALL_IONCUBE=false # PHP 8.0 is not supported yet. Reference: https://forum.ioncube.com/viewtopic.php?t=4592
PHP_FPM_INSTALL_RDKAFKA=false
PHP_FPM_INSTALL_GETTEXT=false
PHP_FPM_INSTALL_XMLRPC=false
@@ -251,11 +257,13 @@ PHP_FPM_INSTALL_PING=false
PHP_FPM_INSTALL_SSHPASS=false
PHP_FPM_INSTALL_MAILPARSE=false
PHP_FPM_INSTALL_WKHTMLTOPDF=false
+PHP_FPM_INSTALL_PHPDECIMAL=false
PHP_FPM_FFMPEG=false
PHP_FPM_AUDIOWAVEFORM=false
PHP_FPM_ADDITIONAL_LOCALES="en_US.UTF-8 es_ES.UTF-8 fr_FR.UTF-8"
PHP_FPM_INSTALL_DOCKER_CLIENT=false
PHP_FPM_DEFAULT_LOCALE=POSIX
+PHP_FPM_XDEBUG_PORT=9003
PHP_FPM_PUID=1000
PHP_FPM_PGID=1000
@@ -271,8 +279,11 @@ PHP_FPM_NEW_RELIC_APP_NAME=app_name
PHP_WORKER_INSTALL_BZ2=false
PHP_WORKER_INSTALL_GD=false
PHP_WORKER_INSTALL_IMAGEMAGICK=false
+PHP_WORKER_IMAGEMAGICK_VERSION=latest
PHP_WORKER_INSTALL_GMP=false
+PHP_WORKER_INSTALL_GNUPG=false
PHP_WORKER_INSTALL_PGSQL=false
+PHP_WORKER_INSTALL_MONGO=false
PHP_WORKER_INSTALL_BCMATH=false
# PHP_WORKER_INSTALL_OCI8 Does not work in php5.6 version
PHP_WORKER_INSTALL_OCI8=false
@@ -310,12 +321,15 @@ NGINX_SSL_PATH=./nginx/ssl/
LARAVEL_HORIZON_INSTALL_BZ2=false
LARAVEL_HORIZON_INSTALL_GD=false
LARAVEL_HORIZON_INSTALL_GMP=false
+LARAVEL_HORIZON_INSTALL_GNUPG=false
LARAVEL_HORIZON_INSTALL_IMAGEMAGICK=false
+LARAVEL_HORIZON_IMAGEMAGICK_VERSION=latest
LARAVEL_HORIZON_INSTALL_SOCKETS=false
LARAVEL_HORIZON_INSTALL_YAML=false
LARAVEL_HORIZON_INSTALL_ZIP_ARCHIVE=false
-LARAVEL_HORIZON_INSTALL_PHPREDIS=true
+LARAVEL_HORIZON_INSTALL_PHPREDIS=false
LARAVEL_HORIZON_INSTALL_MONGO=false
+LARAVEL_HORIZON_INSTALL_CASSANDRA=false
LARAVEL_HORIZON_INSTALL_FFMPEG=false
LARAVEL_HORIZON_INSTALL_AUDIOWAVEFORM=false
LARAVEL_HORIZON_PGID=1000
@@ -327,10 +341,12 @@ APACHE_HOST_HTTP_PORT=80
APACHE_HOST_HTTPS_PORT=443
APACHE_HOST_LOG_PATH=./logs/apache2
APACHE_SITES_PATH=./apache2/sites
+APACHE_SSL_PATH=./apache2/ssl
APACHE_PHP_UPSTREAM_CONTAINER=php-fpm
APACHE_PHP_UPSTREAM_PORT=9000
APACHE_PHP_UPSTREAM_TIMEOUT=60
APACHE_DOCUMENT_ROOT=/var/www/
+APACHE_SSL_PATH=./apache2/ssl/
APACHE_INSTALL_HTTP2=false
### MYSQL #################################################
@@ -868,6 +884,15 @@ PGADMIN_PORT=5050
PGADMIN_DEFAULT_EMAIL=pgadmin4@pgadmin.org
PGADMIN_DEFAULT_PASSWORD=admin
+### SWAGGER EDITOR ###########################################
+
+SWAGGER_EDITOR_PORT=5151
+
+### SWAGGER UI ###############################################
+
+SWAGGER_API_URL=http://generator.swagger.io/api/swagger.json
+SWAGGER_UI_PORT=5555
+
### SONARQUBE ################################################
## docker-compose up -d sonarqube
## (If you encounter a database error)
diff --git a/laradock b/laradock
index 3a73aa6..ecdfa17 160000
--- a/laradock
+++ b/laradock
@@ -1 +1 @@
-Subproject commit 3a73aa60eeb40a807f7ed064f51d1ac12d7ce26f
+Subproject commit ecdfa174dc82771ff5effa3303b65505eb09ae8a
From 56dabc22d53ae7ac5af0004c2151181785781d3f Mon Sep 17 00:00:00 2001
From: Yuta Nagamiya
Date: Sat, 3 Apr 2021 19:58:07 +0900
Subject: [PATCH 13/19] Add global_namespace_import
---
.php_cs.dist | 1 +
1 file changed, 1 insertion(+)
diff --git a/.php_cs.dist b/.php_cs.dist
index 2fa2632..8739662 100644
--- a/.php_cs.dist
+++ b/.php_cs.dist
@@ -9,6 +9,7 @@ return PhpCsFixer\Config::create()
'inheritDoc' => 'inheritdoc',
],
],
+ 'global_namespace_import' => ['import_classes' => true, 'import_constants' => true, 'import_functions' => true],
'native_constant_invocation' => true,
'native_function_invocation' => true,
'no_empty_phpdoc' => true,
From 97c34ff5e6ebda28acd9213ca089e066f860e617 Mon Sep 17 00:00:00 2001
From: Yuta Nagamiya
Date: Sat, 3 Apr 2021 19:58:28 +0900
Subject: [PATCH 14/19] Change order of formatters
To insert an empty line between class import, function import, and
constant import.
---
composer.json | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/composer.json b/composer.json
index c4f57d0..97c9bd4 100644
--- a/composer.json
+++ b/composer.json
@@ -47,8 +47,8 @@
"@psalm"
],
"fmt": [
- "@phpcbf",
- "@php-cs-fixer"
+ "@php-cs-fixer",
+ "@phpcbf"
],
"doc": [
"@phpdoc"
From d169c64cd0168d5116df1769323cdfd012782bfd Mon Sep 17 00:00:00 2001
From: Yuta Nagamiya
Date: Sat, 3 Apr 2021 20:38:22 +0900
Subject: [PATCH 15/19] Update dependencies
---
composer.json | 2 +-
composer.lock | 18 +++++++++++-------
2 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/composer.json b/composer.json
index 97c9bd4..d0c5bfc 100644
--- a/composer.json
+++ b/composer.json
@@ -20,7 +20,7 @@
],
"require": {
"php": "^7.3|^8.0",
- "ngmy/typed-array": "^0.9.0"
+ "ngmy/typed-array": "^0.10.0"
},
"autoload": {
"psr-4": {
diff --git a/composer.lock b/composer.lock
index be1a53b..a168d9d 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": "242e07387a353272851cb3d7246270c5",
+ "content-hash": "7be8f676ffc0ca7f978ad4ee569d52ca",
"packages": [
{
"name": "ngmy/typed-array",
- "version": "0.9.0",
+ "version": "0.10.0",
"source": {
"type": "git",
"url": "https://github.com/ngmy/php-typed-array.git",
- "reference": "c55688a86db5f83141623d25a32f9a80dbfab5b8"
+ "reference": "107a930460de2cf59cc9dbfca721b94bd8a2e48a"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/ngmy/php-typed-array/zipball/c55688a86db5f83141623d25a32f9a80dbfab5b8",
- "reference": "c55688a86db5f83141623d25a32f9a80dbfab5b8",
+ "url": "https://api.github.com/repos/ngmy/php-typed-array/zipball/107a930460de2cf59cc9dbfca721b94bd8a2e48a",
+ "reference": "107a930460de2cf59cc9dbfca721b94bd8a2e48a",
"shasum": ""
},
"require": {
@@ -48,6 +48,10 @@
"array",
"type"
],
+ "support": {
+ "issues": "https://github.com/ngmy/php-typed-array/issues",
+ "source": "https://github.com/ngmy/php-typed-array/tree/0.10.0"
+ },
"funding": [
{
"url": "https://flattr.com/@ngmy",
@@ -58,7 +62,7 @@
"type": "github"
}
],
- "time": "2021-03-30T11:23:06+00:00"
+ "time": "2021-04-03T08:51:46+00:00"
}
],
"packages-dev": [],
@@ -71,5 +75,5 @@
"php": "^7.3|^8.0"
},
"platform-dev": [],
- "plugin-api-version": "1.1.0"
+ "plugin-api-version": "2.0.0"
}
From 33e5d3ce2cde9fe64a8a0955ca979bfc5bacd55f Mon Sep 17 00:00:00 2001
From: Yuta Nagamiya
Date: Sat, 3 Apr 2021 20:54:00 +0900
Subject: [PATCH 16/19] Fix types
---
src/Enum.php | 12 +++++--
src/EnumMap.php | 79 +++++++++++++++++++++++++++++++++++++++----
src/EnumSet.php | 73 ++++++++++++++++++++++++++++++++++-----
tests/EnumMapTest.php | 2 ++
tests/EnumSetTest.php | 4 +++
tests/EnumTest.php | 4 +--
6 files changed, 156 insertions(+), 18 deletions(-)
diff --git a/src/Enum.php b/src/Enum.php
index 097db9c..1b729c9 100644
--- a/src/Enum.php
+++ b/src/Enum.php
@@ -14,6 +14,7 @@ abstract class Enum
/**
* @var array>
* @phpstan-var array>
+ * @psalm-var array>
*/
private static $names = [];
@@ -27,6 +28,8 @@ abstract class Enum
* @return static
*
* @phpstan-param list $arguments
+ *
+ * @psalm-param list $arguments
*/
final public static function __callStatic(string $name, array $arguments): self
{
@@ -49,6 +52,8 @@ final public static function valueOf(string $name): self
* @return array
*
* @phpstan-return list
+ *
+ * @psalm-return list
*/
final public static function values(): array
{
@@ -64,6 +69,8 @@ final public static function values(): array
* @internal
*
* @phpstan-return list
+ *
+ * @psalm-return list
*/
final public static function names(): array
{
@@ -115,8 +122,9 @@ public function __toString(): string
*/
final public function ordinal(): int
{
- \assert(\is_int(\array_search($this->name, self::names())));
- return \array_search($this->name, self::names());
+ $ordinal = \array_search($this->name, self::names());
+ \assert(\is_int($ordinal));
+ return $ordinal;
}
/**
diff --git a/src/EnumMap.php b/src/EnumMap.php
index 96ef7f5..61797ec 100644
--- a/src/EnumMap.php
+++ b/src/EnumMap.php
@@ -19,21 +19,28 @@
* @see https://www.php.net/manual/en/class.countable.php
* @see https://www.php.net/manual/en/class.iteratoraggregate.php
*
- * @phpstan-template TKey
+ * @phpstan-template TKey of Enum
* @phpstan-template TValue
* @phpstan-implements ArrayAccess
* @phpstan-implements IteratorAggregate
+ *
+ * @psalm-template TKey of Enum
+ * @psalm-template TValue
+ * @template-implements ArrayAccess
+ * @template-implements IteratorAggregate
*/
class EnumMap implements ArrayAccess, Countable, IteratorAggregate
{
/**
* @var TypedArray
* @phpstan-var TypedArray
+ * @psalm-var TypedArray
*/
private $typedArray;
/**
* @var array
* @phpstan-var array
+ * @psalm-var array
*/
private $keys = [];
@@ -42,9 +49,13 @@ class EnumMap implements ArrayAccess, Countable, IteratorAggregate
*
* @return EnumMap
*
- * @phpstan-template TEnum
+ * @phpstan-template TEnum of Enum
* @phpstan-param class-string $class
- * @return EnumMap
+ * @phpstan-return EnumMap
+ *
+ * @psalm-template TEnum of Enum
+ * @psalm-param class-string $class
+ * @psalm-return EnumMap
*/
public static function new(string $class): self
{
@@ -59,6 +70,8 @@ public static function new(string $class): self
* @return EnumMap>
*
* @phpstan-return EnumMap>
+ *
+ * @psalm-return EnumMap>
*/
public function withArrayValue(): self
{
@@ -71,6 +84,8 @@ public function withArrayValue(): self
* @return EnumMap
*
* @phpstan-return EnumMap
+ *
+ * @psalm-return EnumMap
*/
public function withBoolValue(): self
{
@@ -83,6 +98,8 @@ public function withBoolValue(): self
* @return EnumMap
*
* @phpstan-return EnumMap
+ *
+ * @psalm-return EnumMap
*/
public function withFloatValue(): self
{
@@ -95,6 +112,8 @@ public function withFloatValue(): self
* @return EnumMap
*
* @phpstan-return EnumMap
+ *
+ * @psalm-return EnumMap
*/
public function withIntValue(): self
{
@@ -107,6 +126,8 @@ public function withIntValue(): self
* @return EnumMap
*
* @phpstan-return EnumMap
+ *
+ * @psalm-return EnumMap
*/
public function withMixedValue(): self
{
@@ -119,6 +140,8 @@ public function withMixedValue(): self
* @return EnumMap
*
* @phpstan-return EnumMap
+ *
+ * @psalm-return EnumMap
*/
public function withObjectValue(): self
{
@@ -131,6 +154,8 @@ public function withObjectValue(): self
* @return EnumMap
*
* @phpstan-return EnumMap
+ *
+ * @psalm-return EnumMap
*/
public function withResourceValue(): self
{
@@ -143,6 +168,8 @@ public function withResourceValue(): self
* @return EnumMap
*
* @phpstan-return EnumMap
+ *
+ * @psalm-return EnumMap
*/
public function withStringValue(): self
{
@@ -157,6 +184,10 @@ public function withStringValue(): self
* @phpstan-template TClass
* @phpstan-param class-string $class
* @phpstan-return EnumMap
+ *
+ * @psalm-template TClass
+ * @psalm-param class-string $class
+ * @psalm-return EnumMap
*/
public function withClassValue(string $class): self
{
@@ -171,6 +202,10 @@ public function withClassValue(string $class): self
* @phpstan-template TInterface
* @phpstan-param class-string $interface
* @phpstan-return EnumMap
+ *
+ * @psalm-template TInterface
+ * @psalm-param class-string $interface
+ * @psalm-return EnumMap
*/
public function withInterfaceValue(string $interface): self
{
@@ -184,6 +219,9 @@ public function withInterfaceValue(string $interface): self
*
* @phpstan-param class-string $trait
* @phpstan-return EnumMap
+ *
+ * @psalm-param trait-string $trait
+ * @psalm-return EnumMap
*/
public function withTraitValue(string $trait): self
{
@@ -204,6 +242,8 @@ public function isEmpty(): bool
* @return array
*
* @phpstan-return array
+ *
+ * @psalm-return array
*/
public function toArray(): array
{
@@ -211,13 +251,18 @@ public function toArray(): array
return \array_reduce(\array_keys($array), function (array $carry, int $hashCode) use ($array): array {
$key = $this->keys[$hashCode];
$carry[$key->name()] = $array[$hashCode];
+ /** @psalm-var array $carry */
return $carry;
}, []);
}
/**
- * @param mixed $key
+ * @param Enum $key
* @see https://www.php.net/manual/en/arrayaccess.offsetexists.php
+ *
+ * @phpstan-param TKey $key
+ *
+ * @psalm-param TKey $key
*/
public function offsetExists($key): bool
{
@@ -225,11 +270,15 @@ public function offsetExists($key): bool
}
/**
- * @param mixed $key
+ * @param Enum $key
* @return mixed|null
* @see https://www.php.net/manual/en/arrayaccess.offsetget.php
*
+ * @phpstan-param TKey $key
* @phpstan-return TValue|null
+ *
+ * @psalm-param TKey $key
+ * @psalm-return TValue|null
*/
public function offsetGet($key)
{
@@ -243,6 +292,9 @@ public function offsetGet($key)
*
* @phpstan-param TKey $key
* @phpstan-param TValue $value
+ *
+ * @psalm-param TKey $key
+ * @psalm-param TValue $value
*/
public function offsetSet($key, $value): void
{
@@ -251,8 +303,12 @@ public function offsetSet($key, $value): void
}
/**
- * @param mixed $key
+ * @param Enum $key
* @see https://www.php.net/manual/en/arrayaccess.offsetunset.php
+ *
+ * @phpstan-param TKey $key
+ *
+ * @psalm-param TKey $key
*/
public function offsetUnset($key): void
{
@@ -262,9 +318,14 @@ public function offsetUnset($key): void
/**
* @see https://www.php.net/manual/en/countable.count.php
+ *
+ * @phpstan-return 0|positive-int
+ *
+ * @psalm-return 0|positive-int
*/
public function count(): int
{
+ /** @psalm-var 0|positive-int */
return \count($this->typedArray);
}
@@ -273,6 +334,8 @@ public function count(): int
* @see https://www.php.net/manual/en/iteratoraggregate.getiterator.php
*
* @phpstan-return Traversable
+ *
+ * @psalm-return Traversable
*/
public function getIterator(): Traversable
{
@@ -281,6 +344,8 @@ public function getIterator(): Traversable
/**
* @phpstan-param class-string $class
+ *
+ * @psalm-param class-string $class
*/
private static function validateEnum(string $class): void
{
@@ -295,6 +360,8 @@ private static function validateEnum(string $class): void
* @param TypedArray $typedArray
*
* @phpstan-param TypedArray $typedArray
+ *
+ * @psalm-param TypedArray $typedArray
*/
private function __construct(TypedArray $typedArray)
{
diff --git a/src/EnumSet.php b/src/EnumSet.php
index 46dd16e..996b308 100644
--- a/src/EnumSet.php
+++ b/src/EnumSet.php
@@ -18,15 +18,20 @@
* @see https://www.php.net/manual/en/class.countable.php
* @see https://www.php.net/manual/en/class.iteratoraggregate.php
*
- * @phpstan-template T
+ * @phpstan-template T of Enum
* @phpstan-implements ArrayAccess
* @phpstan-implements IteratorAggregate
+ *
+ * @psalm-template T of Enum
+ * @template-implements ArrayAccess
+ * @template-implements IteratorAggregate
*/
class EnumSet implements ArrayAccess, Countable, IteratorAggregate
{
/**
* @var EnumMap
* @phpstan-var EnumMap
+ * @psalm-var EnumMap
*/
private $enumMap;
@@ -35,9 +40,13 @@ class EnumSet implements ArrayAccess, Countable, IteratorAggregate
*
* @return EnumSet
*
- * @phpstan-template TEnum
+ * @phpstan-template TEnum of Enum
* @phpstan-param class-string $class
* @phpstan-return EnumSet
+ *
+ * @psalm-template TEnum of Enum
+ * @psalm-param class-string $class
+ * @psalm-return EnumSet
*/
public static function allOf(string $class): self
{
@@ -54,9 +63,13 @@ public static function allOf(string $class): self
*
* @return EnumSet
*
- * @phpstan-template TEnum
+ * @phpstan-template TEnum of Enum
* @phpstan-param class-string $class
* @phpstan-return EnumSet
+ *
+ * @psalm-template TEnum of Enum
+ * @psalm-param class-string $class
+ * @psalm-return EnumSet
*/
public static function noneOf(string $class): self
{
@@ -72,6 +85,10 @@ public static function noneOf(string $class): self
* @phpstan-template TEnum of Enum
* @phpstan-param TEnum $enum
* @phpstan-return EnumSet
+ *
+ * @psalm-template TEnum of Enum
+ * @psalm-param TEnum $enum
+ * @psalm-return EnumSet
*/
public static function of(Enum $enum): self
{
@@ -90,6 +107,11 @@ public static function of(Enum $enum): self
* @phpstan-param TEnum $from
* @phpstan-param TEnum $to
* @phpstan-return EnumSet
+ *
+ * @psalm-template TEnum of Enum
+ * @psalm-param TEnum $from
+ * @psalm-param TEnum $to
+ * @psalm-return EnumSet
*/
public static function range(Enum $from, Enum $to): self
{
@@ -127,7 +149,12 @@ public static function range(Enum $from, Enum $to): self
if ($i > $ordinalTo) {
break;
}
- $enums[] = $classFrom::{$names[$i]}();
+ /**
+ * @phpstan-var TEnum $enum
+ * @psalm-var TEnum $enum
+ */
+ $enum = $classFrom::{$names[$i]}();
+ $enums[] = $enum;
}
$enumSet = new self(EnumMap::new($classFrom)->withClassValue($classFrom));
foreach ($enums as $enum) {
@@ -150,12 +177,15 @@ public function isEmpty(): bool
* @return array
*
* @phpstan-return list
+ *
+ * @psalm-return list
*/
public function toArray(): array
{
/**
* @var array
* @phpstan-var list
+ * @psalm-var list
*/
$array = $this->enumMap->toArray();
\usort($array, function (object $enum1, object $enum2): int {
@@ -167,8 +197,12 @@ public function toArray(): array
}
/**
- * @param mixed $key
+ * @param Enum $key
* @see https://www.php.net/manual/en/arrayaccess.offsetexists.php
+ *
+ * @phpstan-param T $key
+ *
+ * @psalm-param T $key
*/
public function offsetExists($key): bool
{
@@ -176,11 +210,15 @@ public function offsetExists($key): bool
}
/**
- * @param mixed $key
+ * @param Enum $key
* @return Enum|null
* @see https://www.php.net/manual/en/arrayaccess.offsetget.php
*
+ * @phpstan-param T $key
* @phpstan-return T|null
+ *
+ * @psalm-param T $key
+ * @psalm-return T|null
*/
public function offsetGet($key)
{
@@ -192,7 +230,11 @@ public function offsetGet($key)
* @param Enum $enum
* @see https://www.php.net/manual/en/arrayaccess.offsetset.php
*
- * @phpstan-param T $enum
+ * @phpstan-param T|null $key
+ * @phpstan-param T $enum
+ *
+ * @psalm-param T|null $key
+ * @psalm-param T $enum
*/
public function offsetSet($key, $enum): void
{
@@ -200,8 +242,12 @@ public function offsetSet($key, $enum): void
}
/**
- * @param mixed $key
+ * @param Enum $key
* @see https://www.php.net/manual/en/arrayaccess.offsetunset.php
+ *
+ * @phpstan-param T $key
+ *
+ * @psalm-param T $key
*/
public function offsetUnset($key): void
{
@@ -210,9 +256,14 @@ public function offsetUnset($key): void
/**
* @see https://www.php.net/manual/en/countable.count.php
+ *
+ * @phpstan-return 0|positive-int
+ *
+ * @psalm-return 0|positive-int
*/
public function count(): int
{
+ /** @psalm-var 0|positive-int */
return \count($this->enumMap);
}
@@ -221,6 +272,8 @@ public function count(): int
* @see https://www.php.net/manual/en/iteratoraggregate.getiterator.php
*
* @phpstan-return Traversable
+ *
+ * @psalm-return Traversable
*/
public function getIterator(): Traversable
{
@@ -229,6 +282,8 @@ public function getIterator(): Traversable
/**
* @phpstan-param class-string $class
+ *
+ * @psalm-param class-string $class
*/
private static function validateEnum(string $class): void
{
@@ -243,6 +298,8 @@ private static function validateEnum(string $class): void
* @param EnumMap $enumMap
*
* @phpstan-param EnumMap $enumMap
+ *
+ * @psalm-param EnumMap $enumMap
*/
private function __construct(EnumMap $enumMap)
{
diff --git a/tests/EnumMapTest.php b/tests/EnumMapTest.php
index 2235420..4c383e0 100644
--- a/tests/EnumMapTest.php
+++ b/tests/EnumMapTest.php
@@ -36,6 +36,8 @@ public function testNew(string $class, Exception $exception = null): void
if ($exception instanceof Exception) {
$this->expectException(\get_class($exception));
}
+ // NOTE: To test that an exception is thrown
+ // @phpstan-ignore-next-line
EnumMap::new($class);
}
diff --git a/tests/EnumSetTest.php b/tests/EnumSetTest.php
index 0b07c26..9de8ddb 100644
--- a/tests/EnumSetTest.php
+++ b/tests/EnumSetTest.php
@@ -39,6 +39,8 @@ public function testAllOf(string $class, $expected): void
if ($expected instanceof Exception) {
$this->expectException(\get_class($expected));
}
+ // NOTE: To test that an exception is thrown
+ // @phpstan-ignore-next-line
$actual = EnumSet::allOf($class);
$this->assertEquals($expected, $actual->toArray());
}
@@ -66,6 +68,8 @@ public function testNoneOf(string $class, $expected): void
if ($expected instanceof Exception) {
$this->expectException(\get_class($expected));
}
+ // NOTE: To test that an exception is thrown
+ // @phpstan-ignore-next-line
$actual = EnumSet::noneOf($class);
$this->assertEquals($expected, $actual->toArray());
}
diff --git a/tests/EnumTest.php b/tests/EnumTest.php
index 05e5046..0528d80 100644
--- a/tests/EnumTest.php
+++ b/tests/EnumTest.php
@@ -86,7 +86,7 @@ public function valuesProvider(): array
}
/**
- * @param Exception|array $expected
+ * @param array|Exception $expected
* @dataProvider valuesProvider
*
* @phpstan-param class-string $class
@@ -130,7 +130,7 @@ public function namesProvider(): array
}
/**
- * @param Exception|array $expected
+ * @param array|Exception $expected
* @dataProvider namesProvider
* @runInSeparateProcess
* @preserveGlobalState disabled
From 7733763c0a5a94cd9d6f826700b8fbe266a5ab51 Mon Sep 17 00:00:00 2001
From: Yuta Nagamiya
Date: Sat, 3 Apr 2021 20:54:56 +0900
Subject: [PATCH 17/19] Format code
---
src/Enum.php | 39 +++++++++++++++++++++++++++------------
src/EnumMap.php | 15 +++++++++++----
src/EnumSet.php | 33 +++++++++++++++++++++------------
tests/Data/Enum3.php | 5 ++++-
tests/EnumMapTest.php | 23 +++++++++++++++--------
tests/EnumSetTest.php | 16 ++++++++++------
tests/EnumTest.php | 24 +++++++++++++++---------
7 files changed, 103 insertions(+), 52 deletions(-)
diff --git a/src/Enum.php b/src/Enum.php
index 1b729c9..5a17eab 100644
--- a/src/Enum.php
+++ b/src/Enum.php
@@ -9,6 +9,21 @@
use LogicException;
use ReflectionClass;
+use function array_keys;
+use function array_map;
+use function array_search;
+use function assert;
+use function explode;
+use function get_called_class;
+use function in_array;
+use function is_int;
+use function ord;
+use function preg_match;
+use function sprintf;
+use function strlen;
+
+use const PHP_EOL;
+
abstract class Enum
{
/**
@@ -57,7 +72,7 @@ final public static function valueOf(string $name): self
*/
final public static function values(): array
{
- return \array_map(function (string $name): self {
+ return array_map(function (string $name): self {
return self::valueOf($name);
}, self::names());
}
@@ -75,22 +90,22 @@ final public static function values(): array
final public static function names(): array
{
self::validateInheritance();
- $class = \get_called_class();
+ $class = get_called_class();
if (isset(self::$names[$class])) {
return self::$names[$class];
}
self::$names[$class] = [];
$reflectionClass = new ReflectionClass($class);
$staticProperties = $reflectionClass->getStaticProperties();
- foreach (\array_keys($staticProperties) as $propertyName) {
+ foreach (array_keys($staticProperties) as $propertyName) {
$reflectionProperty = $reflectionClass->getProperty($propertyName);
$docComment = $reflectionProperty->getDocComment();
if ($docComment === false) {
continue;
}
- $lines = \explode(\PHP_EOL, $docComment);
+ $lines = explode(PHP_EOL, $docComment);
foreach ($lines as $line) {
- if (!\preg_match('/@[^\s]+/', $line, $mathces) || $mathces[0] != '@enum') {
+ if (!preg_match('/@[^\s]+/', $line, $mathces) || $mathces[0] != '@enum') {
continue;
}
self::$names[$class][] = $propertyName;
@@ -122,8 +137,8 @@ public function __toString(): string
*/
final public function ordinal(): int
{
- $ordinal = \array_search($this->name, self::names());
- \assert(\is_int($ordinal));
+ $ordinal = array_search($this->name, self::names());
+ assert(is_int($ordinal));
return $ordinal;
}
@@ -141,9 +156,9 @@ final public function equals(object $other): bool
final public function hashCode(): int
{
$result = 17;
- $nameLength = \strlen($this->name);
+ $nameLength = strlen($this->name);
for ($i = 0; $i < $nameLength; ++$i) {
- $result = 31 * $result + \ord($this->name[$i]);
+ $result = 31 * $result + ord($this->name[$i]);
}
return $result;
}
@@ -171,7 +186,7 @@ final protected function __clone()
private static function validateInheritance(): void
{
- $reflectionClass = new ReflectionClass(\get_called_class());
+ $reflectionClass = new ReflectionClass(get_called_class());
while ($reflectionClass = $reflectionClass->getParentClass()) {
if ($reflectionClass->getName() != self::class) {
throw new LogicException('You are not allowed to inherit from the concrete enum class.');
@@ -181,8 +196,8 @@ private static function validateInheritance(): void
final private function __construct(string $name)
{
- if (!\in_array($name, self::names())) {
- throw new InvalidArgumentException(\sprintf('The name "%s" is not defined.', $name));
+ if (!in_array($name, self::names())) {
+ throw new InvalidArgumentException(sprintf('The name "%s" is not defined.', $name));
}
$this->name = $name;
}
diff --git a/src/EnumMap.php b/src/EnumMap.php
index 61797ec..e666ef0 100644
--- a/src/EnumMap.php
+++ b/src/EnumMap.php
@@ -12,6 +12,13 @@
use Ngmy\TypedArray\TypedArray;
use Traversable;
+use function array_keys;
+use function array_reduce;
+use function class_exists;
+use function count;
+use function get_parent_class;
+use function sprintf;
+
/**
* @implements ArrayAccess
* @implements IteratorAggregate
@@ -248,7 +255,7 @@ public function isEmpty(): bool
public function toArray(): array
{
$array = $this->typedArray->toArray();
- return \array_reduce(\array_keys($array), function (array $carry, int $hashCode) use ($array): array {
+ return array_reduce(array_keys($array), function (array $carry, int $hashCode) use ($array): array {
$key = $this->keys[$hashCode];
$carry[$key->name()] = $array[$hashCode];
/** @psalm-var array $carry */
@@ -326,7 +333,7 @@ public function offsetUnset($key): void
public function count(): int
{
/** @psalm-var 0|positive-int */
- return \count($this->typedArray);
+ return count($this->typedArray);
}
/**
@@ -349,9 +356,9 @@ public function getIterator(): Traversable
*/
private static function validateEnum(string $class): void
{
- if (!\class_exists($class) || \get_parent_class($class) != Enum::class) {
+ if (!class_exists($class) || get_parent_class($class) != Enum::class) {
throw new InvalidArgumentException(
- \sprintf('The type of the key must be the concrete enum class, "%s" given.', $class)
+ sprintf('The type of the key must be the concrete enum class, "%s" given.', $class)
);
};
}
diff --git a/src/EnumSet.php b/src/EnumSet.php
index 996b308..a159981 100644
--- a/src/EnumSet.php
+++ b/src/EnumSet.php
@@ -11,6 +11,15 @@
use IteratorAggregate;
use Traversable;
+use function assert;
+use function class_exists;
+use function count;
+use function get_class;
+use function get_parent_class;
+use function method_exists;
+use function sprintf;
+use function usort;
+
/**
* @implements ArrayAccess
* @implements IteratorAggregate
@@ -92,7 +101,7 @@ public static function noneOf(string $class): self
*/
public static function of(Enum $enum): self
{
- $class = \get_class($enum);
+ $class = get_class($enum);
$enumSet = new self(EnumMap::new($class)->withClassValue($class));
$enumSet[] = $enum;
return $enumSet;
@@ -115,11 +124,11 @@ public static function of(Enum $enum): self
*/
public static function range(Enum $from, Enum $to): self
{
- $classFrom = \get_class($from);
- $classTo = \get_class($to);
+ $classFrom = get_class($from);
+ $classTo = get_class($to);
if ($classFrom != $classTo) {
throw new InvalidArgumentException(
- \sprintf(
+ sprintf(
'The range enum classes must be the same class, "%s" and "%s" given.',
$classFrom,
$classTo
@@ -130,7 +139,7 @@ public static function range(Enum $from, Enum $to): self
$ordinalTo = $to->ordinal();
if ($ordinalFrom > $ordinalTo) {
throw new InvalidArgumentException(
- \sprintf(
+ sprintf(
'The range "%s" (position %s) to "%s" (position %s) is invalid.',
$classFrom,
$ordinalFrom,
@@ -141,7 +150,7 @@ public static function range(Enum $from, Enum $to): self
}
$enums = [];
$names = $classFrom::names();
- $nameCount = \count($names);
+ $nameCount = count($names);
for ($i = 0; $i < $nameCount; ++$i) {
if ($i < $ordinalFrom) {
continue;
@@ -188,9 +197,9 @@ public function toArray(): array
* @psalm-var list
*/
$array = $this->enumMap->toArray();
- \usort($array, function (object $enum1, object $enum2): int {
- \assert(\method_exists($enum1, 'ordinal'));
- \assert(\method_exists($enum2, 'ordinal'));
+ usort($array, function (object $enum1, object $enum2): int {
+ assert(method_exists($enum1, 'ordinal'));
+ assert(method_exists($enum2, 'ordinal'));
return $enum1->ordinal() < $enum2->ordinal() ? -1 : 1;
});
return $array;
@@ -264,7 +273,7 @@ public function offsetUnset($key): void
public function count(): int
{
/** @psalm-var 0|positive-int */
- return \count($this->enumMap);
+ return count($this->enumMap);
}
/**
@@ -287,9 +296,9 @@ public function getIterator(): Traversable
*/
private static function validateEnum(string $class): void
{
- if (!\class_exists($class) || \get_parent_class($class) != Enum::class) {
+ if (!class_exists($class) || get_parent_class($class) != Enum::class) {
throw new InvalidArgumentException(
- \sprintf('The type of the value must be the concrete enum class, "%s" given.', $class)
+ sprintf('The type of the value must be the concrete enum class, "%s" given.', $class)
);
};
}
diff --git a/tests/Data/Enum3.php b/tests/Data/Enum3.php
index eb8f5b4..4f9dfc4 100644
--- a/tests/Data/Enum3.php
+++ b/tests/Data/Enum3.php
@@ -6,6 +6,9 @@
use Ngmy\Enum\Enum;
+use function strtolower;
+use function ucwords;
+
/**
* @method static self FOO()
* @method static self BAR()
@@ -34,6 +37,6 @@ class Enum3 extends Enum
*/
public function __toString(): string
{
- return \ucwords(\strtolower($this->name()));
+ return ucwords(strtolower($this->name()));
}
}
diff --git a/tests/EnumMapTest.php b/tests/EnumMapTest.php
index 4c383e0..6dcb152 100644
--- a/tests/EnumMapTest.php
+++ b/tests/EnumMapTest.php
@@ -8,6 +8,13 @@
use InvalidArgumentException;
use Ngmy\Enum\Enum;
use Ngmy\Enum\EnumMap;
+use stdClass;
+
+use function assert;
+use function get_class;
+use function is_array;
+use function is_null;
+use function tmpfile;
class EnumMapTest extends TestCase
{
@@ -18,7 +25,7 @@ public function newProvider(): array
{
return [
[Data\Enum1::class],
- [\stdClass::class, new InvalidArgumentException()],
+ [stdClass::class, new InvalidArgumentException()],
['a', new InvalidArgumentException()],
];
}
@@ -30,11 +37,11 @@ public function newProvider(): array
*/
public function testNew(string $class, Exception $exception = null): void
{
- if (\is_null($exception)) {
+ if (is_null($exception)) {
$this->expectNotToPerformAssertions();
}
if ($exception instanceof Exception) {
- $this->expectException(\get_class($exception));
+ $this->expectException(get_class($exception));
}
// NOTE: To test that an exception is thrown
// @phpstan-ignore-next-line
@@ -117,9 +124,9 @@ public function testCount(array $enums, int $expected): void
*/
public function dataProvider(): array
{
- $resource1 = \tmpfile();
- $resource2 = \tmpfile();
- $resource3 = \tmpfile();
+ $resource1 = tmpfile();
+ $resource2 = tmpfile();
+ $resource3 = tmpfile();
return [
[
@@ -248,12 +255,12 @@ public function dataProvider(): array
public function test(EnumMap $enumMap, array $keys, array $values, $expected): void
{
if ($expected instanceof Exception) {
- $this->expectException(\get_class($expected));
+ $this->expectException(get_class($expected));
}
foreach ($keys as $i => $key) {
$enumMap[$key] = $values[$i];
}
- \assert(\is_array($expected));
+ assert(is_array($expected));
$this->assertEquals($expected, $enumMap->toArray());
$i = 0;
foreach ($enumMap as $name => $value) {
diff --git a/tests/EnumSetTest.php b/tests/EnumSetTest.php
index 9de8ddb..96f2c8c 100644
--- a/tests/EnumSetTest.php
+++ b/tests/EnumSetTest.php
@@ -10,6 +10,10 @@
use Ngmy\Enum\EnumSet;
use stdClass;
+use function assert;
+use function get_class;
+use function is_array;
+
class EnumSetTest extends TestCase
{
/**
@@ -37,7 +41,7 @@ public function allOfProvider(): array
public function testAllOf(string $class, $expected): void
{
if ($expected instanceof Exception) {
- $this->expectException(\get_class($expected));
+ $this->expectException(get_class($expected));
}
// NOTE: To test that an exception is thrown
// @phpstan-ignore-next-line
@@ -66,7 +70,7 @@ public function noneOfProvider(): array
public function testNoneOf(string $class, $expected): void
{
if ($expected instanceof Exception) {
- $this->expectException(\get_class($expected));
+ $this->expectException(get_class($expected));
}
// NOTE: To test that an exception is thrown
// @phpstan-ignore-next-line
@@ -93,7 +97,7 @@ public function ofProvider(): array
public function testOf(Enum $class, $expected): void
{
if ($expected instanceof Exception) {
- $this->expectException(\get_class($expected));
+ $this->expectException(get_class($expected));
}
$actual = EnumSet::of($class);
$this->assertEquals($expected, $actual->toArray());
@@ -139,7 +143,7 @@ public function rangeProvider(): array
public function testRange(Enum $from, Enum $to, $expected): void
{
if ($expected instanceof Exception) {
- $this->expectException(\get_class($expected));
+ $this->expectException(get_class($expected));
}
$actual = EnumSet::range($from, $to);
$this->assertEquals($expected, $actual->toArray());
@@ -246,12 +250,12 @@ public function enumSetProvider(): array
public function testEnumSet(EnumSet $enumSet, array $enums, $expected): void
{
if ($expected instanceof Exception) {
- $this->expectException(\get_class($expected));
+ $this->expectException(get_class($expected));
}
foreach ($enums as $enum) {
$enumSet[] = $enum;
}
- \assert(\is_array($expected));
+ assert(is_array($expected));
$this->assertEquals($expected, $enumSet->toArray());
$i = 0;
foreach ($enumSet as $enum) {
diff --git a/tests/EnumTest.php b/tests/EnumTest.php
index 0528d80..babfd9f 100644
--- a/tests/EnumTest.php
+++ b/tests/EnumTest.php
@@ -11,6 +11,12 @@
use Ngmy\Enum\Enum;
use ReflectionClass;
+use function assert;
+use function get_class;
+use function is_string;
+use function serialize;
+use function unserialize;
+
class EnumTest extends TestCase
{
/**
@@ -40,10 +46,10 @@ public function valueOfProvider(): array
public function testValueOf(string $class, string $name, $expected): void
{
if ($expected instanceof Exception) {
- $this->expectException(\get_class($expected));
+ $this->expectException(get_class($expected));
}
$actual = $class::valueOf($name);
- \assert(\is_string($expected));
+ assert(is_string($expected));
$this->assertInstanceOf($expected, $actual);
}
@@ -57,10 +63,10 @@ public function testValueOf(string $class, string $name, $expected): void
public function testMagicFactoryMethod(string $class, string $name, $expected): void
{
if ($expected instanceof Exception) {
- $this->expectException(\get_class($expected));
+ $this->expectException(get_class($expected));
}
$actual = $class::$name();
- \assert(\is_string($expected));
+ assert(is_string($expected));
$this->assertInstanceOf($expected, $actual);
}
@@ -95,7 +101,7 @@ public function valuesProvider(): array
public function testValues(string $class, $expected): void
{
if ($expected instanceof Exception) {
- $this->expectException(\get_class($expected));
+ $this->expectException(get_class($expected));
}
$this->assertEquals($expected, $class::values());
}
@@ -141,7 +147,7 @@ public function namesProvider(): array
public function testNames(string $class, $expected): void
{
if ($expected instanceof Exception) {
- $this->expectException(\get_class($expected));
+ $this->expectException(get_class($expected));
}
$fromReflection = $class::names();
$fromCache = $class::names();
@@ -292,7 +298,7 @@ public function getInstanceProvider(): array
public function testGetInstance(string $class, $value, $expected): void
{
if ($expected instanceof Exception) {
- $this->expectException(\get_class($expected));
+ $this->expectException(get_class($expected));
}
$this->assertEquals($expected, $class::getInstance($value));
}
@@ -329,9 +335,9 @@ public function testSetter(): void
public function testUnserialize(): void
{
$foo = Data\Enum1::FOO();
- $serializedFoo = \serialize($foo);
+ $serializedFoo = serialize($foo);
$this->expectException(BadMethodCallException::class);
- \unserialize($serializedFoo);
+ unserialize($serializedFoo);
}
public function testClone(): void
From 50136a9d25d1c06ea0237af5650d1f609694cfb6 Mon Sep 17 00:00:00 2001
From: Yuta Nagamiya
Date: Sat, 3 Apr 2021 21:46:41 +0900
Subject: [PATCH 18/19] Update dependencies
---
composer.json | 2 +-
composer.lock | 14 +++++++-------
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/composer.json b/composer.json
index d0c5bfc..9fb3b76 100644
--- a/composer.json
+++ b/composer.json
@@ -20,7 +20,7 @@
],
"require": {
"php": "^7.3|^8.0",
- "ngmy/typed-array": "^0.10.0"
+ "ngmy/typed-array": "^0.11.0"
},
"autoload": {
"psr-4": {
diff --git a/composer.lock b/composer.lock
index a168d9d..7b687d7 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": "7be8f676ffc0ca7f978ad4ee569d52ca",
+ "content-hash": "08291a67ba4ef71a81a03982068481c7",
"packages": [
{
"name": "ngmy/typed-array",
- "version": "0.10.0",
+ "version": "0.11.0",
"source": {
"type": "git",
"url": "https://github.com/ngmy/php-typed-array.git",
- "reference": "107a930460de2cf59cc9dbfca721b94bd8a2e48a"
+ "reference": "8dc440701096474f8848a7bd5d4028661277874f"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/ngmy/php-typed-array/zipball/107a930460de2cf59cc9dbfca721b94bd8a2e48a",
- "reference": "107a930460de2cf59cc9dbfca721b94bd8a2e48a",
+ "url": "https://api.github.com/repos/ngmy/php-typed-array/zipball/8dc440701096474f8848a7bd5d4028661277874f",
+ "reference": "8dc440701096474f8848a7bd5d4028661277874f",
"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.10.0"
+ "source": "https://github.com/ngmy/php-typed-array/tree/0.11.0"
},
"funding": [
{
@@ -62,7 +62,7 @@
"type": "github"
}
],
- "time": "2021-04-03T08:51:46+00:00"
+ "time": "2021-04-03T12:43:11+00:00"
}
],
"packages-dev": [],
From 41b011d836b2edc6382d70f8c436f093fe4cdb96 Mon Sep 17 00:00:00 2001
From: Yuta Nagamiya
Date: Sat, 3 Apr 2021 21:50:08 +0900
Subject: [PATCH 19/19] Generate the API documentation
---
docs/api/classes/Ngmy-Enum-Enum.html | 59 +-
docs/api/classes/Ngmy-Enum-EnumMap.html | 444 ++++++++++-
docs/api/classes/Ngmy-Enum-EnumSet.html | 349 ++++++++-
.../classes/Ngmy-TypedArray-TypedArray.html | 691 ++++++++++++++++--
4 files changed, 1416 insertions(+), 127 deletions(-)
diff --git a/docs/api/classes/Ngmy-Enum-Enum.html b/docs/api/classes/Ngmy-Enum-Enum.html
index 174c5f2..8c7a8aa 100644
--- a/docs/api/classes/Ngmy-Enum-Enum.html
+++ b/docs/api/classes/Ngmy-Enum-Enum.html
@@ -90,7 +90,7 @@
@@ -241,7 +241,7 @@
@@ -272,7 +272,7 @@
@@ -298,6 +298,15 @@
Returns the enum constant of the specified name.
@@ -366,6 +375,15 @@
+
+
+ psalm-param
+
+
+
+
+
@@ -389,7 +407,7 @@
@@ -440,7 +458,7 @@
Returns the name of this enum constant, as contained in the declaration.
@@ -474,7 +492,7 @@
@@ -506,7 +524,7 @@
Returns true if the specified object is equal to this enum constant.
@@ -550,7 +568,7 @@
Returns the hash code for this enum constant
@@ -584,7 +602,7 @@
Returns the name of this enum constant, exactly as declared in its enum declaration.
@@ -618,7 +636,7 @@
Returns the ordinal of this enum constant.
@@ -653,7 +671,7 @@
Returns the enum constant of the specified name.
@@ -697,7 +715,7 @@
Returns all constants of this enum type.
@@ -723,6 +741,15 @@
+
+
+ psalm-return
+
+
+
+
+
@@ -746,7 +773,7 @@
@@ -779,7 +806,7 @@
@@ -821,7 +848,7 @@
diff --git a/docs/api/classes/Ngmy-Enum-EnumMap.html b/docs/api/classes/Ngmy-Enum-EnumMap.html
index 705355a..945c8cf 100644
--- a/docs/api/classes/Ngmy-Enum-EnumMap.html
+++ b/docs/api/classes/Ngmy-Enum-EnumMap.html
@@ -93,7 +93,7 @@
@@ -155,7 +155,7 @@
-
@@ -185,6 +185,42 @@
IteratorAggregate<string, TValue>
+
+
+ psalm-template
+
+
+
+
+
+
+
+ psalm-template
+
+
+
+
+
+
+
+ template-implements
+
+
+
+ ArrayAccess<TKey, TValue>
+
+
+
+
+ template-implements
+
+
+
+ IteratorAggregate<string, TValue>
+
+
@@ -410,7 +446,7 @@
@@ -436,6 +472,15 @@
+
+
+ psalm-var
+
+
+
+
+
@@ -456,7 +501,7 @@
@@ -482,6 +527,15 @@
+
+
+ psalm-var
+
+
+
+ TypedArray<TKey, TValue>
+
+
@@ -506,7 +560,7 @@
@@ -531,6 +585,24 @@
+
+
+ phpstan-return
+
+
+
+
+
+
+
+ psalm-return
+
+
+
+
+
@@ -554,7 +626,7 @@
@@ -588,6 +660,15 @@
Traversable<string, TValue>
+
+
+ psalm-return
+
+
+
+ Traversable<string, TValue>
+
+
@@ -611,7 +692,7 @@
Determines if the enum map is empty or not.
@@ -645,7 +726,7 @@
Creates a new instance of the enum map with the specified enum type key.
@@ -678,7 +759,7 @@
-
@@ -690,6 +771,42 @@
+
+
+ phpstan-return
+
+
+
+
+
+
+
+ psalm-template
+
+
+
+
+
+
+
+ psalm-param
+
+
+
+
+
+
+
+ psalm-return
+
+
+
+
+
@@ -713,13 +830,13 @@
public
- offsetExists(mixed $key) : bool
+ offsetExists(Enum $key) : bool
@@ -727,7 +844,7 @@ Parameters
-
$key
- : mixed
+ : Enum
-
@@ -749,6 +866,24 @@
+
+ -
+ phpstan-param
+
+ -
+
+
+
+
+ -
+ psalm-param
+
+ -
+
+
+
@@ -772,13 +907,13 @@
public
- offsetGet(mixed $key) : mixed|null
+ offsetGet(Enum $key) : mixed|null
@@ -786,7 +921,7 @@ Parameters
-
$key
- : mixed
+ : Enum
-
@@ -808,6 +943,15 @@
+
+ -
+ phpstan-param
+
+ -
+
+
+
-
phpstan-return
@@ -817,6 +961,24 @@
+
+ -
+ psalm-param
+
+ -
+
+
+
+
+ -
+ psalm-return
+
+ -
+
+
+
@@ -840,7 +1002,7 @@
@@ -902,6 +1064,24 @@
+
+
+ psalm-param
+
+
+
+
+
+
+
+ psalm-param
+
+
+
+
+
@@ -925,13 +1105,13 @@
public
- offsetUnset(mixed $key) : void
+ offsetUnset(Enum $key) : void
@@ -939,7 +1119,7 @@ Parameters
-
$key
- : mixed
+ : Enum
-
@@ -961,6 +1141,24 @@
+
+ -
+ phpstan-param
+
+ -
+
+
+
+
+ -
+ psalm-param
+
+ -
+
+
+
@@ -984,7 +1182,7 @@
Gets the enum map of values as a plain array.
@@ -1010,6 +1208,15 @@
+
+
+ psalm-return
+
+
+
+
+
@@ -1033,7 +1240,7 @@
Returns a new instance of the enum map with the array type value.
@@ -1059,6 +1266,15 @@
EnumMap<TKey, array<int|string, mixed>>
+
+
+ psalm-return
+
+
+
+ EnumMap<TKey, array<int|string, mixed>>
+
+
@@ -1082,7 +1298,7 @@
Returns a new instance of the enum map with the bool type value.
@@ -1108,6 +1324,15 @@
+
+
+ psalm-return
+
+
+
+
+
@@ -1131,7 +1356,7 @@
Returns a new instance of the enum map with the specified class type value.
@@ -1185,6 +1410,33 @@
+
+
+ psalm-template
+
+
+
+
+
+
+
+ psalm-param
+
+
+
+
+
+
+
+ psalm-return
+
+
+
+
+
@@ -1208,7 +1460,7 @@
Returns a new instance of the enum map with the float type value.
@@ -1234,6 +1486,15 @@
+
+
+ psalm-return
+
+
+
+
+
@@ -1257,7 +1518,7 @@
Returns a new instance of the enum map with the class type value that implements the specified interface.
@@ -1311,6 +1572,33 @@
EnumMap<TKey, TInterface>
+
+
+ psalm-template
+
+
+
+
+
+
+
+ psalm-param
+
+
+
+ class-string $interface
+
+
+
+
+ psalm-return
+
+
+
+ EnumMap<TKey, TInterface>
+
+
@@ -1334,7 +1622,7 @@
Returns a new instance of the enum map with the int type value.
@@ -1360,6 +1648,15 @@
+
+
+ psalm-return
+
+
+
+
+
@@ -1383,7 +1680,7 @@
Returns a new instance of the enum map with the mixed type value.
@@ -1409,6 +1706,15 @@
+
+
+ psalm-return
+
+
+
+
+
@@ -1432,7 +1738,7 @@
Returns a new instance of the enum map with the object type value.
@@ -1458,6 +1764,15 @@
+
+
+ psalm-return
+
+
+
+
+
@@ -1481,7 +1796,7 @@
Returns a new instance of the enum map with the resource type value.
@@ -1507,6 +1822,15 @@
+
+
+ psalm-return
+
+
+
+ EnumMap<TKey, resource>
+
+
@@ -1530,7 +1854,7 @@
Returns a new instance of the enum map with the string type value.
@@ -1556,6 +1880,15 @@
+
+
+ psalm-return
+
+
+
+
+
@@ -1579,7 +1912,7 @@
Returns a new instance of the enum map with the class type value that uses the specified trait.
@@ -1615,6 +1948,33 @@
+
+
+ phpstan-return
+
+
+
+
+
+
+
+ psalm-param
+
+
+
+
+
+
+
+ psalm-return
+
+
+
+
+
@@ -1638,7 +1998,7 @@
@@ -1674,6 +2034,15 @@
TypedArray<TKey, TValue> $typedArray
+
+
+ psalm-param
+
+
+
+ TypedArray<TKey, TValue> $typedArray
+
+
@@ -1697,7 +2066,7 @@
@@ -1732,6 +2101,15 @@
+
+
+ psalm-param
+
+
+
+
+
diff --git a/docs/api/classes/Ngmy-Enum-EnumSet.html b/docs/api/classes/Ngmy-Enum-EnumSet.html
index 13aa8e8..bef61df 100644
--- a/docs/api/classes/Ngmy-Enum-EnumSet.html
+++ b/docs/api/classes/Ngmy-Enum-EnumSet.html
@@ -93,7 +93,7 @@
@@ -155,7 +155,7 @@
-
@@ -176,6 +176,33 @@
IteratorAggregate<int, T>
+
+
+ psalm-template
+
+
+
+
+
+
+
+ template-implements
+
+
+
+
+
+
+
+ template-implements
+
+
+
+ IteratorAggregate<int, T>
+
+
@@ -338,7 +365,7 @@
@@ -364,6 +391,15 @@
+
+
+ psalm-var
+
+
+
+
+
@@ -388,7 +424,7 @@
Creates an enum set containing all of the elements in the specified element type.
@@ -421,7 +457,7 @@
-
@@ -442,6 +478,33 @@
+
+
+ psalm-template
+
+
+
+
+
+
+
+ psalm-param
+
+
+
+
+
+
+
+ psalm-return
+
+
+
+
+
@@ -465,7 +528,7 @@
@@ -490,6 +553,24 @@
+
+
+ phpstan-return
+
+
+
+
+
+
+
+ psalm-return
+
+
+
+
+
@@ -513,7 +594,7 @@
@@ -547,6 +628,15 @@
+
+
+ psalm-return
+
+
+
+
+
@@ -570,7 +660,7 @@
Determines if the enum set is empty or not.
@@ -604,7 +694,7 @@
Creates an empty enum set with the specified element type.
@@ -637,7 +727,7 @@
-
@@ -658,6 +748,33 @@
+
+
+ psalm-template
+
+
+
+
+
+
+
+ psalm-param
+
+
+
+
+
+
+
+ psalm-return
+
+
+
+
+
@@ -681,7 +798,7 @@
Creates an enum set initially containing the specified element.
@@ -735,6 +852,33 @@
+
+
+ psalm-template
+
+
+
+
+
+
+
+ psalm-param
+
+
+
+
+
+
+
+ psalm-return
+
+
+
+
+
@@ -758,13 +902,13 @@
public
- offsetExists(mixed $key) : bool
+ offsetExists(Enum $key) : bool
@@ -772,7 +916,7 @@ Parameters
-
$key
- : mixed
+ : Enum
-
@@ -794,6 +938,24 @@
+
+ -
+ phpstan-param
+
+ -
+
+
+
+
+ -
+ psalm-param
+
+ -
+
+
+
@@ -817,13 +979,13 @@
public
- offsetGet(mixed $key) : Enum|null
+ offsetGet(Enum $key) : Enum|null
@@ -831,7 +993,7 @@ Parameters
-
$key
- : mixed
+ : Enum
-
@@ -853,6 +1015,15 @@
+
+ -
+ phpstan-param
+
+ -
+
+
+
-
phpstan-return
@@ -862,6 +1033,24 @@
+
+ -
+ psalm-param
+
+ -
+
+
+
+
+ -
+ psalm-return
+
+ -
+
+
+
@@ -885,7 +1074,7 @@
@@ -935,7 +1124,34 @@
-
+
+ phpstan-param
+
+
+
+
+
+
+
+ psalm-param
+
+
+
+
+
+
+
+ psalm-param
+
+
+
+
@@ -961,13 +1177,13 @@
public
- offsetUnset(mixed $key) : void
+ offsetUnset(Enum $key) : void
@@ -975,7 +1191,7 @@ Parameters
-
$key
- : mixed
+ : Enum
-
@@ -997,6 +1213,24 @@
+
+ -
+ phpstan-param
+
+ -
+
+
+
+
+ -
+ psalm-param
+
+ -
+
+
+
@@ -1020,7 +1254,7 @@
Creates an enum set initially containing all of the elements in the range defined by the two specified endpoints.
@@ -1090,6 +1324,42 @@
+
+
+ psalm-template
+
+
+
+
+
+
+
+ psalm-param
+
+
+
+
+
+
+
+ psalm-param
+
+
+
+
+
+
+
+ psalm-return
+
+
+
+
+
@@ -1113,7 +1383,7 @@
Gets the enum set of values as a plain array.
@@ -1139,6 +1409,15 @@
+
+
+ psalm-return
+
+
+
+
+
@@ -1162,7 +1441,7 @@
@@ -1198,6 +1477,15 @@
+
+
+ psalm-param
+
+
+
+
+
@@ -1221,7 +1509,7 @@
@@ -1256,6 +1544,15 @@
+
+
+ psalm-param
+
+
+
+
+
diff --git a/docs/api/classes/Ngmy-TypedArray-TypedArray.html b/docs/api/classes/Ngmy-TypedArray-TypedArray.html
index 7107afb..f40cbda 100644
--- a/docs/api/classes/Ngmy-TypedArray-TypedArray.html
+++ b/docs/api/classes/Ngmy-TypedArray-TypedArray.html
@@ -93,7 +93,7 @@
@@ -185,6 +185,51 @@
IteratorAggregate<int|string, TValue>
+
+
+ psalm-template
+
+
+
+
+
+
+
+ psalm-template
+
+
+
+
+
+
+
+ template-implements
+
+
+
+ ArrayAccess<TKey, TValue>
+
+
+
+
+ template-implements
+
+
+
+ IteratorAggregate<int|string, TValue>
+
+
+
+
+ psalm-type
+
+
+
+
+
@@ -294,7 +339,7 @@
getIterator()
- : Traversable<int|string, mixed>
+ : ArrayIterator<int|string, mixed>
@@ -534,7 +579,7 @@
@@ -559,7 +604,7 @@
@@ -584,7 +629,7 @@
@@ -609,7 +654,7 @@
@@ -649,7 +694,7 @@
@@ -680,7 +725,7 @@
The hash map of key's hash codes and keys.
@@ -708,6 +753,15 @@
+
+
+ psalm-var
+
+
+
+ array<int|string, TKey>
+
+
@@ -728,7 +782,7 @@
@@ -754,6 +808,15 @@
+
+
+ psalm-var
+
+
+
+
+
@@ -774,7 +837,7 @@
@@ -805,7 +868,7 @@
The hash map of key's hash codes and values.
@@ -832,6 +895,15 @@
array<int|string, TValue>
+
+
+ psalm-var
+
+
+
+ array<int|string, TValue>
+
+
@@ -852,7 +924,7 @@
@@ -878,6 +950,15 @@
+
+
+ psalm-var
+
+
+
+
+
@@ -902,7 +983,7 @@
@@ -927,6 +1008,24 @@
+
+
+ phpstan-return
+
+
+
+
+
+
+
+ psalm-return
+
+
+
+
+
@@ -950,13 +1049,13 @@
public
- getIterator() : Traversable<int|string, mixed>
+ getIterator() : ArrayIterator<int|string, mixed>
@@ -981,14 +1080,27 @@
- Traversable<int|string, TValue>
+ ArrayIterator<int|string, TValue>
+
+
+
+
+ psalm-return
+
+
+
+ ArrayIterator<(
+TKey is IntArrayKey|object
+? int
+: (TKey is bool|float|string|resource ? string : int|string)
+), TValue>
Return values
- Traversable<int|string, mixed>
+ ArrayIterator<int|string, mixed>
—
@@ -1007,7 +1119,7 @@
Determines if the typed array is empty or not.
@@ -1041,7 +1153,7 @@
Creates a new instance of the typed array.
@@ -1075,7 +1187,7 @@
@@ -1111,6 +1223,24 @@
+
+
+ phpstan-param
+
+
+
+
+
+
+
+ psalm-param
+
+
+
+
+
@@ -1134,7 +1264,7 @@
@@ -1170,6 +1300,15 @@
+
+
+ phpstan-param
+
+
+
+
+
phpstan-return
@@ -1179,6 +1318,24 @@
+
+
+ psalm-param
+
+
+
+
+
+
+
+ psalm-return
+
+
+
+
+
@@ -1202,7 +1359,7 @@
@@ -1264,6 +1421,24 @@
+
+
+ psalm-param
+
+
+
+
+
+
+
+ psalm-param
+
+
+
+
+
@@ -1287,7 +1462,7 @@
@@ -1323,6 +1498,24 @@
+
+
+ phpstan-param
+
+
+
+
+
+
+
+ psalm-param
+
+
+
+
+
@@ -1346,7 +1539,7 @@
Gets the typed array of values as a plain array.
@@ -1372,6 +1565,19 @@
array<int|string, TValue>
+
+
+ psalm-return
+
+
+
+ array<(
+TKey is IntArrayKey|object
+? int
+: (TKey is bool|float|string|resource ? string : int|string)
+), TValue>
+
+
@@ -1395,7 +1601,7 @@
Returns a new instance of the typed array with the array type value.
@@ -1421,6 +1627,15 @@
TypedArray<TKey, array<int|string, mixed>>
+
+
+ psalm-return
+
+
+
+ TypedArray<TKey, array<int|string, mixed>>
+
+
@@ -1444,7 +1659,7 @@
Returns a new instance of the typed array with the bool type key.
@@ -1470,6 +1685,15 @@
+
+
+ psalm-return
+
+
+
+ TypedArray<bool, TValue>
+
+
@@ -1493,7 +1717,7 @@
Returns a new instance of the typed array with the bool type value.
@@ -1519,6 +1743,15 @@
+
+
+ psalm-return
+
+
+
+
+
@@ -1542,7 +1775,7 @@
Returns a new instance of the typed array with the specified class type key.
@@ -1553,7 +1786,7 @@
If you are using an object as the key, it is recommended that you implement the equals()
and hashCode() methods on the object to determine whether keys are equal or not.
-Otherwise, the === operator and spl_object_hash() function are used to determine it.
+Otherwise, the === operator and spl_object_id() function are used to determine it.
Parameters
@@ -1608,6 +1841,33 @@
TypedArray<TClass, TValue>
+
+
+ psalm-template
+
+
+
+
+
+
+
+ psalm-param
+
+
+
+
+
+
+
+ psalm-return
+
+
+
+ TypedArray<TClass, TValue>
+
+
@@ -1631,7 +1891,7 @@
Returns a new instance of the typed array with the specified class type value.
@@ -1685,6 +1945,33 @@
+
+
+ psalm-template
+
+
+
+
+
+
+
+ psalm-param
+
+
+
+
+
+
+
+ psalm-return
+
+
+
+ TypedArray<TKey, TClass>
+
+
@@ -1708,7 +1995,7 @@
Returns a new instance of the typed array with the float type key.
@@ -1734,6 +2021,15 @@
TypedArray<float, TValue>
+
+
+ psalm-return
+
+
+
+ TypedArray<float, TValue>
+
+
@@ -1757,7 +2053,7 @@
Returns a new instance of the typed array with the float type value.
@@ -1783,6 +2079,15 @@
+
+
+ psalm-return
+
+
+
+ TypedArray<TKey, float>
+
+
@@ -1806,7 +2111,7 @@
Returns a new instance of the typed array with the class type key that implements the specified interface.
@@ -1817,7 +2122,7 @@
If you are using an object as the key, it is recommended that you implement the equals()
and hashCode() methods on the object to determine whether keys are equal or not.
-Otherwise, the === operator and spl_object_hash() function are used to determine it.
+Otherwise, the === operator and spl_object_id() function are used to determine it.
Parameters
@@ -1872,6 +2177,33 @@
TypedArray<TInterface, TValue>
+
+
+ psalm-template
+
+
+
+
+
+
+
+ psalm-param
+
+
+
+ class-string $interface
+
+
+
+
+ psalm-return
+
+
+
+ TypedArray<TInterface, TValue>
+
+
@@ -1895,7 +2227,7 @@
Returns a new instance of the typed array with the class type value that implements the specified interface.
@@ -1949,6 +2281,33 @@
TypedArray<TKey, TInterface>
+
+
+ psalm-template
+
+
+
+
+
+
+
+ psalm-param
+
+
+
+ class-string $interface
+
+
+
+
+ psalm-return
+
+
+
+ TypedArray<TKey, TInterface>
+
+
@@ -1972,7 +2331,7 @@
Returns a new instance of the typed array with the int type key.
@@ -1998,6 +2357,15 @@
TypedArray<int|null, TValue>
+
+
+ psalm-return
+
+
+
+ TypedArray<IntArrayKey, TValue>
+
+
@@ -2021,7 +2389,7 @@
Returns a new instance of the typed array with the int type value.
@@ -2047,6 +2415,15 @@
+
+
+ psalm-return
+
+
+
+
+
@@ -2070,7 +2447,7 @@
Returns a new instance of the typed array with the mixed type key.
@@ -2096,6 +2473,15 @@
TypedArray<mixed, TValue>
+
+
+ psalm-return
+
+
+
+ TypedArray<mixed, TValue>
+
+
@@ -2119,7 +2505,7 @@
Returns a new instance of the typed array with the mixed type value.
@@ -2145,6 +2531,15 @@
+
+
+ psalm-return
+
+
+
+ TypedArray<TKey, mixed>
+
+
@@ -2168,7 +2563,7 @@
Returns a new instance of the typed array with the object type key.
@@ -2179,7 +2574,7 @@
If you are using an object as the key, it is recommended that you implement the equals()
and hashCode() methods on the object to determine whether keys are equal or not.
-Otherwise, the === operator and spl_object_hash() function are used to determine it.
+Otherwise, the === operator and spl_object_id() function are used to determine it.
@@ -2206,6 +2601,15 @@
TypedArray<object, TValue>
+
+
+ psalm-return
+
+
+
+ TypedArray<object, TValue>
+
+
@@ -2229,7 +2633,7 @@
Returns a new instance of the typed array with the object type value.
@@ -2255,6 +2659,15 @@
+
+
+ psalm-return
+
+
+
+ TypedArray<TKey, object>
+
+
@@ -2278,7 +2691,7 @@
Returns a new instance of the typed array with the resource type key.
@@ -2304,6 +2717,15 @@
TypedArray<resource, TValue>
+
+
+ psalm-return
+
+
+
+ TypedArray<resource, TValue>
+
+
@@ -2327,7 +2749,7 @@
Returns a new instance of the typed array with the resource type value.
@@ -2353,6 +2775,15 @@
TypedArray<TKey, resource>
+
+
+ psalm-return
+
+
+
+ TypedArray<TKey, resource>
+
+
@@ -2376,7 +2807,7 @@
Returns a new instance of the typed array with the string type key.
@@ -2402,6 +2833,15 @@
TypedArray<string, TValue>
+
+
+ psalm-return
+
+
+
+ TypedArray<string, TValue>
+
+
@@ -2425,7 +2865,7 @@
Returns a new instance of the typed array with the string type value.
@@ -2451,6 +2891,15 @@
+
+
+ psalm-return
+
+
+
+ TypedArray<TKey, string>
+
+
@@ -2474,7 +2923,7 @@
Returns a new instance of the typed array with the class type key that uses the specified trait.
@@ -2485,7 +2934,7 @@
If you are using an object as the key, it is recommended that you implement the equals()
and hashCode() methods on the object to determine whether keys are equal or not.
-Otherwise, the === operator and spl_object_hash() function are used to determine it.
+Otherwise, the === operator and spl_object_id() function are used to determine it.
Parameters
@@ -2522,6 +2971,33 @@
+
+
+ phpstan-return
+
+
+
+ TypedArray<object, TValue>
+
+
+
+
+ psalm-param
+
+
+
+
+
+
+
+ psalm-return
+
+
+
+ TypedArray<object, TValue>
+
+
@@ -2545,7 +3021,7 @@
Returns a new instance of the typed array with the class type value that uses the specified trait.
@@ -2581,6 +3057,33 @@
+
+
+ phpstan-return
+
+
+
+ TypedArray<TKey, object>
+
+
+
+
+ psalm-param
+
+
+
+
+
+
+
+ psalm-return
+
+
+
+ TypedArray<TKey, object>
+
+
@@ -2604,7 +3107,7 @@
@@ -2667,7 +3170,7 @@
@@ -2690,6 +3193,48 @@ Parameters
+
+ Tags
+
+
+
+ -
+ phpstan-param
+
+ -
+
+
+
+
+ -
+ phpstan-return
+
+ -
+
+
+
+
+ -
+ psalm-param
+
+ -
+
+
+
+
+ -
+ psalm-return
+
+ -
+
+
+
+
+
Return values
int|string|null
@@ -2711,7 +3256,7 @@
@@ -2742,6 +3287,48 @@ Parameters
+
+ Tags
+
+
+
+ -
+ phpstan-param
+
+ -
+
+
+
+
+ -
+ phpstan-param
+
+ -
+
+
int|string|null $keyHashCode
+
+
+
+ -
+ psalm-param
+
+ -
+
+
+
+
+ -
+ psalm-param
+
+ -
+
+
IntArrayKey|string $keyHashCode
+
+
+
+
Return values
bool