public function findTokens($file, FileTokens $fileTokens) { $notFound = sprintf('Failed to find $capabilities in %s file', $fileTokens->file); $statements = $this->parser->parseFile($file); $assign = $this->filter->findFirstVariableAssignment($statements, 'capabilities', $notFound); if (!$assign->expr instanceof Array_) { throw new \RuntimeException(sprintf('The $capabilities variable is not set to an array in %s file', $fileTokens->file)); } foreach ($this->filter->arrayStringKeys($assign->expr) as $key) { $fileTokens->compare($key); } }
public function findTokens($file, FileTokens $fileTokens) { $statements = $this->parser->parseFile($file); foreach ($this->filter->filterAssignments($statements) as $assign) { // Looking for a assignment to an array key, EG: $string['something']. if ($assign->var instanceof ArrayDimFetch) { // Grab the array index. $arrayIndex = $assign->var->dim; if ($arrayIndex instanceof String_) { $fileTokens->compare($arrayIndex->value); } } } }
public function testFindTokens() { $file = __DIR__ . '/../../Fixture/moodle-local_travis/lib.php'; $fileTokens = FileTokens::create('lib.php')->mustHave('local_travis_subtract'); $finder = new FunctionFinder(); $finder->findTokens($file, $fileTokens); $this->assertTrue($fileTokens->hasFoundAllTokens()); }
public function testFindTokens() { $file = __DIR__ . '/../../Fixture/moodle-local_travis/db/access.php'; $fileTokens = FileTokens::create('db/access.php')->mustHave('local/travis:view'); $finder = new CapabilityFinder(); $finder->findTokens($file, $fileTokens); $this->assertTrue($fileTokens->hasFoundAllTokens()); }
public function testFindTokensNameSpaceClass() { $file = __DIR__ . '/../../Fixture/moodle-local_travis/classes/math.php'; $fileTokens = FileTokens::create('lib.php')->mustHave('local_travis\\math'); $finder = new ClassFinder(); $finder->findTokens($file, $fileTokens); $this->assertTrue($fileTokens->hasFoundAllTokens()); }
public function getRequiredTablePrefix() { return FileTokens::create('db/install.xml')->mustHaveAny([$this->plugin->name, $this->plugin->component]); }
public function getRequiredCapabilities() { return FileTokens::create('db/access.php')->mustHave('repository/' . $this->plugin->name . ':view'); }
public function getRequiredClasses() { return [FileTokens::create($this->plugin->component . '.php')->mustHave($this->plugin->component)]; }
public function getRequiredStrings() { return FileTokens::create($this->getLangFile())->mustHave('filtername'); }
public function getRequiredTablePrefix() { return FileTokens::create('db/install.xml')->mustHaveAny(['qtype_', 'question_']); }
public function getRequiredClasses() { return [FileTokens::create('renderer.php')->mustHave('format_' . $this->plugin->name . '_renderer')]; }
public function getRequiredClasses() { return [FileTokens::create('auth.php')->mustHave('auth_plugin_' . $this->plugin->name)]; }