repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
paratestphp/paratest
src/Runners/PHPUnit/WrapperRunner.php
WrapperRunner.streamsOf
private function streamsOf(array $workers): array { $streams = []; foreach (array_keys($workers) as $index) { $streams[$index] = $this->streams[$index]; } return $streams; }
php
private function streamsOf(array $workers): array { $streams = []; foreach (array_keys($workers) as $index) { $streams[$index] = $this->streams[$index]; } return $streams; }
[ "private", "function", "streamsOf", "(", "array", "$", "workers", ")", ":", "array", "{", "$", "streams", "=", "[", "]", ";", "foreach", "(", "array_keys", "(", "$", "workers", ")", "as", "$", "index", ")", "{", "$", "streams", "[", "$", "index", "...
Returns the output streams of a subset of workers. @param array keys are positions in $this->workers @return array
[ "Returns", "the", "output", "streams", "of", "a", "subset", "of", "workers", "." ]
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Runners/PHPUnit/WrapperRunner.php#L170-L178
train
paratestphp/paratest
src/Runners/PHPUnit/BaseRunner.php
BaseRunner.verifyConfiguration
protected function verifyConfiguration() { if (isset($this->options->filtered['configuration']) && !file_exists($this->options->filtered['configuration']->getPath())) { $this->printer->println(sprintf('Could not read "%s".', $this->options->filtered['configuration'])); exit(1); } }
php
protected function verifyConfiguration() { if (isset($this->options->filtered['configuration']) && !file_exists($this->options->filtered['configuration']->getPath())) { $this->printer->println(sprintf('Could not read "%s".', $this->options->filtered['configuration'])); exit(1); } }
[ "protected", "function", "verifyConfiguration", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "options", "->", "filtered", "[", "'configuration'", "]", ")", "&&", "!", "file_exists", "(", "$", "this", "->", "options", "->", "filtered", "[", ...
Ensures a valid configuration was supplied. If not causes ParaTest to print the error message and exit immediately with an exit code of 1.
[ "Ensures", "a", "valid", "configuration", "was", "supplied", ".", "If", "not", "causes", "ParaTest", "to", "print", "the", "error", "message", "and", "exit", "immediately", "with", "an", "exit", "code", "of", "1", "." ]
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Runners/PHPUnit/BaseRunner.php#L78-L84
train
paratestphp/paratest
src/Runners/PHPUnit/BaseRunner.php
BaseRunner.log
protected function log() { if (!isset($this->options->filtered['log-junit'])) { return; } $output = $this->options->filtered['log-junit']; $writer = new Writer($this->interpreter, $this->options->path); $writer->write($output); }
php
protected function log() { if (!isset($this->options->filtered['log-junit'])) { return; } $output = $this->options->filtered['log-junit']; $writer = new Writer($this->interpreter, $this->options->path); $writer->write($output); }
[ "protected", "function", "log", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "options", "->", "filtered", "[", "'log-junit'", "]", ")", ")", "{", "return", ";", "}", "$", "output", "=", "$", "this", "->", "options", "->", "filter...
Write output to JUnit format if requested.
[ "Write", "output", "to", "JUnit", "format", "if", "requested", "." ]
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Runners/PHPUnit/BaseRunner.php#L116-L124
train
paratestphp/paratest
src/Runners/PHPUnit/BaseRunner.php
BaseRunner.logCoverage
protected function logCoverage() { if (!$this->hasCoverage()) { return; } $filteredOptions = $this->options->filtered; $reporter = $this->getCoverage()->getReporter(); if (isset($filteredOptions['coverage-clover'])) { $reporter->clover($filteredOptions['coverage-clover']); } if (isset($filteredOptions['coverage-html'])) { $reporter->html($filteredOptions['coverage-html']); } if (isset($filteredOptions['coverage-text'])) { $reporter->text(); } if (isset($filteredOptions['coverage-xml'])) { $reporter->xml($filteredOptions['coverage-xml']); } $reporter->php($filteredOptions['coverage-php']); }
php
protected function logCoverage() { if (!$this->hasCoverage()) { return; } $filteredOptions = $this->options->filtered; $reporter = $this->getCoverage()->getReporter(); if (isset($filteredOptions['coverage-clover'])) { $reporter->clover($filteredOptions['coverage-clover']); } if (isset($filteredOptions['coverage-html'])) { $reporter->html($filteredOptions['coverage-html']); } if (isset($filteredOptions['coverage-text'])) { $reporter->text(); } if (isset($filteredOptions['coverage-xml'])) { $reporter->xml($filteredOptions['coverage-xml']); } $reporter->php($filteredOptions['coverage-php']); }
[ "protected", "function", "logCoverage", "(", ")", "{", "if", "(", "!", "$", "this", "->", "hasCoverage", "(", ")", ")", "{", "return", ";", "}", "$", "filteredOptions", "=", "$", "this", "->", "options", "->", "filtered", ";", "$", "reporter", "=", "...
Write coverage to file if requested.
[ "Write", "coverage", "to", "file", "if", "requested", "." ]
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Runners/PHPUnit/BaseRunner.php#L129-L155
train
paratestphp/paratest
src/Runners/PHPUnit/BaseRunner.php
BaseRunner.overrideEnvironmentVariables
protected function overrideEnvironmentVariables() { if (!isset($this->options->filtered['configuration'])) { return; } $variables = $this->options->filtered['configuration']->getEnvironmentVariables(); foreach ($variables as $key => $value) { putenv(sprintf('%s=%s', $key, $value)); $_ENV[$key] = $value; } }
php
protected function overrideEnvironmentVariables() { if (!isset($this->options->filtered['configuration'])) { return; } $variables = $this->options->filtered['configuration']->getEnvironmentVariables(); foreach ($variables as $key => $value) { putenv(sprintf('%s=%s', $key, $value)); $_ENV[$key] = $value; } }
[ "protected", "function", "overrideEnvironmentVariables", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "options", "->", "filtered", "[", "'configuration'", "]", ")", ")", "{", "return", ";", "}", "$", "variables", "=", "$", "this", "->"...
Overrides envirenment variables if needed.
[ "Overrides", "envirenment", "variables", "if", "needed", "." ]
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Runners/PHPUnit/BaseRunner.php#L184-L197
train
paratestphp/paratest
src/Parser/ParsedClass.php
ParsedClass.getMethods
public function getMethods(array $annotations = []): array { $methods = array_filter($this->methods, function (ParsedFunction $method) use ($annotations): bool { foreach ($annotations as $a => $v) { foreach (explode(',', $v) as $subValue) { if ($method->hasAnnotation($a, $subValue)) { return true; } } } return false; }); return $methods ?: $this->methods; }
php
public function getMethods(array $annotations = []): array { $methods = array_filter($this->methods, function (ParsedFunction $method) use ($annotations): bool { foreach ($annotations as $a => $v) { foreach (explode(',', $v) as $subValue) { if ($method->hasAnnotation($a, $subValue)) { return true; } } } return false; }); return $methods ?: $this->methods; }
[ "public", "function", "getMethods", "(", "array", "$", "annotations", "=", "[", "]", ")", ":", "array", "{", "$", "methods", "=", "array_filter", "(", "$", "this", "->", "methods", ",", "function", "(", "ParsedFunction", "$", "method", ")", "use", "(", ...
Return the methods of this parsed class optionally filtering on annotations present on a method. @param array $annotations @return array
[ "Return", "the", "methods", "of", "this", "parsed", "class", "optionally", "filtering", "on", "annotations", "present", "on", "a", "method", "." ]
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Parser/ParsedClass.php#L38-L53
train
paratestphp/paratest
src/Logging/LogInterpreter.php
LogInterpreter.getCases
public function getCases(): array { $cases = []; foreach ($this->readers as $reader) { foreach ($reader->getSuites() as $suite) { $cases = array_merge($cases, $suite->cases); foreach ($suite->suites as $nested) { $this->extendEmptyCasesFromSuites($nested->cases, $suite); $cases = array_merge($cases, $nested->cases); } } } return $cases; }
php
public function getCases(): array { $cases = []; foreach ($this->readers as $reader) { foreach ($reader->getSuites() as $suite) { $cases = array_merge($cases, $suite->cases); foreach ($suite->suites as $nested) { $this->extendEmptyCasesFromSuites($nested->cases, $suite); $cases = array_merge($cases, $nested->cases); } } } return $cases; }
[ "public", "function", "getCases", "(", ")", ":", "array", "{", "$", "cases", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "readers", "as", "$", "reader", ")", "{", "foreach", "(", "$", "reader", "->", "getSuites", "(", ")", "as", "$", "...
Get all test case objects found within the collection of Reader objects. @return array
[ "Get", "all", "test", "case", "objects", "found", "within", "the", "collection", "of", "Reader", "objects", "." ]
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Logging/LogInterpreter.php#L76-L90
train
paratestphp/paratest
src/Logging/LogInterpreter.php
LogInterpreter.extendEmptyCasesFromSuites
protected function extendEmptyCasesFromSuites(array $cases, TestSuite $suite) { $class = $suite->name; $file = $suite->file; /** @var TestCase $case */ foreach ($cases as $case) { if (empty($case->class)) { $case->class = $class; } if (empty($case->file)) { $case->file = $file; } } }
php
protected function extendEmptyCasesFromSuites(array $cases, TestSuite $suite) { $class = $suite->name; $file = $suite->file; /** @var TestCase $case */ foreach ($cases as $case) { if (empty($case->class)) { $case->class = $class; } if (empty($case->file)) { $case->file = $file; } } }
[ "protected", "function", "extendEmptyCasesFromSuites", "(", "array", "$", "cases", ",", "TestSuite", "$", "suite", ")", "{", "$", "class", "=", "$", "suite", "->", "name", ";", "$", "file", "=", "$", "suite", "->", "file", ";", "/** @var TestCase $case */", ...
Fix problem with empty testcase from DataProvider. @param array $cases @param TestSuite $suite
[ "Fix", "problem", "with", "empty", "testcase", "from", "DataProvider", "." ]
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Logging/LogInterpreter.php#L98-L112
train
paratestphp/paratest
src/Logging/LogInterpreter.php
LogInterpreter.flattenCases
public function flattenCases(): array { $dict = []; foreach ($this->getCases() as $case) { if (!isset($dict[$case->file])) { $dict[$case->file] = new TestSuite($case->class, 0, 0, 0, 0, 0, 0); } $dict[$case->file]->cases[] = $case; ++$dict[$case->file]->tests; $dict[$case->file]->assertions += $case->assertions; $dict[$case->file]->failures += \count($case->failures); $dict[$case->file]->errors += \count($case->errors); $dict[$case->file]->skipped += \count($case->skipped); $dict[$case->file]->time += $case->time; $dict[$case->file]->file = $case->file; } return array_values($dict); }
php
public function flattenCases(): array { $dict = []; foreach ($this->getCases() as $case) { if (!isset($dict[$case->file])) { $dict[$case->file] = new TestSuite($case->class, 0, 0, 0, 0, 0, 0); } $dict[$case->file]->cases[] = $case; ++$dict[$case->file]->tests; $dict[$case->file]->assertions += $case->assertions; $dict[$case->file]->failures += \count($case->failures); $dict[$case->file]->errors += \count($case->errors); $dict[$case->file]->skipped += \count($case->skipped); $dict[$case->file]->time += $case->time; $dict[$case->file]->file = $case->file; } return array_values($dict); }
[ "public", "function", "flattenCases", "(", ")", ":", "array", "{", "$", "dict", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getCases", "(", ")", "as", "$", "case", ")", "{", "if", "(", "!", "isset", "(", "$", "dict", "[", "$", "case...
Flattens all cases into their respective suites. @return array $suites a collection of suites and their cases
[ "Flattens", "all", "cases", "into", "their", "respective", "suites", "." ]
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Logging/LogInterpreter.php#L119-L137
train
paratestphp/paratest
src/Logging/LogInterpreter.php
LogInterpreter.getNumericValue
protected function getNumericValue(string $property) { return ($property === 'time') ? (float) $this->accumulate('getTotalTime') : (int) $this->accumulate('getTotal' . ucfirst($property)); }
php
protected function getNumericValue(string $property) { return ($property === 'time') ? (float) $this->accumulate('getTotalTime') : (int) $this->accumulate('getTotal' . ucfirst($property)); }
[ "protected", "function", "getNumericValue", "(", "string", "$", "property", ")", "{", "return", "(", "$", "property", "===", "'time'", ")", "?", "(", "float", ")", "$", "this", "->", "accumulate", "(", "'getTotalTime'", ")", ":", "(", "int", ")", "$", ...
Returns a value as either a float or int. @param $property @return float|int
[ "Returns", "a", "value", "as", "either", "a", "float", "or", "int", "." ]
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Logging/LogInterpreter.php#L146-L151
train
paratestphp/paratest
src/Logging/LogInterpreter.php
LogInterpreter.mergeMessages
private function mergeMessages(string $method): array { $messages = []; foreach ($this->readers as $reader) { $messages = array_merge($messages, $reader->{$method}()); } return $messages; }
php
private function mergeMessages(string $method): array { $messages = []; foreach ($this->readers as $reader) { $messages = array_merge($messages, $reader->{$method}()); } return $messages; }
[ "private", "function", "mergeMessages", "(", "string", "$", "method", ")", ":", "array", "{", "$", "messages", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "readers", "as", "$", "reader", ")", "{", "$", "messages", "=", "array_merge", "(", ...
Flatten messages into a single collection based on an accessor method. @param $method @return array
[ "Flatten", "messages", "into", "a", "single", "collection", "based", "on", "an", "accessor", "method", "." ]
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Logging/LogInterpreter.php#L174-L182
train
paratestphp/paratest
src/Logging/LogInterpreter.php
LogInterpreter.accumulate
private function accumulate(string $method) { return array_reduce($this->readers, function ($result, $reader) use ($method) { $result += $reader->$method(); return $result; }, 0); }
php
private function accumulate(string $method) { return array_reduce($this->readers, function ($result, $reader) use ($method) { $result += $reader->$method(); return $result; }, 0); }
[ "private", "function", "accumulate", "(", "string", "$", "method", ")", "{", "return", "array_reduce", "(", "$", "this", "->", "readers", ",", "function", "(", "$", "result", ",", "$", "reader", ")", "use", "(", "$", "method", ")", "{", "$", "result", ...
Reduces a collection of readers down to a single result based on an accessor. @param $method @return mixed
[ "Reduces", "a", "collection", "of", "readers", "down", "to", "a", "single", "result", "based", "on", "an", "accessor", "." ]
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Logging/LogInterpreter.php#L192-L199
train
paratestphp/paratest
src/Runners/PHPUnit/SqliteRunner.php
SqliteRunner.startWorkers
protected function startWorkers(): void { $wrapper = realpath(__DIR__ . '/../../../bin/phpunit-sqlite-wrapper'); for ($i = 1; $i <= $this->options->processes; ++$i) { $worker = new SqliteWorker($this->dbFileName); if ($this->options->noTestTokens) { $token = null; $uniqueToken = null; } else { $token = $i; $uniqueToken = uniqid(); } $worker->start($wrapper, $token, $uniqueToken); $this->workers[] = $worker; } }
php
protected function startWorkers(): void { $wrapper = realpath(__DIR__ . '/../../../bin/phpunit-sqlite-wrapper'); for ($i = 1; $i <= $this->options->processes; ++$i) { $worker = new SqliteWorker($this->dbFileName); if ($this->options->noTestTokens) { $token = null; $uniqueToken = null; } else { $token = $i; $uniqueToken = uniqid(); } $worker->start($wrapper, $token, $uniqueToken); $this->workers[] = $worker; } }
[ "protected", "function", "startWorkers", "(", ")", ":", "void", "{", "$", "wrapper", "=", "realpath", "(", "__DIR__", ".", "'/../../../bin/phpunit-sqlite-wrapper'", ")", ";", "for", "(", "$", "i", "=", "1", ";", "$", "i", "<=", "$", "this", "->", "option...
Start all workers.
[ "Start", "all", "workers", "." ]
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Runners/PHPUnit/SqliteRunner.php#L51-L67
train
paratestphp/paratest
src/Runners/PHPUnit/SqliteRunner.php
SqliteRunner.waitForAllToFinish
private function waitForAllToFinish(): void { do { foreach ($this->workers as $key => $worker) { if (!$worker->isRunning()) { unset($this->workers[$key]); } } usleep(10000); $this->printOutput(); } while (\count($this->workers) > 0); }
php
private function waitForAllToFinish(): void { do { foreach ($this->workers as $key => $worker) { if (!$worker->isRunning()) { unset($this->workers[$key]); } } usleep(10000); $this->printOutput(); } while (\count($this->workers) > 0); }
[ "private", "function", "waitForAllToFinish", "(", ")", ":", "void", "{", "do", "{", "foreach", "(", "$", "this", "->", "workers", "as", "$", "key", "=>", "$", "worker", ")", "{", "if", "(", "!", "$", "worker", "->", "isRunning", "(", ")", ")", "{",...
Wait for all workers to complete their tests and print output.
[ "Wait", "for", "all", "workers", "to", "complete", "their", "tests", "and", "print", "output", "." ]
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Runners/PHPUnit/SqliteRunner.php#L72-L83
train
paratestphp/paratest
src/Runners/PHPUnit/SqliteRunner.php
SqliteRunner.createTable
private function createTable(): void { $statement = 'CREATE TABLE tests ( id INTEGER PRIMARY KEY, command TEXT NOT NULL UNIQUE, file_name TEXT NOT NULL, reserved_by_process_id INTEGER, completed INTEGER DEFAULT 0 )'; if ($this->db->exec($statement) === false) { throw new Exception('Error while creating sqlite database table: ' . $this->db->errorCode()); } }
php
private function createTable(): void { $statement = 'CREATE TABLE tests ( id INTEGER PRIMARY KEY, command TEXT NOT NULL UNIQUE, file_name TEXT NOT NULL, reserved_by_process_id INTEGER, completed INTEGER DEFAULT 0 )'; if ($this->db->exec($statement) === false) { throw new Exception('Error while creating sqlite database table: ' . $this->db->errorCode()); } }
[ "private", "function", "createTable", "(", ")", ":", "void", "{", "$", "statement", "=", "'CREATE TABLE tests (\n id INTEGER PRIMARY KEY,\n command TEXT NOT NULL UNIQUE,\n file_name TEXT NOT NULL,\n ...
Initialize test queue table. @throws Exception
[ "Initialize", "test", "queue", "table", "." ]
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Runners/PHPUnit/SqliteRunner.php#L90-L103
train
paratestphp/paratest
src/Runners/PHPUnit/SqliteRunner.php
SqliteRunner.printOutput
private function printOutput(): void { foreach ($this->db->query('SELECT id, file_name FROM tests WHERE completed = 1')->fetchAll() as $test) { $this->printer->printFeedback($this->pending[$test['file_name']]); $this->db->prepare('DELETE FROM tests WHERE id = :id')->execute([ 'id' => $test['id'], ]); } }
php
private function printOutput(): void { foreach ($this->db->query('SELECT id, file_name FROM tests WHERE completed = 1')->fetchAll() as $test) { $this->printer->printFeedback($this->pending[$test['file_name']]); $this->db->prepare('DELETE FROM tests WHERE id = :id')->execute([ 'id' => $test['id'], ]); } }
[ "private", "function", "printOutput", "(", ")", ":", "void", "{", "foreach", "(", "$", "this", "->", "db", "->", "query", "(", "'SELECT id, file_name FROM tests WHERE completed = 1'", ")", "->", "fetchAll", "(", ")", "as", "$", "test", ")", "{", "$", "this",...
Loop through all completed tests and print their output.
[ "Loop", "through", "all", "completed", "tests", "and", "print", "their", "output", "." ]
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Runners/PHPUnit/SqliteRunner.php#L122-L130
train
paratestphp/paratest
src/Runners/PHPUnit/SqliteRunner.php
SqliteRunner.checkIfWorkersCrashed
private function checkIfWorkersCrashed(): void { if ($this->db->query('SELECT COUNT(id) FROM tests')->fetchColumn(0) === '0') { return; } throw new RuntimeException( 'Some workers have crashed.' . PHP_EOL . '----------------------' . PHP_EOL . 'All workers have quit, but some tests are still to be executed.' . PHP_EOL . 'This may be the case if some tests were killed forcefully (for example, using exit()).' . PHP_EOL . '----------------------' . PHP_EOL . 'Failed test command(s):' . PHP_EOL . '----------------------' . PHP_EOL . implode(PHP_EOL, $this->db->query('SELECT command FROM tests')->fetchAll(PDO::FETCH_COLUMN)) ); }
php
private function checkIfWorkersCrashed(): void { if ($this->db->query('SELECT COUNT(id) FROM tests')->fetchColumn(0) === '0') { return; } throw new RuntimeException( 'Some workers have crashed.' . PHP_EOL . '----------------------' . PHP_EOL . 'All workers have quit, but some tests are still to be executed.' . PHP_EOL . 'This may be the case if some tests were killed forcefully (for example, using exit()).' . PHP_EOL . '----------------------' . PHP_EOL . 'Failed test command(s):' . PHP_EOL . '----------------------' . PHP_EOL . implode(PHP_EOL, $this->db->query('SELECT command FROM tests')->fetchAll(PDO::FETCH_COLUMN)) ); }
[ "private", "function", "checkIfWorkersCrashed", "(", ")", ":", "void", "{", "if", "(", "$", "this", "->", "db", "->", "query", "(", "'SELECT COUNT(id) FROM tests'", ")", "->", "fetchColumn", "(", "0", ")", "===", "'0'", ")", "{", "return", ";", "}", "thr...
Make sure that all tests were executed successfully.
[ "Make", "sure", "that", "all", "tests", "were", "executed", "successfully", "." ]
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Runners/PHPUnit/SqliteRunner.php#L135-L151
train
paratestphp/paratest
src/Logging/MetaProvider.php
MetaProvider.getNumericValue
protected function getNumericValue(string $property) { return ($property === 'time') ? (float) $this->suites[0]->$property : (int) $this->suites[0]->$property; }
php
protected function getNumericValue(string $property) { return ($property === 'time') ? (float) $this->suites[0]->$property : (int) $this->suites[0]->$property; }
[ "protected", "function", "getNumericValue", "(", "string", "$", "property", ")", "{", "return", "(", "$", "property", "===", "'time'", ")", "?", "(", "float", ")", "$", "this", "->", "suites", "[", "0", "]", "->", "$", "property", ":", "(", "int", ")...
Return a value as a float or integer. @param $property @return float|int
[ "Return", "a", "value", "as", "a", "float", "or", "integer", "." ]
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Logging/MetaProvider.php#L54-L59
train
paratestphp/paratest
src/Logging/MetaProvider.php
MetaProvider.getMessages
protected function getMessages(string $type): array { $messages = []; $suites = $this->isSingle ? $this->suites : $this->suites[0]->suites; foreach ($suites as $suite) { $messages = array_merge($messages, array_reduce($suite->cases, function ($result, $case) use ($type) { return array_merge($result, array_reduce($case->$type, function ($msgs, $msg) { $msgs[] = $msg['text']; return $msgs; }, [])); }, [])); } return $messages; }
php
protected function getMessages(string $type): array { $messages = []; $suites = $this->isSingle ? $this->suites : $this->suites[0]->suites; foreach ($suites as $suite) { $messages = array_merge($messages, array_reduce($suite->cases, function ($result, $case) use ($type) { return array_merge($result, array_reduce($case->$type, function ($msgs, $msg) { $msgs[] = $msg['text']; return $msgs; }, [])); }, [])); } return $messages; }
[ "protected", "function", "getMessages", "(", "string", "$", "type", ")", ":", "array", "{", "$", "messages", "=", "[", "]", ";", "$", "suites", "=", "$", "this", "->", "isSingle", "?", "$", "this", "->", "suites", ":", "$", "this", "->", "suites", ...
Return messages for a given type. @param $type @return array
[ "Return", "messages", "for", "a", "given", "type", "." ]
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Logging/MetaProvider.php#L68-L83
train
paratestphp/paratest
src/Runners/PHPUnit/Options.php
Options.defaults
protected static function defaults(): array { return [ 'processes' => 'auto', 'path' => '', 'phpunit' => static::phpunit(), 'functional' => false, 'stop-on-failure' => false, 'runner' => 'Runner', 'no-test-tokens' => false, 'colors' => false, 'testsuite' => '', 'max-batch-size' => 0, 'filter' => null, 'parallel-suite' => false, 'passthru' => null, 'passthru-php' => null, 'verbose' => 0, ]; }
php
protected static function defaults(): array { return [ 'processes' => 'auto', 'path' => '', 'phpunit' => static::phpunit(), 'functional' => false, 'stop-on-failure' => false, 'runner' => 'Runner', 'no-test-tokens' => false, 'colors' => false, 'testsuite' => '', 'max-batch-size' => 0, 'filter' => null, 'parallel-suite' => false, 'passthru' => null, 'passthru-php' => null, 'verbose' => 0, ]; }
[ "protected", "static", "function", "defaults", "(", ")", ":", "array", "{", "return", "[", "'processes'", "=>", "'auto'", ",", "'path'", "=>", "''", ",", "'phpunit'", "=>", "static", "::", "phpunit", "(", ")", ",", "'functional'", "=>", "false", ",", "'s...
Returns a collection of ParaTest's default option values. @return array
[ "Returns", "a", "collection", "of", "ParaTest", "s", "default", "option", "values", "." ]
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Runners/PHPUnit/Options.php#L216-L235
train
paratestphp/paratest
src/Runners/PHPUnit/Options.php
Options.phpunit
protected static function phpunit(): string { $vendor = static::vendorDir(); $phpunit = $vendor . \DIRECTORY_SEPARATOR . 'phpunit' . \DIRECTORY_SEPARATOR . 'phpunit' . \DIRECTORY_SEPARATOR . 'phpunit'; if (file_exists($phpunit)) { return $phpunit; } return 'phpunit'; }
php
protected static function phpunit(): string { $vendor = static::vendorDir(); $phpunit = $vendor . \DIRECTORY_SEPARATOR . 'phpunit' . \DIRECTORY_SEPARATOR . 'phpunit' . \DIRECTORY_SEPARATOR . 'phpunit'; if (file_exists($phpunit)) { return $phpunit; } return 'phpunit'; }
[ "protected", "static", "function", "phpunit", "(", ")", ":", "string", "{", "$", "vendor", "=", "static", "::", "vendorDir", "(", ")", ";", "$", "phpunit", "=", "$", "vendor", ".", "\\", "DIRECTORY_SEPARATOR", ".", "'phpunit'", ".", "\\", "DIRECTORY_SEPARA...
Get the path to phpunit First checks if a Windows batch script is in the composer vendors directory. Composer automatically handles creating a .bat file, so if on windows this should be the case. Second look for the phpunit binary under nix Defaults to phpunit on the users PATH. @return string $phpunit the path to phpunit
[ "Get", "the", "path", "to", "phpunit", "First", "checks", "if", "a", "Windows", "batch", "script", "is", "in", "the", "composer", "vendors", "directory", ".", "Composer", "automatically", "handles", "creating", "a", ".", "bat", "file", "so", "if", "on", "w...
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Runners/PHPUnit/Options.php#L246-L256
train
paratestphp/paratest
src/Runners/PHPUnit/Options.php
Options.filterOptions
protected function filterOptions(array $options): array { $filtered = array_diff_key($options, [ 'processes' => $this->processes, 'path' => $this->path, 'phpunit' => $this->phpunit, 'functional' => $this->functional, 'stop-on-failure' => $this->stopOnFailure, 'runner' => $this->runner, 'no-test-tokens' => $this->noTestTokens, 'colors' => $this->colors, 'testsuite' => $this->testsuite, 'max-batch-size' => $this->maxBatchSize, 'filter' => $this->filter, 'parallel-suite' => $this->parallelSuite, 'passthru' => $this->passthru, 'passthru-php' => $this->passthruPhp, 'verbose' => $this->verbose, ]); if ($configuration = $this->getConfigurationPath($filtered)) { $filtered['configuration'] = new Configuration($configuration); } return $filtered; }
php
protected function filterOptions(array $options): array { $filtered = array_diff_key($options, [ 'processes' => $this->processes, 'path' => $this->path, 'phpunit' => $this->phpunit, 'functional' => $this->functional, 'stop-on-failure' => $this->stopOnFailure, 'runner' => $this->runner, 'no-test-tokens' => $this->noTestTokens, 'colors' => $this->colors, 'testsuite' => $this->testsuite, 'max-batch-size' => $this->maxBatchSize, 'filter' => $this->filter, 'parallel-suite' => $this->parallelSuite, 'passthru' => $this->passthru, 'passthru-php' => $this->passthruPhp, 'verbose' => $this->verbose, ]); if ($configuration = $this->getConfigurationPath($filtered)) { $filtered['configuration'] = new Configuration($configuration); } return $filtered; }
[ "protected", "function", "filterOptions", "(", "array", "$", "options", ")", ":", "array", "{", "$", "filtered", "=", "array_diff_key", "(", "$", "options", ",", "[", "'processes'", "=>", "$", "this", "->", "processes", ",", "'path'", "=>", "$", "this", ...
Filter options to distinguish between paratest internal options and any other options.
[ "Filter", "options", "to", "distinguish", "between", "paratest", "internal", "options", "and", "any", "other", "options", "." ]
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Runners/PHPUnit/Options.php#L277-L301
train
paratestphp/paratest
src/Runners/PHPUnit/Options.php
Options.getConfigurationPath
protected function getConfigurationPath(array $filtered) { if (isset($filtered['configuration'])) { return $this->getDefaultConfigurationForPath($filtered['configuration'], $filtered['configuration']); } return $this->getDefaultConfigurationForPath(); }
php
protected function getConfigurationPath(array $filtered) { if (isset($filtered['configuration'])) { return $this->getDefaultConfigurationForPath($filtered['configuration'], $filtered['configuration']); } return $this->getDefaultConfigurationForPath(); }
[ "protected", "function", "getConfigurationPath", "(", "array", "$", "filtered", ")", "{", "if", "(", "isset", "(", "$", "filtered", "[", "'configuration'", "]", ")", ")", "{", "return", "$", "this", "->", "getDefaultConfigurationForPath", "(", "$", "filtered",...
Take an array of filtered options and return a configuration path. @param $filtered @return string|null
[ "Take", "an", "array", "of", "filtered", "options", "and", "return", "a", "configuration", "path", "." ]
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Runners/PHPUnit/Options.php#L311-L318
train
paratestphp/paratest
src/Runners/PHPUnit/Options.php
Options.initAnnotations
protected function initAnnotations() { $annotatedOptions = ['group']; foreach ($this->filtered as $key => $value) { if (\in_array($key, $annotatedOptions, true)) { $this->annotations[$key] = $value; } } }
php
protected function initAnnotations() { $annotatedOptions = ['group']; foreach ($this->filtered as $key => $value) { if (\in_array($key, $annotatedOptions, true)) { $this->annotations[$key] = $value; } } }
[ "protected", "function", "initAnnotations", "(", ")", "{", "$", "annotatedOptions", "=", "[", "'group'", "]", ";", "foreach", "(", "$", "this", "->", "filtered", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "\\", "in_array", "(", "$", "...
Load options that are represented by annotations inside of tests i.e @group group1 = --group group1.
[ "Load", "options", "that", "are", "represented", "by", "annotations", "inside", "of", "tests", "i", ".", "e" ]
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Runners/PHPUnit/Options.php#L351-L359
train
paratestphp/paratest
src/Runners/PHPUnit/ResultPrinter.php
ResultPrinter.start
public function start(Options $options) { $this->numTestsWidth = \strlen((string) $this->totalCases); $this->maxColumn = $this->numberOfColumns + (\DIRECTORY_SEPARATOR === '\\' ? -1 : 0) // fix windows blank lines - \strlen($this->getProgress()); printf( "\nRunning phpunit in %d process%s with %s%s\n\n", $options->processes, $options->processes > 1 ? 'es' : '', $options->phpunit, $options->functional ? '. Functional mode is ON.' : '' ); if (isset($options->filtered['configuration'])) { printf("Configuration read from %s\n\n", $options->filtered['configuration']->getPath()); } $this->timer->start(); $this->colors = $options->colors; $this->processSkipped = $this->isSkippedIncompleTestCanBeTracked($options); }
php
public function start(Options $options) { $this->numTestsWidth = \strlen((string) $this->totalCases); $this->maxColumn = $this->numberOfColumns + (\DIRECTORY_SEPARATOR === '\\' ? -1 : 0) // fix windows blank lines - \strlen($this->getProgress()); printf( "\nRunning phpunit in %d process%s with %s%s\n\n", $options->processes, $options->processes > 1 ? 'es' : '', $options->phpunit, $options->functional ? '. Functional mode is ON.' : '' ); if (isset($options->filtered['configuration'])) { printf("Configuration read from %s\n\n", $options->filtered['configuration']->getPath()); } $this->timer->start(); $this->colors = $options->colors; $this->processSkipped = $this->isSkippedIncompleTestCanBeTracked($options); }
[ "public", "function", "start", "(", "Options", "$", "options", ")", "{", "$", "this", "->", "numTestsWidth", "=", "\\", "strlen", "(", "(", "string", ")", "$", "this", "->", "totalCases", ")", ";", "$", "this", "->", "maxColumn", "=", "$", "this", "-...
Initializes printing constraints, prints header information and starts the test timer. @param Options $options
[ "Initializes", "printing", "constraints", "prints", "header", "information", "and", "starts", "the", "test", "timer", "." ]
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Runners/PHPUnit/ResultPrinter.php#L135-L154
train
paratestphp/paratest
src/Runners/PHPUnit/ResultPrinter.php
ResultPrinter.printResults
public function printResults() { echo $this->getHeader(); echo $this->getErrors(); echo $this->getFailures(); echo $this->getWarnings(); echo $this->getFooter(); }
php
public function printResults() { echo $this->getHeader(); echo $this->getErrors(); echo $this->getFailures(); echo $this->getWarnings(); echo $this->getFooter(); }
[ "public", "function", "printResults", "(", ")", "{", "echo", "$", "this", "->", "getHeader", "(", ")", ";", "echo", "$", "this", "->", "getErrors", "(", ")", ";", "echo", "$", "this", "->", "getFailures", "(", ")", ";", "echo", "$", "this", "->", "...
Print final results.
[ "Print", "final", "results", "." ]
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Runners/PHPUnit/ResultPrinter.php#L178-L185
train
paratestphp/paratest
src/Runners/PHPUnit/ResultPrinter.php
ResultPrinter.printFeedback
public function printFeedback(ExecutableTest $test) { try { $reader = new Reader($test->getTempFile()); } catch (\InvalidArgumentException $e) { throw new \RuntimeException(sprintf( "%s\n" . "The process: %s\n" . "This means a PHPUnit process was unable to run \"%s\"\n", $e->getMessage(), $test->getLastCommand(), $test->getPath() )); } $this->results->addReader($reader); $this->processReaderFeedback($reader, $test->getTestCount()); $this->printTestWarnings($test); }
php
public function printFeedback(ExecutableTest $test) { try { $reader = new Reader($test->getTempFile()); } catch (\InvalidArgumentException $e) { throw new \RuntimeException(sprintf( "%s\n" . "The process: %s\n" . "This means a PHPUnit process was unable to run \"%s\"\n", $e->getMessage(), $test->getLastCommand(), $test->getPath() )); } $this->results->addReader($reader); $this->processReaderFeedback($reader, $test->getTestCount()); $this->printTestWarnings($test); }
[ "public", "function", "printFeedback", "(", "ExecutableTest", "$", "test", ")", "{", "try", "{", "$", "reader", "=", "new", "Reader", "(", "$", "test", "->", "getTempFile", "(", ")", ")", ";", "}", "catch", "(", "\\", "InvalidArgumentException", "$", "e"...
Prints the individual "quick" feedback for run tests, that is the ".EF" items. @param ExecutableTest $test
[ "Prints", "the", "individual", "quick", "feedback", "for", "run", "tests", "that", "is", "the", ".", "EF", "items", "." ]
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Runners/PHPUnit/ResultPrinter.php#L193-L210
train
paratestphp/paratest
src/Runners/PHPUnit/ResultPrinter.php
ResultPrinter.processReaderFeedback
protected function processReaderFeedback(Reader $reader, int $expectedTestCount) { $feedbackItems = $reader->getFeedback(); $actualTestCount = \count($feedbackItems); $this->processTestOverhead($actualTestCount, $expectedTestCount); foreach ($feedbackItems as $item) { $this->printFeedbackItem($item); if ($item === 'S') { ++$this->totalSkippedOrIncomplete; } } if ($this->processSkipped) { $this->printSkippedAndIncomplete($actualTestCount, $expectedTestCount); } }
php
protected function processReaderFeedback(Reader $reader, int $expectedTestCount) { $feedbackItems = $reader->getFeedback(); $actualTestCount = \count($feedbackItems); $this->processTestOverhead($actualTestCount, $expectedTestCount); foreach ($feedbackItems as $item) { $this->printFeedbackItem($item); if ($item === 'S') { ++$this->totalSkippedOrIncomplete; } } if ($this->processSkipped) { $this->printSkippedAndIncomplete($actualTestCount, $expectedTestCount); } }
[ "protected", "function", "processReaderFeedback", "(", "Reader", "$", "reader", ",", "int", "$", "expectedTestCount", ")", "{", "$", "feedbackItems", "=", "$", "reader", "->", "getFeedback", "(", ")", ";", "$", "actualTestCount", "=", "\\", "count", "(", "$"...
Process reader feedback and print it. @param Reader $reader @param int $expectedTestCount
[ "Process", "reader", "feedback", "and", "print", "it", "." ]
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Runners/PHPUnit/ResultPrinter.php#L302-L320
train
paratestphp/paratest
src/Runners/PHPUnit/ResultPrinter.php
ResultPrinter.printSkippedAndIncomplete
protected function printSkippedAndIncomplete(int $actualTestCount, int $expectedTestCount) { $overhead = $expectedTestCount - $actualTestCount; if ($overhead > 0) { for ($i = 0; $i < $overhead; ++$i) { $this->printFeedbackItem('S'); } } }
php
protected function printSkippedAndIncomplete(int $actualTestCount, int $expectedTestCount) { $overhead = $expectedTestCount - $actualTestCount; if ($overhead > 0) { for ($i = 0; $i < $overhead; ++$i) { $this->printFeedbackItem('S'); } } }
[ "protected", "function", "printSkippedAndIncomplete", "(", "int", "$", "actualTestCount", ",", "int", "$", "expectedTestCount", ")", "{", "$", "overhead", "=", "$", "expectedTestCount", "-", "$", "actualTestCount", ";", "if", "(", "$", "overhead", ">", "0", ")...
Prints S for skipped and incomplete tests. If for some reason process return less tests than expected then we threat all remaining as skipped or incomplete and print them as skipped (S letter) @param int $actualTestCount @param int $expectedTestCount
[ "Prints", "S", "for", "skipped", "and", "incomplete", "tests", "." ]
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Runners/PHPUnit/ResultPrinter.php#L388-L396
train
paratestphp/paratest
src/Runners/PHPUnit/ResultPrinter.php
ResultPrinter.printFeedbackItem
protected function printFeedbackItem(string $item) { echo $item; ++$this->column; ++$this->casesProcessed; if ($this->column === $this->maxColumn) { echo $this->getProgress(); $this->println(); } }
php
protected function printFeedbackItem(string $item) { echo $item; ++$this->column; ++$this->casesProcessed; if ($this->column === $this->maxColumn) { echo $this->getProgress(); $this->println(); } }
[ "protected", "function", "printFeedbackItem", "(", "string", "$", "item", ")", "{", "echo", "$", "item", ";", "++", "$", "this", "->", "column", ";", "++", "$", "this", "->", "casesProcessed", ";", "if", "(", "$", "this", "->", "column", "===", "$", ...
Prints a single "quick" feedback item and increments the total number of processed cases and the column position. @param $item
[ "Prints", "a", "single", "quick", "feedback", "item", "and", "increments", "the", "total", "number", "of", "processed", "cases", "and", "the", "column", "position", "." ]
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Runners/PHPUnit/ResultPrinter.php#L405-L414
train
paratestphp/paratest
src/Runners/PHPUnit/ResultPrinter.php
ResultPrinter.getDefects
protected function getDefects(array $defects, string $type): string { $count = \count($defects); if ($count === 0) { return ''; } $output = sprintf( "There %s %d %s%s:\n", ($count === 1) ? 'was' : 'were', $count, $type, ($count === 1) ? '' : 's' ); for ($i = 1; $i <= \count($defects); ++$i) { $output .= sprintf("\n%d) %s\n", $i, $defects[$i - 1]); } return $output; }
php
protected function getDefects(array $defects, string $type): string { $count = \count($defects); if ($count === 0) { return ''; } $output = sprintf( "There %s %d %s%s:\n", ($count === 1) ? 'was' : 'were', $count, $type, ($count === 1) ? '' : 's' ); for ($i = 1; $i <= \count($defects); ++$i) { $output .= sprintf("\n%d) %s\n", $i, $defects[$i - 1]); } return $output; }
[ "protected", "function", "getDefects", "(", "array", "$", "defects", ",", "string", "$", "type", ")", ":", "string", "{", "$", "count", "=", "\\", "count", "(", "$", "defects", ")", ";", "if", "(", "$", "count", "===", "0", ")", "{", "return", "''"...
Method that returns a formatted string for a collection of errors or failures. @param array $defects @param $type @return string
[ "Method", "that", "returns", "a", "formatted", "string", "for", "a", "collection", "of", "errors", "or", "failures", "." ]
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Runners/PHPUnit/ResultPrinter.php#L425-L444
train
paratestphp/paratest
src/Runners/PHPUnit/ResultPrinter.php
ResultPrinter.getProgress
protected function getProgress(): string { return sprintf( ' %' . $this->numTestsWidth . 'd / %' . $this->numTestsWidth . 'd (%3s%%)', $this->casesProcessed, $this->totalCases, floor(($this->totalCases ? $this->casesProcessed / $this->totalCases : 0) * 100) ); }
php
protected function getProgress(): string { return sprintf( ' %' . $this->numTestsWidth . 'd / %' . $this->numTestsWidth . 'd (%3s%%)', $this->casesProcessed, $this->totalCases, floor(($this->totalCases ? $this->casesProcessed / $this->totalCases : 0) * 100) ); }
[ "protected", "function", "getProgress", "(", ")", ":", "string", "{", "return", "sprintf", "(", "' %'", ".", "$", "this", "->", "numTestsWidth", ".", "'d / %'", ".", "$", "this", "->", "numTestsWidth", ".", "'d (%3s%%)'", ",", "$", "this", "->", "casesProc...
Prints progress for large test collections.
[ "Prints", "progress", "for", "large", "test", "collections", "." ]
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Runners/PHPUnit/ResultPrinter.php#L449-L457
train
paratestphp/paratest
src/Runners/PHPUnit/ResultPrinter.php
ResultPrinter.getFailedFooter
private function getFailedFooter(): string { $formatString = "FAILURES!\nTests: %d, Assertions: %d, Failures: %d, Errors: %d.\n"; return "\n" . $this->red( sprintf( $formatString, $this->results->getTotalTests(), $this->results->getTotalAssertions(), $this->results->getTotalFailures(), $this->results->getTotalErrors() ) ); }
php
private function getFailedFooter(): string { $formatString = "FAILURES!\nTests: %d, Assertions: %d, Failures: %d, Errors: %d.\n"; return "\n" . $this->red( sprintf( $formatString, $this->results->getTotalTests(), $this->results->getTotalAssertions(), $this->results->getTotalFailures(), $this->results->getTotalErrors() ) ); }
[ "private", "function", "getFailedFooter", "(", ")", ":", "string", "{", "$", "formatString", "=", "\"FAILURES!\\nTests: %d, Assertions: %d, Failures: %d, Errors: %d.\\n\"", ";", "return", "\"\\n\"", ".", "$", "this", "->", "red", "(", "sprintf", "(", "$", "formatStrin...
Get the footer for a test collection that had tests with failures or errors. @return string
[ "Get", "the", "footer", "for", "a", "test", "collection", "that", "had", "tests", "with", "failures", "or", "errors", "." ]
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Runners/PHPUnit/ResultPrinter.php#L465-L478
train
paratestphp/paratest
src/Runners/PHPUnit/ResultPrinter.php
ResultPrinter.getSuccessFooter
private function getSuccessFooter(): string { $tests = $this->totalCases; $asserts = $this->results->getTotalAssertions(); if ($this->totalSkippedOrIncomplete > 0) { // phpunit 4.5 produce NOT plural version for test(s) and assertion(s) in that case // also it shows result in standard color scheme return sprintf( "OK, but incomplete, skipped, or risky tests!\n" . "Tests: %d, Assertions: %d, Incomplete: %d.\n", $tests, $asserts, $this->totalSkippedOrIncomplete ); } // phpunit 4.5 produce plural version for test(s) and assertion(s) in that case // also it shows result as black text on green background return $this->green(sprintf( "OK (%d test%s, %d assertion%s)\n", $tests, ($tests === 1) ? '' : 's', $asserts, ($asserts === 1) ? '' : 's' )); }
php
private function getSuccessFooter(): string { $tests = $this->totalCases; $asserts = $this->results->getTotalAssertions(); if ($this->totalSkippedOrIncomplete > 0) { // phpunit 4.5 produce NOT plural version for test(s) and assertion(s) in that case // also it shows result in standard color scheme return sprintf( "OK, but incomplete, skipped, or risky tests!\n" . "Tests: %d, Assertions: %d, Incomplete: %d.\n", $tests, $asserts, $this->totalSkippedOrIncomplete ); } // phpunit 4.5 produce plural version for test(s) and assertion(s) in that case // also it shows result as black text on green background return $this->green(sprintf( "OK (%d test%s, %d assertion%s)\n", $tests, ($tests === 1) ? '' : 's', $asserts, ($asserts === 1) ? '' : 's' )); }
[ "private", "function", "getSuccessFooter", "(", ")", ":", "string", "{", "$", "tests", "=", "$", "this", "->", "totalCases", ";", "$", "asserts", "=", "$", "this", "->", "results", "->", "getTotalAssertions", "(", ")", ";", "if", "(", "$", "this", "->"...
Get the footer for a test collection containing all successful tests. @return string
[ "Get", "the", "footer", "for", "a", "test", "collection", "containing", "all", "successful", "tests", "." ]
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Runners/PHPUnit/ResultPrinter.php#L486-L512
train
paratestphp/paratest
src/Runners/PHPUnit/Runner.php
Runner.run
public function run() { parent::run(); while (\count($this->running) || \count($this->pending)) { foreach ($this->running as $key => $test) { try { if (!$this->testIsStillRunning($test)) { unset($this->running[$key]); $this->releaseToken($key); } } catch (\Exception $e) { if ($this->options->verbose) { echo "An error for $key: {$e->getMessage()}" . PHP_EOL; echo "Command: {$test->getLastCommand()}" . PHP_EOL; echo 'StdErr: ' . $test->getStderr() . PHP_EOL; echo 'StdOut: ' . $test->getStdout() . PHP_EOL; } throw $e; } } $this->fillRunQueue(); usleep(10000); } $this->complete(); }
php
public function run() { parent::run(); while (\count($this->running) || \count($this->pending)) { foreach ($this->running as $key => $test) { try { if (!$this->testIsStillRunning($test)) { unset($this->running[$key]); $this->releaseToken($key); } } catch (\Exception $e) { if ($this->options->verbose) { echo "An error for $key: {$e->getMessage()}" . PHP_EOL; echo "Command: {$test->getLastCommand()}" . PHP_EOL; echo 'StdErr: ' . $test->getStderr() . PHP_EOL; echo 'StdOut: ' . $test->getStdout() . PHP_EOL; } throw $e; } } $this->fillRunQueue(); usleep(10000); } $this->complete(); }
[ "public", "function", "run", "(", ")", "{", "parent", "::", "run", "(", ")", ";", "while", "(", "\\", "count", "(", "$", "this", "->", "running", ")", "||", "\\", "count", "(", "$", "this", "->", "pending", ")", ")", "{", "foreach", "(", "$", "...
The money maker. Runs all ExecutableTest objects in separate processes.
[ "The", "money", "maker", ".", "Runs", "all", "ExecutableTest", "objects", "in", "separate", "processes", "." ]
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Runners/PHPUnit/Runner.php#L28-L53
train
paratestphp/paratest
src/Runners/PHPUnit/Runner.php
Runner.fillRunQueue
private function fillRunQueue() { $opts = $this->options; while (\count($this->pending) && \count($this->running) < $opts->processes) { $tokenData = $this->getNextAvailableToken(); if ($tokenData !== false) { $this->acquireToken($tokenData['token']); $env = ['TEST_TOKEN' => $tokenData['token'], 'UNIQUE_TEST_TOKEN' => $tokenData['unique']] + Habitat::getAll(); $this->running[$tokenData['token']] = array_shift($this->pending)->run($opts->phpunit, $opts->filtered, $env, $opts->passthru, $opts->passthruPhp); if ($opts->verbose) { $cmd = $this->running[$tokenData['token']]; echo "\nExecuting test via: {$cmd->getLastCommand()}\n"; } } } }
php
private function fillRunQueue() { $opts = $this->options; while (\count($this->pending) && \count($this->running) < $opts->processes) { $tokenData = $this->getNextAvailableToken(); if ($tokenData !== false) { $this->acquireToken($tokenData['token']); $env = ['TEST_TOKEN' => $tokenData['token'], 'UNIQUE_TEST_TOKEN' => $tokenData['unique']] + Habitat::getAll(); $this->running[$tokenData['token']] = array_shift($this->pending)->run($opts->phpunit, $opts->filtered, $env, $opts->passthru, $opts->passthruPhp); if ($opts->verbose) { $cmd = $this->running[$tokenData['token']]; echo "\nExecuting test via: {$cmd->getLastCommand()}\n"; } } } }
[ "private", "function", "fillRunQueue", "(", ")", "{", "$", "opts", "=", "$", "this", "->", "options", ";", "while", "(", "\\", "count", "(", "$", "this", "->", "pending", ")", "&&", "\\", "count", "(", "$", "this", "->", "running", ")", "<", "$", ...
This method removes ExecutableTest objects from the pending collection and adds them to the running collection. It is also in charge of recycling and acquiring available test tokens for use.
[ "This", "method", "removes", "ExecutableTest", "objects", "from", "the", "pending", "collection", "and", "adds", "them", "to", "the", "running", "collection", ".", "It", "is", "also", "in", "charge", "of", "recycling", "and", "acquiring", "available", "test", ...
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Runners/PHPUnit/Runner.php#L78-L93
train
paratestphp/paratest
src/Runners/PHPUnit/Runner.php
Runner.setExitCode
private function setExitCode(ExecutableTest $test) { $exit = $test->getExitCode(); if ($exit > $this->exitcode) { $this->exitcode = $exit; } }
php
private function setExitCode(ExecutableTest $test) { $exit = $test->getExitCode(); if ($exit > $this->exitcode) { $this->exitcode = $exit; } }
[ "private", "function", "setExitCode", "(", "ExecutableTest", "$", "test", ")", "{", "$", "exit", "=", "$", "test", "->", "getExitCode", "(", ")", ";", "if", "(", "$", "exit", ">", "$", "this", "->", "exitcode", ")", "{", "$", "this", "->", "exitcode"...
If the provided test object has an exit code higher than the currently set exit code, that exit code will be set as the overall exit code. @param ExecutableTest $test
[ "If", "the", "provided", "test", "object", "has", "an", "exit", "code", "higher", "than", "the", "currently", "set", "exit", "code", "that", "exit", "code", "will", "be", "set", "as", "the", "overall", "exit", "code", "." ]
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Runners/PHPUnit/Runner.php#L139-L145
train
paratestphp/paratest
src/Runners/PHPUnit/Runner.php
Runner.initTokens
protected function initTokens() { $this->tokens = []; for ($i = 1; $i <= $this->options->processes; ++$i) { $this->tokens[$i] = ['token' => $i, 'unique' => uniqid(sprintf('%s_', $i)), 'available' => true]; } }
php
protected function initTokens() { $this->tokens = []; for ($i = 1; $i <= $this->options->processes; ++$i) { $this->tokens[$i] = ['token' => $i, 'unique' => uniqid(sprintf('%s_', $i)), 'available' => true]; } }
[ "protected", "function", "initTokens", "(", ")", "{", "$", "this", "->", "tokens", "=", "[", "]", ";", "for", "(", "$", "i", "=", "1", ";", "$", "i", "<=", "$", "this", "->", "options", "->", "processes", ";", "++", "$", "i", ")", "{", "$", "...
Initialize the available test tokens based on how many processes ParaTest will be run in.
[ "Initialize", "the", "available", "test", "tokens", "based", "on", "how", "many", "processes", "ParaTest", "will", "be", "run", "in", "." ]
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Runners/PHPUnit/Runner.php#L151-L157
train
paratestphp/paratest
src/Runners/PHPUnit/Runner.php
Runner.releaseToken
protected function releaseToken($tokenIdentifier) { $filtered = array_filter($this->tokens, function ($val) use ($tokenIdentifier) { return $val['token'] === $tokenIdentifier; }); $keys = array_keys($filtered); $this->tokens[$keys[0]]['available'] = true; }
php
protected function releaseToken($tokenIdentifier) { $filtered = array_filter($this->tokens, function ($val) use ($tokenIdentifier) { return $val['token'] === $tokenIdentifier; }); $keys = array_keys($filtered); $this->tokens[$keys[0]]['available'] = true; }
[ "protected", "function", "releaseToken", "(", "$", "tokenIdentifier", ")", "{", "$", "filtered", "=", "array_filter", "(", "$", "this", "->", "tokens", ",", "function", "(", "$", "val", ")", "use", "(", "$", "tokenIdentifier", ")", "{", "return", "$", "v...
Flag a token as available for use. @param string $tokenIdentifier
[ "Flag", "a", "token", "as", "available", "for", "use", "." ]
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Runners/PHPUnit/Runner.php#L181-L188
train
paratestphp/paratest
src/Runners/PHPUnit/Runner.php
Runner.acquireToken
protected function acquireToken($tokenIdentifier) { $filtered = array_filter($this->tokens, function ($val) use ($tokenIdentifier) { return $val['token'] === $tokenIdentifier; }); $keys = array_keys($filtered); $this->tokens[$keys[0]]['available'] = false; }
php
protected function acquireToken($tokenIdentifier) { $filtered = array_filter($this->tokens, function ($val) use ($tokenIdentifier) { return $val['token'] === $tokenIdentifier; }); $keys = array_keys($filtered); $this->tokens[$keys[0]]['available'] = false; }
[ "protected", "function", "acquireToken", "(", "$", "tokenIdentifier", ")", "{", "$", "filtered", "=", "array_filter", "(", "$", "this", "->", "tokens", ",", "function", "(", "$", "val", ")", "use", "(", "$", "tokenIdentifier", ")", "{", "return", "$", "v...
Flag a token as acquired and not available for use. @param string $tokenIdentifier
[ "Flag", "a", "token", "as", "acquired", "and", "not", "available", "for", "use", "." ]
34094d805bcabb6d9c2e20554c702c436c8a50d3
https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Runners/PHPUnit/Runner.php#L195-L202
train
twigphp/Twig-extensions
lib/Twig/Extensions/Extension/Date.php
Twig_Extensions_Extension_Date.diff
public function diff(Twig_Environment $env, $date, $now = null) { // Convert both dates to DateTime instances. $date = twig_date_converter($env, $date); $now = twig_date_converter($env, $now); // Get the difference between the two DateTime objects. $diff = $date->diff($now); // Check for each interval if it appears in the $diff object. foreach (self::$units as $attribute => $unit) { $count = $diff->$attribute; if (0 !== $count) { return $this->getPluralizedInterval($count, $diff->invert, $unit); } } return ''; }
php
public function diff(Twig_Environment $env, $date, $now = null) { // Convert both dates to DateTime instances. $date = twig_date_converter($env, $date); $now = twig_date_converter($env, $now); // Get the difference between the two DateTime objects. $diff = $date->diff($now); // Check for each interval if it appears in the $diff object. foreach (self::$units as $attribute => $unit) { $count = $diff->$attribute; if (0 !== $count) { return $this->getPluralizedInterval($count, $diff->invert, $unit); } } return ''; }
[ "public", "function", "diff", "(", "Twig_Environment", "$", "env", ",", "$", "date", ",", "$", "now", "=", "null", ")", "{", "// Convert both dates to DateTime instances.", "$", "date", "=", "twig_date_converter", "(", "$", "env", ",", "$", "date", ")", ";",...
Filter for converting dates to a time ago string like Facebook and Twitter has. @param Twig_Environment $env a Twig_Environment instance @param string|DateTime $date a string or DateTime object to convert @param string|DateTime $now A string or DateTime object to compare with. If none given, the current time will be used. @return string the converted time
[ "Filter", "for", "converting", "dates", "to", "a", "time", "ago", "string", "like", "Facebook", "and", "Twitter", "has", "." ]
9aefd75d87dea6d0dfbf04469ce939b4b29dabc9
https://github.com/twigphp/Twig-extensions/blob/9aefd75d87dea6d0dfbf04469ce939b4b29dabc9/lib/Twig/Extensions/Extension/Date.php#L62-L81
train
laravelista/comments
src/CommentsController.php
CommentsController.store
public function store(Request $request) { $this->authorize('create-comment', Comment::class); $this->validate($request, [ 'commentable_type' => 'required|string', 'commentable_id' => 'required|integer|min:1', 'message' => 'required|string' ]); $model = $request->commentable_type::findOrFail($request->commentable_id); $comment = new Comment; $comment->commenter()->associate(auth()->user()); $comment->commentable()->associate($model); $comment->comment = $request->message; $comment->save(); return redirect()->to(url()->previous() . '#comment-' . $comment->id); }
php
public function store(Request $request) { $this->authorize('create-comment', Comment::class); $this->validate($request, [ 'commentable_type' => 'required|string', 'commentable_id' => 'required|integer|min:1', 'message' => 'required|string' ]); $model = $request->commentable_type::findOrFail($request->commentable_id); $comment = new Comment; $comment->commenter()->associate(auth()->user()); $comment->commentable()->associate($model); $comment->comment = $request->message; $comment->save(); return redirect()->to(url()->previous() . '#comment-' . $comment->id); }
[ "public", "function", "store", "(", "Request", "$", "request", ")", "{", "$", "this", "->", "authorize", "(", "'create-comment'", ",", "Comment", "::", "class", ")", ";", "$", "this", "->", "validate", "(", "$", "request", ",", "[", "'commentable_type'", ...
Creates a new comment for given model.
[ "Creates", "a", "new", "comment", "for", "given", "model", "." ]
6940da1c250c702c80983b8f9a4d41a2ef759f64
https://github.com/laravelista/comments/blob/6940da1c250c702c80983b8f9a4d41a2ef759f64/src/CommentsController.php#L22-L41
train
laravelista/comments
src/CommentsController.php
CommentsController.update
public function update(Request $request, Comment $comment) { $this->authorize('edit-comment', $comment); $this->validate($request, [ 'message' => 'required|string' ]); $comment->update([ 'comment' => $request->message ]); return redirect()->to(url()->previous() . '#comment-' . $comment->id); }
php
public function update(Request $request, Comment $comment) { $this->authorize('edit-comment', $comment); $this->validate($request, [ 'message' => 'required|string' ]); $comment->update([ 'comment' => $request->message ]); return redirect()->to(url()->previous() . '#comment-' . $comment->id); }
[ "public", "function", "update", "(", "Request", "$", "request", ",", "Comment", "$", "comment", ")", "{", "$", "this", "->", "authorize", "(", "'edit-comment'", ",", "$", "comment", ")", ";", "$", "this", "->", "validate", "(", "$", "request", ",", "["...
Updates the message of the comment.
[ "Updates", "the", "message", "of", "the", "comment", "." ]
6940da1c250c702c80983b8f9a4d41a2ef759f64
https://github.com/laravelista/comments/blob/6940da1c250c702c80983b8f9a4d41a2ef759f64/src/CommentsController.php#L46-L59
train
laravelista/comments
src/CommentsController.php
CommentsController.reply
public function reply(Request $request, Comment $comment) { $this->authorize('reply-to-comment', $comment); $this->validate($request, [ 'message' => 'required|string' ]); $reply = new Comment; $reply->commenter()->associate(auth()->user()); $reply->commentable()->associate($comment->commentable); $reply->parent()->associate($comment); $reply->comment = $request->message; $reply->save(); return redirect()->to(url()->previous() . '#comment-' . $reply->id); }
php
public function reply(Request $request, Comment $comment) { $this->authorize('reply-to-comment', $comment); $this->validate($request, [ 'message' => 'required|string' ]); $reply = new Comment; $reply->commenter()->associate(auth()->user()); $reply->commentable()->associate($comment->commentable); $reply->parent()->associate($comment); $reply->comment = $request->message; $reply->save(); return redirect()->to(url()->previous() . '#comment-' . $reply->id); }
[ "public", "function", "reply", "(", "Request", "$", "request", ",", "Comment", "$", "comment", ")", "{", "$", "this", "->", "authorize", "(", "'reply-to-comment'", ",", "$", "comment", ")", ";", "$", "this", "->", "validate", "(", "$", "request", ",", ...
Creates a reply "comment" to a comment.
[ "Creates", "a", "reply", "comment", "to", "a", "comment", "." ]
6940da1c250c702c80983b8f9a4d41a2ef759f64
https://github.com/laravelista/comments/blob/6940da1c250c702c80983b8f9a4d41a2ef759f64/src/CommentsController.php#L76-L92
train
yii2mod/yii2-comments
controllers/DefaultController.php
DefaultController.getCommentAttributesFromEntity
protected function getCommentAttributesFromEntity($entity) { $decryptEntity = Yii::$app->getSecurity()->decryptByKey(utf8_decode($entity), $this->getModule()->id); if (false !== $decryptEntity) { return Json::decode($decryptEntity); } throw new BadRequestHttpException(Yii::t('yii2mod.comments', 'Oops, something went wrong. Please try again later.')); }
php
protected function getCommentAttributesFromEntity($entity) { $decryptEntity = Yii::$app->getSecurity()->decryptByKey(utf8_decode($entity), $this->getModule()->id); if (false !== $decryptEntity) { return Json::decode($decryptEntity); } throw new BadRequestHttpException(Yii::t('yii2mod.comments', 'Oops, something went wrong. Please try again later.')); }
[ "protected", "function", "getCommentAttributesFromEntity", "(", "$", "entity", ")", "{", "$", "decryptEntity", "=", "Yii", "::", "$", "app", "->", "getSecurity", "(", ")", "->", "decryptByKey", "(", "utf8_decode", "(", "$", "entity", ")", ",", "$", "this", ...
Get list of attributes from encrypted entity @param $entity string encrypted entity @return array|mixed @throws BadRequestHttpException
[ "Get", "list", "of", "attributes", "from", "encrypted", "entity" ]
30cbeecf45b41ee80e12460c7af1bea7efcfc0ce
https://github.com/yii2mod/yii2-comments/blob/30cbeecf45b41ee80e12460c7af1bea7efcfc0ce/controllers/DefaultController.php#L177-L185
train
yii2mod/yii2-comments
widgets/Comment.php
Comment.init
public function init() { parent::init(); if (empty($this->model)) { throw new InvalidConfigException(Yii::t('yii2mod.comments', 'The "model" property must be set.')); } if (empty($this->pjaxContainerId)) { $this->pjaxContainerId = 'comment-pjax-container-' . $this->getId(); } if (empty($this->model->{$this->entityIdAttribute})) { throw new InvalidConfigException(Yii::t('yii2mod.comments', 'The "entityIdAttribute" value for widget model cannot be empty.')); } $this->entity = hash('crc32', get_class($this->model)); $this->entityId = $this->model->{$this->entityIdAttribute}; if (empty($this->relatedTo)) { $this->relatedTo = get_class($this->model) . ':' . $this->entityId; } $this->encryptedEntity = $this->getEncryptedEntity(); $this->commentWrapperId = $this->entity . $this->entityId; $this->registerAssets(); }
php
public function init() { parent::init(); if (empty($this->model)) { throw new InvalidConfigException(Yii::t('yii2mod.comments', 'The "model" property must be set.')); } if (empty($this->pjaxContainerId)) { $this->pjaxContainerId = 'comment-pjax-container-' . $this->getId(); } if (empty($this->model->{$this->entityIdAttribute})) { throw new InvalidConfigException(Yii::t('yii2mod.comments', 'The "entityIdAttribute" value for widget model cannot be empty.')); } $this->entity = hash('crc32', get_class($this->model)); $this->entityId = $this->model->{$this->entityIdAttribute}; if (empty($this->relatedTo)) { $this->relatedTo = get_class($this->model) . ':' . $this->entityId; } $this->encryptedEntity = $this->getEncryptedEntity(); $this->commentWrapperId = $this->entity . $this->entityId; $this->registerAssets(); }
[ "public", "function", "init", "(", ")", "{", "parent", "::", "init", "(", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "model", ")", ")", "{", "throw", "new", "InvalidConfigException", "(", "Yii", "::", "t", "(", "'yii2mod.comments'", ",", "...
Initializes the widget params.
[ "Initializes", "the", "widget", "params", "." ]
30cbeecf45b41ee80e12460c7af1bea7efcfc0ce
https://github.com/yii2mod/yii2-comments/blob/30cbeecf45b41ee80e12460c7af1bea7efcfc0ce/widgets/Comment.php#L103-L130
train
yii2mod/yii2-comments
widgets/Comment.php
Comment.getEncryptedEntity
protected function getEncryptedEntity() { return utf8_encode(Yii::$app->getSecurity()->encryptByKey(Json::encode([ 'entity' => $this->entity, 'entityId' => $this->entityId, 'relatedTo' => $this->relatedTo, ]), $this->getModule()->id)); }
php
protected function getEncryptedEntity() { return utf8_encode(Yii::$app->getSecurity()->encryptByKey(Json::encode([ 'entity' => $this->entity, 'entityId' => $this->entityId, 'relatedTo' => $this->relatedTo, ]), $this->getModule()->id)); }
[ "protected", "function", "getEncryptedEntity", "(", ")", "{", "return", "utf8_encode", "(", "Yii", "::", "$", "app", "->", "getSecurity", "(", ")", "->", "encryptByKey", "(", "Json", "::", "encode", "(", "[", "'entity'", "=>", "$", "this", "->", "entity", ...
Get encrypted entity @return string
[ "Get", "encrypted", "entity" ]
30cbeecf45b41ee80e12460c7af1bea7efcfc0ce
https://github.com/yii2mod/yii2-comments/blob/30cbeecf45b41ee80e12460c7af1bea7efcfc0ce/widgets/Comment.php#L164-L171
train
yii2mod/yii2-comments
widgets/Comment.php
Comment.getCommentDataProvider
protected function getCommentDataProvider($commentClass) { $dataProvider = new ArrayDataProvider($this->dataProviderConfig); if (!isset($this->dataProviderConfig['allModels'])) { $dataProvider->allModels = $commentClass::getTree($this->entity, $this->entityId, $this->maxLevel); } return $dataProvider; }
php
protected function getCommentDataProvider($commentClass) { $dataProvider = new ArrayDataProvider($this->dataProviderConfig); if (!isset($this->dataProviderConfig['allModels'])) { $dataProvider->allModels = $commentClass::getTree($this->entity, $this->entityId, $this->maxLevel); } return $dataProvider; }
[ "protected", "function", "getCommentDataProvider", "(", "$", "commentClass", ")", "{", "$", "dataProvider", "=", "new", "ArrayDataProvider", "(", "$", "this", "->", "dataProviderConfig", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "dataProviderC...
Get comment ArrayDataProvider @param CommentModel $commentClass @return ArrayDataProvider
[ "Get", "comment", "ArrayDataProvider" ]
30cbeecf45b41ee80e12460c7af1bea7efcfc0ce
https://github.com/yii2mod/yii2-comments/blob/30cbeecf45b41ee80e12460c7af1bea7efcfc0ce/widgets/Comment.php#L201-L209
train
yii2mod/yii2-comments
models/CommentModel.php
CommentModel.getTree
public static function getTree($entity, $entityId, $maxLevel = null) { $query = static::find() ->alias('c') ->approved() ->andWhere([ 'c.entityId' => $entityId, 'c.entity' => $entity, ]) ->orderBy(['c.parentId' => SORT_ASC, 'c.createdAt' => SORT_ASC]) ->with(['author']); if ($maxLevel > 0) { $query->andWhere(['<=', 'c.level', $maxLevel]); } $models = $query->all(); if (!empty($models)) { $models = static::buildTree($models); } return $models; }
php
public static function getTree($entity, $entityId, $maxLevel = null) { $query = static::find() ->alias('c') ->approved() ->andWhere([ 'c.entityId' => $entityId, 'c.entity' => $entity, ]) ->orderBy(['c.parentId' => SORT_ASC, 'c.createdAt' => SORT_ASC]) ->with(['author']); if ($maxLevel > 0) { $query->andWhere(['<=', 'c.level', $maxLevel]); } $models = $query->all(); if (!empty($models)) { $models = static::buildTree($models); } return $models; }
[ "public", "static", "function", "getTree", "(", "$", "entity", ",", "$", "entityId", ",", "$", "maxLevel", "=", "null", ")", "{", "$", "query", "=", "static", "::", "find", "(", ")", "->", "alias", "(", "'c'", ")", "->", "approved", "(", ")", "->",...
Get comments tree. @param string $entity @param string $entityId @param null $maxLevel @return array|ActiveRecord[]
[ "Get", "comments", "tree", "." ]
30cbeecf45b41ee80e12460c7af1bea7efcfc0ce
https://github.com/yii2mod/yii2-comments/blob/30cbeecf45b41ee80e12460c7af1bea7efcfc0ce/models/CommentModel.php#L235-L258
train
yii2mod/yii2-comments
models/CommentModel.php
CommentModel.buildTree
protected static function buildTree(&$data, $rootID = 0) { $tree = []; foreach ($data as $id => $node) { if ($node->parentId == $rootID) { unset($data[$id]); $node->children = self::buildTree($data, $node->id); $tree[] = $node; } } return $tree; }
php
protected static function buildTree(&$data, $rootID = 0) { $tree = []; foreach ($data as $id => $node) { if ($node->parentId == $rootID) { unset($data[$id]); $node->children = self::buildTree($data, $node->id); $tree[] = $node; } } return $tree; }
[ "protected", "static", "function", "buildTree", "(", "&", "$", "data", ",", "$", "rootID", "=", "0", ")", "{", "$", "tree", "=", "[", "]", ";", "foreach", "(", "$", "data", "as", "$", "id", "=>", "$", "node", ")", "{", "if", "(", "$", "node", ...
Build comments tree. @param array $data comments list @param int $rootID @return array|ActiveRecord[]
[ "Build", "comments", "tree", "." ]
30cbeecf45b41ee80e12460c7af1bea7efcfc0ce
https://github.com/yii2mod/yii2-comments/blob/30cbeecf45b41ee80e12460c7af1bea7efcfc0ce/models/CommentModel.php#L268-L281
train
yii2mod/yii2-comments
models/CommentModel.php
CommentModel.getAuthors
public static function getAuthors() { $query = static::find() ->alias('c') ->select(['c.createdBy', 'a.username']) ->joinWith('author a') ->groupBy(['c.createdBy', 'a.username']) ->orderBy('a.username') ->asArray() ->all(); return ArrayHelper::map($query, 'createdBy', 'author.username'); }
php
public static function getAuthors() { $query = static::find() ->alias('c') ->select(['c.createdBy', 'a.username']) ->joinWith('author a') ->groupBy(['c.createdBy', 'a.username']) ->orderBy('a.username') ->asArray() ->all(); return ArrayHelper::map($query, 'createdBy', 'author.username'); }
[ "public", "static", "function", "getAuthors", "(", ")", "{", "$", "query", "=", "static", "::", "find", "(", ")", "->", "alias", "(", "'c'", ")", "->", "select", "(", "[", "'c.createdBy'", ",", "'a.username'", "]", ")", "->", "joinWith", "(", "'author ...
Get list of all authors @return array
[ "Get", "list", "of", "all", "authors" ]
30cbeecf45b41ee80e12460c7af1bea7efcfc0ce
https://github.com/yii2mod/yii2-comments/blob/30cbeecf45b41ee80e12460c7af1bea7efcfc0ce/models/CommentModel.php#L354-L366
train
yii2mod/yii2-comments
models/CommentModel.php
CommentModel.beforeModeration
public function beforeModeration() { $descendantIds = ArrayHelper::getColumn($this->getDescendants()->asArray()->all(), 'id'); if (!empty($descendantIds)) { static::updateAll(['status' => $this->status], ['id' => $descendantIds]); } return true; }
php
public function beforeModeration() { $descendantIds = ArrayHelper::getColumn($this->getDescendants()->asArray()->all(), 'id'); if (!empty($descendantIds)) { static::updateAll(['status' => $this->status], ['id' => $descendantIds]); } return true; }
[ "public", "function", "beforeModeration", "(", ")", "{", "$", "descendantIds", "=", "ArrayHelper", "::", "getColumn", "(", "$", "this", "->", "getDescendants", "(", ")", "->", "asArray", "(", ")", "->", "all", "(", ")", ",", "'id'", ")", ";", "if", "("...
Before moderation event @return bool
[ "Before", "moderation", "event" ]
30cbeecf45b41ee80e12460c7af1bea7efcfc0ce
https://github.com/yii2mod/yii2-comments/blob/30cbeecf45b41ee80e12460c7af1bea7efcfc0ce/models/CommentModel.php#L404-L413
train
nexylan/slack
src/Client.php
Client.getAttachmentsAsArrays
private function getAttachmentsAsArrays(Message $message): array { $attachments = []; foreach ($message->getAttachments() as $attachment) { $attachments[] = $attachment->toArray(); } return $attachments; }
php
private function getAttachmentsAsArrays(Message $message): array { $attachments = []; foreach ($message->getAttachments() as $attachment) { $attachments[] = $attachment->toArray(); } return $attachments; }
[ "private", "function", "getAttachmentsAsArrays", "(", "Message", "$", "message", ")", ":", "array", "{", "$", "attachments", "=", "[", "]", ";", "foreach", "(", "$", "message", "->", "getAttachments", "(", ")", "as", "$", "attachment", ")", "{", "$", "at...
Get the attachments in array form. @param \Nexy\Slack\Message $message @return array
[ "Get", "the", "attachments", "in", "array", "form", "." ]
ba417382d0c54cc7c7e0ca2719e39a4f659236dc
https://github.com/nexylan/slack/blob/ba417382d0c54cc7c7e0ca2719e39a4f659236dc/src/Client.php#L185-L194
train
Behat/Gherkin
src/Behat/Gherkin/Gherkin.php
Gherkin.setBasePath
public function setBasePath($path) { foreach ($this->loaders as $loader) { if ($loader instanceof FileLoaderInterface) { $loader->setBasePath($path); } } }
php
public function setBasePath($path) { foreach ($this->loaders as $loader) { if ($loader instanceof FileLoaderInterface) { $loader->setBasePath($path); } } }
[ "public", "function", "setBasePath", "(", "$", "path", ")", "{", "foreach", "(", "$", "this", "->", "loaders", "as", "$", "loader", ")", "{", "if", "(", "$", "loader", "instanceof", "FileLoaderInterface", ")", "{", "$", "loader", "->", "setBasePath", "("...
Sets base features path. @param string $path Loaders base path
[ "Sets", "base", "features", "path", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Gherkin.php#L73-L80
train
Behat/Gherkin
src/Behat/Gherkin/Gherkin.php
Gherkin.load
public function load($resource, array $filters = array()) { $filters = array_merge($this->filters, $filters); $matches = array(); if (preg_match('/^(.*)\:(\d+)-(\d+|\*)$/', $resource, $matches)) { $resource = $matches[1]; $filters[] = new LineRangeFilter($matches[2], $matches[3]); } elseif (preg_match('/^(.*)\:(\d+)$/', $resource, $matches)) { $resource = $matches[1]; $filters[] = new LineFilter($matches[2]); } $loader = $this->resolveLoader($resource); if (null === $loader) { return array(); } $features = array(); foreach ($loader->load($resource) as $feature) { foreach ($filters as $filter) { $feature = $filter->filterFeature($feature); if (!$feature->hasScenarios() && !$filter->isFeatureMatch($feature)) { continue 2; } } $features[] = $feature; } return $features; }
php
public function load($resource, array $filters = array()) { $filters = array_merge($this->filters, $filters); $matches = array(); if (preg_match('/^(.*)\:(\d+)-(\d+|\*)$/', $resource, $matches)) { $resource = $matches[1]; $filters[] = new LineRangeFilter($matches[2], $matches[3]); } elseif (preg_match('/^(.*)\:(\d+)$/', $resource, $matches)) { $resource = $matches[1]; $filters[] = new LineFilter($matches[2]); } $loader = $this->resolveLoader($resource); if (null === $loader) { return array(); } $features = array(); foreach ($loader->load($resource) as $feature) { foreach ($filters as $filter) { $feature = $filter->filterFeature($feature); if (!$feature->hasScenarios() && !$filter->isFeatureMatch($feature)) { continue 2; } } $features[] = $feature; } return $features; }
[ "public", "function", "load", "(", "$", "resource", ",", "array", "$", "filters", "=", "array", "(", ")", ")", "{", "$", "filters", "=", "array_merge", "(", "$", "this", "->", "filters", ",", "$", "filters", ")", ";", "$", "matches", "=", "array", ...
Loads & filters resource with added loaders. @param mixed $resource Resource to load @param FeatureFilterInterface[] $filters Additional filters @return array
[ "Loads", "&", "filters", "resource", "with", "added", "loaders", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Gherkin.php#L90-L123
train
Behat/Gherkin
src/Behat/Gherkin/Gherkin.php
Gherkin.resolveLoader
public function resolveLoader($resource) { foreach ($this->loaders as $loader) { if ($loader->supports($resource)) { return $loader; } } return null; }
php
public function resolveLoader($resource) { foreach ($this->loaders as $loader) { if ($loader->supports($resource)) { return $loader; } } return null; }
[ "public", "function", "resolveLoader", "(", "$", "resource", ")", "{", "foreach", "(", "$", "this", "->", "loaders", "as", "$", "loader", ")", "{", "if", "(", "$", "loader", "->", "supports", "(", "$", "resource", ")", ")", "{", "return", "$", "loade...
Resolves loader by resource. @param mixed $resource Resource to load @return LoaderInterface
[ "Resolves", "loader", "by", "resource", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Gherkin.php#L132-L141
train
Behat/Gherkin
src/Behat/Gherkin/Lexer.php
Lexer.analyse
public function analyse($input, $language = 'en') { // try to detect unsupported encoding if ('UTF-8' !== mb_detect_encoding($input, 'UTF-8', true)) { throw new LexerException('Feature file is not in UTF8 encoding'); } $input = strtr($input, array("\r\n" => "\n", "\r" => "\n")); $this->lines = explode("\n", $input); $this->linesCount = count($this->lines); $this->line = $this->lines[0]; $this->lineNumber = 1; $this->trimmedLine = null; $this->eos = false; $this->deferredObjects = array(); $this->deferredObjectsCount = 0; $this->stashedToken = null; $this->inPyString = false; $this->pyStringSwallow = 0; $this->featureStarted = false; $this->allowMultilineArguments = false; $this->allowSteps = false; $this->keywords->setLanguage($this->language = $language); $this->keywordsCache = array(); $this->stepKeywordTypesCache = array(); }
php
public function analyse($input, $language = 'en') { // try to detect unsupported encoding if ('UTF-8' !== mb_detect_encoding($input, 'UTF-8', true)) { throw new LexerException('Feature file is not in UTF8 encoding'); } $input = strtr($input, array("\r\n" => "\n", "\r" => "\n")); $this->lines = explode("\n", $input); $this->linesCount = count($this->lines); $this->line = $this->lines[0]; $this->lineNumber = 1; $this->trimmedLine = null; $this->eos = false; $this->deferredObjects = array(); $this->deferredObjectsCount = 0; $this->stashedToken = null; $this->inPyString = false; $this->pyStringSwallow = 0; $this->featureStarted = false; $this->allowMultilineArguments = false; $this->allowSteps = false; $this->keywords->setLanguage($this->language = $language); $this->keywordsCache = array(); $this->stepKeywordTypesCache = array(); }
[ "public", "function", "analyse", "(", "$", "input", ",", "$", "language", "=", "'en'", ")", "{", "// try to detect unsupported encoding", "if", "(", "'UTF-8'", "!==", "mb_detect_encoding", "(", "$", "input", ",", "'UTF-8'", ",", "true", ")", ")", "{", "throw...
Sets lexer input. @param string $input Input string @param string $language Language name @throws Exception\LexerException
[ "Sets", "lexer", "input", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Lexer.php#L60-L89
train
Behat/Gherkin
src/Behat/Gherkin/Lexer.php
Lexer.predictToken
public function predictToken() { if (null === $this->stashedToken) { $this->stashedToken = $this->getNextToken(); } return $this->stashedToken; }
php
public function predictToken() { if (null === $this->stashedToken) { $this->stashedToken = $this->getNextToken(); } return $this->stashedToken; }
[ "public", "function", "predictToken", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "stashedToken", ")", "{", "$", "this", "->", "stashedToken", "=", "$", "this", "->", "getNextToken", "(", ")", ";", "}", "return", "$", "this", "->", "s...
Predicts for number of tokens. @return array
[ "Predicts", "for", "number", "of", "tokens", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Lexer.php#L128-L135
train
Behat/Gherkin
src/Behat/Gherkin/Lexer.php
Lexer.takeToken
public function takeToken($type, $value = null) { return array( 'type' => $type, 'line' => $this->lineNumber, 'value' => $value ?: null, 'deferred' => false ); }
php
public function takeToken($type, $value = null) { return array( 'type' => $type, 'line' => $this->lineNumber, 'value' => $value ?: null, 'deferred' => false ); }
[ "public", "function", "takeToken", "(", "$", "type", ",", "$", "value", "=", "null", ")", "{", "return", "array", "(", "'type'", "=>", "$", "type", ",", "'line'", "=>", "$", "this", "->", "lineNumber", ",", "'value'", "=>", "$", "value", "?", ":", ...
Constructs token with specified parameters. @param string $type Token type @param string $value Token value @return array
[ "Constructs", "token", "with", "specified", "parameters", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Lexer.php#L145-L153
train
Behat/Gherkin
src/Behat/Gherkin/Lexer.php
Lexer.consumeLine
protected function consumeLine() { ++$this->lineNumber; if (($this->lineNumber - 1) === $this->linesCount) { $this->eos = true; return; } $this->line = $this->lines[$this->lineNumber - 1]; $this->trimmedLine = null; }
php
protected function consumeLine() { ++$this->lineNumber; if (($this->lineNumber - 1) === $this->linesCount) { $this->eos = true; return; } $this->line = $this->lines[$this->lineNumber - 1]; $this->trimmedLine = null; }
[ "protected", "function", "consumeLine", "(", ")", "{", "++", "$", "this", "->", "lineNumber", ";", "if", "(", "(", "$", "this", "->", "lineNumber", "-", "1", ")", "===", "$", "this", "->", "linesCount", ")", "{", "$", "this", "->", "eos", "=", "tru...
Consumes line from input & increments line counter.
[ "Consumes", "line", "from", "input", "&", "increments", "line", "counter", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Lexer.php#L158-L170
train
Behat/Gherkin
src/Behat/Gherkin/Lexer.php
Lexer.getTrimmedLine
protected function getTrimmedLine() { return null !== $this->trimmedLine ? $this->trimmedLine : $this->trimmedLine = trim($this->line); }
php
protected function getTrimmedLine() { return null !== $this->trimmedLine ? $this->trimmedLine : $this->trimmedLine = trim($this->line); }
[ "protected", "function", "getTrimmedLine", "(", ")", "{", "return", "null", "!==", "$", "this", "->", "trimmedLine", "?", "$", "this", "->", "trimmedLine", ":", "$", "this", "->", "trimmedLine", "=", "trim", "(", "$", "this", "->", "line", ")", ";", "}...
Returns trimmed version of line. @return string
[ "Returns", "trimmed", "version", "of", "line", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Lexer.php#L177-L180
train
Behat/Gherkin
src/Behat/Gherkin/Lexer.php
Lexer.getNextToken
protected function getNextToken() { return $this->getDeferredToken() ?: $this->scanEOS() ?: $this->scanLanguage() ?: $this->scanComment() ?: $this->scanPyStringOp() ?: $this->scanPyStringContent() ?: $this->scanStep() ?: $this->scanScenario() ?: $this->scanBackground() ?: $this->scanOutline() ?: $this->scanExamples() ?: $this->scanFeature() ?: $this->scanTags() ?: $this->scanTableRow() ?: $this->scanNewline() ?: $this->scanText(); }
php
protected function getNextToken() { return $this->getDeferredToken() ?: $this->scanEOS() ?: $this->scanLanguage() ?: $this->scanComment() ?: $this->scanPyStringOp() ?: $this->scanPyStringContent() ?: $this->scanStep() ?: $this->scanScenario() ?: $this->scanBackground() ?: $this->scanOutline() ?: $this->scanExamples() ?: $this->scanFeature() ?: $this->scanTags() ?: $this->scanTableRow() ?: $this->scanNewline() ?: $this->scanText(); }
[ "protected", "function", "getNextToken", "(", ")", "{", "return", "$", "this", "->", "getDeferredToken", "(", ")", "?", ":", "$", "this", "->", "scanEOS", "(", ")", "?", ":", "$", "this", "->", "scanLanguage", "(", ")", "?", ":", "$", "this", "->", ...
Returns next token from input. @return array
[ "Returns", "next", "token", "from", "input", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Lexer.php#L216-L234
train
Behat/Gherkin
src/Behat/Gherkin/Lexer.php
Lexer.scanInput
protected function scanInput($regex, $type) { if (!preg_match($regex, $this->line, $matches)) { return null; } $token = $this->takeToken($type, $matches[1]); $this->consumeLine(); return $token; }
php
protected function scanInput($regex, $type) { if (!preg_match($regex, $this->line, $matches)) { return null; } $token = $this->takeToken($type, $matches[1]); $this->consumeLine(); return $token; }
[ "protected", "function", "scanInput", "(", "$", "regex", ",", "$", "type", ")", "{", "if", "(", "!", "preg_match", "(", "$", "regex", ",", "$", "this", "->", "line", ",", "$", "matches", ")", ")", "{", "return", "null", ";", "}", "$", "token", "=...
Scans for token with specified regex. @param string $regex Regular expression @param string $type Expected token type @return null|array
[ "Scans", "for", "token", "with", "specified", "regex", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Lexer.php#L244-L254
train
Behat/Gherkin
src/Behat/Gherkin/Lexer.php
Lexer.scanInputForKeywords
protected function scanInputForKeywords($keywords, $type) { if (!preg_match('/^(\s*)(' . $keywords . '):\s*(.*)/u', $this->line, $matches)) { return null; } $token = $this->takeToken($type, $matches[3]); $token['keyword'] = $matches[2]; $token['indent'] = mb_strlen($matches[1], 'utf8'); $this->consumeLine(); // turn off language searching if ('Feature' === $type) { $this->featureStarted = true; } // turn off PyString and Table searching if ('Feature' === $type || 'Scenario' === $type || 'Outline' === $type) { $this->allowMultilineArguments = false; } elseif ('Examples' === $type) { $this->allowMultilineArguments = true; } // turn on steps searching if ('Scenario' === $type || 'Background' === $type || 'Outline' === $type) { $this->allowSteps = true; } return $token; }
php
protected function scanInputForKeywords($keywords, $type) { if (!preg_match('/^(\s*)(' . $keywords . '):\s*(.*)/u', $this->line, $matches)) { return null; } $token = $this->takeToken($type, $matches[3]); $token['keyword'] = $matches[2]; $token['indent'] = mb_strlen($matches[1], 'utf8'); $this->consumeLine(); // turn off language searching if ('Feature' === $type) { $this->featureStarted = true; } // turn off PyString and Table searching if ('Feature' === $type || 'Scenario' === $type || 'Outline' === $type) { $this->allowMultilineArguments = false; } elseif ('Examples' === $type) { $this->allowMultilineArguments = true; } // turn on steps searching if ('Scenario' === $type || 'Background' === $type || 'Outline' === $type) { $this->allowSteps = true; } return $token; }
[ "protected", "function", "scanInputForKeywords", "(", "$", "keywords", ",", "$", "type", ")", "{", "if", "(", "!", "preg_match", "(", "'/^(\\s*)('", ".", "$", "keywords", ".", "'):\\s*(.*)/u'", ",", "$", "this", "->", "line", ",", "$", "matches", ")", ")...
Scans for token with specified keywords. @param string $keywords Keywords (splitted with |) @param string $type Expected token type @return null|array
[ "Scans", "for", "token", "with", "specified", "keywords", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Lexer.php#L264-L294
train
Behat/Gherkin
src/Behat/Gherkin/Lexer.php
Lexer.getKeywords
protected function getKeywords($type) { if (!isset($this->keywordsCache[$type])) { $getter = 'get' . $type . 'Keywords'; $keywords = $this->keywords->$getter(); if ('Step' === $type) { $padded = array(); foreach (explode('|', $keywords) as $keyword) { $padded[] = false !== mb_strpos($keyword, '<', 0, 'utf8') ? preg_quote(mb_substr($keyword, 0, -1, 'utf8'), '/') . '\s*' : preg_quote($keyword, '/') . '\s+'; } $keywords = implode('|', $padded); } $this->keywordsCache[$type] = $keywords; } return $this->keywordsCache[$type]; }
php
protected function getKeywords($type) { if (!isset($this->keywordsCache[$type])) { $getter = 'get' . $type . 'Keywords'; $keywords = $this->keywords->$getter(); if ('Step' === $type) { $padded = array(); foreach (explode('|', $keywords) as $keyword) { $padded[] = false !== mb_strpos($keyword, '<', 0, 'utf8') ? preg_quote(mb_substr($keyword, 0, -1, 'utf8'), '/') . '\s*' : preg_quote($keyword, '/') . '\s+'; } $keywords = implode('|', $padded); } $this->keywordsCache[$type] = $keywords; } return $this->keywordsCache[$type]; }
[ "protected", "function", "getKeywords", "(", "$", "type", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "keywordsCache", "[", "$", "type", "]", ")", ")", "{", "$", "getter", "=", "'get'", ".", "$", "type", ".", "'Keywords'", ";", "$", ...
Returns keywords for provided type. @param string $type Keyword type @return string
[ "Returns", "keywords", "for", "provided", "type", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Lexer.php#L317-L338
train
Behat/Gherkin
src/Behat/Gherkin/Lexer.php
Lexer.scanStep
protected function scanStep() { if (!$this->allowSteps) { return null; } $keywords = $this->getKeywords('Step'); if (!preg_match('/^\s*(' . $keywords . ')([^\s].+)/u', $this->line, $matches)) { return null; } $keyword = trim($matches[1]); $token = $this->takeToken('Step', $keyword); $token['keyword_type'] = $this->getStepKeywordType($keyword); $token['text'] = $matches[2]; $this->consumeLine(); $this->allowMultilineArguments = true; return $token; }
php
protected function scanStep() { if (!$this->allowSteps) { return null; } $keywords = $this->getKeywords('Step'); if (!preg_match('/^\s*(' . $keywords . ')([^\s].+)/u', $this->line, $matches)) { return null; } $keyword = trim($matches[1]); $token = $this->takeToken('Step', $keyword); $token['keyword_type'] = $this->getStepKeywordType($keyword); $token['text'] = $matches[2]; $this->consumeLine(); $this->allowMultilineArguments = true; return $token; }
[ "protected", "function", "scanStep", "(", ")", "{", "if", "(", "!", "$", "this", "->", "allowSteps", ")", "{", "return", "null", ";", "}", "$", "keywords", "=", "$", "this", "->", "getKeywords", "(", "'Step'", ")", ";", "if", "(", "!", "preg_match", ...
Scans Step from input & returns it if found. @return null|array
[ "Scans", "Step", "from", "input", "&", "returns", "it", "if", "found", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Lexer.php#L395-L415
train
Behat/Gherkin
src/Behat/Gherkin/Lexer.php
Lexer.scanPyStringOp
protected function scanPyStringOp() { if (!$this->allowMultilineArguments) { return null; } if (false === ($pos = mb_strpos($this->line, '"""', 0, 'utf8'))) { return null; } $this->inPyString = !$this->inPyString; $token = $this->takeToken('PyStringOp'); $this->pyStringSwallow = $pos; $this->consumeLine(); return $token; }
php
protected function scanPyStringOp() { if (!$this->allowMultilineArguments) { return null; } if (false === ($pos = mb_strpos($this->line, '"""', 0, 'utf8'))) { return null; } $this->inPyString = !$this->inPyString; $token = $this->takeToken('PyStringOp'); $this->pyStringSwallow = $pos; $this->consumeLine(); return $token; }
[ "protected", "function", "scanPyStringOp", "(", ")", "{", "if", "(", "!", "$", "this", "->", "allowMultilineArguments", ")", "{", "return", "null", ";", "}", "if", "(", "false", "===", "(", "$", "pos", "=", "mb_strpos", "(", "$", "this", "->", "line", ...
Scans PyString from input & returns it if found. @return null|array
[ "Scans", "PyString", "from", "input", "&", "returns", "it", "if", "found", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Lexer.php#L422-L439
train
Behat/Gherkin
src/Behat/Gherkin/Lexer.php
Lexer.scanPyStringContent
protected function scanPyStringContent() { if (!$this->inPyString) { return null; } $token = $this->scanText(); // swallow trailing spaces $token['value'] = preg_replace('/^\s{0,' . $this->pyStringSwallow . '}/u', '', $token['value']); return $token; }
php
protected function scanPyStringContent() { if (!$this->inPyString) { return null; } $token = $this->scanText(); // swallow trailing spaces $token['value'] = preg_replace('/^\s{0,' . $this->pyStringSwallow . '}/u', '', $token['value']); return $token; }
[ "protected", "function", "scanPyStringContent", "(", ")", "{", "if", "(", "!", "$", "this", "->", "inPyString", ")", "{", "return", "null", ";", "}", "$", "token", "=", "$", "this", "->", "scanText", "(", ")", ";", "// swallow trailing spaces", "$", "tok...
Scans PyString content. @return null|array
[ "Scans", "PyString", "content", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Lexer.php#L446-L457
train
Behat/Gherkin
src/Behat/Gherkin/Lexer.php
Lexer.scanTableRow
protected function scanTableRow() { if (!$this->allowMultilineArguments) { return null; } $line = $this->getTrimmedLine(); if (!isset($line[0]) || '|' !== $line[0] || '|' !== substr($line, -1)) { return null; } $token = $this->takeToken('TableRow'); $line = mb_substr($line, 1, mb_strlen($line, 'utf8') - 2, 'utf8'); $columns = array_map(function ($column) { return trim(str_replace('\\|', '|', $column)); }, preg_split('/(?<!\\\)\|/u', $line)); $token['columns'] = $columns; $this->consumeLine(); return $token; }
php
protected function scanTableRow() { if (!$this->allowMultilineArguments) { return null; } $line = $this->getTrimmedLine(); if (!isset($line[0]) || '|' !== $line[0] || '|' !== substr($line, -1)) { return null; } $token = $this->takeToken('TableRow'); $line = mb_substr($line, 1, mb_strlen($line, 'utf8') - 2, 'utf8'); $columns = array_map(function ($column) { return trim(str_replace('\\|', '|', $column)); }, preg_split('/(?<!\\\)\|/u', $line)); $token['columns'] = $columns; $this->consumeLine(); return $token; }
[ "protected", "function", "scanTableRow", "(", ")", "{", "if", "(", "!", "$", "this", "->", "allowMultilineArguments", ")", "{", "return", "null", ";", "}", "$", "line", "=", "$", "this", "->", "getTrimmedLine", "(", ")", ";", "if", "(", "!", "isset", ...
Scans Table Row from input & returns it if found. @return null|array
[ "Scans", "Table", "Row", "from", "input", "&", "returns", "it", "if", "found", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Lexer.php#L464-L485
train
Behat/Gherkin
src/Behat/Gherkin/Lexer.php
Lexer.scanTags
protected function scanTags() { $line = $this->getTrimmedLine(); if (!isset($line[0]) || '@' !== $line[0]) { return null; } $token = $this->takeToken('Tag'); $tags = explode('@', mb_substr($line, 1, mb_strlen($line, 'utf8') - 1, 'utf8')); $tags = array_map('trim', $tags); $token['tags'] = $tags; $this->consumeLine(); return $token; }
php
protected function scanTags() { $line = $this->getTrimmedLine(); if (!isset($line[0]) || '@' !== $line[0]) { return null; } $token = $this->takeToken('Tag'); $tags = explode('@', mb_substr($line, 1, mb_strlen($line, 'utf8') - 1, 'utf8')); $tags = array_map('trim', $tags); $token['tags'] = $tags; $this->consumeLine(); return $token; }
[ "protected", "function", "scanTags", "(", ")", "{", "$", "line", "=", "$", "this", "->", "getTrimmedLine", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "line", "[", "0", "]", ")", "||", "'@'", "!==", "$", "line", "[", "0", "]", ")", "{", ...
Scans Tags from input & returns it if found. @return null|array
[ "Scans", "Tags", "from", "input", "&", "returns", "it", "if", "found", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Lexer.php#L492-L507
train
Behat/Gherkin
src/Behat/Gherkin/Lexer.php
Lexer.scanLanguage
protected function scanLanguage() { if ($this->featureStarted) { return null; } if ($this->inPyString) { return null; } if (0 !== mb_strpos(ltrim($this->line), '#', 0, 'utf8')) { return null; } return $this->scanInput('/^\s*\#\s*language:\s*([\w_\-]+)\s*$/', 'Language'); }
php
protected function scanLanguage() { if ($this->featureStarted) { return null; } if ($this->inPyString) { return null; } if (0 !== mb_strpos(ltrim($this->line), '#', 0, 'utf8')) { return null; } return $this->scanInput('/^\s*\#\s*language:\s*([\w_\-]+)\s*$/', 'Language'); }
[ "protected", "function", "scanLanguage", "(", ")", "{", "if", "(", "$", "this", "->", "featureStarted", ")", "{", "return", "null", ";", "}", "if", "(", "$", "this", "->", "inPyString", ")", "{", "return", "null", ";", "}", "if", "(", "0", "!==", "...
Scans Language specifier from input & returns it if found. @return null|array
[ "Scans", "Language", "specifier", "from", "input", "&", "returns", "it", "if", "found", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Lexer.php#L514-L529
train
Behat/Gherkin
src/Behat/Gherkin/Lexer.php
Lexer.scanComment
protected function scanComment() { if ($this->inPyString) { return null; } $line = $this->getTrimmedLine(); if (0 !== mb_strpos($line, '#', 0, 'utf8')) { return null; } $token = $this->takeToken('Comment', $line); $this->consumeLine(); return $token; }
php
protected function scanComment() { if ($this->inPyString) { return null; } $line = $this->getTrimmedLine(); if (0 !== mb_strpos($line, '#', 0, 'utf8')) { return null; } $token = $this->takeToken('Comment', $line); $this->consumeLine(); return $token; }
[ "protected", "function", "scanComment", "(", ")", "{", "if", "(", "$", "this", "->", "inPyString", ")", "{", "return", "null", ";", "}", "$", "line", "=", "$", "this", "->", "getTrimmedLine", "(", ")", ";", "if", "(", "0", "!==", "mb_strpos", "(", ...
Scans Comment from input & returns it if found. @return null|array
[ "Scans", "Comment", "from", "input", "&", "returns", "it", "if", "found", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Lexer.php#L536-L551
train
Behat/Gherkin
src/Behat/Gherkin/Lexer.php
Lexer.scanNewline
protected function scanNewline() { if ('' !== $this->getTrimmedLine()) { return null; } $token = $this->takeToken('Newline', mb_strlen($this->line, 'utf8')); $this->consumeLine(); return $token; }
php
protected function scanNewline() { if ('' !== $this->getTrimmedLine()) { return null; } $token = $this->takeToken('Newline', mb_strlen($this->line, 'utf8')); $this->consumeLine(); return $token; }
[ "protected", "function", "scanNewline", "(", ")", "{", "if", "(", "''", "!==", "$", "this", "->", "getTrimmedLine", "(", ")", ")", "{", "return", "null", ";", "}", "$", "token", "=", "$", "this", "->", "takeToken", "(", "'Newline'", ",", "mb_strlen", ...
Scans Newline from input & returns it if found. @return null|array
[ "Scans", "Newline", "from", "input", "&", "returns", "it", "if", "found", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Lexer.php#L558-L568
train
Behat/Gherkin
src/Behat/Gherkin/Loader/GherkinFileLoader.php
GherkinFileLoader.parseFeature
protected function parseFeature($path) { $filename = $this->findRelativePath($path); $content = file_get_contents($path); $feature = $this->parser->parse($content, $filename); return $feature; }
php
protected function parseFeature($path) { $filename = $this->findRelativePath($path); $content = file_get_contents($path); $feature = $this->parser->parse($content, $filename); return $feature; }
[ "protected", "function", "parseFeature", "(", "$", "path", ")", "{", "$", "filename", "=", "$", "this", "->", "findRelativePath", "(", "$", "path", ")", ";", "$", "content", "=", "file_get_contents", "(", "$", "path", ")", ";", "$", "feature", "=", "$"...
Parses feature at provided absolute path. @param string $path Feature path @return FeatureNode
[ "Parses", "feature", "at", "provided", "absolute", "path", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Loader/GherkinFileLoader.php#L94-L101
train
Behat/Gherkin
src/Behat/Gherkin/Node/ExampleNode.php
ExampleNode.createExampleSteps
protected function createExampleSteps() { $steps = array(); foreach ($this->outlineSteps as $outlineStep) { $keyword = $outlineStep->getKeyword(); $keywordType = $outlineStep->getKeywordType(); $text = $this->replaceTextTokens($outlineStep->getText()); $args = $this->replaceArgumentsTokens($outlineStep->getArguments()); $line = $outlineStep->getLine(); $steps[] = new StepNode($keyword, $text, $args, $line, $keywordType); } return $steps; }
php
protected function createExampleSteps() { $steps = array(); foreach ($this->outlineSteps as $outlineStep) { $keyword = $outlineStep->getKeyword(); $keywordType = $outlineStep->getKeywordType(); $text = $this->replaceTextTokens($outlineStep->getText()); $args = $this->replaceArgumentsTokens($outlineStep->getArguments()); $line = $outlineStep->getLine(); $steps[] = new StepNode($keyword, $text, $args, $line, $keywordType); } return $steps; }
[ "protected", "function", "createExampleSteps", "(", ")", "{", "$", "steps", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "outlineSteps", "as", "$", "outlineStep", ")", "{", "$", "keyword", "=", "$", "outlineStep", "->", "getKeyword", "...
Creates steps for this example from abstract outline steps. @return StepNode[]
[ "Creates", "steps", "for", "this", "example", "from", "abstract", "outline", "steps", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Node/ExampleNode.php#L186-L200
train
Behat/Gherkin
src/Behat/Gherkin/Node/ExampleNode.php
ExampleNode.replaceArgumentsTokens
protected function replaceArgumentsTokens(array $arguments) { foreach ($arguments as $num => $argument) { if ($argument instanceof TableNode) { $arguments[$num] = $this->replaceTableArgumentTokens($argument); } if ($argument instanceof PyStringNode) { $arguments[$num] = $this->replacePyStringArgumentTokens($argument); } } return $arguments; }
php
protected function replaceArgumentsTokens(array $arguments) { foreach ($arguments as $num => $argument) { if ($argument instanceof TableNode) { $arguments[$num] = $this->replaceTableArgumentTokens($argument); } if ($argument instanceof PyStringNode) { $arguments[$num] = $this->replacePyStringArgumentTokens($argument); } } return $arguments; }
[ "protected", "function", "replaceArgumentsTokens", "(", "array", "$", "arguments", ")", "{", "foreach", "(", "$", "arguments", "as", "$", "num", "=>", "$", "argument", ")", "{", "if", "(", "$", "argument", "instanceof", "TableNode", ")", "{", "$", "argumen...
Replaces tokens in arguments with row values. @param ArgumentInterface[] $arguments @return ArgumentInterface[]
[ "Replaces", "tokens", "in", "arguments", "with", "row", "values", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Node/ExampleNode.php#L209-L221
train
Behat/Gherkin
src/Behat/Gherkin/Node/ExampleNode.php
ExampleNode.replaceTableArgumentTokens
protected function replaceTableArgumentTokens(TableNode $argument) { $table = $argument->getTable(); foreach ($table as $line => $row) { foreach (array_keys($row) as $col) { $table[$line][$col] = $this->replaceTextTokens($table[$line][$col]); } } return new TableNode($table); }
php
protected function replaceTableArgumentTokens(TableNode $argument) { $table = $argument->getTable(); foreach ($table as $line => $row) { foreach (array_keys($row) as $col) { $table[$line][$col] = $this->replaceTextTokens($table[$line][$col]); } } return new TableNode($table); }
[ "protected", "function", "replaceTableArgumentTokens", "(", "TableNode", "$", "argument", ")", "{", "$", "table", "=", "$", "argument", "->", "getTable", "(", ")", ";", "foreach", "(", "$", "table", "as", "$", "line", "=>", "$", "row", ")", "{", "foreach...
Replaces tokens in table with row values. @param TableNode $argument @return TableNode
[ "Replaces", "tokens", "in", "table", "with", "row", "values", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Node/ExampleNode.php#L230-L240
train
Behat/Gherkin
src/Behat/Gherkin/Node/ExampleNode.php
ExampleNode.replacePyStringArgumentTokens
protected function replacePyStringArgumentTokens(PyStringNode $argument) { $strings = $argument->getStrings(); foreach ($strings as $line => $string) { $strings[$line] = $this->replaceTextTokens($strings[$line]); } return new PyStringNode($strings, $argument->getLine()); }
php
protected function replacePyStringArgumentTokens(PyStringNode $argument) { $strings = $argument->getStrings(); foreach ($strings as $line => $string) { $strings[$line] = $this->replaceTextTokens($strings[$line]); } return new PyStringNode($strings, $argument->getLine()); }
[ "protected", "function", "replacePyStringArgumentTokens", "(", "PyStringNode", "$", "argument", ")", "{", "$", "strings", "=", "$", "argument", "->", "getStrings", "(", ")", ";", "foreach", "(", "$", "strings", "as", "$", "line", "=>", "$", "string", ")", ...
Replaces tokens in PyString with row values. @param PyStringNode $argument @return PyStringNode
[ "Replaces", "tokens", "in", "PyString", "with", "row", "values", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Node/ExampleNode.php#L249-L257
train
Behat/Gherkin
src/Behat/Gherkin/Node/ExampleNode.php
ExampleNode.replaceTextTokens
protected function replaceTextTokens($text) { foreach ($this->tokens as $key => $val) { $text = str_replace('<' . $key . '>', $val, $text); } return $text; }
php
protected function replaceTextTokens($text) { foreach ($this->tokens as $key => $val) { $text = str_replace('<' . $key . '>', $val, $text); } return $text; }
[ "protected", "function", "replaceTextTokens", "(", "$", "text", ")", "{", "foreach", "(", "$", "this", "->", "tokens", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "text", "=", "str_replace", "(", "'<'", ".", "$", "key", ".", "'>'", ",", "$",...
Replaces tokens in text with row values. @param string $text @return string
[ "Replaces", "tokens", "in", "text", "with", "row", "values", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Node/ExampleNode.php#L266-L273
train
Behat/Gherkin
src/Behat/Gherkin/Keywords/KeywordsDumper.php
KeywordsDumper.dumpKeywords
public function dumpKeywords(array $keywords, $isShort) { if ($isShort) { return 1 < count($keywords) ? '(' . implode('|', $keywords) . ')' : $keywords[0]; } return $keywords[0]; }
php
public function dumpKeywords(array $keywords, $isShort) { if ($isShort) { return 1 < count($keywords) ? '(' . implode('|', $keywords) . ')' : $keywords[0]; } return $keywords[0]; }
[ "public", "function", "dumpKeywords", "(", "array", "$", "keywords", ",", "$", "isShort", ")", "{", "if", "(", "$", "isShort", ")", "{", "return", "1", "<", "count", "(", "$", "keywords", ")", "?", "'('", ".", "implode", "(", "'|'", ",", "$", "keyw...
Defaults keywords dumper. @param array $keywords Keywords list @param Boolean $isShort Is short version @return string
[ "Defaults", "keywords", "dumper", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Keywords/KeywordsDumper.php#L54-L61
train
Behat/Gherkin
src/Behat/Gherkin/Keywords/KeywordsDumper.php
KeywordsDumper.dump
public function dump($language, $short = true, $excludeAsterisk = false) { $this->keywords->setLanguage($language); $languageComment = ''; if ('en' !== $language) { $languageComment = "# language: $language\n"; } $keywords = explode('|', $this->keywords->getFeatureKeywords()); if ($short) { $keywords = call_user_func($this->keywordsDumper, $keywords, $short); return trim($languageComment . $this->dumpFeature($keywords, $short, $excludeAsterisk)); } $features = array(); foreach ($keywords as $keyword) { $keyword = call_user_func($this->keywordsDumper, array($keyword), $short); $features[] = trim($languageComment . $this->dumpFeature($keyword, $short, $excludeAsterisk)); } return $features; }
php
public function dump($language, $short = true, $excludeAsterisk = false) { $this->keywords->setLanguage($language); $languageComment = ''; if ('en' !== $language) { $languageComment = "# language: $language\n"; } $keywords = explode('|', $this->keywords->getFeatureKeywords()); if ($short) { $keywords = call_user_func($this->keywordsDumper, $keywords, $short); return trim($languageComment . $this->dumpFeature($keywords, $short, $excludeAsterisk)); } $features = array(); foreach ($keywords as $keyword) { $keyword = call_user_func($this->keywordsDumper, array($keyword), $short); $features[] = trim($languageComment . $this->dumpFeature($keyword, $short, $excludeAsterisk)); } return $features; }
[ "public", "function", "dump", "(", "$", "language", ",", "$", "short", "=", "true", ",", "$", "excludeAsterisk", "=", "false", ")", "{", "$", "this", "->", "keywords", "->", "setLanguage", "(", "$", "language", ")", ";", "$", "languageComment", "=", "'...
Dumps keyworded feature into string. @param string $language Keywords language @param Boolean $short Dump short version @param bool $excludeAsterisk @return string|array String for short version and array of features for extended
[ "Dumps", "keyworded", "feature", "into", "string", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Keywords/KeywordsDumper.php#L72-L95
train
Behat/Gherkin
src/Behat/Gherkin/Keywords/KeywordsDumper.php
KeywordsDumper.dumpFeature
protected function dumpFeature($keyword, $short = true, $excludeAsterisk = false) { $dump = <<<GHERKIN {$keyword}: Internal operations In order to stay secret As a secret organization We need to be able to erase past agents' memory GHERKIN; // Background $keywords = explode('|', $this->keywords->getBackgroundKeywords()); if ($short) { $keywords = call_user_func($this->keywordsDumper, $keywords, $short); $dump .= $this->dumpBackground($keywords, $short, $excludeAsterisk); } else { $keyword = call_user_func($this->keywordsDumper, array($keywords[0]), $short); $dump .= $this->dumpBackground($keyword, $short, $excludeAsterisk); } // Scenario $keywords = explode('|', $this->keywords->getScenarioKeywords()); if ($short) { $keywords = call_user_func($this->keywordsDumper, $keywords, $short); $dump .= $this->dumpScenario($keywords, $short, $excludeAsterisk); } else { foreach ($keywords as $keyword) { $keyword = call_user_func($this->keywordsDumper, array($keyword), $short); $dump .= $this->dumpScenario($keyword, $short, $excludeAsterisk); } } // Outline $keywords = explode('|', $this->keywords->getOutlineKeywords()); if ($short) { $keywords = call_user_func($this->keywordsDumper, $keywords, $short); $dump .= $this->dumpOutline($keywords, $short, $excludeAsterisk); } else { foreach ($keywords as $keyword) { $keyword = call_user_func($this->keywordsDumper, array($keyword), $short); $dump .= $this->dumpOutline($keyword, $short, $excludeAsterisk); } } return $dump; }
php
protected function dumpFeature($keyword, $short = true, $excludeAsterisk = false) { $dump = <<<GHERKIN {$keyword}: Internal operations In order to stay secret As a secret organization We need to be able to erase past agents' memory GHERKIN; // Background $keywords = explode('|', $this->keywords->getBackgroundKeywords()); if ($short) { $keywords = call_user_func($this->keywordsDumper, $keywords, $short); $dump .= $this->dumpBackground($keywords, $short, $excludeAsterisk); } else { $keyword = call_user_func($this->keywordsDumper, array($keywords[0]), $short); $dump .= $this->dumpBackground($keyword, $short, $excludeAsterisk); } // Scenario $keywords = explode('|', $this->keywords->getScenarioKeywords()); if ($short) { $keywords = call_user_func($this->keywordsDumper, $keywords, $short); $dump .= $this->dumpScenario($keywords, $short, $excludeAsterisk); } else { foreach ($keywords as $keyword) { $keyword = call_user_func($this->keywordsDumper, array($keyword), $short); $dump .= $this->dumpScenario($keyword, $short, $excludeAsterisk); } } // Outline $keywords = explode('|', $this->keywords->getOutlineKeywords()); if ($short) { $keywords = call_user_func($this->keywordsDumper, $keywords, $short); $dump .= $this->dumpOutline($keywords, $short, $excludeAsterisk); } else { foreach ($keywords as $keyword) { $keyword = call_user_func($this->keywordsDumper, array($keyword), $short); $dump .= $this->dumpOutline($keyword, $short, $excludeAsterisk); } } return $dump; }
[ "protected", "function", "dumpFeature", "(", "$", "keyword", ",", "$", "short", "=", "true", ",", "$", "excludeAsterisk", "=", "false", ")", "{", "$", "dump", "=", " <<<GHERKIN\n{$keyword}: Internal operations\n In order to stay secret\n As a secret organization\n We nee...
Dumps feature example. @param string $keyword Item keyword @param Boolean $short Dump short version? @return string
[ "Dumps", "feature", "example", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Keywords/KeywordsDumper.php#L105-L151
train
Behat/Gherkin
src/Behat/Gherkin/Keywords/KeywordsDumper.php
KeywordsDumper.dumpBackground
protected function dumpBackground($keyword, $short = true, $excludeAsterisk = false) { $dump = <<<GHERKIN {$keyword}: GHERKIN; // Given $dump .= $this->dumpStep( $this->keywords->getGivenKeywords(), 'there is agent A', $short, $excludeAsterisk ); // And $dump .= $this->dumpStep( $this->keywords->getAndKeywords(), 'there is agent B', $short, $excludeAsterisk ); return $dump . "\n"; }
php
protected function dumpBackground($keyword, $short = true, $excludeAsterisk = false) { $dump = <<<GHERKIN {$keyword}: GHERKIN; // Given $dump .= $this->dumpStep( $this->keywords->getGivenKeywords(), 'there is agent A', $short, $excludeAsterisk ); // And $dump .= $this->dumpStep( $this->keywords->getAndKeywords(), 'there is agent B', $short, $excludeAsterisk ); return $dump . "\n"; }
[ "protected", "function", "dumpBackground", "(", "$", "keyword", ",", "$", "short", "=", "true", ",", "$", "excludeAsterisk", "=", "false", ")", "{", "$", "dump", "=", " <<<GHERKIN\n {$keyword}:\n\nGHERKIN", ";", "// Given", "$", "dump", ".=", "$", "this", "...
Dumps background example. @param string $keyword Item keyword @param Boolean $short Dump short version? @return string
[ "Dumps", "background", "example", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Keywords/KeywordsDumper.php#L161-L185
train
Behat/Gherkin
src/Behat/Gherkin/Keywords/KeywordsDumper.php
KeywordsDumper.dumpScenario
protected function dumpScenario($keyword, $short = true, $excludeAsterisk = false) { $dump = <<<GHERKIN {$keyword}: Erasing agent memory GHERKIN; // Given $dump .= $this->dumpStep( $this->keywords->getGivenKeywords(), 'there is agent J', $short, $excludeAsterisk ); // And $dump .= $this->dumpStep( $this->keywords->getAndKeywords(), 'there is agent K', $short, $excludeAsterisk ); // When $dump .= $this->dumpStep( $this->keywords->getWhenKeywords(), 'I erase agent K\'s memory', $short, $excludeAsterisk ); // Then $dump .= $this->dumpStep( $this->keywords->getThenKeywords(), 'there should be agent J', $short, $excludeAsterisk ); // But $dump .= $this->dumpStep( $this->keywords->getButKeywords(), 'there should not be agent K', $short, $excludeAsterisk ); return $dump . "\n"; }
php
protected function dumpScenario($keyword, $short = true, $excludeAsterisk = false) { $dump = <<<GHERKIN {$keyword}: Erasing agent memory GHERKIN; // Given $dump .= $this->dumpStep( $this->keywords->getGivenKeywords(), 'there is agent J', $short, $excludeAsterisk ); // And $dump .= $this->dumpStep( $this->keywords->getAndKeywords(), 'there is agent K', $short, $excludeAsterisk ); // When $dump .= $this->dumpStep( $this->keywords->getWhenKeywords(), 'I erase agent K\'s memory', $short, $excludeAsterisk ); // Then $dump .= $this->dumpStep( $this->keywords->getThenKeywords(), 'there should be agent J', $short, $excludeAsterisk ); // But $dump .= $this->dumpStep( $this->keywords->getButKeywords(), 'there should not be agent K', $short, $excludeAsterisk ); return $dump . "\n"; }
[ "protected", "function", "dumpScenario", "(", "$", "keyword", ",", "$", "short", "=", "true", ",", "$", "excludeAsterisk", "=", "false", ")", "{", "$", "dump", "=", " <<<GHERKIN\n {$keyword}: Erasing agent memory\n\nGHERKIN", ";", "// Given", "$", "dump", ".=", ...
Dumps scenario example. @param string $keyword Item keyword @param Boolean $short Dump short version? @return string
[ "Dumps", "scenario", "example", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Keywords/KeywordsDumper.php#L195-L243
train
Behat/Gherkin
src/Behat/Gherkin/Keywords/KeywordsDumper.php
KeywordsDumper.dumpOutline
protected function dumpOutline($keyword, $short = true, $excludeAsterisk = false) { $dump = <<<GHERKIN {$keyword}: Erasing other agents' memory GHERKIN; // Given $dump .= $this->dumpStep( $this->keywords->getGivenKeywords(), 'there is agent <agent1>', $short, $excludeAsterisk ); // And $dump .= $this->dumpStep( $this->keywords->getAndKeywords(), 'there is agent <agent2>', $short, $excludeAsterisk ); // When $dump .= $this->dumpStep( $this->keywords->getWhenKeywords(), 'I erase agent <agent2>\'s memory', $short, $excludeAsterisk ); // Then $dump .= $this->dumpStep( $this->keywords->getThenKeywords(), 'there should be agent <agent1>', $short, $excludeAsterisk ); // But $dump .= $this->dumpStep( $this->keywords->getButKeywords(), 'there should not be agent <agent2>', $short, $excludeAsterisk ); $keywords = explode('|', $this->keywords->getExamplesKeywords()); if ($short) { $keyword = call_user_func($this->keywordsDumper, $keywords, $short); } else { $keyword = call_user_func($this->keywordsDumper, array($keywords[0]), $short); } $dump .= <<<GHERKIN {$keyword}: | agent1 | agent2 | | D | M | GHERKIN; return $dump . "\n"; }
php
protected function dumpOutline($keyword, $short = true, $excludeAsterisk = false) { $dump = <<<GHERKIN {$keyword}: Erasing other agents' memory GHERKIN; // Given $dump .= $this->dumpStep( $this->keywords->getGivenKeywords(), 'there is agent <agent1>', $short, $excludeAsterisk ); // And $dump .= $this->dumpStep( $this->keywords->getAndKeywords(), 'there is agent <agent2>', $short, $excludeAsterisk ); // When $dump .= $this->dumpStep( $this->keywords->getWhenKeywords(), 'I erase agent <agent2>\'s memory', $short, $excludeAsterisk ); // Then $dump .= $this->dumpStep( $this->keywords->getThenKeywords(), 'there should be agent <agent1>', $short, $excludeAsterisk ); // But $dump .= $this->dumpStep( $this->keywords->getButKeywords(), 'there should not be agent <agent2>', $short, $excludeAsterisk ); $keywords = explode('|', $this->keywords->getExamplesKeywords()); if ($short) { $keyword = call_user_func($this->keywordsDumper, $keywords, $short); } else { $keyword = call_user_func($this->keywordsDumper, array($keywords[0]), $short); } $dump .= <<<GHERKIN {$keyword}: | agent1 | agent2 | | D | M | GHERKIN; return $dump . "\n"; }
[ "protected", "function", "dumpOutline", "(", "$", "keyword", ",", "$", "short", "=", "true", ",", "$", "excludeAsterisk", "=", "false", ")", "{", "$", "dump", "=", " <<<GHERKIN\n {$keyword}: Erasing other agents' memory\n\nGHERKIN", ";", "// Given", "$", "dump", ...
Dumps outline example. @param string $keyword Item keyword @param Boolean $short Dump short version? @return string
[ "Dumps", "outline", "example", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Keywords/KeywordsDumper.php#L253-L316
train
Behat/Gherkin
src/Behat/Gherkin/Keywords/KeywordsDumper.php
KeywordsDumper.dumpStep
protected function dumpStep($keywords, $text, $short = true, $excludeAsterisk = false) { $dump = ''; $keywords = explode('|', $keywords); if ($short) { $keywords = array_map( function ($keyword) { return str_replace('<', '', $keyword); }, $keywords ); $keywords = call_user_func($this->keywordsDumper, $keywords, $short); $dump .= <<<GHERKIN {$keywords} {$text} GHERKIN; } else { foreach ($keywords as $keyword) { if ($excludeAsterisk && '*' === $keyword) { continue; } $indent = ' '; if (false !== mb_strpos($keyword, '<', 0, 'utf8')) { $keyword = mb_substr($keyword, 0, -1, 'utf8'); $indent = ''; } $keyword = call_user_func($this->keywordsDumper, array($keyword), $short); $dump .= <<<GHERKIN {$keyword}{$indent}{$text} GHERKIN; } } return $dump; }
php
protected function dumpStep($keywords, $text, $short = true, $excludeAsterisk = false) { $dump = ''; $keywords = explode('|', $keywords); if ($short) { $keywords = array_map( function ($keyword) { return str_replace('<', '', $keyword); }, $keywords ); $keywords = call_user_func($this->keywordsDumper, $keywords, $short); $dump .= <<<GHERKIN {$keywords} {$text} GHERKIN; } else { foreach ($keywords as $keyword) { if ($excludeAsterisk && '*' === $keyword) { continue; } $indent = ' '; if (false !== mb_strpos($keyword, '<', 0, 'utf8')) { $keyword = mb_substr($keyword, 0, -1, 'utf8'); $indent = ''; } $keyword = call_user_func($this->keywordsDumper, array($keyword), $short); $dump .= <<<GHERKIN {$keyword}{$indent}{$text} GHERKIN; } } return $dump; }
[ "protected", "function", "dumpStep", "(", "$", "keywords", ",", "$", "text", ",", "$", "short", "=", "true", ",", "$", "excludeAsterisk", "=", "false", ")", "{", "$", "dump", "=", "''", ";", "$", "keywords", "=", "explode", "(", "'|'", ",", "$", "k...
Dumps step example. @param string $keywords Item keyword @param string $text Step text @param Boolean $short Dump short version? @return string
[ "Dumps", "step", "example", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Keywords/KeywordsDumper.php#L327-L364
train
Behat/Gherkin
src/Behat/Gherkin/Loader/YamlFileLoader.php
YamlFileLoader.supports
public function supports($path) { return is_string($path) && is_file($absolute = $this->findAbsolutePath($path)) && 'yml' === pathinfo($absolute, PATHINFO_EXTENSION); }
php
public function supports($path) { return is_string($path) && is_file($absolute = $this->findAbsolutePath($path)) && 'yml' === pathinfo($absolute, PATHINFO_EXTENSION); }
[ "public", "function", "supports", "(", "$", "path", ")", "{", "return", "is_string", "(", "$", "path", ")", "&&", "is_file", "(", "$", "absolute", "=", "$", "this", "->", "findAbsolutePath", "(", "$", "path", ")", ")", "&&", "'yml'", "===", "pathinfo",...
Checks if current loader supports provided resource. @param mixed $path Resource to load @return Boolean
[ "Checks", "if", "current", "loader", "supports", "provided", "resource", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Loader/YamlFileLoader.php#L37-L42
train
Behat/Gherkin
src/Behat/Gherkin/Loader/ArrayLoader.php
ArrayLoader.loadFeatureHash
protected function loadFeatureHash(array $hash, $line = 0) { $hash = array_merge( array( 'title' => null, 'description' => null, 'tags' => array(), 'keyword' => 'Feature', 'language' => 'en', 'line' => $line, 'scenarios' => array(), ), $hash ); $background = isset($hash['background']) ? $this->loadBackgroundHash($hash['background']) : null; $scenarios = array(); foreach ((array) $hash['scenarios'] as $scenarioIterator => $scenarioHash) { if (isset($scenarioHash['type']) && 'outline' === $scenarioHash['type']) { $scenarios[] = $this->loadOutlineHash($scenarioHash, $scenarioIterator); } else { $scenarios[] = $this->loadScenarioHash($scenarioHash, $scenarioIterator); } } return new FeatureNode($hash['title'], $hash['description'], $hash['tags'], $background, $scenarios, $hash['keyword'], $hash['language'], null, $hash['line']); }
php
protected function loadFeatureHash(array $hash, $line = 0) { $hash = array_merge( array( 'title' => null, 'description' => null, 'tags' => array(), 'keyword' => 'Feature', 'language' => 'en', 'line' => $line, 'scenarios' => array(), ), $hash ); $background = isset($hash['background']) ? $this->loadBackgroundHash($hash['background']) : null; $scenarios = array(); foreach ((array) $hash['scenarios'] as $scenarioIterator => $scenarioHash) { if (isset($scenarioHash['type']) && 'outline' === $scenarioHash['type']) { $scenarios[] = $this->loadOutlineHash($scenarioHash, $scenarioIterator); } else { $scenarios[] = $this->loadScenarioHash($scenarioHash, $scenarioIterator); } } return new FeatureNode($hash['title'], $hash['description'], $hash['tags'], $background, $scenarios, $hash['keyword'], $hash['language'], null, $hash['line']); }
[ "protected", "function", "loadFeatureHash", "(", "array", "$", "hash", ",", "$", "line", "=", "0", ")", "{", "$", "hash", "=", "array_merge", "(", "array", "(", "'title'", "=>", "null", ",", "'description'", "=>", "null", ",", "'tags'", "=>", "array", ...
Loads feature from provided feature hash. @param array $hash Feature hash @param integer $line @return FeatureNode
[ "Loads", "feature", "from", "provided", "feature", "hash", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Loader/ArrayLoader.php#L73-L99
train
Behat/Gherkin
src/Behat/Gherkin/Loader/ArrayLoader.php
ArrayLoader.loadBackgroundHash
protected function loadBackgroundHash(array $hash) { $hash = array_merge( array( 'title' => null, 'keyword' => 'Background', 'line' => 0, 'steps' => array(), ), $hash ); $steps = $this->loadStepsHash($hash['steps']); return new BackgroundNode($hash['title'], $steps, $hash['keyword'], $hash['line']); }
php
protected function loadBackgroundHash(array $hash) { $hash = array_merge( array( 'title' => null, 'keyword' => 'Background', 'line' => 0, 'steps' => array(), ), $hash ); $steps = $this->loadStepsHash($hash['steps']); return new BackgroundNode($hash['title'], $steps, $hash['keyword'], $hash['line']); }
[ "protected", "function", "loadBackgroundHash", "(", "array", "$", "hash", ")", "{", "$", "hash", "=", "array_merge", "(", "array", "(", "'title'", "=>", "null", ",", "'keyword'", "=>", "'Background'", ",", "'line'", "=>", "0", ",", "'steps'", "=>", "array"...
Loads background from provided hash. @param array $hash Background hash @return BackgroundNode
[ "Loads", "background", "from", "provided", "hash", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Loader/ArrayLoader.php#L108-L123
train
Behat/Gherkin
src/Behat/Gherkin/Loader/ArrayLoader.php
ArrayLoader.loadScenarioHash
protected function loadScenarioHash(array $hash, $line = 0) { $hash = array_merge( array( 'title' => null, 'tags' => array(), 'keyword' => 'Scenario', 'line' => $line, 'steps' => array(), ), $hash ); $steps = $this->loadStepsHash($hash['steps']); return new ScenarioNode($hash['title'], $hash['tags'], $steps, $hash['keyword'], $hash['line']); }
php
protected function loadScenarioHash(array $hash, $line = 0) { $hash = array_merge( array( 'title' => null, 'tags' => array(), 'keyword' => 'Scenario', 'line' => $line, 'steps' => array(), ), $hash ); $steps = $this->loadStepsHash($hash['steps']); return new ScenarioNode($hash['title'], $hash['tags'], $steps, $hash['keyword'], $hash['line']); }
[ "protected", "function", "loadScenarioHash", "(", "array", "$", "hash", ",", "$", "line", "=", "0", ")", "{", "$", "hash", "=", "array_merge", "(", "array", "(", "'title'", "=>", "null", ",", "'tags'", "=>", "array", "(", ")", ",", "'keyword'", "=>", ...
Loads scenario from provided scenario hash. @param array $hash Scenario hash @param integer $line Scenario definition line @return ScenarioNode
[ "Loads", "scenario", "from", "provided", "scenario", "hash", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Loader/ArrayLoader.php#L133-L149
train
Behat/Gherkin
src/Behat/Gherkin/Loader/ArrayLoader.php
ArrayLoader.loadOutlineHash
protected function loadOutlineHash(array $hash, $line = 0) { $hash = array_merge( array( 'title' => null, 'tags' => array(), 'keyword' => 'Scenario Outline', 'line' => $line, 'steps' => array(), 'examples' => array(), ), $hash ); $steps = $this->loadStepsHash($hash['steps']); if (isset($hash['examples']['keyword'])) { $examplesKeyword = $hash['examples']['keyword']; unset($hash['examples']['keyword']); } else { $examplesKeyword = 'Examples'; } $examples = new ExampleTableNode($hash['examples'], $examplesKeyword); return new OutlineNode($hash['title'], $hash['tags'], $steps, $examples, $hash['keyword'], $hash['line']); }
php
protected function loadOutlineHash(array $hash, $line = 0) { $hash = array_merge( array( 'title' => null, 'tags' => array(), 'keyword' => 'Scenario Outline', 'line' => $line, 'steps' => array(), 'examples' => array(), ), $hash ); $steps = $this->loadStepsHash($hash['steps']); if (isset($hash['examples']['keyword'])) { $examplesKeyword = $hash['examples']['keyword']; unset($hash['examples']['keyword']); } else { $examplesKeyword = 'Examples'; } $examples = new ExampleTableNode($hash['examples'], $examplesKeyword); return new OutlineNode($hash['title'], $hash['tags'], $steps, $examples, $hash['keyword'], $hash['line']); }
[ "protected", "function", "loadOutlineHash", "(", "array", "$", "hash", ",", "$", "line", "=", "0", ")", "{", "$", "hash", "=", "array_merge", "(", "array", "(", "'title'", "=>", "null", ",", "'tags'", "=>", "array", "(", ")", ",", "'keyword'", "=>", ...
Loads outline from provided outline hash. @param array $hash Outline hash @param integer $line Outline definition line @return OutlineNode
[ "Loads", "outline", "from", "provided", "outline", "hash", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Loader/ArrayLoader.php#L159-L185
train
Behat/Gherkin
src/Behat/Gherkin/Loader/ArrayLoader.php
ArrayLoader.loadStepsHash
private function loadStepsHash(array $hash) { $steps = array(); foreach ($hash as $stepIterator => $stepHash) { $steps[] = $this->loadStepHash($stepHash, $stepIterator); } return $steps; }
php
private function loadStepsHash(array $hash) { $steps = array(); foreach ($hash as $stepIterator => $stepHash) { $steps[] = $this->loadStepHash($stepHash, $stepIterator); } return $steps; }
[ "private", "function", "loadStepsHash", "(", "array", "$", "hash", ")", "{", "$", "steps", "=", "array", "(", ")", ";", "foreach", "(", "$", "hash", "as", "$", "stepIterator", "=>", "$", "stepHash", ")", "{", "$", "steps", "[", "]", "=", "$", "this...
Loads steps from provided hash. @param array $hash @return StepNode[]
[ "Loads", "steps", "from", "provided", "hash", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Loader/ArrayLoader.php#L194-L202
train
Behat/Gherkin
src/Behat/Gherkin/Loader/ArrayLoader.php
ArrayLoader.loadStepHash
protected function loadStepHash(array $hash, $line = 0) { $hash = array_merge( array( 'keyword_type' => 'Given', 'type' => 'Given', 'text' => null, 'keyword' => 'Scenario', 'line' => $line, 'arguments' => array(), ), $hash ); $arguments = array(); foreach ($hash['arguments'] as $argumentHash) { if ('table' === $argumentHash['type']) { $arguments[] = $this->loadTableHash($argumentHash['rows']); } elseif ('pystring' === $argumentHash['type']) { $arguments[] = $this->loadPyStringHash($argumentHash, $hash['line'] + 1); } } return new StepNode($hash['type'], $hash['text'], $arguments, $hash['line'], $hash['keyword_type']); }
php
protected function loadStepHash(array $hash, $line = 0) { $hash = array_merge( array( 'keyword_type' => 'Given', 'type' => 'Given', 'text' => null, 'keyword' => 'Scenario', 'line' => $line, 'arguments' => array(), ), $hash ); $arguments = array(); foreach ($hash['arguments'] as $argumentHash) { if ('table' === $argumentHash['type']) { $arguments[] = $this->loadTableHash($argumentHash['rows']); } elseif ('pystring' === $argumentHash['type']) { $arguments[] = $this->loadPyStringHash($argumentHash, $hash['line'] + 1); } } return new StepNode($hash['type'], $hash['text'], $arguments, $hash['line'], $hash['keyword_type']); }
[ "protected", "function", "loadStepHash", "(", "array", "$", "hash", ",", "$", "line", "=", "0", ")", "{", "$", "hash", "=", "array_merge", "(", "array", "(", "'keyword_type'", "=>", "'Given'", ",", "'type'", "=>", "'Given'", ",", "'text'", "=>", "null", ...
Loads step from provided hash. @param array $hash Step hash @param integer $line Step definition line @return StepNode
[ "Loads", "step", "from", "provided", "hash", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Loader/ArrayLoader.php#L212-L236
train
Behat/Gherkin
src/Behat/Gherkin/Loader/ArrayLoader.php
ArrayLoader.loadPyStringHash
protected function loadPyStringHash(array $hash, $line = 0) { $line = isset($hash['line']) ? $hash['line'] : $line; $strings = array(); foreach (explode("\n", $hash['text']) as $string) { $strings[] = $string; } return new PyStringNode($strings, $line); }
php
protected function loadPyStringHash(array $hash, $line = 0) { $line = isset($hash['line']) ? $hash['line'] : $line; $strings = array(); foreach (explode("\n", $hash['text']) as $string) { $strings[] = $string; } return new PyStringNode($strings, $line); }
[ "protected", "function", "loadPyStringHash", "(", "array", "$", "hash", ",", "$", "line", "=", "0", ")", "{", "$", "line", "=", "isset", "(", "$", "hash", "[", "'line'", "]", ")", "?", "$", "hash", "[", "'line'", "]", ":", "$", "line", ";", "$", ...
Loads PyString from provided hash. @param array $hash PyString hash @param integer $line @return PyStringNode
[ "Loads", "PyString", "from", "provided", "hash", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Loader/ArrayLoader.php#L258-L268
train
Behat/Gherkin
src/Behat/Gherkin/Filter/TagFilter.php
TagFilter.isTagsMatchCondition
protected function isTagsMatchCondition($tags) { $satisfies = true; foreach (explode('&&', $this->filterString) as $andTags) { $satisfiesComma = false; foreach (explode(',', $andTags) as $tag) { $tag = str_replace('@', '', trim($tag)); if ('~' === $tag[0]) { $tag = mb_substr($tag, 1, mb_strlen($tag, 'utf8') - 1, 'utf8'); $satisfiesComma = !in_array($tag, $tags) || $satisfiesComma; } else { $satisfiesComma = in_array($tag, $tags) || $satisfiesComma; } } $satisfies = (false !== $satisfiesComma && $satisfies && $satisfiesComma) || false; } return $satisfies; }
php
protected function isTagsMatchCondition($tags) { $satisfies = true; foreach (explode('&&', $this->filterString) as $andTags) { $satisfiesComma = false; foreach (explode(',', $andTags) as $tag) { $tag = str_replace('@', '', trim($tag)); if ('~' === $tag[0]) { $tag = mb_substr($tag, 1, mb_strlen($tag, 'utf8') - 1, 'utf8'); $satisfiesComma = !in_array($tag, $tags) || $satisfiesComma; } else { $satisfiesComma = in_array($tag, $tags) || $satisfiesComma; } } $satisfies = (false !== $satisfiesComma && $satisfies && $satisfiesComma) || false; } return $satisfies; }
[ "protected", "function", "isTagsMatchCondition", "(", "$", "tags", ")", "{", "$", "satisfies", "=", "true", ";", "foreach", "(", "explode", "(", "'&&'", ",", "$", "this", "->", "filterString", ")", "as", "$", "andTags", ")", "{", "$", "satisfiesComma", "...
Checks that node matches condition. @param string[] $tags @return Boolean
[ "Checks", "that", "node", "matches", "condition", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Filter/TagFilter.php#L67-L89
train
Behat/Gherkin
src/Behat/Gherkin/Keywords/ArrayKeywords.php
ArrayKeywords.setLanguage
public function setLanguage($language) { if (!isset($this->keywords[$language])) { $this->language = 'en'; } else { $this->language = $language; } }
php
public function setLanguage($language) { if (!isset($this->keywords[$language])) { $this->language = 'en'; } else { $this->language = $language; } }
[ "public", "function", "setLanguage", "(", "$", "language", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "keywords", "[", "$", "language", "]", ")", ")", "{", "$", "this", "->", "language", "=", "'en'", ";", "}", "else", "{", "$", "t...
Sets keywords holder language. @param string $language Language name
[ "Sets", "keywords", "holder", "language", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Keywords/ArrayKeywords.php#L66-L73
train
Behat/Gherkin
src/Behat/Gherkin/Parser.php
Parser.parse
public function parse($input, $file = null) { $this->languageSpecifierLine = null; $this->input = $input; $this->file = $file; $this->tags = array(); try { $this->lexer->analyse($this->input, 'en'); } catch (LexerException $e) { throw new ParserException( sprintf('Lexer exception "%s" thrown for file %s', $e->getMessage(), $file), 0, $e ); } $feature = null; while ('EOS' !== ($predicted = $this->predictTokenType())) { $node = $this->parseExpression(); if (null === $node || "\n" === $node) { continue; } if (!$feature && $node instanceof FeatureNode) { $feature = $node; continue; } if ($feature && $node instanceof FeatureNode) { throw new ParserException(sprintf( 'Only one feature is allowed per feature file. But %s got multiple.', $this->file )); } if (is_string($node)) { throw new ParserException(sprintf( 'Expected Feature, but got text: "%s"%s', $node, $this->file ? ' in file: ' . $this->file : '' )); } if (!$node instanceof FeatureNode) { throw new ParserException(sprintf( 'Expected Feature, but got %s on line: %d%s', $node->getKeyword(), $node->getLine(), $this->file ? ' in file: ' . $this->file : '' )); } } return $feature; }
php
public function parse($input, $file = null) { $this->languageSpecifierLine = null; $this->input = $input; $this->file = $file; $this->tags = array(); try { $this->lexer->analyse($this->input, 'en'); } catch (LexerException $e) { throw new ParserException( sprintf('Lexer exception "%s" thrown for file %s', $e->getMessage(), $file), 0, $e ); } $feature = null; while ('EOS' !== ($predicted = $this->predictTokenType())) { $node = $this->parseExpression(); if (null === $node || "\n" === $node) { continue; } if (!$feature && $node instanceof FeatureNode) { $feature = $node; continue; } if ($feature && $node instanceof FeatureNode) { throw new ParserException(sprintf( 'Only one feature is allowed per feature file. But %s got multiple.', $this->file )); } if (is_string($node)) { throw new ParserException(sprintf( 'Expected Feature, but got text: "%s"%s', $node, $this->file ? ' in file: ' . $this->file : '' )); } if (!$node instanceof FeatureNode) { throw new ParserException(sprintf( 'Expected Feature, but got %s on line: %d%s', $node->getKeyword(), $node->getLine(), $this->file ? ' in file: ' . $this->file : '' )); } } return $feature; }
[ "public", "function", "parse", "(", "$", "input", ",", "$", "file", "=", "null", ")", "{", "$", "this", "->", "languageSpecifierLine", "=", "null", ";", "$", "this", "->", "input", "=", "$", "input", ";", "$", "this", "->", "file", "=", "$", "file"...
Parses input & returns features array. @param string $input Gherkin string document @param string $file File name @return FeatureNode|null @throws ParserException
[ "Parses", "input", "&", "returns", "features", "array", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Parser.php#L62-L118
train
Behat/Gherkin
src/Behat/Gherkin/Parser.php
Parser.expectTokenType
protected function expectTokenType($type) { $types = (array) $type; if (in_array($this->predictTokenType(), $types)) { return $this->lexer->getAdvancedToken(); } $token = $this->lexer->predictToken(); throw new ParserException(sprintf( 'Expected %s token, but got %s on line: %d%s', implode(' or ', $types), $this->predictTokenType(), $token['line'], $this->file ? ' in file: ' . $this->file : '' )); }
php
protected function expectTokenType($type) { $types = (array) $type; if (in_array($this->predictTokenType(), $types)) { return $this->lexer->getAdvancedToken(); } $token = $this->lexer->predictToken(); throw new ParserException(sprintf( 'Expected %s token, but got %s on line: %d%s', implode(' or ', $types), $this->predictTokenType(), $token['line'], $this->file ? ' in file: ' . $this->file : '' )); }
[ "protected", "function", "expectTokenType", "(", "$", "type", ")", "{", "$", "types", "=", "(", "array", ")", "$", "type", ";", "if", "(", "in_array", "(", "$", "this", "->", "predictTokenType", "(", ")", ",", "$", "types", ")", ")", "{", "return", ...
Returns next token if it's type equals to expected. @param string $type Token type @return array @throws Exception\ParserException
[ "Returns", "next", "token", "if", "it", "s", "type", "equals", "to", "expected", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Parser.php#L129-L145
train
Behat/Gherkin
src/Behat/Gherkin/Parser.php
Parser.parseExpression
protected function parseExpression() { switch ($type = $this->predictTokenType()) { case 'Feature': return $this->parseFeature(); case 'Background': return $this->parseBackground(); case 'Scenario': return $this->parseScenario(); case 'Outline': return $this->parseOutline(); case 'Examples': return $this->parseExamples(); case 'TableRow': return $this->parseTable(); case 'PyStringOp': return $this->parsePyString(); case 'Step': return $this->parseStep(); case 'Text': return $this->parseText(); case 'Newline': return $this->parseNewline(); case 'Tag': return $this->parseTags(); case 'Comment': return $this->parseComment(); case 'Language': return $this->parseLanguage(); case 'EOS': return ''; } throw new ParserException(sprintf('Unknown token type: %s', $type)); }
php
protected function parseExpression() { switch ($type = $this->predictTokenType()) { case 'Feature': return $this->parseFeature(); case 'Background': return $this->parseBackground(); case 'Scenario': return $this->parseScenario(); case 'Outline': return $this->parseOutline(); case 'Examples': return $this->parseExamples(); case 'TableRow': return $this->parseTable(); case 'PyStringOp': return $this->parsePyString(); case 'Step': return $this->parseStep(); case 'Text': return $this->parseText(); case 'Newline': return $this->parseNewline(); case 'Tag': return $this->parseTags(); case 'Comment': return $this->parseComment(); case 'Language': return $this->parseLanguage(); case 'EOS': return ''; } throw new ParserException(sprintf('Unknown token type: %s', $type)); }
[ "protected", "function", "parseExpression", "(", ")", "{", "switch", "(", "$", "type", "=", "$", "this", "->", "predictTokenType", "(", ")", ")", "{", "case", "'Feature'", ":", "return", "$", "this", "->", "parseFeature", "(", ")", ";", "case", "'Backgro...
Parses current expression & returns Node. @return string|FeatureNode|BackgroundNode|ScenarioNode|OutlineNode|TableNode|StepNode @throws ParserException
[ "Parses", "current", "expression", "&", "returns", "Node", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Parser.php#L182-L216
train
Behat/Gherkin
src/Behat/Gherkin/Parser.php
Parser.parseFeature
protected function parseFeature() { $token = $this->expectTokenType('Feature'); $title = trim($token['value']) ?: null; $description = null; $tags = $this->popTags(); $background = null; $scenarios = array(); $keyword = $token['keyword']; $language = $this->lexer->getLanguage(); $file = $this->file; $line = $token['line']; // Parse description, background, scenarios & outlines while ('EOS' !== $this->predictTokenType()) { $node = $this->parseExpression(); if (is_string($node)) { $text = preg_replace('/^\s{0,' . ($token['indent'] + 2) . '}|\s*$/', '', $node); $description .= (null !== $description ? "\n" : '') . $text; continue; } if (!$background && $node instanceof BackgroundNode) { $background = $node; continue; } if ($node instanceof ScenarioInterface) { $scenarios[] = $node; continue; } if ($background instanceof BackgroundNode && $node instanceof BackgroundNode) { throw new ParserException(sprintf( 'Each Feature could have only one Background, but found multiple on lines %d and %d%s', $background->getLine(), $node->getLine(), $this->file ? ' in file: ' . $this->file : '' )); } if (!$node instanceof ScenarioNode) { throw new ParserException(sprintf( 'Expected Scenario, Outline or Background, but got %s on line: %d%s', $node->getNodeType(), $node->getLine(), $this->file ? ' in file: ' . $this->file : '' )); } } return new FeatureNode( rtrim($title) ?: null, rtrim($description) ?: null, $tags, $background, $scenarios, $keyword, $language, $file, $line ); }
php
protected function parseFeature() { $token = $this->expectTokenType('Feature'); $title = trim($token['value']) ?: null; $description = null; $tags = $this->popTags(); $background = null; $scenarios = array(); $keyword = $token['keyword']; $language = $this->lexer->getLanguage(); $file = $this->file; $line = $token['line']; // Parse description, background, scenarios & outlines while ('EOS' !== $this->predictTokenType()) { $node = $this->parseExpression(); if (is_string($node)) { $text = preg_replace('/^\s{0,' . ($token['indent'] + 2) . '}|\s*$/', '', $node); $description .= (null !== $description ? "\n" : '') . $text; continue; } if (!$background && $node instanceof BackgroundNode) { $background = $node; continue; } if ($node instanceof ScenarioInterface) { $scenarios[] = $node; continue; } if ($background instanceof BackgroundNode && $node instanceof BackgroundNode) { throw new ParserException(sprintf( 'Each Feature could have only one Background, but found multiple on lines %d and %d%s', $background->getLine(), $node->getLine(), $this->file ? ' in file: ' . $this->file : '' )); } if (!$node instanceof ScenarioNode) { throw new ParserException(sprintf( 'Expected Scenario, Outline or Background, but got %s on line: %d%s', $node->getNodeType(), $node->getLine(), $this->file ? ' in file: ' . $this->file : '' )); } } return new FeatureNode( rtrim($title) ?: null, rtrim($description) ?: null, $tags, $background, $scenarios, $keyword, $language, $file, $line ); }
[ "protected", "function", "parseFeature", "(", ")", "{", "$", "token", "=", "$", "this", "->", "expectTokenType", "(", "'Feature'", ")", ";", "$", "title", "=", "trim", "(", "$", "token", "[", "'value'", "]", ")", "?", ":", "null", ";", "$", "descript...
Parses feature token & returns it's node. @return FeatureNode @throws ParserException
[ "Parses", "feature", "token", "&", "returns", "it", "s", "node", "." ]
749be1ff9ed4265a4465c90c3900bdebad6b008e
https://github.com/Behat/Gherkin/blob/749be1ff9ed4265a4465c90c3900bdebad6b008e/src/Behat/Gherkin/Parser.php#L225-L289
train