|
1
|
|
|
<?php |
|
2
|
|
|
namespace Yiisoft\Cache\Dependency; |
|
3
|
|
|
|
|
4
|
|
|
use Yiisoft\Cache\CacheInterface; |
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* ExpressionDependency represents a dependency based on the result of a PHP expression. |
|
8
|
|
|
* |
|
9
|
|
|
* ExpressionDependency will use `eval()` to evaluate the PHP expression. |
|
10
|
|
|
* The dependency is reported as unchanged if and only if the result of the expression is |
|
11
|
|
|
* the same as the one evaluated when storing the data to cache. |
|
12
|
|
|
* |
|
13
|
|
|
* A PHP expression can be any PHP code that has a value. To learn more about what an expression is, |
|
14
|
|
|
* please refer to the [php manual](http://www.php.net/manual/en/language.expressions.php). |
|
15
|
|
|
* |
|
16
|
|
|
* For more details and usage information on Cache, see the [guide article on caching](guide:caching-overview). |
|
17
|
|
|
*/ |
|
18
|
|
|
final class ExpressionDependency extends Dependency |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* @var string the string representation of a PHP expression whose result is used to determine the dependency. |
|
22
|
|
|
* A PHP expression can be any PHP code that evaluates to a value. To learn more about what an expression is, |
|
23
|
|
|
* please refer to the [php manual](http://www.php.net/manual/en/language.expressions.php). |
|
24
|
|
|
*/ |
|
25
|
|
|
private $expression; |
|
26
|
|
|
/** |
|
27
|
|
|
* @var mixed custom parameters associated with this dependency. You may get the value |
|
28
|
|
|
* of this property in {@see expression} using `$this->params`. |
|
29
|
|
|
*/ |
|
30
|
|
|
private $params; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @param string $expression the string representation of a PHP expression whose result is used to determine the dependency. |
|
34
|
|
|
* A PHP expression can be any PHP code that evaluates to a value. To learn more about what an expression is, |
|
35
|
|
|
* please refer to the [php manual](http://www.php.net/manual/en/language.expressions.php). |
|
36
|
|
|
* @param mixed $params custom parameters associated with this dependency. You may get the value |
|
37
|
|
|
* of this property in {@see expression} using `$this->params`. |
|
38
|
|
|
*/ |
|
39
|
|
|
public function __construct(string $expression, mixed $params = null) |
|
|
|
|
|
|
40
|
|
|
{ |
|
41
|
|
|
$this->expression = $expression; |
|
42
|
|
|
$this->params = $params; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Generates the data needed to determine if dependency has been changed. |
|
47
|
|
|
* This method returns the result of the PHP expression. |
|
48
|
|
|
* @param CacheInterface $cache the cache component that is currently evaluating this dependency |
|
49
|
|
|
* @return mixed the data needed to determine if dependency has been changed. |
|
50
|
|
|
*/ |
|
51
|
|
|
protected function generateDependencyData(CacheInterface $cache) |
|
52
|
|
|
{ |
|
53
|
|
|
return eval("return {$this->expression};"); |
|
|
|
|
|
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths