diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fd9ce72..028fb9fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ - New #113: Add `Message::trace()` method (@vjik) - New #114: Add `Message::time()` method (@vjik) - Chg #116: Deprecate methods `setCommonContext()` and `getCommonContext()` in `Target` class (@vjik) +- Chg #118: Replace `gettype()` to `get_debug_type()` in exception messages generation (@vjik) ## 2.0.0 May 22, 2022 diff --git a/src/ContextProvider/SystemContextProvider.php b/src/ContextProvider/SystemContextProvider.php index 4a4a5dde..0af3ee57 100644 --- a/src/ContextProvider/SystemContextProvider.php +++ b/src/ContextProvider/SystemContextProvider.php @@ -79,7 +79,7 @@ public function setExcludedTracePaths(array $excludedTracePaths): self throw new InvalidArgumentException( sprintf( 'The trace path must be a string, %s received.', - gettype($excludedTracePath) + get_debug_type($excludedTracePath) ) ); } diff --git a/src/Logger.php b/src/Logger.php index 4d4d755a..af5986f4 100644 --- a/src/Logger.php +++ b/src/Logger.php @@ -15,7 +15,6 @@ use Yiisoft\Log\ContextProvider\ContextProviderInterface; use function count; -use function gettype; use function implode; use function in_array; use function is_string; @@ -113,7 +112,7 @@ public static function validateLevel(mixed $level): string if (!is_string($level)) { throw new \Psr\Log\InvalidArgumentException(sprintf( 'The log message level must be a string, %s provided.', - gettype($level) + get_debug_type($level) )); } @@ -250,7 +249,7 @@ public static function assertLevelIsString(mixed $level): void } throw new \Psr\Log\InvalidArgumentException( - sprintf('The log message level must be a string, %s provided.', gettype($level)) + sprintf('The log message level must be a string, %s provided.', get_debug_type($level)) ); } diff --git a/src/Message/CategoryFilter.php b/src/Message/CategoryFilter.php index 22e77795..1ec8013d 100644 --- a/src/Message/CategoryFilter.php +++ b/src/Message/CategoryFilter.php @@ -8,7 +8,6 @@ use Yiisoft\Log\Message; -use function gettype; use function is_string; use function rtrim; use function sprintf; @@ -123,7 +122,7 @@ private function checkStructure(array $categories): void if (!is_string($category)) { throw new InvalidArgumentException(sprintf( 'The log message category must be a string, %s received.', - gettype($category) + get_debug_type($category) )); } } diff --git a/src/Message/Formatter.php b/src/Message/Formatter.php index 00698dbd..7f231af5 100644 --- a/src/Message/Formatter.php +++ b/src/Message/Formatter.php @@ -8,7 +8,6 @@ use Yiisoft\Log\Message; use Yiisoft\VarDumper\VarDumper; -use function gettype; use function implode; use function is_string; use function is_object; @@ -103,7 +102,7 @@ public function format(Message $message, array $commonContext): string if (!is_string($formatted)) { throw new RuntimeException(sprintf( 'The PHP callable "format" must return a string, %s received.', - gettype($formatted) + get_debug_type($formatted) )); } @@ -151,7 +150,7 @@ private function getPrefix(Message $message, array $commonContext): string if (!is_string($prefix)) { throw new RuntimeException(sprintf( 'The PHP callable "prefix" must return a string, %s received.', - gettype($prefix) + get_debug_type($prefix) )); } diff --git a/src/StreamTarget.php b/src/StreamTarget.php index 4b937e12..e9fd8c05 100644 --- a/src/StreamTarget.php +++ b/src/StreamTarget.php @@ -12,7 +12,6 @@ use function flock; use function fopen; use function fwrite; -use function gettype; use function get_resource_type; use function is_resource; use function sprintf; @@ -79,7 +78,7 @@ private function createStream() if (!is_resource($stream) || get_resource_type($stream) !== 'stream') { throw new InvalidArgumentException(sprintf( 'Invalid stream provided. It must be a string stream identifier or a stream resource, "%s" received.', - gettype($stream), + get_debug_type($stream), )); } diff --git a/src/Target.php b/src/Target.php index efef680d..0ecca2f2 100644 --- a/src/Target.php +++ b/src/Target.php @@ -11,7 +11,6 @@ use Yiisoft\Log\Message\Formatter; use function count; -use function gettype; use function in_array; use function is_bool; use function sprintf; @@ -307,7 +306,7 @@ public function isEnabled(): bool if (!is_bool($enabled = ($this->enabled)())) { throw new RuntimeException(sprintf( 'The PHP callable "enabled" must returns a boolean, %s received.', - gettype($enabled) + get_debug_type($enabled) )); }