<rule ref="Generic.Formatting.SpaceAfterCast">
<properties>
<property name="spacing" value="0" />
</properties>
</rule>
If I change the property name or value, the cached results are still displayed.
I can't replicate this. The hash of the ruleset files being used is included in the cache key, so it should be changing and invalidating the cache.
I tested by using this sample ruleset file called mystandard.xml:
<?xml version="1.0"?>
<ruleset name="MyStandard">
<rule ref="Generic.Formatting.SpaceAfterCast">
<properties>
<property name="spacing" value="1" />
</properties>
</rule>
</ruleset>
And this test file temp.php:
<?php
$foo = (int) $bar;
If you run PHPCS with the -vv command line option, you'll see a lot of cache information at the top. The important bits are:
Generating loaded file list for code hash
=> internal sniff: src/Standards/Generic/Sniffs/Formatting/SpaceAfterCastSniff.php
=> external ruleset: mystandard.xml
=> core file: ...
Generating cache key data
...
=> codeHash: f446873501dfb0de01067b776f520a75
=> rulesetHash: 6437dc4eda23e7c26f5f667da4f4ba90
=> cacheHash: 96a2c234e243
As you change the ruleset file, you should see the codeHash value change as the files being included have had their content changed. The rulesetHash value wont change unless you've modified ignore or include patterns. But that final cacheHash value should also change.
Are you not seeing these values change?
Are you not seeing these values change?
No, they are remaining the same.
Under Generating loaded file list for code hash I see the local phpcs.xml, but not the referenced ruleset.xml – could that be the problem?
I have a local phpcs.xml file that references a standard that has been added to installed_paths.
i.e. phpcs --config-set installed_paths /d/Programming/Projects/mystandard/coding-standard-php.
The ruleset.xml within that standard is not listed.
Thanks for getting back to me - you figured out the problem. The paths for included rulesets were not being added to the ruleset list, so cache wasn't seeing them.
The fix for this will be in 3.4.1