-
Notifications
You must be signed in to change notification settings - Fork 651
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
Different output for get_class
and ::class
#9607
Comments
I found these snippets: https://psalm.dev/r/23928709e1<?php
declare(strict_types=1);
interface ObjectManager
{
/**
* @template T of object
* @param class-string<T> $className
* @return T|null
*/
public function find(string $className): ?object;
}
function test(ObjectManager $dm): void {
$obj = new \stdClass();
/** @psalm-trace $class1 */
$class1 = get_class($obj);
/** @psalm-trace $class2 */
$class2 = $obj::class;
/** @psalm-trace $result1 */
$result1 = $dm->find($class1);
/** @psalm-trace $result2 */
$result2 = $dm->find($class2);
}
|
You're right, get_class is internally handled by Seems like one is handled on template resolution but not the other |
franmomu
added a commit
to franmomu/mongodb-odm
that referenced
this issue
Apr 5, 2023
These new errors are because a bug in psalm with get_class see vimeo/psalm#9607, they will be gone once we use ::class
franmomu
added a commit
to franmomu/mongodb-odm
that referenced
this issue
Apr 5, 2023
These new errors are because a bug in psalm with get_class see vimeo/psalm#9607, they will be gone once we use ::class
franmomu
added a commit
to franmomu/mongodb-odm
that referenced
this issue
Apr 5, 2023
These new errors are because a bug in psalm with get_class see vimeo/psalm#9607, they will be gone once we use ::class
franmomu
added a commit
to franmomu/mongodb-odm
that referenced
this issue
Apr 5, 2023
These new errors are because a bug in psalm with get_class see vimeo/psalm#9607, they will be gone once we use ::class
franmomu
added a commit
to doctrine/mongodb-odm
that referenced
this issue
Apr 5, 2023
* Fix return type * Fix psalm build These new errors are because a bug in psalm with get_class see vimeo/psalm#9607, they will be gone once we use ::class
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Apparently it's the same, but when the result is used in a call, they behave different:
https://psalm.dev/r/23928709e1
The text was updated successfully, but these errors were encountered: