Skip to content
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

implement LtrimFunctionReturnTypeExtension to support class-string #1597

Merged
merged 3 commits into from Aug 6, 2022

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Aug 6, 2022

@@ -0,0 +1,17 @@
<?php declare(strict_types=1);

namespace Bug7483;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried supporting things like

function bar() {
	$absolute = '\A';
	$relative = 'A';

	assertType('class-string', ltrim($absolute, '\\'));
	assertType('class-string', ltrim($relative, '\\'));
}

but from the extension point of view these strings seem not to be class-strings...?

Copy link
Member

Choose a reason for hiding this comment

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

ConstantStringType::isClassString() is just a hint whether the string was created from ::class, so that we don't trigger the autoloading for irrelevant strings, which upsets some custom autoloaders.

Copy link
Member

Choose a reason for hiding this comment

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

So you don't need to do anything about it.

@staabm staabm marked this pull request as ready for review August 6, 2022 09:15
src/Type/Php/LtrimFunctionReturnTypeExtension.php Outdated Show resolved Hide resolved
@@ -0,0 +1,17 @@
<?php declare(strict_types=1);

namespace Bug7483;
Copy link
Member

Choose a reason for hiding this comment

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

ConstantStringType::isClassString() is just a hint whether the string was created from ::class, so that we don't trigger the autoloading for irrelevant strings, which upsets some custom autoloaders.

@ondrejmirtes ondrejmirtes merged commit e91de77 into phpstan:1.8.x Aug 6, 2022
@ondrejmirtes
Copy link
Member

Thank you.

@staabm staabm deleted the ltrim branch June 21, 2023 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants