Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Support string arguments #16

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

Closed
lookyman wants to merge 2 commits into phpstan:master from lookyman:string-arg-support

Conversation

@lookyman
Copy link
Contributor

@lookyman lookyman commented Feb 18, 2018
edited
Loading

No description provided.

'You should use assertFalse() instead of assertSame() when expecting "false"',
];
if ($leftType instanceof ConstantBooleanType) {
if ($leftType->getValue() === true) {
Copy link
Member

@ondrejmirtes ondrejmirtes Feb 18, 2018

Choose a reason for hiding this comment

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

No need to compare against === true, it's boolean itself.

lookyman reacted with thumbs up emoji
$class = $arg->class;
if (!($class instanceof \PhpParser\Node\Name)) {
$class = (string) $class;
} elseif ($arg instanceof \PhpParser\Node\Scalar\String_) {
Copy link
Member

@ondrejmirtes ondrejmirtes Feb 18, 2018

Choose a reason for hiding this comment

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

Please update this with the latest advancements in PHPStan's typesystem. See phpstan/phpstan@a46cbc0 for an example.

Please also move the fixes of changes in PHPStan's dev-master to a separate commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@lookyman lookyman force-pushed the string-arg-support branch 2 times, most recently from 6186e99 to 039c23e Compare February 18, 2018 12:27
Copy link
Member

@ondrejmirtes ondrejmirtes left a comment

Choose a reason for hiding this comment

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

More changes :)

if ($argType instanceof TypeWithClassName) {
$class = $argType->getClassName();
} elseif ($argType instanceof ConstantStringType) {
$class = $argType->getValue();
Copy link
Member

@ondrejmirtes ondrejmirtes Feb 18, 2018

Choose a reason for hiding this comment

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

You didn't add any tests for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There were no tests for this before, that's why. I'll write some asap.

$class = $arg->class;
if (!($class instanceof \PhpParser\Node\Name)) {
$argType = $scope->getType($methodCall->args[$argumentIndex]->value);
if (!($argType instanceof TypeWithClassName)) {
Copy link
Member

@ondrejmirtes ondrejmirtes Feb 18, 2018

Choose a reason for hiding this comment

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

This doesn't look right to me - Foo::class does not result in TypeWithClassName but in ConstantStringType. Also, this does not break on dev-master so I don't see a reason to change it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And you are right of course. Will fix that.

@lookyman lookyman force-pushed the string-arg-support branch 3 times, most recently from e2fd5c4 to 5bc9a47 Compare February 19, 2018 19:47
Copy link
Contributor Author

Ok, how about now?

Copy link
Member

Can you please open a PR with ExtensionTestCase in phpstan/phpstan first? Thank you.

Copy link
Contributor Author

Sure, no problem. Should NodeScopeResolverTest extend it? And if yes, maybe it shouldn't be named ExtensionTestCase.. Can you suggest a better name?

Copy link
Member

ondrejmirtes commented Feb 21, 2018 via email

I’d rather not use inheritance. Make a class under PHPStan\Testing and register it as a service. The tests can get it from the DI container.
On 2018年2月21日 at 15:03, Lukáš Unger ***@***.***> wrote: Sure, no problem. Should NodeScopeResolverTest extend it? And if yes, maybe it shouldn't be named ExtensionTestCase.. Can you suggest a better name? — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#16 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAGZuAMJ2ao_3CV5xizLNwalk8XD3t9hks5tXCJKgaJpZM4SJost> .
-- Ondřej Mirtes
lookyman reacted with thumbs up emoji

Copy link
Contributor Author

I believe this is already irrelevant? Feel free to close this.

Copy link
Member

Yep, right, thanks :)

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

Reviewers

@ondrejmirtes ondrejmirtes ondrejmirtes requested changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /