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

Skip to content

Conversation

@samsonasik
Copy link
Member

@samsonasik samsonasik enabled auto-merge (squash) October 6, 2025 20:27
@samsonasik samsonasik merged commit 24b76ca into main Oct 6, 2025
49 of 50 checks passed
@samsonasik samsonasik deleted the fix-php74-strtolower branch October 6, 2025 20:29
$shortNameLowered = $fullyQualifiedObjectType->getShortNameLowered();
$fullyQualifiedObjectTypeNamespace = strtolower(
substr($fullyQualifiedObjectType->getClassName(), 0, -strlen($fullyQualifiedObjectType->getShortName()) - 1)
substr($fullyQualifiedObjectType->getClassName(), 0, -strlen($fullyQualifiedObjectType->getShortName()) - 1) ?: ''
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a note about PHP 7.4? So we don't accidentally remove it :)

Copy link
Member Author

Choose a reason for hiding this comment

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

sure, I created new PR to add note for it

the RecastingRemovalRector needs also improvement for it, currently skipped

rector-src/rector.php

Lines 57 to 60 in 21b6091

// todo: properly handle, substr() can return false on php 7.x
RecastingRemovalRector::class => [
__DIR__ . '/rules/CodingStyle/ClassNameImport/ClassNameImportSkipVoter/ClassLikeNameClassNameImportSkipVoter.php',
],

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder why this problem is not patched by PHPStan. is it reproducible on the phpstan playground, that we are missing a error here?

Copy link
Member Author

Choose a reason for hiding this comment

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

It seems on phpstan.org, it shows

on php 8.0+, show empy string
on php 7.2+, show false

see https://phpstan.org/r/6c0960c9-23d9-4387-8f95-f13f2f50f33b

Copy link
Contributor

@clxmstaab clxmstaab Oct 7, 2025

Choose a reason for hiding this comment

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

ohh I just see rector-src does not run PHPStan on PHP7.x.. you are only using a single PHP 8.2 job and therefore miss PHPStan errors on all other PHP versions

Copy link
Member Author

Choose a reason for hiding this comment

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

I created PR to skip remove (string) case on substr() on RecastingRemovalRector on getNativeType() method:

$shortNameLowered = $fullyQualifiedObjectType->getShortNameLowered();
$fullyQualifiedObjectTypeNamespace = strtolower(
substr($fullyQualifiedObjectType->getClassName(), 0, -strlen($fullyQualifiedObjectType->getShortName()) - 1)
substr($fullyQualifiedObjectType->getClassName(), 0, -strlen($fullyQualifiedObjectType->getShortName()) - 1) ?: ''
Copy link
Member

Choose a reason for hiding this comment

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

Might be also good candidate for a downgrade rule

@samsonasik
Copy link
Member Author

@TomasVotruba I need to create immediate release 2.2.1 for it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

System error: "strtolower() expects parameter 1 to be string, bool given

4 participants