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

InvalidCast on implicit cast of constant-typed properties to string #5955

Closed
flaviovs opened this issue Jun 19, 2021 · 1 comment · Fixed by #6133
Closed

InvalidCast on implicit cast of constant-typed properties to string #5955

flaviovs opened this issue Jun 19, 2021 · 1 comment · Fixed by #6133
Labels

Comments

@flaviovs
Copy link

See https://psalm.dev/r/8518ebc0a4

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/8518ebc0a4
<?php

/** @property Foo::PROP_* $aprop */
class Foo {
    public const PROP_ONE = 1;
    
	public function __get(string $name) { return self::PROP_ONE; }
}

$obj = new Foo();

echo $obj->aprop; // This works.

echo "$obj->aprop"; // ERROR: InvalidCast

echo (string)$obj->aprop; // Same.
Psalm output (using commit d4311e3):

ERROR: InvalidCast - 14:7 - Foo::PROP_* cannot be cast to string

ERROR: InvalidCast - 16:14 - Foo::PROP_* cannot be cast to string

weirdan added a commit to weirdan/psalm that referenced this issue Jul 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants