From f2f4aab50330c217deeb7a0be3636f4f0dbfd075 Mon Sep 17 00:00:00 2001 From: sasezaki Date: Sat, 25 Mar 2023 15:46:19 +0900 Subject: [PATCH 1/4] Update php, psr/log dependencies for ^2 --- composer.json | 8 ++++---- composer.lock | 24 ++++++++++++------------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/composer.json b/composer.json index 8751986..f0717a1 100644 --- a/composer.json +++ b/composer.json @@ -11,11 +11,11 @@ } ], "require": { - "php": "^7.2 || ^8.0" + "php": ">=8.0.0" }, "require-dev": { "ext-simplexml": "*", - "psr/log": "^1", + "psr/log": "^2", "rector/rector": "0.15.21", "squizlabs/php_codesniffer": "^3.7", "vimeo/psalm": "^5", @@ -33,11 +33,11 @@ "dealerdirect/phpcodesniffer-composer-installer": true }, "platform": { - "php": "7.4.99" + "php": "8.0.99" } }, "conflict": { - "psr/log": ">=2" + "psr/log": "^1 || >=3" }, "scripts" : { "check": [ diff --git a/composer.lock b/composer.lock index 0c45826..a27ca85 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e9edd8d396c3165dab2f3854c641f2d3", + "content-hash": "45e778784545742b1f3d042868ecde1d", "packages": [], "packages-dev": [ { @@ -2461,30 +2461,30 @@ }, { "name": "psr/log", - "version": "1.1.4", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11" + "reference": "ef29f6d262798707a9edd554e2b82517ef3a9376" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11", + "url": "https://api.github.com/repos/php-fig/log/zipball/ef29f6d262798707a9edd554e2b82517ef3a9376", + "reference": "ef29f6d262798707a9edd554e2b82517ef3a9376", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=8.0.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { "psr-4": { - "Psr\\Log\\": "Psr/Log/" + "Psr\\Log\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -2505,9 +2505,9 @@ "psr-3" ], "support": { - "source": "https://github.com/php-fig/log/tree/1.1.4" + "source": "https://github.com/php-fig/log/tree/2.0.0" }, - "time": "2021-05-03T11:20:27+00:00" + "time": "2021-07-14T16:41:46+00:00" }, { "name": "ralouphie/getallheaders", @@ -5234,13 +5234,13 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": "^7.2 || ^8.0" + "php": ">=8.0.0" }, "platform-dev": { "ext-simplexml": "*" }, "platform-overrides": { - "php": "7.4.99" + "php": "8.0.99" }, "plugin-api-version": "2.3.0" } From 7be1118fde2c495deec5724ebb0b524ee54ecfc2 Mon Sep 17 00:00:00 2001 From: sasezaki Date: Sat, 25 Mar 2023 16:20:50 +0900 Subject: [PATCH 2/4] Update stubs & tests --- build/transform-source | 8 +- stubs-for-exception/AbstractLogger.phpstub | 129 ------------------- stubs-for-exception/LoggerInterface.phpstub | 36 +++--- stubs-for-throwable/AbstractLogger.phpstub | 129 ------------------- stubs-for-throwable/LoggerInterface.phpstub | 36 +++--- tests/acceptance/ExceptionAcceptance.feature | 49 ------- tests/acceptance/ThrowableAcceptance.feature | 42 ------ 7 files changed, 38 insertions(+), 391 deletions(-) delete mode 100644 stubs-for-exception/AbstractLogger.phpstub delete mode 100644 stubs-for-throwable/AbstractLogger.phpstub diff --git a/build/transform-source b/build/transform-source index cb6c6f0..ece1bdc 100755 --- a/build/transform-source +++ b/build/transform-source @@ -1,15 +1,11 @@ #!/usr/bin/env bash ## stubs-for-exception -cp vendor/psr/log/Psr/Log/LoggerInterface.php stubs-for-exception/LoggerInterface.php -cp vendor/psr/log/Psr/Log/AbstractLogger.php stubs-for-exception/AbstractLogger.php +cp vendor/psr/log/src/LoggerInterface.php stubs-for-exception/LoggerInterface.php vendor/bin/rector process --config=build/rector-stubs-for-exception.php --clear-cache --no-diffs mv stubs-for-exception/LoggerInterface.php stubs-for-exception/LoggerInterface.phpstub -mv stubs-for-exception/AbstractLogger.php stubs-for-exception/AbstractLogger.phpstub ## stubs-for-throwable -cp vendor/psr/log/Psr/Log/LoggerInterface.php stubs-for-throwable/LoggerInterface.php -cp vendor/psr/log/Psr/Log/AbstractLogger.php stubs-for-throwable/AbstractLogger.php +cp vendor/psr/log/src/LoggerInterface.php stubs-for-throwable/LoggerInterface.php vendor/bin/rector process --config=build/rector-stubs-for-throwable.php --clear-cache --no-diffs mv stubs-for-throwable/LoggerInterface.php stubs-for-throwable/LoggerInterface.phpstub -mv stubs-for-throwable/AbstractLogger.php stubs-for-throwable/AbstractLogger.phpstub diff --git a/stubs-for-exception/AbstractLogger.phpstub b/stubs-for-exception/AbstractLogger.phpstub deleted file mode 100644 index ed80476..0000000 --- a/stubs-for-exception/AbstractLogger.phpstub +++ /dev/null @@ -1,129 +0,0 @@ -log(LogLevel::EMERGENCY, $message, $context); - } - - /** - * Action must be taken immediately. - * - * Example: Entire website down, database unavailable, etc. This should - * trigger the SMS alerts and wake you up. - * - * @param string $message - * @param LoggerContextType $context - * - * @return void - */ - public function alert($message, array $context = array()) - { - $this->log(LogLevel::ALERT, $message, $context); - } - - /** - * Critical conditions. - * - * Example: Application component unavailable, unexpected exception. - * - * @param string $message - * @param LoggerContextType $context - * - * @return void - */ - public function critical($message, array $context = array()) - { - $this->log(LogLevel::CRITICAL, $message, $context); - } - - /** - * Runtime errors that do not require immediate action but should typically - * be logged and monitored. - * - * @param string $message - * @param LoggerContextType $context - * - * @return void - */ - public function error($message, array $context = array()) - { - $this->log(LogLevel::ERROR, $message, $context); - } - - /** - * Exceptional occurrences that are not errors. - * - * Example: Use of deprecated APIs, poor use of an API, undesirable things - * that are not necessarily wrong. - * - * @param string $message - * @param LoggerContextType $context - * - * @return void - */ - public function warning($message, array $context = array()) - { - $this->log(LogLevel::WARNING, $message, $context); - } - - /** - * Normal but significant events. - * - * @param string $message - * @param LoggerContextType $context - * - * @return void - */ - public function notice($message, array $context = array()) - { - $this->log(LogLevel::NOTICE, $message, $context); - } - - /** - * Interesting events. - * - * Example: User logs in, SQL logs. - * - * @param string $message - * @param LoggerContextType $context - * - * @return void - */ - public function info($message, array $context = array()) - { - $this->log(LogLevel::INFO, $message, $context); - } - - /** - * Detailed debug information. - * - * @param string $message - * @param LoggerContextType $context - * - * @return void - */ - public function debug($message, array $context = array()) - { - $this->log(LogLevel::DEBUG, $message, $context); - } -} diff --git a/stubs-for-exception/LoggerInterface.phpstub b/stubs-for-exception/LoggerInterface.phpstub index a97eb8d..5d765c6 100644 --- a/stubs-for-exception/LoggerInterface.phpstub +++ b/stubs-for-exception/LoggerInterface.phpstub @@ -23,12 +23,12 @@ interface LoggerInterface /** * System is unusable. * - * @param string $message + * @param string|\Stringable $message * @param LoggerContextType $context * * @return void */ - public function emergency($message, array $context = array()); + public function emergency(string|\Stringable $message, array $context = []); /** * Action must be taken immediately. @@ -36,35 +36,35 @@ interface LoggerInterface * Example: Entire website down, database unavailable, etc. This should * trigger the SMS alerts and wake you up. * - * @param string $message + * @param string|\Stringable $message * @param LoggerContextType $context * * @return void */ - public function alert($message, array $context = array()); + public function alert(string|\Stringable $message, array $context = []); /** * Critical conditions. * * Example: Application component unavailable, unexpected exception. * - * @param string $message + * @param string|\Stringable $message * @param LoggerContextType $context * * @return void */ - public function critical($message, array $context = array()); + public function critical(string|\Stringable $message, array $context = []); /** * Runtime errors that do not require immediate action but should typically * be logged and monitored. * - * @param string $message + * @param string|\Stringable $message * @param LoggerContextType $context * * @return void */ - public function error($message, array $context = array()); + public function error(string|\Stringable $message, array $context = []); /** * Exceptional occurrences that are not errors. @@ -72,55 +72,55 @@ interface LoggerInterface * Example: Use of deprecated APIs, poor use of an API, undesirable things * that are not necessarily wrong. * - * @param string $message + * @param string|\Stringable $message * @param LoggerContextType $context * * @return void */ - public function warning($message, array $context = array()); + public function warning(string|\Stringable $message, array $context = []); /** * Normal but significant events. * - * @param string $message + * @param string|\Stringable $message * @param LoggerContextType $context * * @return void */ - public function notice($message, array $context = array()); + public function notice(string|\Stringable $message, array $context = []); /** * Interesting events. * * Example: User logs in, SQL logs. * - * @param string $message + * @param string|\Stringable $message * @param LoggerContextType $context * * @return void */ - public function info($message, array $context = array()); + public function info(string|\Stringable $message, array $context = []); /** * Detailed debug information. * - * @param string $message + * @param string|\Stringable $message * @param LoggerContextType $context * * @return void */ - public function debug($message, array $context = array()); + public function debug(string|\Stringable $message, array $context = []); /** * Logs with an arbitrary level. * * @param LogLevel::* $level - * @param string $message + * @param string|\Stringable $message * @param LoggerContextType $context * * @return void * * @throws \Psr\Log\InvalidArgumentException */ - public function log($level, $message, array $context = array()); + public function log($level, string|\Stringable $message, array $context = []); } diff --git a/stubs-for-throwable/AbstractLogger.phpstub b/stubs-for-throwable/AbstractLogger.phpstub deleted file mode 100644 index ed80476..0000000 --- a/stubs-for-throwable/AbstractLogger.phpstub +++ /dev/null @@ -1,129 +0,0 @@ -log(LogLevel::EMERGENCY, $message, $context); - } - - /** - * Action must be taken immediately. - * - * Example: Entire website down, database unavailable, etc. This should - * trigger the SMS alerts and wake you up. - * - * @param string $message - * @param LoggerContextType $context - * - * @return void - */ - public function alert($message, array $context = array()) - { - $this->log(LogLevel::ALERT, $message, $context); - } - - /** - * Critical conditions. - * - * Example: Application component unavailable, unexpected exception. - * - * @param string $message - * @param LoggerContextType $context - * - * @return void - */ - public function critical($message, array $context = array()) - { - $this->log(LogLevel::CRITICAL, $message, $context); - } - - /** - * Runtime errors that do not require immediate action but should typically - * be logged and monitored. - * - * @param string $message - * @param LoggerContextType $context - * - * @return void - */ - public function error($message, array $context = array()) - { - $this->log(LogLevel::ERROR, $message, $context); - } - - /** - * Exceptional occurrences that are not errors. - * - * Example: Use of deprecated APIs, poor use of an API, undesirable things - * that are not necessarily wrong. - * - * @param string $message - * @param LoggerContextType $context - * - * @return void - */ - public function warning($message, array $context = array()) - { - $this->log(LogLevel::WARNING, $message, $context); - } - - /** - * Normal but significant events. - * - * @param string $message - * @param LoggerContextType $context - * - * @return void - */ - public function notice($message, array $context = array()) - { - $this->log(LogLevel::NOTICE, $message, $context); - } - - /** - * Interesting events. - * - * Example: User logs in, SQL logs. - * - * @param string $message - * @param LoggerContextType $context - * - * @return void - */ - public function info($message, array $context = array()) - { - $this->log(LogLevel::INFO, $message, $context); - } - - /** - * Detailed debug information. - * - * @param string $message - * @param LoggerContextType $context - * - * @return void - */ - public function debug($message, array $context = array()) - { - $this->log(LogLevel::DEBUG, $message, $context); - } -} diff --git a/stubs-for-throwable/LoggerInterface.phpstub b/stubs-for-throwable/LoggerInterface.phpstub index 3eaf339..7fd22fd 100644 --- a/stubs-for-throwable/LoggerInterface.phpstub +++ b/stubs-for-throwable/LoggerInterface.phpstub @@ -23,12 +23,12 @@ interface LoggerInterface /** * System is unusable. * - * @param string $message + * @param string|\Stringable $message * @param LoggerContextType $context * * @return void */ - public function emergency($message, array $context = array()); + public function emergency(string|\Stringable $message, array $context = []); /** * Action must be taken immediately. @@ -36,35 +36,35 @@ interface LoggerInterface * Example: Entire website down, database unavailable, etc. This should * trigger the SMS alerts and wake you up. * - * @param string $message + * @param string|\Stringable $message * @param LoggerContextType $context * * @return void */ - public function alert($message, array $context = array()); + public function alert(string|\Stringable $message, array $context = []); /** * Critical conditions. * * Example: Application component unavailable, unexpected exception. * - * @param string $message + * @param string|\Stringable $message * @param LoggerContextType $context * * @return void */ - public function critical($message, array $context = array()); + public function critical(string|\Stringable $message, array $context = []); /** * Runtime errors that do not require immediate action but should typically * be logged and monitored. * - * @param string $message + * @param string|\Stringable $message * @param LoggerContextType $context * * @return void */ - public function error($message, array $context = array()); + public function error(string|\Stringable $message, array $context = []); /** * Exceptional occurrences that are not errors. @@ -72,55 +72,55 @@ interface LoggerInterface * Example: Use of deprecated APIs, poor use of an API, undesirable things * that are not necessarily wrong. * - * @param string $message + * @param string|\Stringable $message * @param LoggerContextType $context * * @return void */ - public function warning($message, array $context = array()); + public function warning(string|\Stringable $message, array $context = []); /** * Normal but significant events. * - * @param string $message + * @param string|\Stringable $message * @param LoggerContextType $context * * @return void */ - public function notice($message, array $context = array()); + public function notice(string|\Stringable $message, array $context = []); /** * Interesting events. * * Example: User logs in, SQL logs. * - * @param string $message + * @param string|\Stringable $message * @param LoggerContextType $context * * @return void */ - public function info($message, array $context = array()); + public function info(string|\Stringable $message, array $context = []); /** * Detailed debug information. * - * @param string $message + * @param string|\Stringable $message * @param LoggerContextType $context * * @return void */ - public function debug($message, array $context = array()); + public function debug(string|\Stringable $message, array $context = []); /** * Logs with an arbitrary level. * * @param LogLevel::* $level - * @param string $message + * @param string|\Stringable $message * @param LoggerContextType $context * * @return void * * @throws \Psr\Log\InvalidArgumentException */ - public function log($level, $message, array $context = array()); + public function log($level, string|\Stringable $message, array $context = []); } diff --git a/tests/acceptance/ExceptionAcceptance.feature b/tests/acceptance/ExceptionAcceptance.feature index 3249634..96d3392 100644 --- a/tests/acceptance/ExceptionAcceptance.feature +++ b/tests/acceptance/ExceptionAcceptance.feature @@ -8,7 +8,6 @@ Feature: Exception - """ @@ -16,20 +15,12 @@ Feature: Exception """ emergency("message", ['exception' => 'foo']); - concrete_abstract()->alert("message", ['exception' => 'foo']); - concrete_abstract()->critical("message", ['exception' => 'foo']); - concrete_abstract()->error("message", ['exception' => 'foo']); - concrete_abstract()->warning("message", ['exception' => 'foo']); - concrete_abstract()->notice("message", ['exception' => 'foo']); - concrete_abstract()->info("message", ['exception' => 'foo']); - concrete_abstract()->debug("message", ['exception' => 'foo']); - concrete_abstract()->emergency("message", ['exception' => new Error]); - concrete_abstract()->alert("message", ['exception' => new Error]); - concrete_abstract()->critical("message", ['exception' => new Error]); - concrete_abstract()->error("message", ['exception' => new Error]); - concrete_abstract()->warning("message", ['exception' => new Error]); - concrete_abstract()->notice("message", ['exception' => new Error]); - concrete_abstract()->info("message", ['exception' => new Error]); - concrete_abstract()->debug("message", ['exception' => new Error]); - """ - When I run Psalm - Then I see these errors - | Type | Message | - | InvalidArgument | Argument 2 of Psr\Log\AbstractLogger::emergency expects array{exception?: Exception}, but array{exception: 'foo'} provided | - | InvalidArgument | Argument 2 of Psr\Log\AbstractLogger::alert expects array{exception?: Exception}, but array{exception: 'foo'} provided | - | InvalidArgument | Argument 2 of Psr\Log\AbstractLogger::critical expects array{exception?: Exception}, but array{exception: 'foo'} provided | - | InvalidArgument | Argument 2 of Psr\Log\AbstractLogger::error expects array{exception?: Exception}, but array{exception: 'foo'} provided | - | InvalidArgument | Argument 2 of Psr\Log\AbstractLogger::warning expects array{exception?: Exception}, but array{exception: 'foo'} provided | - | InvalidArgument | Argument 2 of Psr\Log\AbstractLogger::notice expects array{exception?: Exception}, but array{exception: 'foo'} provided | - | InvalidArgument | Argument 2 of Psr\Log\AbstractLogger::info expects array{exception?: Exception}, but array{exception: 'foo'} provided | - | InvalidArgument | Argument 2 of Psr\Log\AbstractLogger::debug expects array{exception?: Exception}, but array{exception: 'foo'} provided | - | InvalidArgument | Argument 2 of Psr\Log\AbstractLogger::emergency expects array{exception?: Exception}, but array{exception: Error} provided | - | InvalidArgument | Argument 2 of Psr\Log\AbstractLogger::alert expects array{exception?: Exception}, but array{exception: Error} provided | - | InvalidArgument | Argument 2 of Psr\Log\AbstractLogger::critical expects array{exception?: Exception}, but array{exception: Error} provided | - | InvalidArgument | Argument 2 of Psr\Log\AbstractLogger::error expects array{exception?: Exception}, but array{exception: Error} provided | - | InvalidArgument | Argument 2 of Psr\Log\AbstractLogger::warning expects array{exception?: Exception}, but array{exception: Error} provided | - | InvalidArgument | Argument 2 of Psr\Log\AbstractLogger::notice expects array{exception?: Exception}, but array{exception: Error} provided | - | InvalidArgument | Argument 2 of Psr\Log\AbstractLogger::info expects array{exception?: Exception}, but array{exception: Error} provided | - | InvalidArgument | Argument 2 of Psr\Log\AbstractLogger::debug expects array{exception?: Exception}, but array{exception: Error} provided | - And I see no other errors diff --git a/tests/acceptance/ThrowableAcceptance.feature b/tests/acceptance/ThrowableAcceptance.feature index b174c2d..db0ebc5 100644 --- a/tests/acceptance/ThrowableAcceptance.feature +++ b/tests/acceptance/ThrowableAcceptance.feature @@ -8,7 +8,6 @@ Feature: Throwable - """ @@ -16,20 +15,12 @@ Feature: Throwable """ emergency("message", ['exception' => 'foo']); - concrete_abstract()->alert("message", ['exception' => 'foo']); - concrete_abstract()->critical("message", ['exception' => 'foo']); - concrete_abstract()->error("message", ['exception' => 'foo']); - concrete_abstract()->warning("message", ['exception' => 'foo']); - concrete_abstract()->notice("message", ['exception' => 'foo']); - concrete_abstract()->info("message", ['exception' => 'foo']); - concrete_abstract()->debug("message", ['exception' => 'foo']); - concrete_abstract()->emergency("message", ['exception' => new Error]); - concrete_abstract()->alert("message", ['exception' => new Error]); - concrete_abstract()->critical("message", ['exception' => new Error]); - concrete_abstract()->error("message", ['exception' => new Error]); - concrete_abstract()->warning("message", ['exception' => new Error]); - concrete_abstract()->notice("message", ['exception' => new Error]); - concrete_abstract()->info("message", ['exception' => new Error]); - concrete_abstract()->debug("message", ['exception' => new Error]); - """ - When I run Psalm - Then I see these errors - | Type | Message | - | InvalidArgument | Argument 2 of Psr\Log\AbstractLogger::emergency expects array{exception?: Throwable}, but array{exception: 'foo'} provided | - | InvalidArgument | Argument 2 of Psr\Log\AbstractLogger::alert expects array{exception?: Throwable}, but array{exception: 'foo'} provided | - | InvalidArgument | Argument 2 of Psr\Log\AbstractLogger::critical expects array{exception?: Throwable}, but array{exception: 'foo'} provided | - | InvalidArgument | Argument 2 of Psr\Log\AbstractLogger::error expects array{exception?: Throwable}, but array{exception: 'foo'} provided | - | InvalidArgument | Argument 2 of Psr\Log\AbstractLogger::warning expects array{exception?: Throwable}, but array{exception: 'foo'} provided | - | InvalidArgument | Argument 2 of Psr\Log\AbstractLogger::notice expects array{exception?: Throwable}, but array{exception: 'foo'} provided | - | InvalidArgument | Argument 2 of Psr\Log\AbstractLogger::info expects array{exception?: Throwable}, but array{exception: 'foo'} provided | - | InvalidArgument | Argument 2 of Psr\Log\AbstractLogger::debug expects array{exception?: Throwable}, but array{exception: 'foo'} provided | - And I see no other errors From 3088ecb8cc20f6f9918d752a7a1898fdd96e402f Mon Sep 17 00:00:00 2001 From: sasezaki Date: Sat, 25 Mar 2023 16:23:04 +0900 Subject: [PATCH 3/4] Update README about only support LoggerInteface --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index c47c89c..811e0d2 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,6 @@ But, You can use this for individual purpose. Add the following files to your stub settings. ``` stubs-for-throwable/LoggerInterface.phpstub -stubs-for-throwable/AbstractLogger.phpstub ``` ## Features @@ -50,6 +49,5 @@ public function log($level, $message, array $context = array()) ## Not Support (Not planned) -- Stub `LoggerAwareTrait` with @psalm-require-implements - - https://psalm.dev/docs/annotating_code/supported_annotations/#psalm-require-implements +- Stub `LoggerAwareTrait` From 274fd1fdfde0901586933006c68a585834b2a707 Mon Sep 17 00:00:00 2001 From: sasezaki Date: Sat, 25 Mar 2023 16:27:17 +0900 Subject: [PATCH 4/4] Update GA php versions --- .github/workflows/codecept.yml | 2 +- .github/workflows/coding-standards.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/codecept.yml b/.github/workflows/codecept.yml index 43701dc..3c854c1 100644 --- a/.github/workflows/codecept.yml +++ b/.github/workflows/codecept.yml @@ -17,7 +17,7 @@ jobs: - "highest" - "locked" php-version: - - "7.4" + - "8.0" operating-system: - "ubuntu-latest" diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index a460b90..72fb22f 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -15,7 +15,7 @@ jobs: dependencies: - "locked" php-version: - - "7.4" + - "8.0" operating-system: - "ubuntu-latest"