rules[] = $rule; } /** * {@inheritDoc} */ public function getModified(): array { $mod = $this->modified; $this->modified = []; return $mod; } /** * {@inheritDoc} */ public function getWatched(): array { return []; } public function loop() { foreach ($this->rules as $rule) { $this->checkRule($rule); } } private function checkRule(Rule $rule) { clearstatcache(); $paths = $rule->getWatchedFiles(); $check = []; foreach ($paths as $path) { if (str_contains($path, '*')) { $check = array_merge($check, glob($path)); } else { $check[] = $path; } } foreach ($check as $path) { if (empty($this->watched[$path])) { $this->watched[$path] = filemtime($path); } else { $mtime = filemtime($path); if ($mtime > $this->watched[$path]) { printf("* modified: %s (%s)\n", $path, $rule->getName()); $this->watched[$path] = $mtime; if (!in_array($rule, $this->modified)) { $this->modified[] = $rule; } } } } } }