<commit_before><?php
/**
 * @link http://www.yiiframework.com/
 * @copyright Copyright (c) 2008 Yii Software LLC
 * @license http://www.yiiframework.com/license/
 */

namespace yii\caching;

/**
 * ChainedDependency represents a dependency which is composed of a list of other dependencies.
 *
 * When [[dependOnAll]] is true, if any of the dependencies has changed, this dependency is
 * considered changed; When [[dependOnAll]] is false, if one of the dependencies has NOT changed,
 * this dependency is considered NOT changed.
 *
 * For more details and usage information on Cache, see the [guide article on caching](guide:caching-overview).
 *
 * @author <NAME> <<EMAIL>>
 * @since 2.0
 */
class ChainedDependency extends Dependency
{
    /**
     * @var Dependency[] list of dependencies that this dependency is composed of.
     * Each array element must be a dependency object.
     */
    public $dependencies = [];
    /**
     * @var bool whether this dependency is depending on every dependency in [[dependencies]].
     * Defaults to true, meaning if any of the dependencies has changed, this dependency is considered changed.
     * When it is set false, it means if one of the dependencies has NOT changed, this dependency
     * is considered NOT changed.
     */
    public $dependOnAll = true;


    /**
     * Evaluates the dependency by generating and saving the data related with dependency.
     * @param CacheInterface $cache the cache component that is currently evaluating this dependency
     */
    public function evaluateDependency($cache)
    {
        foreach ($this->dependencies as $dependency) {
            $dependency->evaluateDependency($cache);
        }
    }

    /**
     * Generates the data needed to determine if dependency has been changed.
     * This method does nothing in this class.
     * @param CacheInterface $cache the cache component that is currently evaluating this dependency
     * @return mixed the data needed to determine if dependency has been changed.
     */
    protected function generateDependencyData($cache)
    {
        return null;
    }

    /**
     * {@inheritdoc}
     */
    public function isChanged($cache)
    {
        foreach ($this->dependencies as $dependency) {
            if ($this->dependOnAll && $dependency->isChanged($cache)) {
                return true;
            } elseif (!$this->dependOnAll && !$dependency->isChanged($cache)) {
                return false;
            }
        }

        return !$this->dependOnAll;<commit_msg>ChainedDependency 翻译<commit_after><?php
/**
 * @link http://www.yiiframework.com/
 * @copyright Copyright (c) 2008 Yii Software LLC
 * @license http://www.yiiframework.com/license/
 */

namespace yii\caching;

/**
 * ChainedDependency 表示由一系列其它依赖类组成的组合依赖类。
 *
 * 当 [[dependOnAll]] 是 true 时，如果依赖组合里任何一个依赖发生了变化，那么该依赖
 * 就被认为是发生了变化；当 [[dependOnAll]] 是 false 时，如果依赖组合里任何其中一个依赖没有发生变化，
 * 那么该依赖就被认为是没有发生变化。
 *
 * 在 Cache 上更多的详情和详细的使用信息，请参考 [guide article on caching](guide:caching-overview)。
 *
 * @author <NAME> <<EMAIL>>
 * @since 2.0
 */
class ChainedDependency extends Dependency
{
    /**
     * @var Dependency[] 该组合依赖类包含的其它依赖列表。
     * 每个数组元素必须是一个依赖对象。
     */
    public $dependencies = [];
    /**
     * @var bool 是否当前组合依赖对象依赖在 [[dependencies]] 里的每个依赖对象。
     * 默认是 true，这表明任何一个依赖发生变化，组合依赖对象就被认为是发生了变化。
     * 当设置为 false 时，这表明依赖里任何其中一个依赖对象没有发生变化，
     * 组合依赖对象就被认为是没有发生变化。
     */
    public $dependOnAll = true;


    /**
     * 通过生成和保存依赖相关的数据来计算依赖。
     * @param CacheInterface $cache 正在计算缓存依赖的缓存组件。
     */
    public function evaluateDependency($cache)
    {
        foreach ($this->dependencies as $dependency) {
            $dependency->evaluateDependency($cache);
        }
    }

    /**
     * 生成在判断依赖是否发生变化时用到的依赖数据。
     * 该方法在当前类里什么也不需要做。
     * @param CacheInterface $cache 正在计算缓存依赖的缓存组件。
     * @return mixed 判断依赖是否发生变化时用到的依赖数据。
     */
    protected function generateDependencyData($cache)
    {
        return null;
    }

    /**
     * {@inheritdoc}
     */
    public function isChanged($cache)
    {
        foreach ($this->dependencies as $dependency) {
            if ($this->dependOnAll && $dependency->isChanged($cache)) {
                return true;
            } elseif (!$this->dependOnAll && !$dependency->isChanged($cache)) {
                return false;
            }
        }

        return !$this->dependOnAll;
{'fraction_non_alphanumeric': 0.10689812699862951, 'fraction_numerical': 0.002740977615349475, 'mean_word_length': 2.7491438356164384, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2874823', 'n_tokens_mistral': 1472, 'n_tokens_neox': 1496, 'n_words': 366}