-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: replace types in Logger
#6633
Conversation
if (! is_string($message)) { | ||
$message = print_r($message, true); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be more of a feature enhancement rather than a simple docblock fix, so this is proper for 4.3
.
However, I'm not convinced that we should allow array|int|object
as additions to possible types for $message
. If we are to look at the Psr\Log
specification, the $message
is only limited to string|\Stringable
. Plus, I find it unsightly for an array
-type message to be just a print_r()
of itself rather than it being properly formatted into a string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, we can accept array|int|object
addition in function handle
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, $message
type is string|\Stringable
.
https://github.com/php-fig/log/blob/fe5ea303b0887d5caefd3d431c3e61ad47037001/src/LoggerInterface.php#L30
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree, changing to a PSR-3 compatible logger may break apps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kenjis I found this when git cherry-pick --continue
------ ---------------------------------------------------------------------------------------------------------------------
Line system\CLI\Console.php
------ ---------------------------------------------------------------------------------------------------------------------
Ignored error pattern #^Strict comparison using === between array<mixed, mixed> and array{} will always evaluate to
false\.$# in path D:\Project\laragon\www\ci4\system\CLI\Console.php was not matched in reported errors.
71 Strict comparison using === between array and array{} will always evaluate to false.
------ ---------------------------------------------------------------------------------------------------------------------
[ERROR] Found 2 errors
Fix the phpstan error(s) before commit.
I fix in phpstan-baseline.neon.dist #^Strict comparison using === between array<mixed, mixed> and array{} will always evaluate to false
to #^Strict comparison using === between array and array{} will always evaluate to false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've fixed the error.
See #6627
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Psr\Log\LoggerInterface
still with string
only (v1.1.4), I think we set now string
only. \Stringable
still under develop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stringable
can be used in PHP 8.0 or later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment:
CodeIgniter4/system/Log/Logger.php
Line 23 in 15fa3f1
* The message MUST be a string or object implementing __toString(). |
if (! is_string($message)) { | ||
$message = print_r($message, true); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is not acceptable.
CodeIgniter4/system/Log/Logger.php
Line 23 in 15fa3f1
* The message MUST be a string or object implementing __toString(). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still in 4.3
branch if remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we change, it would be incompatible with PSR-3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, i will send PR another with develop
branch. Many phpstan error in my branch
------ -------------------------------------------------------------------------------------------------------------------
Line system\Cache\Handlers\MemcachedHandler.php
------ -------------------------------------------------------------------------------------------------------------------
Ignored error pattern #^Method MemcachePool\:\:decrement\(\) invoked with 4 parameters, 1\-2 required\.$# in path
D:\Project\laragon\www\ci4\system\Cache\Handlers\MemcachedHandler.php was not matched in reported errors.
Ignored error pattern #^Method MemcachePool\:\:increment\(\) invoked with 4 parameters, 1\-2 required\.$# in path
D:\Project\laragon\www\ci4\system\Cache\Handlers\MemcachedHandler.php was not matched in reported errors.
------ -------------------------------------------------------------------------------------------------------------------
------ -------------------------------------------------------------------------------------------------
Line system\HTTP\URI.php
------ -------------------------------------------------------------------------------------------------
Ignored error pattern #^Cannot unset offset 'path' on array{host: non-empty-string}\.$# in path
D:\Project\laragon\www\ci4\system\HTTP\URI.php was not matched in reported errors.
------ -------------------------------------------------------------------------------------------------
------ -----------------------------------------------------------------------------------------------
Line system\Helpers\text_helper.php
------ -----------------------------------------------------------------------------------------------
Ignored error pattern #^Variable \$pool might not be defined\.$# in path
D:\Project\laragon\www\ci4\system\Helpers\text_helper.php was not matched in reported errors.
------ -----------------------------------------------------------------------------------------------
------ ------------------------------------------------------------------------------
Line system\Model.php
------ ------------------------------------------------------------------------------
684 Offset 'data' on array on left side of ?? always exists and is not nullable.
710 Offset 'data' on array on left side of ?? always exists and is not nullable.
------ ------------------------------------------------------------------------------
[ERROR] Found 7 errors
Fix the phpstan error(s) before commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kenjis I create new branch with uptodate remote branch develop
. But have result phpstan error
------ ----------------------------------------------------------------------------
Line system\Helpers\array_helper.php
------ ----------------------------------------------------------------------------
51 Result of && is always false.
51 Strict comparison using !== between 0 and 0 will always evaluate to false.
------ ----------------------------------------------------------------------------
[ERROR] Found 2 errors
Fix the phpstan error(s) before commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohh mistake, 1 hour ago phpstan release 1.8.8
and in this PR using 1.8.7
@kenjis
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think $message should be strring or stringable.
in |
Yes. |
Description
See #6310.
Checklist: