Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Make the code easier to statically analyse#10231

Merged
greg0ire merged 1 commit into
doctrine:2.14.xfrom
greg0ire:static-analysis-improvements
Nov 16, 2022
Merged

Make the code easier to statically analyse#10231
greg0ire merged 1 commit into
doctrine:2.14.xfrom
greg0ire:static-analysis-improvements

Conversation

@greg0ire
Copy link
Copy Markdown
Member

@greg0ire greg0ire commented Nov 14, 2022

While working on migrating the codebase to PHP 8, I noticed that a rule (NullToStrictStringFuncCallArgRector) often triggered that consists in adding casts to string, because internal functions have become more strict in PHP 8.1 (they no longer accept anything than a string).

I tried finding why those arguments were not considered already strings, and tried to fix some of that with this PR.

* Validates & completes the basic mapping information based on typed property.
*
* @param mixed[] $mapping The mapping.
* @param array{type: self::ONE_TO_ONE|self::MANY_TO_ONE|self::ONE_TO_MANY|self::MANY_TO_MANY, fieldName: string, targetEntity?: class-string} $mapping The mapping.
Copy link
Copy Markdown
Member Author

@greg0ire greg0ire Nov 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find a way to make this multiline and have phpcs be happy with it… it's probably the pipes.

private function quoteLiteral($literal): string
{
if (is_numeric($literal) && ! is_string($literal)) {
if (is_int($literal) || is_float($literal)) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

About this, see vimeo/psalm#8703

@greg0ire greg0ire added this to the 2.14.0 milestone Nov 16, 2022
@greg0ire greg0ire merged commit 1ce806f into doctrine:2.14.x Nov 16, 2022
@greg0ire greg0ire deleted the static-analysis-improvements branch November 16, 2022 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants