Skip to content

Result cache not used because not comparing well #12027

@sp-alberto-lopez

Description

@sp-alberto-lopez

Bug report

We are running PHPStan 1.12.10 in Github Actions.
We are caching composer dependencies, and in every new commit the cache is not used due to:

Result cache not used because the metadata do not match: projectConfig, composerInstalled

We did a diff between the previous and the new resultCache.php and found differences in the composer installed.php, because the order of versions is not sorted.
Also is reporting that projectConfig does not match, but it has no differences.

Result cache not used because the metadata do not match: projectConfig, composerInstalled
Result cache is saved.

PHP runtime version: 8.1.8
 [OK] No errors                                                                 
PHP version for analysis: 8.1.8 (from runtime)


PHPStan version: 1.12.10
PHPStan running from:
/code/vendor/phpstan/phpstan

Extension installer:
phpstan/phpstan-symfony: 1.4.12

Discovered Composer project root:
/code

Parallel processing scheduler:
# of detected CPU cores:   2
# of analysed files:       32
# of jobs:                 2
# of spawned processes:    1

Symfony's consoleApplicationLoader: No

Elapsed time: 2 seconds
Used memory: 122 MB
docker compose -f docker-compose.yml -f docker-compose-ci.yml exec -T fpm sh -c "diff -c5 /code/tmp/phpstan/resultCache.php /code/tmp/phpstan/resultCache.php.bak || true"
*** /code/tmp/phpstan/resultCache.php	Wed Nov 13 11:59:42 2024
--- /code/tmp/phpstan/resultCache.php.bak	Wed Nov 13 11:59:40 2024
***************
*** 1,9 ****
  <?php declare(strict_types = 1);
  
  return [
! 	'lastFullAnalysisTime' => 1731499180,
  	'meta' => array (
    'cacheVersion' => 'v12-linesToIgnore',
    'phpstanVersion' => '1.12.10',
    'phpVersion' => 80108,
    'projectConfig' => '{parameters: {level: 1, tmpDir: /code/tmp/phpstan, paths: [/code/src/GPBMetadata, /code/src/SP/Bundle/AbuseControlBundle]}}',
--- 1,9 ----
  <?php declare(strict_types = 1);
  
  return [
! 	'lastFullAnalysisTime' => 1731497701,
  	'meta' => array (
    'cacheVersion' => 'v12-linesToIgnore',
    'phpstanVersion' => '1.12.10',
    'phpVersion' => 80108,
    'projectConfig' => '{parameters: {level: 1, tmpDir: /code/tmp/phpstan, paths: [/code/src/GPBMetadata, /code/src/SP/Bundle/AbuseControlBundle]}}',
***************
*** 1145,1156 ****
          'psr/log-implementation' => 
          array (
            'dev_requirement' => false,
            'provided' => 
            array (
!             0 => '1.0.0',
!             1 => '1.0|2.0',
            ),
          ),
          'psr/simple-cache' => 
          array (
            'pretty_version' => '1.0.1',
--- 1145,1156 ----
          'psr/log-implementation' => 
          array (
            'dev_requirement' => false,
            'provided' => 
            array (
!             0 => '1.0|2.0',
!             1 => '1.0.0',
            ),
          ),
          'psr/simple-cache' => 
          array (
            'pretty_version' => '1.0.1',

Code snippet that reproduces the problem

No response

Expected output

Cache used.

Did PHPStan help you today? Did it make you happy in any way?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions