Custom cache dependencies #5690
Replies: 1 comment
-
@ondrejmirtes I would like to share progress I've made towards resolving this result cache problem. Firstly I've got rid off dealing with non-PHP files by first converting them to PHP code. E.g. for SQL Secondly, to flag certain $tableType = $scope->getType(
new PhpParser\Node\Expr\MethodCall(
new PhpParser\Node\Expr\New_(
new PhpParser\Node\Name\FullyQualified(DatabaseSchema::class),
),
'getTable__' . $tableName . '__write',
),
); Still the problem with result cache persists. If the problem is solved by incorrect SQL query, I will fix PHP file with it and result cache gets properly invalidated. But if I fix the problem instead on schema level, PHPStan doesn't have a reason to rerun rules for afforementioned PHP file with the query. After some digging through PHPStan internals, I've succeeded in circumventing this problem in hackish way (in my opinion :) ). I've introduced fake type extending public function getReferencedClasses(): array
{
return array_values(
array_unique([
...parent::getReferencedClasses(),
...$this->customReferencedClasses,
]),
);
} Dynamic return type extension hooked for I have one question though - could there be less hackish way :)? Maybe a dedicated extension (that could specify dependencies of a node), or something with AST & node attributes... I would be happy to attempt to contribute, but I guess this is something that needs to fit into PHPStan vision, hence my lengthy description above. |
Beta Was this translation helpful? Give feedback.
-
In relation to #5688 asked earlier today, I would like to lay out our use-cases at @contentking:
schema.graphql
fileCREATE TABLE
statements described insql
filesElasticsearch\Client
calls whether they match ES mappings described in ES index templates stored in somejson
files(all these would be custom rules)
After getting more accustomed with writing extensions for PHPStan, it's immense power is intoxicating :). But to implement these further extensions, we've hit roadblock in form of the caching. We don't know how to tell PHPStan to invalidate relevant parts of result cache when these non-PHP files change. We could solve it in brute-force way if these were NEON files by importing them as custom config (thus invalidating whole cache), but that's not the case.
I would love to know if there is some envisioned path forward (now speculating: maybe in form of ability to set custom file dependencies in rules).
Beta Was this translation helpful? Give feedback.
All reactions