vimeo / psalm

A static analysis tool for finding errors in PHP applications
https://psalm.dev
MIT License
5.54k stars 660 forks source link

Psalm fails to interfere type with annotations #11060

Open vasilvestre opened 1 month ago

vasilvestre commented 1 month ago

My error is this : Method Zenstruck\Foundry\Persistence\Proxy::getCode does not exist.

Despite my configuration and the annotations.

TaxonUpdater.php :

foreach (LocaleFactory::all() as $locale) {
    $this->createTranslation($object, $locale->getCode() ?? '', $attributes);
}

LocaleFactory.php :

/**
 * @extends AbstractModelFactory<LocaleInterface>
 *
 * @method static LocaleInterface[]|Proxy[] all()
 */
final class LocaleFactory extends AbstractModelFactory implements FactoryWithModelClassAwareInterface

(I tested Proxy[] without success)

AbstractModelFactory.php :

/**
 * @template TModel of object
 *
 * @template-extends PersistentProxyObjectFactory<TModel>
 */
abstract class AbstractModelFactory extends PersistentProxyObjectFactory

Proxy.php :

/**
 * @template TProxiedObject of object
 *
 * @mixin TProxiedObject
 */
interface Proxy

If you need me to share more code I'm available. The code can be found at https://github.com/akawakaweb/sylius-fixtures-plugin/tree/fix/foundry-compat

psalm-github-bot[bot] commented 1 month ago

Hey @vasilvestre, can you reproduce the issue on https://psalm.dev? These will be used as phpunit tests when implementing the feature or fixing this bug.

vasilvestre commented 1 month ago

Hey @vasilvestre, can you reproduce the issue on https://psalm.dev? These will be used as phpunit tests when implementing the feature or fixing this bug.

The case is too complicated to reproduce on the web UI afaik.