Increase psalm error level to 1#84
Merged
samdark merged 5 commits intoyiisoft:masterfrom Jul 14, 2022
Merged
Conversation
Contributor
dood-
commented
Jul 13, 2022
| Q | A |
|---|---|
| Is bugfix? | ❌ |
| New feature? | ❌ |
| Breaks BC? | ❌ |
| Fixed issues | #78 |
vjik
requested changes
Jul 14, 2022
| { | ||
| $timestamp = (string) $message->context('time', microtime(true)); | ||
| /** @var float $timestamp */ | ||
| $timestamp = $message->context('time', microtime(true)); |
Member
There was a problem hiding this comment.
Suggested change
| $timestamp = $message->context('time', microtime(true)); | |
| $timestamp = (string) $message->context('time', microtime(true)); |
Contributor
Author
There was a problem hiding this comment.
Psalm shows error without the type declaration
PossiblyInvalidCast - src/Message/Formatter.php:146:31 - array{category?: string, memory?: int, time?: float, trace?: list<array{class?: string, file: string, function?: string, line: int, type?: string}>} cannot be cast to string (see https://psalm.dev/190)
$timestamp = (string) $message->context('time', microtime(true));
Member
There was a problem hiding this comment.
Psalm can not determine type of result, but we known that for time always returns float. I think we can suppress this error.
Comment on lines
+23
to
+24
| * args?:array, | ||
| * object?:object, |
Member
There was a problem hiding this comment.
Keys "args" and "object" removed in Logger::collectTrace().
Contributor
Author
There was a problem hiding this comment.
Psalm shows errors without these keys
ERROR: InvalidArrayOffset - src/Logger.php:316:31 - Cannot access value on variable $trace using offset value of 'object', expecting 'file', 'line', 'function', 'class' or 'type' (see https://psalm.dev/115)
unset($trace['object'], $trace['args']);
Can be solved by adding array to the type
* @psalm-type Backtrace = list<array{
* file:string,
* line:int,
* function?:string,
* class?:string,
* type?:string,
* }&array>
Member
There was a problem hiding this comment.
To method Logger::collectTrace pass parameter:
list<array{
file:string,
line:int,
function?:string,
class?:string,
type?:string,
args?:array,
object?:object,
}>
..., but result of method is:
list<array{
file:string,
line:int,
function?:string,
class?:string,
type?:string,
}>
Co-authored-by: Sergei Predvoditelev <sergey.predvoditelev@gmail.com>
samdark
approved these changes
Jul 14, 2022
Member
|
Thanks. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.