-
Notifications
You must be signed in to change notification settings - Fork 25
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
Failure with phpstan/phpstan-phpunit
and PHPStan cache usage
#297
Comments
phpstan/phpstan-phpunit
and PHPStan cache usage.phpstan/phpstan-phpunit
and PHPStan cache usage
Thanks for opening your first issue here! Weird problem, not exactly sure what is going on. Somehow the Extension Attribute Autoloaders get triggered even though the classname Let me try to run a few tests to see if I can reproduce the problem somehow. |
Sadly, I can't reproduce your issue so far. I installed the PHPUnit extension in a test project and with or without the tmpDir setting, PHPStan works fine when I execute it multiple times in a row. What confuses me a bit is that you write it fails when you enable the cache. PHPStan always uses a file cache. If you do not define the Any chance that you can share a reproducible test case with me? |
Hi @shochdoerfer, thanks for your hint about |
@Wohlie have you been able to figure out why things are failing? |
Hi @shochdoerfer, I have tested without overriding the cache directory and have the same problem. If I change the config Here is my example. Make sure you mount Magento root folder to docker-entrypoint.sh
Dockerfile
Place this
|
can confirm this issue by using rector/rector and symplify/easy-coding-standard. Also debugged a little bit, but didn't find the issue. i'll have another look into this issue, if i'll find the time for it. |
@rommelfreddy please provide a proper test case so that I can reproduce the issue and debug it. |
digged a little bit deeper. but do not have any idea what the context is. and also no clue who is calling this. i am using the latest versions of
|
The issue which will happen is that the cache-folder can not created. But maybe by the following issue: If I have the following class, the error exists for me. <?php
class MyClass
{
/**
* @var StoreFactory
*/
private $myFactory;
} Please notice, that i missed the import or the FQCN for the factory. If I have the following class, the error disappears. <?php
class MyClass
{
/**
* @var \Magento\Store\Model\StoreFactory
*/
private $myFactory;
} In my case the missing import is in a third-party package, so i only could fix the issue via composer-patches. One addition: |
@rommelfreddy thx for digging deeper, "interesting" behavior. Not exactly sure why the cache file can't get written in your case. Maybe it's an idea to do an additional file_exists() check before requiring the file. |
already tried this :D |
need to correct me. The factory in my example does already exist as defined class (not autogenerated) in the same namespace (so also in the same folder). It seems like, that there is something wrong with generating the factories. Sadly i am not able to use xdebug within this scope. don't know why. |
will you investigate more into this to fix this issue? it is a very annoying bug |
@rommelfreddy my bad was quite busy with other stuff and lost track of this issue. Any chance you can provide me with a simple demo project to be able to reproduce the issue? |
sadly not, because i can not tell to the proper way to reproduce the issue safely. |
Hello, I have an issue with FileCacheStorage with rector and phpstan :(
I have this error when I run rector :
When I look the logs, I see that the problem comes from this module : Full error trace
|
@dimitriBouteille thx for reporting this. Any chance you could provide me with more details and a demo project which allows me to reproduce the issue? I haven't yet used Rector, and I am not sure if you are running Rector (wich runs PHPStan?) or if you just have Rector installed and you run PHPStan. The more I understand, the better I can debug the issue and hopefully provide a fix. Not sure why the cache directory could not be created. Are you running your setup also in Docker? |
@shochdoerfer Thanks for the quick response:) I can’t share the source code of the project, it’s a private project. To bring information, I installed rector in addition to phpstan and the Magento extension. It is when I execute I don’t use Docker. Do you know if it is possible to disable the cache while waiting for a fix? If it helps, here is the phpstan configuration and rector : rector.php return static function (\Rector\Config\RectorConfig $rectorConfig): void {
$rectorConfig
->paths([
__DIR__ . '/Api',
__DIR__ . '/Block',
__DIR__ . '/Controller',
__DIR__ . '/Cron',
__DIR__ . '/Gateway',
__DIR__ . '/Helper',
__DIR__ . '/Logger',
__DIR__ . '/Model',
__DIR__ . '/Ui',
]);
$rectorConfig->cacheDirectory(__DIR__ . '/var/cache/rector');
$rectorConfig->containerCacheDirectory(__DIR__);
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_81);
$rectorConfig->importShortClasses(false);
// register single rule
$rectorConfig
->rule(\Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector::class);
// ??
$rectorConfig->skip([
\Rector\CodeQuality\Rector\Array_\CallableThisArrayToAnonymousFunctionRector::class,
]);
// here we can define, what sets of rules will be applied
// tip: use "SetList" class to autocomplete sets with your IDE
$rectorConfig->sets([
\Rector\Set\ValueObject\SetList::CODE_QUALITY,
]);
}; phpstan.neon parameters:
level: 5
excludePaths:
- vendor
- etc
- view
- doc
- rector.php
ignoreErrors:
-
message: '#Use service contracts to persist entities in favour of Magento\\Quote\\Model\\QuoteIdMask::load\(\) method#'
-
message: '#Parameter \#1 \$prefix of method Magento\\Framework\\View\\Page\\Title::prepend\(\) expects string, Magento\\Framework\\Phrase given.#'
-
message: '#Parameter \#1 \$message of method Magento\\Framework\\Message\\ManagerInterface::addErrorMessage\(\) expects string, Magento\\Framework\\Phrase given.#'
-
message: '#Parameter \#1 \$modelId of method Magento\\Framework\\Model\\AbstractModel::load\(\) expects int, string given.#'
paths:
- . |
Hello @shochdoerfer Any news ? |
Hi, I'm using this extension together with
phpstan/phpstan-phpunit
.Without PHPStan cache, everything works fine. If I enable PHPStan cache, I receive get the following error on the second run, where that cache is used:
My configuration is the following:
Any thoughts?
The text was updated successfully, but these errors were encountered: