repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
browscap/browscap
src/Browscap/Writer/JsonWriter.php
JsonWriter.renderHeader
public function renderHeader(array $comments = []) : void { if ($this->isSilent()) { return; } $this->logger->debug('rendering comments'); fwrite($this->file, ' "comments": [' . PHP_EOL); foreach ($comments as $i => $text) { fwrite($this->file, ' ...
php
public function renderHeader(array $comments = []) : void { if ($this->isSilent()) { return; } $this->logger->debug('rendering comments'); fwrite($this->file, ' "comments": [' . PHP_EOL); foreach ($comments as $i => $text) { fwrite($this->file, ' ...
[ "public", "function", "renderHeader", "(", "array", "$", "comments", "=", "[", "]", ")", ":", "void", "{", "if", "(", "$", "this", "->", "isSilent", "(", ")", ")", "{", "return", ";", "}", "$", "this", "->", "logger", "->", "debug", "(", "'renderin...
Generate the header @param string[] $comments
[ "Generate", "the", "header" ]
train
https://github.com/browscap/browscap/blob/5dca9e80c43eb50f703e68b6851e1da7e683b85c/src/Browscap/Writer/JsonWriter.php#L164-L185
browscap/browscap
src/Browscap/Writer/JsonWriter.php
JsonWriter.renderSectionHeader
public function renderSectionHeader(string $sectionName) : void { if ($this->isSilent()) { return; } fwrite($this->file, ' ' . $this->formatter->formatPropertyName($sectionName) . ': '); }
php
public function renderSectionHeader(string $sectionName) : void { if ($this->isSilent()) { return; } fwrite($this->file, ' ' . $this->formatter->formatPropertyName($sectionName) . ': '); }
[ "public", "function", "renderSectionHeader", "(", "string", "$", "sectionName", ")", ":", "void", "{", "if", "(", "$", "this", "->", "isSilent", "(", ")", ")", "{", "return", ";", "}", "fwrite", "(", "$", "this", "->", "file", ",", "' '", ".", "$", ...
renders the header for a section @param string $sectionName
[ "renders", "the", "header", "for", "a", "section" ]
train
https://github.com/browscap/browscap/blob/5dca9e80c43eb50f703e68b6851e1da7e683b85c/src/Browscap/Writer/JsonWriter.php#L242-L249
browscap/browscap
src/Browscap/Command/BuildCommand.php
BuildCommand.execute
protected function execute(InputInterface $input, OutputInterface $output) : ?int { $loggerHelper = new LoggerHelper(); $logger = $loggerHelper->create($output); $logger->info('Build started.'); /** @var string $buildFolder */ $buildFolder = $input->getOption('output'...
php
protected function execute(InputInterface $input, OutputInterface $output) : ?int { $loggerHelper = new LoggerHelper(); $logger = $loggerHelper->create($output); $logger->info('Build started.'); /** @var string $buildFolder */ $buildFolder = $input->getOption('output'...
[ "protected", "function", "execute", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", ":", "?", "int", "{", "$", "loggerHelper", "=", "new", "LoggerHelper", "(", ")", ";", "$", "logger", "=", "$", "loggerHelper", "->", "creat...
@param InputInterface $input @param OutputInterface $output @throws \Exception @throws \Assert\AssertionFailedException @return int|null null or 0 if everything went fine, or an error code
[ "@param", "InputInterface", "$input", "@param", "OutputInterface", "$output" ]
train
https://github.com/browscap/browscap/blob/5dca9e80c43eb50f703e68b6851e1da7e683b85c/src/Browscap/Command/BuildCommand.php#L51-L94
browscap/browscap
src/Browscap/Filter/StandardFilter.php
StandardFilter.isOutputProperty
public function isOutputProperty(string $property, WriterInterface $writer) : bool { if (!$this->propertyHolder->isOutputProperty($property, $writer)) { return false; } if ($this->propertyHolder->isLiteModeProperty($property, $writer)) { return true; } ...
php
public function isOutputProperty(string $property, WriterInterface $writer) : bool { if (!$this->propertyHolder->isOutputProperty($property, $writer)) { return false; } if ($this->propertyHolder->isLiteModeProperty($property, $writer)) { return true; } ...
[ "public", "function", "isOutputProperty", "(", "string", "$", "property", ",", "WriterInterface", "$", "writer", ")", ":", "bool", "{", "if", "(", "!", "$", "this", "->", "propertyHolder", "->", "isOutputProperty", "(", "$", "property", ",", "$", "writer", ...
checks if a property should be in the output @param string $property @param WriterInterface $writer @return bool
[ "checks", "if", "a", "property", "should", "be", "in", "the", "output" ]
train
https://github.com/browscap/browscap/blob/5dca9e80c43eb50f703e68b6851e1da7e683b85c/src/Browscap/Filter/StandardFilter.php#L69-L80
browscap/browscap
src/Browscap/Coverage/Processor.php
Processor.process
public function process(array $coveredIds) : void { $this->setCoveredPatternIds($coveredIds); $finder = new Finder(); $finder->files(); $finder->name('*.json'); $finder->ignoreDotFiles(true); $finder->ignoreVCS(true); $finder->sortByName(); $finder->i...
php
public function process(array $coveredIds) : void { $this->setCoveredPatternIds($coveredIds); $finder = new Finder(); $finder->files(); $finder->name('*.json'); $finder->ignoreDotFiles(true); $finder->ignoreVCS(true); $finder->sortByName(); $finder->i...
[ "public", "function", "process", "(", "array", "$", "coveredIds", ")", ":", "void", "{", "$", "this", "->", "setCoveredPatternIds", "(", "$", "coveredIds", ")", ";", "$", "finder", "=", "new", "Finder", "(", ")", ";", "$", "finder", "->", "files", "(",...
Process the directory of JSON files using the collected pattern ids @param string[] $coveredIds
[ "Process", "the", "directory", "of", "JSON", "files", "using", "the", "collected", "pattern", "ids" ]
train
https://github.com/browscap/browscap/blob/5dca9e80c43eb50f703e68b6851e1da7e683b85c/src/Browscap/Coverage/Processor.php#L100-L129
browscap/browscap
src/Browscap/Coverage/Processor.php
Processor.write
public function write(string $fileName) : void { file_put_contents( $fileName, // str_replace here is to convert empty arrays into empty JS objects, which is expected by // codecov.io. Owner of the service said he was going to patch it, haven't tested since //...
php
public function write(string $fileName) : void { file_put_contents( $fileName, // str_replace here is to convert empty arrays into empty JS objects, which is expected by // codecov.io. Owner of the service said he was going to patch it, haven't tested since //...
[ "public", "function", "write", "(", "string", "$", "fileName", ")", ":", "void", "{", "file_put_contents", "(", "$", "fileName", ",", "// str_replace here is to convert empty arrays into empty JS objects, which is expected by", "// codecov.io. Owner of the service said he was going...
Write the coverage data in JSON format to specified filename @param string $fileName
[ "Write", "the", "coverage", "data", "in", "JSON", "format", "to", "specified", "filename" ]
train
https://github.com/browscap/browscap/blob/5dca9e80c43eb50f703e68b6851e1da7e683b85c/src/Browscap/Coverage/Processor.php#L136-L146
browscap/browscap
src/Browscap/Coverage/Processor.php
Processor.processFile
public function processFile(string $file, string $contents, array $coveredIds) : array { // These keynames are expected by Istanbul compatible coverage reporters // the format is outlined here: https://github.com/gotwarlost/istanbul/blob/master/coverage.json.md $this->fileCoverage = [ ...
php
public function processFile(string $file, string $contents, array $coveredIds) : array { // These keynames are expected by Istanbul compatible coverage reporters // the format is outlined here: https://github.com/gotwarlost/istanbul/blob/master/coverage.json.md $this->fileCoverage = [ ...
[ "public", "function", "processFile", "(", "string", "$", "file", ",", "string", "$", "contents", ",", "array", "$", "coveredIds", ")", ":", "array", "{", "// These keynames are expected by Istanbul compatible coverage reporters", "// the format is outlined here: https://githu...
Process an individual file for coverage data using covered ids @param string $file @param string $contents @param string[] $coveredIds @return array
[ "Process", "an", "individual", "file", "for", "coverage", "data", "using", "covered", "ids" ]
train
https://github.com/browscap/browscap/blob/5dca9e80c43eb50f703e68b6851e1da7e683b85c/src/Browscap/Coverage/Processor.php#L177-L222
browscap/browscap
src/Browscap/Coverage/Processor.php
Processor.getLocationCoordinates
private function getLocationCoordinates(Lexer $lexer, bool $end = false, string $content = '') : array { $lineNumber = $lexer->yylineno; $lineContent = $this->fileLines[$lineNumber]; if ('' === $content) { $content = $lexer->yytext; } $position = mb_strpos($lin...
php
private function getLocationCoordinates(Lexer $lexer, bool $end = false, string $content = '') : array { $lineNumber = $lexer->yylineno; $lineContent = $this->fileLines[$lineNumber]; if ('' === $content) { $content = $lexer->yytext; } $position = mb_strpos($lin...
[ "private", "function", "getLocationCoordinates", "(", "Lexer", "$", "lexer", ",", "bool", "$", "end", "=", "false", ",", "string", "$", "content", "=", "''", ")", ":", "array", "{", "$", "lineNumber", "=", "$", "lexer", "->", "yylineno", ";", "$", "lin...
Builds the location object for the current position in the JSON file @param Lexer $lexer @param bool $end @param string $content @return array
[ "Builds", "the", "location", "object", "for", "the", "current", "position", "in", "the", "JSON", "file" ]
train
https://github.com/browscap/browscap/blob/5dca9e80c43eb50f703e68b6851e1da7e683b85c/src/Browscap/Coverage/Processor.php#L233-L249
browscap/browscap
src/Browscap/Coverage/Processor.php
Processor.handleJsonRoot
private function handleJsonRoot(Lexer $lexer) : void { do { $code = $lexer->lex(); if (self::JSON_OBJECT_START === $code) { $code = $this->handleJsonDivision($lexer); } } while (self::JSON_EOF !== $code); }
php
private function handleJsonRoot(Lexer $lexer) : void { do { $code = $lexer->lex(); if (self::JSON_OBJECT_START === $code) { $code = $this->handleJsonDivision($lexer); } } while (self::JSON_EOF !== $code); }
[ "private", "function", "handleJsonRoot", "(", "Lexer", "$", "lexer", ")", ":", "void", "{", "do", "{", "$", "code", "=", "$", "lexer", "->", "lex", "(", ")", ";", "if", "(", "self", "::", "JSON_OBJECT_START", "===", "$", "code", ")", "{", "$", "cod...
JSON file processing entry point Hands execution off to applicable method when certain tokens are encountered (in this case, Division is the only one), returns to caller when EOF is reached @param Lexer $lexer
[ "JSON", "file", "processing", "entry", "point" ]
train
https://github.com/browscap/browscap/blob/5dca9e80c43eb50f703e68b6851e1da7e683b85c/src/Browscap/Coverage/Processor.php#L259-L268
browscap/browscap
src/Browscap/Coverage/Processor.php
Processor.handleJsonDivision
private function handleJsonDivision(Lexer $lexer) : int { $enterUaGroup = false; do { $code = $lexer->lex(); if (self::JSON_STRING === $code && 'userAgents' === $lexer->yytext) { $enterUaGroup = true; } elseif (self::JSON_ARRAY_START === $code &&...
php
private function handleJsonDivision(Lexer $lexer) : int { $enterUaGroup = false; do { $code = $lexer->lex(); if (self::JSON_STRING === $code && 'userAgents' === $lexer->yytext) { $enterUaGroup = true; } elseif (self::JSON_ARRAY_START === $code &&...
[ "private", "function", "handleJsonDivision", "(", "Lexer", "$", "lexer", ")", ":", "int", "{", "$", "enterUaGroup", "=", "false", ";", "do", "{", "$", "code", "=", "$", "lexer", "->", "lex", "(", ")", ";", "if", "(", "self", "::", "JSON_STRING", "===...
Processes the Division block (which is the root JSON object essentially) Lexes the main division object and hands execution off to relevant methods for further processing. Returns the next token code returned from the lexer. @param Lexer $lexer @return int
[ "Processes", "the", "Division", "block", "(", "which", "is", "the", "root", "JSON", "object", "essentially", ")" ]
train
https://github.com/browscap/browscap/blob/5dca9e80c43eb50f703e68b6851e1da7e683b85c/src/Browscap/Coverage/Processor.php#L280-L298
browscap/browscap
src/Browscap/Coverage/Processor.php
Processor.handleUseragentGroup
private function handleUseragentGroup(Lexer $lexer) : int { $useragentPosition = 0; do { $code = $lexer->lex(); if (self::JSON_OBJECT_START === $code) { $code = $this->handleUseragentBlock($lexer, $useragentPosition); ++$useragentPosition; ...
php
private function handleUseragentGroup(Lexer $lexer) : int { $useragentPosition = 0; do { $code = $lexer->lex(); if (self::JSON_OBJECT_START === $code) { $code = $this->handleUseragentBlock($lexer, $useragentPosition); ++$useragentPosition; ...
[ "private", "function", "handleUseragentGroup", "(", "Lexer", "$", "lexer", ")", ":", "int", "{", "$", "useragentPosition", "=", "0", ";", "do", "{", "$", "code", "=", "$", "lexer", "->", "lex", "(", ")", ";", "if", "(", "self", "::", "JSON_OBJECT_START...
Processes the userAgents array @param Lexer $lexer @return int
[ "Processes", "the", "userAgents", "array" ]
train
https://github.com/browscap/browscap/blob/5dca9e80c43eb50f703e68b6851e1da7e683b85c/src/Browscap/Coverage/Processor.php#L307-L321
browscap/browscap
src/Browscap/Coverage/Processor.php
Processor.handleUseragentBlock
private function handleUseragentBlock(Lexer $lexer, int $useragentPosition) : int { $enterChildGroup = false; do { $code = $lexer->lex(); if (self::JSON_STRING === $code && 'children' === $lexer->yytext) { $enterChildGroup = true; } elseif (self:...
php
private function handleUseragentBlock(Lexer $lexer, int $useragentPosition) : int { $enterChildGroup = false; do { $code = $lexer->lex(); if (self::JSON_STRING === $code && 'children' === $lexer->yytext) { $enterChildGroup = true; } elseif (self:...
[ "private", "function", "handleUseragentBlock", "(", "Lexer", "$", "lexer", ",", "int", "$", "useragentPosition", ")", ":", "int", "{", "$", "enterChildGroup", "=", "false", ";", "do", "{", "$", "code", "=", "$", "lexer", "->", "lex", "(", ")", ";", "if...
Processes each userAgent object in the userAgents array @param Lexer $lexer @param int $useragentPosition @return int
[ "Processes", "each", "userAgent", "object", "in", "the", "userAgents", "array" ]
train
https://github.com/browscap/browscap/blob/5dca9e80c43eb50f703e68b6851e1da7e683b85c/src/Browscap/Coverage/Processor.php#L331-L349
browscap/browscap
src/Browscap/Coverage/Processor.php
Processor.handleChildrenGroup
private function handleChildrenGroup(Lexer $lexer, int $useragentPosition) : int { $childPosition = 0; do { $code = $lexer->lex(); if (self::JSON_OBJECT_START === $code) { $code = $this->handleChildBlock($lexer, $useragentPosition, $childPosition); ...
php
private function handleChildrenGroup(Lexer $lexer, int $useragentPosition) : int { $childPosition = 0; do { $code = $lexer->lex(); if (self::JSON_OBJECT_START === $code) { $code = $this->handleChildBlock($lexer, $useragentPosition, $childPosition); ...
[ "private", "function", "handleChildrenGroup", "(", "Lexer", "$", "lexer", ",", "int", "$", "useragentPosition", ")", ":", "int", "{", "$", "childPosition", "=", "0", ";", "do", "{", "$", "code", "=", "$", "lexer", "->", "lex", "(", ")", ";", "if", "(...
Processes the children array of a userAgent object @param Lexer $lexer @param int $useragentPosition @return int
[ "Processes", "the", "children", "array", "of", "a", "userAgent", "object" ]
train
https://github.com/browscap/browscap/blob/5dca9e80c43eb50f703e68b6851e1da7e683b85c/src/Browscap/Coverage/Processor.php#L359-L373
browscap/browscap
src/Browscap/Coverage/Processor.php
Processor.handleChildBlock
private function handleChildBlock(Lexer $lexer, int $useragentPosition, int $childPosition) : int { $enterPlatforms = false; $enterDevices = false; $collectMatch = false; $functionStart = $this->getLocationCoordinates($lexer); $functionDeclaration = []; do...
php
private function handleChildBlock(Lexer $lexer, int $useragentPosition, int $childPosition) : int { $enterPlatforms = false; $enterDevices = false; $collectMatch = false; $functionStart = $this->getLocationCoordinates($lexer); $functionDeclaration = []; do...
[ "private", "function", "handleChildBlock", "(", "Lexer", "$", "lexer", ",", "int", "$", "useragentPosition", ",", "int", "$", "childPosition", ")", ":", "int", "{", "$", "enterPlatforms", "=", "false", ";", "$", "enterDevices", "=", "false", ";", "$", "col...
Processes each child object in the children array @param Lexer $lexer @param int $useragentPosition @param int $childPosition @return int
[ "Processes", "each", "child", "object", "in", "the", "children", "array" ]
train
https://github.com/browscap/browscap/blob/5dca9e80c43eb50f703e68b6851e1da7e683b85c/src/Browscap/Coverage/Processor.php#L384-L443
browscap/browscap
src/Browscap/Coverage/Processor.php
Processor.handleDeviceBlock
private function handleDeviceBlock(Lexer $lexer, int $useragentPosition, int $childPosition) : int { $capturedKey = false; $sawColon = false; $branchStart = $this->getLocationCoordinates($lexer); $branchLocations = []; $branchCoverage = []; do { ...
php
private function handleDeviceBlock(Lexer $lexer, int $useragentPosition, int $childPosition) : int { $capturedKey = false; $sawColon = false; $branchStart = $this->getLocationCoordinates($lexer); $branchLocations = []; $branchCoverage = []; do { ...
[ "private", "function", "handleDeviceBlock", "(", "Lexer", "$", "lexer", ",", "int", "$", "useragentPosition", ",", "int", "$", "childPosition", ")", ":", "int", "{", "$", "capturedKey", "=", "false", ";", "$", "sawColon", "=", "false", ";", "$", "branchSta...
Process the "devices" has in the child object @param Lexer $lexer @param int $useragentPosition @param int $childPosition @return int
[ "Process", "the", "devices", "has", "in", "the", "child", "object" ]
train
https://github.com/browscap/browscap/blob/5dca9e80c43eb50f703e68b6851e1da7e683b85c/src/Browscap/Coverage/Processor.php#L454-L488
browscap/browscap
src/Browscap/Coverage/Processor.php
Processor.handlePlatformBlock
private function handlePlatformBlock(Lexer $lexer, int $useragentPosition, int $childPosition) : int { $branchStart = $this->getLocationCoordinates($lexer); $branchLocations = []; $branchCoverage = []; do { $code = $lexer->lex(); if (self::JSON_STRING =...
php
private function handlePlatformBlock(Lexer $lexer, int $useragentPosition, int $childPosition) : int { $branchStart = $this->getLocationCoordinates($lexer); $branchLocations = []; $branchCoverage = []; do { $code = $lexer->lex(); if (self::JSON_STRING =...
[ "private", "function", "handlePlatformBlock", "(", "Lexer", "$", "lexer", ",", "int", "$", "useragentPosition", ",", "int", "$", "childPosition", ")", ":", "int", "{", "$", "branchStart", "=", "$", "this", "->", "getLocationCoordinates", "(", "$", "lexer", "...
Processes the "platforms" hash in the child object @param Lexer $lexer @param int $useragentPosition @param int $childPosition @return int
[ "Processes", "the", "platforms", "hash", "in", "the", "child", "object" ]
train
https://github.com/browscap/browscap/blob/5dca9e80c43eb50f703e68b6851e1da7e683b85c/src/Browscap/Coverage/Processor.php#L499-L525
browscap/browscap
src/Browscap/Coverage/Processor.php
Processor.ignoreObjectBlock
private function ignoreObjectBlock(Lexer $lexer) : int { do { $code = $lexer->lex(); // recursively ignore nested objects if (self::JSON_OBJECT_START === $code) { $this->ignoreObjectBlock($lexer); } } while (self::JSON_OBJECT_END !== $...
php
private function ignoreObjectBlock(Lexer $lexer) : int { do { $code = $lexer->lex(); // recursively ignore nested objects if (self::JSON_OBJECT_START === $code) { $this->ignoreObjectBlock($lexer); } } while (self::JSON_OBJECT_END !== $...
[ "private", "function", "ignoreObjectBlock", "(", "Lexer", "$", "lexer", ")", ":", "int", "{", "do", "{", "$", "code", "=", "$", "lexer", "->", "lex", "(", ")", ";", "// recursively ignore nested objects", "if", "(", "self", "::", "JSON_OBJECT_START", "===", ...
Processes JSON object block that isn't needed for coverage data @param Lexer $lexer @return int
[ "Processes", "JSON", "object", "block", "that", "isn", "t", "needed", "for", "coverage", "data" ]
train
https://github.com/browscap/browscap/blob/5dca9e80c43eb50f703e68b6851e1da7e683b85c/src/Browscap/Coverage/Processor.php#L534-L546
browscap/browscap
src/Browscap/Coverage/Processor.php
Processor.collectFunction
private function collectFunction(array $start, array $end, array $declaration, int $coverage = 0) : void { $this->fileCoverage['fnMap'][] = [ 'name' => '(anonymous_' . $this->funcCount . ')', 'decl' => $declaration, 'loc' => ['start' => $start, 'end' => $end], ]; ...
php
private function collectFunction(array $start, array $end, array $declaration, int $coverage = 0) : void { $this->fileCoverage['fnMap'][] = [ 'name' => '(anonymous_' . $this->funcCount . ')', 'decl' => $declaration, 'loc' => ['start' => $start, 'end' => $end], ]; ...
[ "private", "function", "collectFunction", "(", "array", "$", "start", ",", "array", "$", "end", ",", "array", "$", "declaration", ",", "int", "$", "coverage", "=", "0", ")", ":", "void", "{", "$", "this", "->", "fileCoverage", "[", "'fnMap'", "]", "[",...
Collects and stores a function's location information as well as any passed in coverage counts @param array $start @param array $end @param array $declaration @param int $coverage
[ "Collects", "and", "stores", "a", "function", "s", "location", "information", "as", "well", "as", "any", "passed", "in", "coverage", "counts" ]
train
https://github.com/browscap/browscap/blob/5dca9e80c43eb50f703e68b6851e1da7e683b85c/src/Browscap/Coverage/Processor.php#L556-L571
browscap/browscap
src/Browscap/Coverage/Processor.php
Processor.collectBranch
private function collectBranch(array $start, array $end, array $locations, array $coverage = []) : void { $this->fileCoverage['branchMap'][] = [ 'type' => 'switch', 'locations' => $locations, 'loc' => ['start' => $start, 'end' => $end], ]; $this->fileCove...
php
private function collectBranch(array $start, array $end, array $locations, array $coverage = []) : void { $this->fileCoverage['branchMap'][] = [ 'type' => 'switch', 'locations' => $locations, 'loc' => ['start' => $start, 'end' => $end], ]; $this->fileCove...
[ "private", "function", "collectBranch", "(", "array", "$", "start", ",", "array", "$", "end", ",", "array", "$", "locations", ",", "array", "$", "coverage", "=", "[", "]", ")", ":", "void", "{", "$", "this", "->", "fileCoverage", "[", "'branchMap'", "]...
Collects and stores a branch's location information as well as any coverage counts @param array $start @param array $end @param array $locations @param int[] $coverage
[ "Collects", "and", "stores", "a", "branch", "s", "location", "information", "as", "well", "as", "any", "coverage", "counts" ]
train
https://github.com/browscap/browscap/blob/5dca9e80c43eb50f703e68b6851e1da7e683b85c/src/Browscap/Coverage/Processor.php#L581-L597
browscap/browscap
src/Browscap/Coverage/Processor.php
Processor.collectStatement
private function collectStatement(array $start, array $end, int $coverage = 0) : void { $this->fileCoverage['statementMap'][] = [ 'start' => $start, 'end' => $end, ]; $this->fileCoverage['s'][] = $coverage; }
php
private function collectStatement(array $start, array $end, int $coverage = 0) : void { $this->fileCoverage['statementMap'][] = [ 'start' => $start, 'end' => $end, ]; $this->fileCoverage['s'][] = $coverage; }
[ "private", "function", "collectStatement", "(", "array", "$", "start", ",", "array", "$", "end", ",", "int", "$", "coverage", "=", "0", ")", ":", "void", "{", "$", "this", "->", "fileCoverage", "[", "'statementMap'", "]", "[", "]", "=", "[", "'start'",...
Collects and stores a statement's location information as well as any coverage counts @param array $start @param array $end @param int $coverage
[ "Collects", "and", "stores", "a", "statement", "s", "location", "information", "as", "well", "as", "any", "coverage", "counts" ]
train
https://github.com/browscap/browscap/blob/5dca9e80c43eb50f703e68b6851e1da7e683b85c/src/Browscap/Coverage/Processor.php#L606-L614
browscap/browscap
src/Browscap/Coverage/Processor.php
Processor.groupIdsByFile
private function groupIdsByFile(array $ids) : array { $covered = []; foreach ($ids as $id) { $file = mb_substr($id, 0, (int) mb_strpos($id, '::')); if (!isset($covered[$file])) { $covered[$file] = []; } $covered[$file][] = mb_substr(...
php
private function groupIdsByFile(array $ids) : array { $covered = []; foreach ($ids as $id) { $file = mb_substr($id, 0, (int) mb_strpos($id, '::')); if (!isset($covered[$file])) { $covered[$file] = []; } $covered[$file][] = mb_substr(...
[ "private", "function", "groupIdsByFile", "(", "array", "$", "ids", ")", ":", "array", "{", "$", "covered", "=", "[", "]", ";", "foreach", "(", "$", "ids", "as", "$", "id", ")", "{", "$", "file", "=", "mb_substr", "(", "$", "id", ",", "0", ",", ...
Groups pattern ids by their filename prefix @param string[] $ids @return array
[ "Groups", "pattern", "ids", "by", "their", "filename", "prefix" ]
train
https://github.com/browscap/browscap/blob/5dca9e80c43eb50f703e68b6851e1da7e683b85c/src/Browscap/Coverage/Processor.php#L623-L638
browscap/browscap
src/Browscap/Coverage/Processor.php
Processor.getCoverageCount
private function getCoverageCount(string $id, array $covered) : int { $id = str_replace('\/', '/', $id); [$u, $c, $d, $p] = explode('::', $id); $u = preg_quote(mb_substr($u, 1), '/'); $c = preg_quote(mb_substr($c, 1), '/'); $p = preg_quote(mb_substr($p, 1), '/')...
php
private function getCoverageCount(string $id, array $covered) : int { $id = str_replace('\/', '/', $id); [$u, $c, $d, $p] = explode('::', $id); $u = preg_quote(mb_substr($u, 1), '/'); $c = preg_quote(mb_substr($c, 1), '/'); $p = preg_quote(mb_substr($p, 1), '/')...
[ "private", "function", "getCoverageCount", "(", "string", "$", "id", ",", "array", "$", "covered", ")", ":", "int", "{", "$", "id", "=", "str_replace", "(", "'\\/'", ",", "'/'", ",", "$", "id", ")", ";", "[", "$", "u", ",", "$", "c", ",", "$", ...
Counts number of times given generated pattern id is covered by patterns ids collected during tests @param string $id @param string[] $covered @return int
[ "Counts", "number", "of", "times", "given", "generated", "pattern", "id", "is", "covered", "by", "patterns", "ids", "collected", "during", "tests" ]
train
https://github.com/browscap/browscap/blob/5dca9e80c43eb50f703e68b6851e1da7e683b85c/src/Browscap/Coverage/Processor.php#L648-L676
browscap/browscap
src/Browscap/Data/Factory/DeviceFactory.php
DeviceFactory.build
public function build(array $deviceData, string $deviceName) : Device { Assertion::keyExists($deviceData, 'standard', 'the value for "standard" key is missing for device "' . $deviceName . '"'); Assertion::boolean($deviceData['standard'], 'the value for "standard" key has to be a boolean value for d...
php
public function build(array $deviceData, string $deviceName) : Device { Assertion::keyExists($deviceData, 'standard', 'the value for "standard" key is missing for device "' . $deviceName . '"'); Assertion::boolean($deviceData['standard'], 'the value for "standard" key has to be a boolean value for d...
[ "public", "function", "build", "(", "array", "$", "deviceData", ",", "string", "$", "deviceName", ")", ":", "Device", "{", "Assertion", "::", "keyExists", "(", "$", "deviceData", ",", "'standard'", ",", "'the value for \"standard\" key is missing for device \"'", "....
validates the $deviceData array and creates Device objects from it @param array $deviceData The Device data for the current object @param string $deviceName The name for the current device @throws \RuntimeException if the file does not exist or has invalid JSON @throws \Assert\AssertionFailedException...
[ "validates", "the", "$deviceData", "array", "and", "creates", "Device", "objects", "from", "it" ]
train
https://github.com/browscap/browscap/blob/5dca9e80c43eb50f703e68b6851e1da7e683b85c/src/Browscap/Data/Factory/DeviceFactory.php#L22-L42
browscap/browscap
src/Browscap/Writer/XmlWriter.php
XmlWriter.fileStart
public function fileStart() : void { if ($this->isSilent()) { return; } fwrite($this->file, '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL); fwrite($this->file, '<browsercaps>' . PHP_EOL); }
php
public function fileStart() : void { if ($this->isSilent()) { return; } fwrite($this->file, '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL); fwrite($this->file, '<browsercaps>' . PHP_EOL); }
[ "public", "function", "fileStart", "(", ")", ":", "void", "{", "if", "(", "$", "this", "->", "isSilent", "(", ")", ")", "{", "return", ";", "}", "fwrite", "(", "$", "this", "->", "file", ",", "'<?xml version=\"1.0\" encoding=\"UTF-8\"?>'", ".", "PHP_EOL", ...
Generates a start sequence for the output file
[ "Generates", "a", "start", "sequence", "for", "the", "output", "file" ]
train
https://github.com/browscap/browscap/blob/5dca9e80c43eb50f703e68b6851e1da7e683b85c/src/Browscap/Writer/XmlWriter.php#L131-L139
browscap/browscap
src/Browscap/Writer/XmlWriter.php
XmlWriter.renderHeader
public function renderHeader(array $comments = []) : void { if ($this->isSilent()) { return; } $this->logger->debug('rendering comments'); fwrite($this->file, '<comments>' . PHP_EOL); foreach ($comments as $text) { fwrite($this->file, '<comment><![C...
php
public function renderHeader(array $comments = []) : void { if ($this->isSilent()) { return; } $this->logger->debug('rendering comments'); fwrite($this->file, '<comments>' . PHP_EOL); foreach ($comments as $text) { fwrite($this->file, '<comment><![C...
[ "public", "function", "renderHeader", "(", "array", "$", "comments", "=", "[", "]", ")", ":", "void", "{", "if", "(", "$", "this", "->", "isSilent", "(", ")", ")", "{", "return", ";", "}", "$", "this", "->", "logger", "->", "debug", "(", "'renderin...
Generate the header @param string[] $comments
[ "Generate", "the", "header" ]
train
https://github.com/browscap/browscap/blob/5dca9e80c43eb50f703e68b6851e1da7e683b85c/src/Browscap/Writer/XmlWriter.php#L158-L173
browscap/browscap
src/Browscap/Writer/XmlWriter.php
XmlWriter.renderVersion
public function renderVersion(array $versionData = []) : void { if ($this->isSilent()) { return; } $this->logger->debug('rendering version information'); fwrite($this->file, '<gjk_browscap_version>' . PHP_EOL); if (!isset($versionData['version'])) { ...
php
public function renderVersion(array $versionData = []) : void { if ($this->isSilent()) { return; } $this->logger->debug('rendering version information'); fwrite($this->file, '<gjk_browscap_version>' . PHP_EOL); if (!isset($versionData['version'])) { ...
[ "public", "function", "renderVersion", "(", "array", "$", "versionData", "=", "[", "]", ")", ":", "void", "{", "if", "(", "$", "this", "->", "isSilent", "(", ")", ")", "{", "return", ";", "}", "$", "this", "->", "logger", "->", "debug", "(", "'rend...
renders the version information @param string[] $versionData
[ "renders", "the", "version", "information" ]
train
https://github.com/browscap/browscap/blob/5dca9e80c43eb50f703e68b6851e1da7e683b85c/src/Browscap/Writer/XmlWriter.php#L180-L202
bschmitt/laravel-amqp
src/Consumer.php
Consumer.acknowledge
public function acknowledge(AMQPMessage $message) { $message->delivery_info['channel']->basic_ack($message->delivery_info['delivery_tag']); if ($message->body === 'quit') { $message->delivery_info['channel']->basic_cancel($message->delivery_info['consumer_tag']); } }
php
public function acknowledge(AMQPMessage $message) { $message->delivery_info['channel']->basic_ack($message->delivery_info['delivery_tag']); if ($message->body === 'quit') { $message->delivery_info['channel']->basic_cancel($message->delivery_info['consumer_tag']); } }
[ "public", "function", "acknowledge", "(", "AMQPMessage", "$", "message", ")", "{", "$", "message", "->", "delivery_info", "[", "'channel'", "]", "->", "basic_ack", "(", "$", "message", "->", "delivery_info", "[", "'delivery_tag'", "]", ")", ";", "if", "(", ...
Acknowledges a message @param AMQPMessage $message
[ "Acknowledges", "a", "message" ]
train
https://github.com/bschmitt/laravel-amqp/blob/d105e24b85ff9b026d35cdf0bfd34019d5e00bba/src/Consumer.php#L99-L106
bschmitt/laravel-amqp
src/Consumer.php
Consumer.reject
public function reject(AMQPMessage $message, $requeue = false) { $message->delivery_info['channel']->basic_reject($message->delivery_info['delivery_tag'], $requeue); }
php
public function reject(AMQPMessage $message, $requeue = false) { $message->delivery_info['channel']->basic_reject($message->delivery_info['delivery_tag'], $requeue); }
[ "public", "function", "reject", "(", "AMQPMessage", "$", "message", ",", "$", "requeue", "=", "false", ")", "{", "$", "message", "->", "delivery_info", "[", "'channel'", "]", "->", "basic_reject", "(", "$", "message", "->", "delivery_info", "[", "'delivery_t...
Rejects a message and requeues it if wanted (default: false) @param AMQPMessage $message @param bool $requeue
[ "Rejects", "a", "message", "and", "requeues", "it", "if", "wanted", "(", "default", ":", "false", ")" ]
train
https://github.com/bschmitt/laravel-amqp/blob/d105e24b85ff9b026d35cdf0bfd34019d5e00bba/src/Consumer.php#L114-L117
bschmitt/laravel-amqp
src/LumenServiceProvider.php
LumenServiceProvider.register
public function register() { $this->app->bind('Bschmitt\Amqp\Publisher', function ($app) { return new Publisher($app->config); }); $this->app->bind('Bschmitt\Amqp\Consumer', function ($app) { return new Consumer($app->config); }); $this->app->bind('A...
php
public function register() { $this->app->bind('Bschmitt\Amqp\Publisher', function ($app) { return new Publisher($app->config); }); $this->app->bind('Bschmitt\Amqp\Consumer', function ($app) { return new Consumer($app->config); }); $this->app->bind('A...
[ "public", "function", "register", "(", ")", "{", "$", "this", "->", "app", "->", "bind", "(", "'Bschmitt\\Amqp\\Publisher'", ",", "function", "(", "$", "app", ")", "{", "return", "new", "Publisher", "(", "$", "app", "->", "config", ")", ";", "}", ")", ...
Register bindings in the container. @return void
[ "Register", "bindings", "in", "the", "container", "." ]
train
https://github.com/bschmitt/laravel-amqp/blob/d105e24b85ff9b026d35cdf0bfd34019d5e00bba/src/LumenServiceProvider.php#L29-L44
bschmitt/laravel-amqp
src/AmqpServiceProvider.php
AmqpServiceProvider.boot
public function boot() { $this->app->bind('Amqp', 'Bschmitt\Amqp\Amqp'); if (!class_exists('Amqp')) { class_alias('Bschmitt\Amqp\Facades\Amqp', 'Amqp'); } $this->publishes([ __DIR__.'/../config/amqp.php' => config_path('amqp.php'), ]); }
php
public function boot() { $this->app->bind('Amqp', 'Bschmitt\Amqp\Amqp'); if (!class_exists('Amqp')) { class_alias('Bschmitt\Amqp\Facades\Amqp', 'Amqp'); } $this->publishes([ __DIR__.'/../config/amqp.php' => config_path('amqp.php'), ]); }
[ "public", "function", "boot", "(", ")", "{", "$", "this", "->", "app", "->", "bind", "(", "'Amqp'", ",", "'Bschmitt\\Amqp\\Amqp'", ")", ";", "if", "(", "!", "class_exists", "(", "'Amqp'", ")", ")", "{", "class_alias", "(", "'Bschmitt\\Amqp\\Facades\\Amqp'", ...
Bootstrap any application services. @return void
[ "Bootstrap", "any", "application", "services", "." ]
train
https://github.com/bschmitt/laravel-amqp/blob/d105e24b85ff9b026d35cdf0bfd34019d5e00bba/src/AmqpServiceProvider.php#L24-L34
bschmitt/laravel-amqp
src/AmqpServiceProvider.php
AmqpServiceProvider.register
public function register() { $this->app->singleton('Bschmitt\Amqp\Publisher', function ($app) { return new Publisher(config()); }); $this->app->singleton('Bschmitt\Amqp\Consumer', function ($app) { return new Consumer(config()); }); }
php
public function register() { $this->app->singleton('Bschmitt\Amqp\Publisher', function ($app) { return new Publisher(config()); }); $this->app->singleton('Bschmitt\Amqp\Consumer', function ($app) { return new Consumer(config()); }); }
[ "public", "function", "register", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'Bschmitt\\Amqp\\Publisher'", ",", "function", "(", "$", "app", ")", "{", "return", "new", "Publisher", "(", "config", "(", ")", ")", ";", "}", ")", ";"...
Register the application services. @return void
[ "Register", "the", "application", "services", "." ]
train
https://github.com/bschmitt/laravel-amqp/blob/d105e24b85ff9b026d35cdf0bfd34019d5e00bba/src/AmqpServiceProvider.php#L41-L49
zgabievi/laravel-promocodes
src/Traits/Rewardable.php
Rewardable.applyCode
public function applyCode($code, $callback = null) { try { if ($promocode = Promocodes::check($code)) { if ($promocode->users()->wherePivot(config('promocodes.related_pivot_key'), $this->id)->exists()) { throw new AlreadyUsedException; } ...
php
public function applyCode($code, $callback = null) { try { if ($promocode = Promocodes::check($code)) { if ($promocode->users()->wherePivot(config('promocodes.related_pivot_key'), $this->id)->exists()) { throw new AlreadyUsedException; } ...
[ "public", "function", "applyCode", "(", "$", "code", ",", "$", "callback", "=", "null", ")", "{", "try", "{", "if", "(", "$", "promocode", "=", "Promocodes", "::", "check", "(", "$", "code", ")", ")", "{", "if", "(", "$", "promocode", "->", "users"...
Apply promocode to user and get callback. @param string $code @param null|\Closure $callback @return null|\Gabievi\Promocodes\Model\Promocode @throws AlreadyUsedException
[ "Apply", "promocode", "to", "user", "and", "get", "callback", "." ]
train
https://github.com/zgabievi/laravel-promocodes/blob/173198a136b3b218c3ba6a60fc1850bdbc263647/src/Traits/Rewardable.php#L33-L63
zgabievi/laravel-promocodes
src/Promocodes.php
Promocodes.output
public function output($amount = 1) { $collection = []; for ($i = 1; $i <= $amount; $i++) { $random = $this->generate(); while (!$this->validate($collection, $random)) { $random = $this->generate(); } array_push($collection, $random)...
php
public function output($amount = 1) { $collection = []; for ($i = 1; $i <= $amount; $i++) { $random = $this->generate(); while (!$this->validate($collection, $random)) { $random = $this->generate(); } array_push($collection, $random)...
[ "public", "function", "output", "(", "$", "amount", "=", "1", ")", "{", "$", "collection", "=", "[", "]", ";", "for", "(", "$", "i", "=", "1", ";", "$", "i", "<=", "$", "amount", ";", "$", "i", "++", ")", "{", "$", "random", "=", "$", "this...
Generates promocodes as many as you wish. @param int $amount @return array
[ "Generates", "promocodes", "as", "many", "as", "you", "wish", "." ]
train
https://github.com/zgabievi/laravel-promocodes/blob/173198a136b3b218c3ba6a60fc1850bdbc263647/src/Promocodes.php#L45-L60
zgabievi/laravel-promocodes
src/Promocodes.php
Promocodes.create
public function create($amount = 1, $reward = null, array $data = [], $expires_in = null, $is_disposable = false) { $records = []; foreach ($this->output($amount) as $code) { $records[] = [ 'code' => $code, 'reward' => $reward, 'data' => j...
php
public function create($amount = 1, $reward = null, array $data = [], $expires_in = null, $is_disposable = false) { $records = []; foreach ($this->output($amount) as $code) { $records[] = [ 'code' => $code, 'reward' => $reward, 'data' => j...
[ "public", "function", "create", "(", "$", "amount", "=", "1", ",", "$", "reward", "=", "null", ",", "array", "$", "data", "=", "[", "]", ",", "$", "expires_in", "=", "null", ",", "$", "is_disposable", "=", "false", ")", "{", "$", "records", "=", ...
Save promocodes into database Successful insert returns generated promocodes Fail will return empty collection. @param int $amount @param null $reward @param array $data @param int|null $expires_in @param bool $is_disposable @return \Illuminate\Support\Collection
[ "Save", "promocodes", "into", "database", "Successful", "insert", "returns", "generated", "promocodes", "Fail", "will", "return", "empty", "collection", "." ]
train
https://github.com/zgabievi/laravel-promocodes/blob/173198a136b3b218c3ba6a60fc1850bdbc263647/src/Promocodes.php#L75-L98
zgabievi/laravel-promocodes
src/Promocodes.php
Promocodes.createDisposable
public function createDisposable($amount = 1, $reward = null, array $data = [], $expires_in = null) { return $this->create($amount, $reward, $data, $expires_in, true); }
php
public function createDisposable($amount = 1, $reward = null, array $data = [], $expires_in = null) { return $this->create($amount, $reward, $data, $expires_in, true); }
[ "public", "function", "createDisposable", "(", "$", "amount", "=", "1", ",", "$", "reward", "=", "null", ",", "array", "$", "data", "=", "[", "]", ",", "$", "expires_in", "=", "null", ")", "{", "return", "$", "this", "->", "create", "(", "$", "amou...
Save one-time use promocodes into database Successful insert returns generated promocodes Fail will return empty collection. @param int $amount @param null $reward @param array $data @param int|null $expires_in @return \Illuminate\Support\Collection
[ "Save", "one", "-", "time", "use", "promocodes", "into", "database", "Successful", "insert", "returns", "generated", "promocodes", "Fail", "will", "return", "empty", "collection", "." ]
train
https://github.com/zgabievi/laravel-promocodes/blob/173198a136b3b218c3ba6a60fc1850bdbc263647/src/Promocodes.php#L112-L115
zgabievi/laravel-promocodes
src/Promocodes.php
Promocodes.check
public function check($code) { $promocode = Promocode::byCode($code)->first(); if ($promocode === null) { throw new InvalidPromocodeException; } if ($promocode->isExpired() || ($promocode->isDisposable() && $promocode->users()->exists())) { return false; ...
php
public function check($code) { $promocode = Promocode::byCode($code)->first(); if ($promocode === null) { throw new InvalidPromocodeException; } if ($promocode->isExpired() || ($promocode->isDisposable() && $promocode->users()->exists())) { return false; ...
[ "public", "function", "check", "(", "$", "code", ")", "{", "$", "promocode", "=", "Promocode", "::", "byCode", "(", "$", "code", ")", "->", "first", "(", ")", ";", "if", "(", "$", "promocode", "===", "null", ")", "{", "throw", "new", "InvalidPromocod...
Check promocode in database if it is valid. @param string $code @return bool|Promocode @throws InvalidPromocodeException
[ "Check", "promocode", "in", "database", "if", "it", "is", "valid", "." ]
train
https://github.com/zgabievi/laravel-promocodes/blob/173198a136b3b218c3ba6a60fc1850bdbc263647/src/Promocodes.php#L125-L138
zgabievi/laravel-promocodes
src/Promocodes.php
Promocodes.apply
public function apply($code) { if (!auth()->check()) { throw new UnauthenticatedException; } try { if ($promocode = $this->check($code)) { if ($this->isSecondUsageAttempt($promocode)) { throw new AlreadyUsedException; ...
php
public function apply($code) { if (!auth()->check()) { throw new UnauthenticatedException; } try { if ($promocode = $this->check($code)) { if ($this->isSecondUsageAttempt($promocode)) { throw new AlreadyUsedException; ...
[ "public", "function", "apply", "(", "$", "code", ")", "{", "if", "(", "!", "auth", "(", ")", "->", "check", "(", ")", ")", "{", "throw", "new", "UnauthenticatedException", ";", "}", "try", "{", "if", "(", "$", "promocode", "=", "$", "this", "->", ...
Apply promocode to user that it's used from now. @param string $code @return bool|Promocode @throws AlreadyUsedException @throws UnauthenticatedException
[ "Apply", "promocode", "to", "user", "that", "it", "s", "used", "from", "now", "." ]
train
https://github.com/zgabievi/laravel-promocodes/blob/173198a136b3b218c3ba6a60fc1850bdbc263647/src/Promocodes.php#L149-L173
zgabievi/laravel-promocodes
src/Promocodes.php
Promocodes.disable
public function disable($code) { $promocode = Promocode::byCode($code)->first(); if ($promocode === null) { throw new InvalidPromocodeException; } $promocode->expires_at = Carbon::now(); return $promocode->save(); }
php
public function disable($code) { $promocode = Promocode::byCode($code)->first(); if ($promocode === null) { throw new InvalidPromocodeException; } $promocode->expires_at = Carbon::now(); return $promocode->save(); }
[ "public", "function", "disable", "(", "$", "code", ")", "{", "$", "promocode", "=", "Promocode", "::", "byCode", "(", "$", "code", ")", "->", "first", "(", ")", ";", "if", "(", "$", "promocode", "===", "null", ")", "{", "throw", "new", "InvalidPromoc...
Expire code as it won't usable anymore. @param string $code @return bool @throws InvalidPromocodeException
[ "Expire", "code", "as", "it", "won", "t", "usable", "anymore", "." ]
train
https://github.com/zgabievi/laravel-promocodes/blob/173198a136b3b218c3ba6a60fc1850bdbc263647/src/Promocodes.php#L196-L207
zgabievi/laravel-promocodes
src/Promocodes.php
Promocodes.clearRedundant
public function clearRedundant() { Promocode::all()->each(function (Promocode $promocode) { if ($promocode->isExpired() || ($promocode->isDisposable() && $promocode->users()->exists())) { $promocode->users()->detach(); $promocode->delete(); } }...
php
public function clearRedundant() { Promocode::all()->each(function (Promocode $promocode) { if ($promocode->isExpired() || ($promocode->isDisposable() && $promocode->users()->exists())) { $promocode->users()->detach(); $promocode->delete(); } }...
[ "public", "function", "clearRedundant", "(", ")", "{", "Promocode", "::", "all", "(", ")", "->", "each", "(", "function", "(", "Promocode", "$", "promocode", ")", "{", "if", "(", "$", "promocode", "->", "isExpired", "(", ")", "||", "(", "$", "promocode...
Clear all expired and used promotion codes that can not be used anymore. @return void
[ "Clear", "all", "expired", "and", "used", "promotion", "codes", "that", "can", "not", "be", "used", "anymore", "." ]
train
https://github.com/zgabievi/laravel-promocodes/blob/173198a136b3b218c3ba6a60fc1850bdbc263647/src/Promocodes.php#L215-L223
zgabievi/laravel-promocodes
src/Promocodes.php
Promocodes.generate
private function generate() { $characters = config('promocodes.characters'); $mask = config('promocodes.mask'); $promocode = ''; $random = []; for ($i = 1; $i <= $this->length; $i++) { $character = $characters[rand(0, strlen($characters) - 1)]; $rando...
php
private function generate() { $characters = config('promocodes.characters'); $mask = config('promocodes.mask'); $promocode = ''; $random = []; for ($i = 1; $i <= $this->length; $i++) { $character = $characters[rand(0, strlen($characters) - 1)]; $rando...
[ "private", "function", "generate", "(", ")", "{", "$", "characters", "=", "config", "(", "'promocodes.characters'", ")", ";", "$", "mask", "=", "config", "(", "'promocodes.mask'", ")", ";", "$", "promocode", "=", "''", ";", "$", "random", "=", "[", "]", ...
Here will be generated single code using your parameters from config. @return string
[ "Here", "will", "be", "generated", "single", "code", "using", "your", "parameters", "from", "config", "." ]
train
https://github.com/zgabievi/laravel-promocodes/blob/173198a136b3b218c3ba6a60fc1850bdbc263647/src/Promocodes.php#L230-L255
zgabievi/laravel-promocodes
src/Promocodes.php
Promocodes.isSecondUsageAttempt
public function isSecondUsageAttempt(Promocode $promocode) { return $promocode->users()->wherePivot(config('promocodes.related_pivot_key', 'user_id'), auth()->id())->exists(); }
php
public function isSecondUsageAttempt(Promocode $promocode) { return $promocode->users()->wherePivot(config('promocodes.related_pivot_key', 'user_id'), auth()->id())->exists(); }
[ "public", "function", "isSecondUsageAttempt", "(", "Promocode", "$", "promocode", ")", "{", "return", "$", "promocode", "->", "users", "(", ")", "->", "wherePivot", "(", "config", "(", "'promocodes.related_pivot_key'", ",", "'user_id'", ")", ",", "auth", "(", ...
Check if user is trying to apply code again. @param Promocode $promocode @return bool
[ "Check", "if", "user", "is", "trying", "to", "apply", "code", "again", "." ]
train
https://github.com/zgabievi/laravel-promocodes/blob/173198a136b3b218c3ba6a60fc1850bdbc263647/src/Promocodes.php#L301-L304
zgabievi/laravel-promocodes
migrations/2016_05_17_221000_create_promocodes_table.php
CreatePromocodesTable.up
public function up() { Schema::create(config('promocodes.table', 'promocodes'), function (Blueprint $table) { $table->increments('id'); $table->string('code', 32)->unique(); $table->double('reward', 10, 2)->nullable(); $table->text('data')->nullable(); ...
php
public function up() { Schema::create(config('promocodes.table', 'promocodes'), function (Blueprint $table) { $table->increments('id'); $table->string('code', 32)->unique(); $table->double('reward', 10, 2)->nullable(); $table->text('data')->nullable(); ...
[ "public", "function", "up", "(", ")", "{", "Schema", "::", "create", "(", "config", "(", "'promocodes.table'", ",", "'promocodes'", ")", ",", "function", "(", "Blueprint", "$", "table", ")", "{", "$", "table", "->", "increments", "(", "'id'", ")", ";", ...
Run the migrations. @return void
[ "Run", "the", "migrations", "." ]
train
https://github.com/zgabievi/laravel-promocodes/blob/173198a136b3b218c3ba6a60fc1850bdbc263647/migrations/2016_05_17_221000_create_promocodes_table.php#L13-L38
myclabs/DeepCopy
src/DeepCopy/Reflection/ReflectionHelper.php
ReflectionHelper.getProperties
public static function getProperties(ReflectionClass $reflectionClass): array { $reflectionProperties = $reflectionClass->getProperties(); $reflectionPropertiesByName = []; foreach ($reflectionProperties as $reflectionProperty) { $propertyName = $reflectionProperty->getName(); ...
php
public static function getProperties(ReflectionClass $reflectionClass): array { $reflectionProperties = $reflectionClass->getProperties(); $reflectionPropertiesByName = []; foreach ($reflectionProperties as $reflectionProperty) { $propertyName = $reflectionProperty->getName(); ...
[ "public", "static", "function", "getProperties", "(", "ReflectionClass", "$", "reflectionClass", ")", ":", "array", "{", "$", "reflectionProperties", "=", "$", "reflectionClass", "->", "getProperties", "(", ")", ";", "$", "reflectionPropertiesByName", "=", "[", "]...
Retrieves all properties (including private ones), from object and all its ancestors. Standard \ReflectionClass->getProperties() does not return private properties from ancestor classes. @author muratyaman@gmail.com @see https://secure.php.net/manual/en/reflectionclass.getproperties.php @param ReflectionClass $refle...
[ "Retrieves", "all", "properties", "(", "including", "private", "ones", ")", "from", "object", "and", "all", "its", "ancestors", "." ]
train
https://github.com/myclabs/DeepCopy/blob/86776fc6e6b3ec4fca9f3683e4402fd4cf8760f6/src/DeepCopy/Reflection/ReflectionHelper.php#L22-L44
myclabs/DeepCopy
src/DeepCopy/Matcher/PropertyTypeMatcher.php
PropertyTypeMatcher.matches
public function matches(object $object, ReflectionProperty $reflectionProperty): bool { $reflectionProperty->setAccessible(true); return $reflectionProperty->getValue($object) instanceof $this->propertyType; }
php
public function matches(object $object, ReflectionProperty $reflectionProperty): bool { $reflectionProperty->setAccessible(true); return $reflectionProperty->getValue($object) instanceof $this->propertyType; }
[ "public", "function", "matches", "(", "object", "$", "object", ",", "ReflectionProperty", "$", "reflectionProperty", ")", ":", "bool", "{", "$", "reflectionProperty", "->", "setAccessible", "(", "true", ")", ";", "return", "$", "reflectionProperty", "->", "getVa...
{@inheritdoc}
[ "{" ]
train
https://github.com/myclabs/DeepCopy/blob/86776fc6e6b3ec4fca9f3683e4402fd4cf8760f6/src/DeepCopy/Matcher/PropertyTypeMatcher.php#L25-L30
myclabs/DeepCopy
src/DeepCopy/Filter/Doctrine/DoctrineCollectionFilter.php
DoctrineCollectionFilter.apply
public function apply(object $object, ReflectionProperty $reflectionProperty, callable $objectCopier): void { $reflectionProperty->setAccessible(true); /** @var Collection $oldCollection */ $oldCollection = $reflectionProperty->getValue($object); $newCollection = $oldCollection->map...
php
public function apply(object $object, ReflectionProperty $reflectionProperty, callable $objectCopier): void { $reflectionProperty->setAccessible(true); /** @var Collection $oldCollection */ $oldCollection = $reflectionProperty->getValue($object); $newCollection = $oldCollection->map...
[ "public", "function", "apply", "(", "object", "$", "object", ",", "ReflectionProperty", "$", "reflectionProperty", ",", "callable", "$", "objectCopier", ")", ":", "void", "{", "$", "reflectionProperty", "->", "setAccessible", "(", "true", ")", ";", "/** @var Col...
Copies the object property doctrine collection. {@inheritdoc}
[ "Copies", "the", "object", "property", "doctrine", "collection", "." ]
train
https://github.com/myclabs/DeepCopy/blob/86776fc6e6b3ec4fca9f3683e4402fd4cf8760f6/src/DeepCopy/Filter/Doctrine/DoctrineCollectionFilter.php#L16-L29
myclabs/DeepCopy
src/DeepCopy/Filter/SetNullFilter.php
SetNullFilter.apply
public function apply(object $object, ReflectionProperty $reflectionProperty, callable $objectCopier): void { $reflectionProperty->setAccessible(true); $reflectionProperty->setValue($object, null); }
php
public function apply(object $object, ReflectionProperty $reflectionProperty, callable $objectCopier): void { $reflectionProperty->setAccessible(true); $reflectionProperty->setValue($object, null); }
[ "public", "function", "apply", "(", "object", "$", "object", ",", "ReflectionProperty", "$", "reflectionProperty", ",", "callable", "$", "objectCopier", ")", ":", "void", "{", "$", "reflectionProperty", "->", "setAccessible", "(", "true", ")", ";", "$", "refle...
Sets the object property to null. {@inheritdoc}
[ "Sets", "the", "object", "property", "to", "null", "." ]
train
https://github.com/myclabs/DeepCopy/blob/86776fc6e6b3ec4fca9f3683e4402fd4cf8760f6/src/DeepCopy/Filter/SetNullFilter.php#L14-L18
myclabs/DeepCopy
src/DeepCopy/Matcher/PropertyNameMatcher.php
PropertyNameMatcher.matches
public function matches(object $object, ReflectionProperty $reflectionProperty): bool { return $reflectionProperty->getName() === $this->property; }
php
public function matches(object $object, ReflectionProperty $reflectionProperty): bool { return $reflectionProperty->getName() === $this->property; }
[ "public", "function", "matches", "(", "object", "$", "object", ",", "ReflectionProperty", "$", "reflectionProperty", ")", ":", "bool", "{", "return", "$", "reflectionProperty", "->", "getName", "(", ")", "===", "$", "this", "->", "property", ";", "}" ]
Matches a property by its name. {@inheritdoc}
[ "Matches", "a", "property", "by", "its", "name", "." ]
train
https://github.com/myclabs/DeepCopy/blob/86776fc6e6b3ec4fca9f3683e4402fd4cf8760f6/src/DeepCopy/Matcher/PropertyNameMatcher.php#L27-L30
myclabs/DeepCopy
src/DeepCopy/Filter/ReplaceFilter.php
ReplaceFilter.apply
public function apply(object $object, ReflectionProperty $reflectionProperty, callable $objectCopier): void { $reflectionProperty->setAccessible(true); $value = ($this->callback)($reflectionProperty->getValue($object)); $reflectionProperty->setValue($object, $value); }
php
public function apply(object $object, ReflectionProperty $reflectionProperty, callable $objectCopier): void { $reflectionProperty->setAccessible(true); $value = ($this->callback)($reflectionProperty->getValue($object)); $reflectionProperty->setValue($object, $value); }
[ "public", "function", "apply", "(", "object", "$", "object", ",", "ReflectionProperty", "$", "reflectionProperty", ",", "callable", "$", "objectCopier", ")", ":", "void", "{", "$", "reflectionProperty", "->", "setAccessible", "(", "true", ")", ";", "$", "value...
Replaces the object property by the result of the callback called with the object property. {@inheritdoc}
[ "Replaces", "the", "object", "property", "by", "the", "result", "of", "the", "callback", "called", "with", "the", "object", "property", "." ]
train
https://github.com/myclabs/DeepCopy/blob/86776fc6e6b3ec4fca9f3683e4402fd4cf8760f6/src/DeepCopy/Filter/ReplaceFilter.php#L24-L31
myclabs/DeepCopy
src/DeepCopy/TypeFilter/Date/DateIntervalFilter.php
DateIntervalFilter.apply
public function apply($value) { $copy = new DateInterval('P0D'); foreach ($value as $propertyName => $propertyValue) { $copy->{$propertyName} = $propertyValue; } return $copy; }
php
public function apply($value) { $copy = new DateInterval('P0D'); foreach ($value as $propertyName => $propertyValue) { $copy->{$propertyName} = $propertyValue; } return $copy; }
[ "public", "function", "apply", "(", "$", "value", ")", "{", "$", "copy", "=", "new", "DateInterval", "(", "'P0D'", ")", ";", "foreach", "(", "$", "value", "as", "$", "propertyName", "=>", "$", "propertyValue", ")", "{", "$", "copy", "->", "{", "$", ...
{@inheritdoc} @param DateInterval $value @see https://bugs.php.net/bug.php?id=50559
[ "{", "@inheritdoc", "}" ]
train
https://github.com/myclabs/DeepCopy/blob/86776fc6e6b3ec4fca9f3683e4402fd4cf8760f6/src/DeepCopy/TypeFilter/Date/DateIntervalFilter.php#L17-L26
myclabs/DeepCopy
src/DeepCopy/TypeFilter/Spl/SplDoublyLinkedListFilter.php
SplDoublyLinkedListFilter.apply
public function apply($list): SplDoublyLinkedList { $newList = clone $list; $copy = $this->createCopyClosure(); return $copy($newList); }
php
public function apply($list): SplDoublyLinkedList { $newList = clone $list; $copy = $this->createCopyClosure(); return $copy($newList); }
[ "public", "function", "apply", "(", "$", "list", ")", ":", "SplDoublyLinkedList", "{", "$", "newList", "=", "clone", "$", "list", ";", "$", "copy", "=", "$", "this", "->", "createCopyClosure", "(", ")", ";", "return", "$", "copy", "(", "$", "newList", ...
{@inheritdoc} @param SplDoublyLinkedList $list
[ "{", "@inheritdoc", "}" ]
train
https://github.com/myclabs/DeepCopy/blob/86776fc6e6b3ec4fca9f3683e4402fd4cf8760f6/src/DeepCopy/TypeFilter/Spl/SplDoublyLinkedListFilter.php#L24-L31
Wisembly/elephant.io
src/Engine/AbstractSocketIO.php
AbstractSocketIO.readBytes
protected function readBytes($bytes) { $data = ''; $chunk = null; while ($bytes > 0 && false !== ($chunk = \fread($this->stream, $bytes))) { $bytes -= \strlen($chunk); $data .= $chunk; } if (false === $chunk) { throw new RuntimeException('...
php
protected function readBytes($bytes) { $data = ''; $chunk = null; while ($bytes > 0 && false !== ($chunk = \fread($this->stream, $bytes))) { $bytes -= \strlen($chunk); $data .= $chunk; } if (false === $chunk) { throw new RuntimeException('...
[ "protected", "function", "readBytes", "(", "$", "bytes", ")", "{", "$", "data", "=", "''", ";", "$", "chunk", "=", "null", ";", "while", "(", "$", "bytes", ">", "0", "&&", "false", "!==", "(", "$", "chunk", "=", "\\", "fread", "(", "$", "this", ...
Network safe \fread wrapper @param integer $bytes @return bool|string
[ "Network", "safe", "\\", "fread", "wrapper" ]
train
https://github.com/Wisembly/elephant.io/blob/b22c78a17f0a2e7f229a3932dce141b733b05537/src/Engine/AbstractSocketIO.php#L111-L124
Wisembly/elephant.io
src/Engine/AbstractSocketIO.php
AbstractSocketIO.read
public function read() { if (!\is_resource($this->stream)) { return; } $this->keepAlive(); /* * The first byte contains the FIN bit, the reserved bits, and the * opcode... We're not interested in them. Yet. * the second byte contains the mask b...
php
public function read() { if (!\is_resource($this->stream)) { return; } $this->keepAlive(); /* * The first byte contains the FIN bit, the reserved bits, and the * opcode... We're not interested in them. Yet. * the second byte contains the mask b...
[ "public", "function", "read", "(", ")", "{", "if", "(", "!", "\\", "is_resource", "(", "$", "this", "->", "stream", ")", ")", "{", "return", ";", "}", "$", "this", "->", "keepAlive", "(", ")", ";", "/*\n * The first byte contains the FIN bit, the res...
{@inheritDoc} Be careful, this method may hang your script, as we're not in a non blocking mode.
[ "{", "@inheritDoc", "}" ]
train
https://github.com/Wisembly/elephant.io/blob/b22c78a17f0a2e7f229a3932dce141b733b05537/src/Engine/AbstractSocketIO.php#L132-L207
Wisembly/elephant.io
src/Engine/AbstractSocketIO.php
AbstractSocketIO.parseUrl
protected function parseUrl($url) { $parsed = \parse_url($url); if (false === $parsed) { throw new MalformedUrlException($url); } $server = \array_replace(['scheme' => 'http', 'host' => 'localhost', 'qu...
php
protected function parseUrl($url) { $parsed = \parse_url($url); if (false === $parsed) { throw new MalformedUrlException($url); } $server = \array_replace(['scheme' => 'http', 'host' => 'localhost', 'qu...
[ "protected", "function", "parseUrl", "(", "$", "url", ")", "{", "$", "parsed", "=", "\\", "parse_url", "(", "$", "url", ")", ";", "if", "(", "false", "===", "$", "parsed", ")", "{", "throw", "new", "MalformedUrlException", "(", "$", "url", ")", ";", ...
Parse an url into parts we may expect @param string $url @return string[] information on the given URL
[ "Parse", "an", "url", "into", "parts", "we", "may", "expect" ]
train
https://github.com/Wisembly/elephant.io/blob/b22c78a17f0a2e7f229a3932dce141b733b05537/src/Engine/AbstractSocketIO.php#L222-L251
Wisembly/elephant.io
src/AbstractPayload.php
AbstractPayload.maskData
protected function maskData($data) { $masked = ''; $data = \str_split($data); $key = \str_split($this->maskKey); foreach ($data as $i => $letter) { $masked .= $letter ^ $key[$i % 4]; } return $masked; }
php
protected function maskData($data) { $masked = ''; $data = \str_split($data); $key = \str_split($this->maskKey); foreach ($data as $i => $letter) { $masked .= $letter ^ $key[$i % 4]; } return $masked; }
[ "protected", "function", "maskData", "(", "$", "data", ")", "{", "$", "masked", "=", "''", ";", "$", "data", "=", "\\", "str_split", "(", "$", "data", ")", ";", "$", "key", "=", "\\", "str_split", "(", "$", "this", "->", "maskKey", ")", ";", "for...
Mask a data according to the current mask key @param string $data Data to mask @return string Masked data
[ "Mask", "a", "data", "according", "to", "the", "current", "mask", "key" ]
train
https://github.com/Wisembly/elephant.io/blob/b22c78a17f0a2e7f229a3932dce141b733b05537/src/AbstractPayload.php#L59-L70
Wisembly/elephant.io
src/Engine/SocketIO/Version1X.php
Version1X.connect
public function connect() { if (\is_resource($this->stream)) { return; } $this->handshake(); $protocol = 'http'; $errors = [null, null]; $host = \sprintf('%s:%d', $this->url['host'], $this->url['port']); if (true === $this->url['secured']) { ...
php
public function connect() { if (\is_resource($this->stream)) { return; } $this->handshake(); $protocol = 'http'; $errors = [null, null]; $host = \sprintf('%s:%d', $this->url['host'], $this->url['port']); if (true === $this->url['secured']) { ...
[ "public", "function", "connect", "(", ")", "{", "if", "(", "\\", "is_resource", "(", "$", "this", "->", "stream", ")", ")", "{", "return", ";", "}", "$", "this", "->", "handshake", "(", ")", ";", "$", "protocol", "=", "'http'", ";", "$", "errors", ...
{@inheritDoc}
[ "{" ]
train
https://github.com/Wisembly/elephant.io/blob/b22c78a17f0a2e7f229a3932dce141b733b05537/src/Engine/SocketIO/Version1X.php#L39-L78
Wisembly/elephant.io
src/Engine/SocketIO/Version1X.php
Version1X.emit
public function emit($event, array $args) { $this->keepAlive(); $namespace = $this->namespace; if ('' !== $namespace) { $namespace .= ','; } return $this->write(EngineInterface::MESSAGE, static::EVENT . $namespace . \json_encode([$event, $args])); }
php
public function emit($event, array $args) { $this->keepAlive(); $namespace = $this->namespace; if ('' !== $namespace) { $namespace .= ','; } return $this->write(EngineInterface::MESSAGE, static::EVENT . $namespace . \json_encode([$event, $args])); }
[ "public", "function", "emit", "(", "$", "event", ",", "array", "$", "args", ")", "{", "$", "this", "->", "keepAlive", "(", ")", ";", "$", "namespace", "=", "$", "this", "->", "namespace", ";", "if", "(", "''", "!==", "$", "namespace", ")", "{", "...
{@inheritDoc}
[ "{" ]
train
https://github.com/Wisembly/elephant.io/blob/b22c78a17f0a2e7f229a3932dce141b733b05537/src/Engine/SocketIO/Version1X.php#L96-L106
Wisembly/elephant.io
src/Engine/SocketIO/Version1X.php
Version1X.of
public function of($namespace) { $this->keepAlive(); parent::of($namespace); $this->write(EngineInterface::MESSAGE, static::CONNECT . $namespace); }
php
public function of($namespace) { $this->keepAlive(); parent::of($namespace); $this->write(EngineInterface::MESSAGE, static::CONNECT . $namespace); }
[ "public", "function", "of", "(", "$", "namespace", ")", "{", "$", "this", "->", "keepAlive", "(", ")", ";", "parent", "::", "of", "(", "$", "namespace", ")", ";", "$", "this", "->", "write", "(", "EngineInterface", "::", "MESSAGE", ",", "static", "::...
{@inheritDoc}
[ "{" ]
train
https://github.com/Wisembly/elephant.io/blob/b22c78a17f0a2e7f229a3932dce141b733b05537/src/Engine/SocketIO/Version1X.php#L109-L115
Wisembly/elephant.io
src/Engine/SocketIO/Version1X.php
Version1X.getDefaultOptions
protected function getDefaultOptions() { $defaults = parent::getDefaultOptions(); $defaults['version'] = 2; $defaults['use_b64'] = false; $defaults['transport'] = static::TRANSPORT_POLLING; return $defaults; }
php
protected function getDefaultOptions() { $defaults = parent::getDefaultOptions(); $defaults['version'] = 2; $defaults['use_b64'] = false; $defaults['transport'] = static::TRANSPORT_POLLING; return $defaults; }
[ "protected", "function", "getDefaultOptions", "(", ")", "{", "$", "defaults", "=", "parent", "::", "getDefaultOptions", "(", ")", ";", "$", "defaults", "[", "'version'", "]", "=", "2", ";", "$", "defaults", "[", "'use_b64'", "]", "=", "false", ";", "$", ...
{@inheritDoc}
[ "{" ]
train
https://github.com/Wisembly/elephant.io/blob/b22c78a17f0a2e7f229a3932dce141b733b05537/src/Engine/SocketIO/Version1X.php#L148-L157
Wisembly/elephant.io
src/Engine/SocketIO/Version1X.php
Version1X.handshake
protected function handshake() { if (null !== $this->session) { return; } $query = ['use_b64' => $this->options['use_b64'], 'EIO' => $this->options['version'], 'transport' => $this->options['transport']]; if (isset($this->url[...
php
protected function handshake() { if (null !== $this->session) { return; } $query = ['use_b64' => $this->options['use_b64'], 'EIO' => $this->options['version'], 'transport' => $this->options['transport']]; if (isset($this->url[...
[ "protected", "function", "handshake", "(", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "session", ")", "{", "return", ";", "}", "$", "query", "=", "[", "'use_b64'", "=>", "$", "this", "->", "options", "[", "'use_b64'", "]", ",", "'EIO'", ...
Does the handshake with the Socket.io server and populates the `session` value object
[ "Does", "the", "handshake", "with", "the", "Socket", ".", "io", "server", "and", "populates", "the", "session", "value", "object" ]
train
https://github.com/Wisembly/elephant.io/blob/b22c78a17f0a2e7f229a3932dce141b733b05537/src/Engine/SocketIO/Version1X.php#L160-L231
Wisembly/elephant.io
src/Engine/SocketIO/Version1X.php
Version1X.upgradeTransport
protected function upgradeTransport() { $query = ['sid' => $this->session->id, 'EIO' => $this->options['version'], 'transport' => static::TRANSPORT_WEBSOCKET]; if ($this->options['version'] === 2) { $query['use_b64'] = $this->options['use_...
php
protected function upgradeTransport() { $query = ['sid' => $this->session->id, 'EIO' => $this->options['version'], 'transport' => static::TRANSPORT_WEBSOCKET]; if ($this->options['version'] === 2) { $query['use_b64'] = $this->options['use_...
[ "protected", "function", "upgradeTransport", "(", ")", "{", "$", "query", "=", "[", "'sid'", "=>", "$", "this", "->", "session", "->", "id", ",", "'EIO'", "=>", "$", "this", "->", "options", "[", "'version'", "]", ",", "'transport'", "=>", "static", ":...
Upgrades the transport to WebSocket FYI: Version "2" is used for the EIO param by socket.io v1 Version "3" is used by socket.io v2
[ "Upgrades", "the", "transport", "to", "WebSocket" ]
train
https://github.com/Wisembly/elephant.io/blob/b22c78a17f0a2e7f229a3932dce141b733b05537/src/Engine/SocketIO/Version1X.php#L240-L304
Wisembly/elephant.io
src/Client.php
Client.initialize
public function initialize() { try { $this->logger->debug('Connecting to the websocket'); $this->engine->connect(); $this->logger->debug('Connected to the server'); $this->isConnected = true; } catch (SocketException $e) { $this->logger->e...
php
public function initialize() { try { $this->logger->debug('Connecting to the websocket'); $this->engine->connect(); $this->logger->debug('Connected to the server'); $this->isConnected = true; } catch (SocketException $e) { $this->logger->e...
[ "public", "function", "initialize", "(", ")", "{", "try", "{", "$", "this", "->", "logger", "->", "debug", "(", "'Connecting to the websocket'", ")", ";", "$", "this", "->", "engine", "->", "connect", "(", ")", ";", "$", "this", "->", "logger", "->", "...
Connects to the websocket @return $this
[ "Connects", "to", "the", "websocket" ]
train
https://github.com/Wisembly/elephant.io/blob/b22c78a17f0a2e7f229a3932dce141b733b05537/src/Client.php#L55-L70
Wisembly/elephant.io
src/Client.php
Client.emit
public function emit($event, array $args) { $this->logger->debug('Sending a new message', ['event' => $event, 'args' => $args]); $this->engine->emit($event, $args); return $this; }
php
public function emit($event, array $args) { $this->logger->debug('Sending a new message', ['event' => $event, 'args' => $args]); $this->engine->emit($event, $args); return $this; }
[ "public", "function", "emit", "(", "$", "event", ",", "array", "$", "args", ")", "{", "$", "this", "->", "logger", "->", "debug", "(", "'Sending a new message'", ",", "[", "'event'", "=>", "$", "event", ",", "'args'", "=>", "$", "args", "]", ")", ";"...
Emits a message through the engine @param string $event @param array $args @return $this
[ "Emits", "a", "message", "through", "the", "engine" ]
train
https://github.com/Wisembly/elephant.io/blob/b22c78a17f0a2e7f229a3932dce141b733b05537/src/Client.php#L91-L97
Wisembly/elephant.io
src/Client.php
Client.close
public function close() { $this->logger->debug('Closing the connection to the websocket'); $this->engine->close(); $this->isConnected = false; return $this; }
php
public function close() { $this->logger->debug('Closing the connection to the websocket'); $this->engine->close(); $this->isConnected = false; return $this; }
[ "public", "function", "close", "(", ")", "{", "$", "this", "->", "logger", "->", "debug", "(", "'Closing the connection to the websocket'", ")", ";", "$", "this", "->", "engine", "->", "close", "(", ")", ";", "$", "this", "->", "isConnected", "=", "false",...
Closes the connection @return $this
[ "Closes", "the", "connection" ]
train
https://github.com/Wisembly/elephant.io/blob/b22c78a17f0a2e7f229a3932dce141b733b05537/src/Client.php#L118-L126
Wisembly/elephant.io
src/Engine/SocketIO/Version0X.php
Version0X.close
public function close() { if (!\is_resource($this->stream)) { return; } $this->write(static::CLOSE); \fclose($this->stream); $this->stream = null; $this->session = null; $this->cookies = []; }
php
public function close() { if (!\is_resource($this->stream)) { return; } $this->write(static::CLOSE); \fclose($this->stream); $this->stream = null; $this->session = null; $this->cookies = []; }
[ "public", "function", "close", "(", ")", "{", "if", "(", "!", "\\", "is_resource", "(", "$", "this", "->", "stream", ")", ")", "{", "return", ";", "}", "$", "this", "->", "write", "(", "static", "::", "CLOSE", ")", ";", "\\", "fclose", "(", "$", ...
{@inheritDoc}
[ "{" ]
train
https://github.com/Wisembly/elephant.io/blob/b22c78a17f0a2e7f229a3932dce141b733b05537/src/Engine/SocketIO/Version0X.php#L94-L105
Wisembly/elephant.io
src/Engine/SocketIO/Version0X.php
Version0X.write
public function write($code, $message = null) { if (!\is_resource($this->stream)) { return; } if (!\is_int($code) || 0 > $code || 6 < $code) { throw new InvalidArgumentException('Wrong message type when trying to write on the socket'); } $payload = n...
php
public function write($code, $message = null) { if (!\is_resource($this->stream)) { return; } if (!\is_int($code) || 0 > $code || 6 < $code) { throw new InvalidArgumentException('Wrong message type when trying to write on the socket'); } $payload = n...
[ "public", "function", "write", "(", "$", "code", ",", "$", "message", "=", "null", ")", "{", "if", "(", "!", "\\", "is_resource", "(", "$", "this", "->", "stream", ")", ")", "{", "return", ";", "}", "if", "(", "!", "\\", "is_int", "(", "$", "co...
{@inheritDoc}
[ "{" ]
train
https://github.com/Wisembly/elephant.io/blob/b22c78a17f0a2e7f229a3932dce141b733b05537/src/Engine/SocketIO/Version0X.php#L114-L131
Wisembly/elephant.io
src/Engine/SocketIO/Version0X.php
Version0X.handshake
protected function handshake() { if (null !== $this->session) { return; } $context = $this->context; $protocol = $this->url['secured'] ? 'ssl' : 'http'; if (!isset($context[$protocol])) { $context[$protocol] = []; } $context[$protoco...
php
protected function handshake() { if (null !== $this->session) { return; } $context = $this->context; $protocol = $this->url['secured'] ? 'ssl' : 'http'; if (!isset($context[$protocol])) { $context[$protocol] = []; } $context[$protoco...
[ "protected", "function", "handshake", "(", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "session", ")", "{", "return", ";", "}", "$", "context", "=", "$", "this", "->", "context", ";", "$", "protocol", "=", "$", "this", "->", "url", "[", ...
Does the handshake with the Socket.io server and populates the `session` value object
[ "Does", "the", "handshake", "with", "the", "Socket", ".", "io", "server", "and", "populates", "the", "session", "value", "object" ]
train
https://github.com/Wisembly/elephant.io/blob/b22c78a17f0a2e7f229a3932dce141b733b05537/src/Engine/SocketIO/Version0X.php#L159-L230
Wisembly/elephant.io
src/Engine/SocketIO/Version0X.php
Version0X.upgradeTransport
private function upgradeTransport() { if (!\array_key_exists('websocket', $this->session->upgrades)) { return new UnsupportedTransportException('websocket'); } $url = \sprintf( '/%s/%d/%s/%s', \trim($this->url['path'], '/'), $this->options['pr...
php
private function upgradeTransport() { if (!\array_key_exists('websocket', $this->session->upgrades)) { return new UnsupportedTransportException('websocket'); } $url = \sprintf( '/%s/%d/%s/%s', \trim($this->url['path'], '/'), $this->options['pr...
[ "private", "function", "upgradeTransport", "(", ")", "{", "if", "(", "!", "\\", "array_key_exists", "(", "'websocket'", ",", "$", "this", "->", "session", "->", "upgrades", ")", ")", "{", "return", "new", "UnsupportedTransportException", "(", "'websocket'", ")...
Upgrades the transport to WebSocket
[ "Upgrades", "the", "transport", "to", "WebSocket" ]
train
https://github.com/Wisembly/elephant.io/blob/b22c78a17f0a2e7f229a3932dce141b733b05537/src/Engine/SocketIO/Version0X.php#L233-L288
Wisembly/elephant.io
src/Engine/SocketIO/Session.php
Session.needsHeartbeat
public function needsHeartbeat() { if (0 < $this->timeouts['interval'] && \microtime(true) > ($this->timeouts['interval'] + $this->heartbeat - 5)) { $this->heartbeat = \microtime(true); return true; } return false; }
php
public function needsHeartbeat() { if (0 < $this->timeouts['interval'] && \microtime(true) > ($this->timeouts['interval'] + $this->heartbeat - 5)) { $this->heartbeat = \microtime(true); return true; } return false; }
[ "public", "function", "needsHeartbeat", "(", ")", "{", "if", "(", "0", "<", "$", "this", "->", "timeouts", "[", "'interval'", "]", "&&", "\\", "microtime", "(", "true", ")", ">", "(", "$", "this", "->", "timeouts", "[", "'interval'", "]", "+", "$", ...
Checks whether a new heartbeat is necessary, and does a new heartbeat if it is the case @return Boolean true if there was a heartbeat, false otherwise
[ "Checks", "whether", "a", "new", "heartbeat", "is", "necessary", "and", "does", "a", "new", "heartbeat", "if", "it", "is", "the", "case" ]
train
https://github.com/Wisembly/elephant.io/blob/b22c78a17f0a2e7f229a3932dce141b733b05537/src/Engine/SocketIO/Session.php#L67-L76
doctrine/inflector
lib/Doctrine/Inflector/Inflector.php
Inflector.tableize
public function tableize(string $word) : string { $tableized = preg_replace('~(?<=\\w)([A-Z])~u', '_$1', $word); if ($tableized === null) { throw new RuntimeException(sprintf( 'preg_replace returned null for value "%s"', $word )); } ...
php
public function tableize(string $word) : string { $tableized = preg_replace('~(?<=\\w)([A-Z])~u', '_$1', $word); if ($tableized === null) { throw new RuntimeException(sprintf( 'preg_replace returned null for value "%s"', $word )); } ...
[ "public", "function", "tableize", "(", "string", "$", "word", ")", ":", "string", "{", "$", "tableized", "=", "preg_replace", "(", "'~(?<=\\\\w)([A-Z])~u'", ",", "'_$1'", ",", "$", "word", ")", ";", "if", "(", "$", "tableized", "===", "null", ")", "{", ...
Converts a word into the format for a Doctrine table name. Converts 'ModelName' to 'model_name'.
[ "Converts", "a", "word", "into", "the", "format", "for", "a", "Doctrine", "table", "name", ".", "Converts", "ModelName", "to", "model_name", "." ]
train
https://github.com/doctrine/inflector/blob/c0f6d194a40f2b2d98c8b687d69b2ec67f71dd5c/lib/Doctrine/Inflector/Inflector.php#L231-L243
doctrine/inflector
lib/Doctrine/Inflector/Inflector.php
Inflector.unaccent
public function unaccent(string $string) : string { if (preg_match('/[\x80-\xff]/', $string) === false) { return $string; } if ($this->seemsUtf8($string)) { $string = strtr($string, self::ACCENTED_CHARACTERS); } else { $characters = []; ...
php
public function unaccent(string $string) : string { if (preg_match('/[\x80-\xff]/', $string) === false) { return $string; } if ($this->seemsUtf8($string)) { $string = strtr($string, self::ACCENTED_CHARACTERS); } else { $characters = []; ...
[ "public", "function", "unaccent", "(", "string", "$", "string", ")", ":", "string", "{", "if", "(", "preg_match", "(", "'/[\\x80-\\xff]/'", ",", "$", "string", ")", "===", "false", ")", "{", "return", "$", "string", ";", "}", "if", "(", "$", "this", ...
Remove any illegal characters, accents, etc. @param string $string String to unaccent @return string Unaccented string
[ "Remove", "any", "illegal", "characters", "accents", "etc", "." ]
train
https://github.com/doctrine/inflector/blob/c0f6d194a40f2b2d98c8b687d69b2ec67f71dd5c/lib/Doctrine/Inflector/Inflector.php#L334-L437
doctrine/inflector
lib/Doctrine/Inflector/Inflector.php
Inflector.urlize
public function urlize(string $string) : string { // Remove all non url friendly characters with the unaccent function $unaccented = $this->unaccent($string); if (function_exists('mb_strtolower')) { $lowered = mb_strtolower($unaccented); } else { $lowered = s...
php
public function urlize(string $string) : string { // Remove all non url friendly characters with the unaccent function $unaccented = $this->unaccent($string); if (function_exists('mb_strtolower')) { $lowered = mb_strtolower($unaccented); } else { $lowered = s...
[ "public", "function", "urlize", "(", "string", "$", "string", ")", ":", "string", "{", "// Remove all non url friendly characters with the unaccent function", "$", "unaccented", "=", "$", "this", "->", "unaccent", "(", "$", "string", ")", ";", "if", "(", "function...
Convert any passed string to a url friendly string. Converts 'My first blog post' to 'my-first-blog-post' @param string $string String to urlize. @return string Urlized string.
[ "Convert", "any", "passed", "string", "to", "a", "url", "friendly", "string", ".", "Converts", "My", "first", "blog", "post", "to", "my", "-", "first", "-", "blog", "-", "post" ]
train
https://github.com/doctrine/inflector/blob/c0f6d194a40f2b2d98c8b687d69b2ec67f71dd5c/lib/Doctrine/Inflector/Inflector.php#L447-L481
doctrine/annotations
lib/Doctrine/Annotations/AnnotationException.php
AnnotationException.semanticalErrorConstants
public static function semanticalErrorConstants($identifier, $context = null) { return self::semanticalError(sprintf( "Couldn't find constant %s%s.", $identifier, $context ? ', ' . $context : '' )); }
php
public static function semanticalErrorConstants($identifier, $context = null) { return self::semanticalError(sprintf( "Couldn't find constant %s%s.", $identifier, $context ? ', ' . $context : '' )); }
[ "public", "static", "function", "semanticalErrorConstants", "(", "$", "identifier", ",", "$", "context", "=", "null", ")", "{", "return", "self", "::", "semanticalError", "(", "sprintf", "(", "\"Couldn't find constant %s%s.\"", ",", "$", "identifier", ",", "$", ...
Creates a new AnnotationException describing a constant semantical error. @since 2.3 @param string $identifier @param string $context @return AnnotationException
[ "Creates", "a", "new", "AnnotationException", "describing", "a", "constant", "semantical", "error", "." ]
train
https://github.com/doctrine/annotations/blob/580f6eb30e375805c7dd8f739efd3b95a39a79f8/lib/Doctrine/Annotations/AnnotationException.php#L79-L86
doctrine/annotations
lib/Doctrine/Annotations/AnnotationException.php
AnnotationException.attributeTypeError
public static function attributeTypeError($attributeName, $annotationName, $context, $expected, $actual) { return self::typeError(sprintf( 'Attribute "%s" of @%s declared on %s expects %s, but got %s.', $attributeName, $annotationName, $context, $e...
php
public static function attributeTypeError($attributeName, $annotationName, $context, $expected, $actual) { return self::typeError(sprintf( 'Attribute "%s" of @%s declared on %s expects %s, but got %s.', $attributeName, $annotationName, $context, $e...
[ "public", "static", "function", "attributeTypeError", "(", "$", "attributeName", ",", "$", "annotationName", ",", "$", "context", ",", "$", "expected", ",", "$", "actual", ")", "{", "return", "self", "::", "typeError", "(", "sprintf", "(", "'Attribute \"%s\" o...
Creates a new AnnotationException describing an type error of an attribute. @since 2.2 @param string $attributeName @param string $annotationName @param string $context @param string $expected @param mixed $actual @return AnnotationException
[ "Creates", "a", "new", "AnnotationException", "describing", "an", "type", "error", "of", "an", "attribute", "." ]
train
https://github.com/doctrine/annotations/blob/580f6eb30e375805c7dd8f739efd3b95a39a79f8/lib/Doctrine/Annotations/AnnotationException.php#L101-L111
doctrine/annotations
lib/Doctrine/Annotations/AnnotationException.php
AnnotationException.requiredError
public static function requiredError($attributeName, $annotationName, $context, $expected) { return self::typeError(sprintf( 'Attribute "%s" of @%s declared on %s expects %s. This value should not be null.', $attributeName, $annotationName, $context, ...
php
public static function requiredError($attributeName, $annotationName, $context, $expected) { return self::typeError(sprintf( 'Attribute "%s" of @%s declared on %s expects %s. This value should not be null.', $attributeName, $annotationName, $context, ...
[ "public", "static", "function", "requiredError", "(", "$", "attributeName", ",", "$", "annotationName", ",", "$", "context", ",", "$", "expected", ")", "{", "return", "self", "::", "typeError", "(", "sprintf", "(", "'Attribute \"%s\" of @%s declared on %s expects %s...
Creates a new AnnotationException describing an required error of an attribute. @since 2.2 @param string $attributeName @param string $annotationName @param string $context @param string $expected @return AnnotationException
[ "Creates", "a", "new", "AnnotationException", "describing", "an", "required", "error", "of", "an", "attribute", "." ]
train
https://github.com/doctrine/annotations/blob/580f6eb30e375805c7dd8f739efd3b95a39a79f8/lib/Doctrine/Annotations/AnnotationException.php#L125-L134
doctrine/annotations
lib/Doctrine/Annotations/AnnotationException.php
AnnotationException.enumeratorError
public static function enumeratorError($attributeName, $annotationName, $context, $expected, $given) { return new self(sprintf( '[Enum Error] Attribute "%s" of @%s declared on %s accept only %s, but got %s.', $attributeName, $annotationName, $context, ...
php
public static function enumeratorError($attributeName, $annotationName, $context, $expected, $given) { return new self(sprintf( '[Enum Error] Attribute "%s" of @%s declared on %s accept only %s, but got %s.', $attributeName, $annotationName, $context, ...
[ "public", "static", "function", "enumeratorError", "(", "$", "attributeName", ",", "$", "annotationName", ",", "$", "context", ",", "$", "expected", ",", "$", "given", ")", "{", "return", "new", "self", "(", "sprintf", "(", "'[Enum Error] Attribute \"%s\" of @%s...
Creates a new AnnotationException describing a invalid enummerator. @since 2.4 @param string $attributeName @param string $annotationName @param string $context @param string $expected @param mixed $given @return AnnotationException
[ "Creates", "a", "new", "AnnotationException", "describing", "a", "invalid", "enummerator", "." ]
train
https://github.com/doctrine/annotations/blob/580f6eb30e375805c7dd8f739efd3b95a39a79f8/lib/Doctrine/Annotations/AnnotationException.php#L149-L159
doctrine/annotations
lib/Doctrine/Annotations/IndexedReader.php
IndexedReader.getClassAnnotations
public function getClassAnnotations(\ReflectionClass $class) { $annotations = []; foreach ($this->delegate->getClassAnnotations($class) as $annot) { $annotations[get_class($annot)] = $annot; } return $annotations; }
php
public function getClassAnnotations(\ReflectionClass $class) { $annotations = []; foreach ($this->delegate->getClassAnnotations($class) as $annot) { $annotations[get_class($annot)] = $annot; } return $annotations; }
[ "public", "function", "getClassAnnotations", "(", "\\", "ReflectionClass", "$", "class", ")", "{", "$", "annotations", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "delegate", "->", "getClassAnnotations", "(", "$", "class", ")", "as", "$", "annot...
{@inheritDoc}
[ "{" ]
train
https://github.com/doctrine/annotations/blob/580f6eb30e375805c7dd8f739efd3b95a39a79f8/lib/Doctrine/Annotations/IndexedReader.php#L30-L38
doctrine/annotations
lib/Doctrine/Annotations/IndexedReader.php
IndexedReader.getMethodAnnotations
public function getMethodAnnotations(\ReflectionMethod $method) { $annotations = []; foreach ($this->delegate->getMethodAnnotations($method) as $annot) { $annotations[get_class($annot)] = $annot; } return $annotations; }
php
public function getMethodAnnotations(\ReflectionMethod $method) { $annotations = []; foreach ($this->delegate->getMethodAnnotations($method) as $annot) { $annotations[get_class($annot)] = $annot; } return $annotations; }
[ "public", "function", "getMethodAnnotations", "(", "\\", "ReflectionMethod", "$", "method", ")", "{", "$", "annotations", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "delegate", "->", "getMethodAnnotations", "(", "$", "method", ")", "as", "$", "...
{@inheritDoc}
[ "{" ]
train
https://github.com/doctrine/annotations/blob/580f6eb30e375805c7dd8f739efd3b95a39a79f8/lib/Doctrine/Annotations/IndexedReader.php#L51-L59
doctrine/annotations
lib/Doctrine/Annotations/IndexedReader.php
IndexedReader.getPropertyAnnotations
public function getPropertyAnnotations(\ReflectionProperty $property) { $annotations = []; foreach ($this->delegate->getPropertyAnnotations($property) as $annot) { $annotations[get_class($annot)] = $annot; } return $annotations; }
php
public function getPropertyAnnotations(\ReflectionProperty $property) { $annotations = []; foreach ($this->delegate->getPropertyAnnotations($property) as $annot) { $annotations[get_class($annot)] = $annot; } return $annotations; }
[ "public", "function", "getPropertyAnnotations", "(", "\\", "ReflectionProperty", "$", "property", ")", "{", "$", "annotations", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "delegate", "->", "getPropertyAnnotations", "(", "$", "property", ")", "as", ...
{@inheritDoc}
[ "{" ]
train
https://github.com/doctrine/annotations/blob/580f6eb30e375805c7dd8f739efd3b95a39a79f8/lib/Doctrine/Annotations/IndexedReader.php#L72-L80
doctrine/annotations
lib/Doctrine/Annotations/TokenParser.php
TokenParser.next
public function next($docCommentIsComment = TRUE) { for ($i = $this->pointer; $i < $this->numTokens; $i++) { $this->pointer++; if ($this->tokens[$i][0] === T_WHITESPACE || $this->tokens[$i][0] === T_COMMENT || ($docCommentIsComment && $this->tokens[$i]...
php
public function next($docCommentIsComment = TRUE) { for ($i = $this->pointer; $i < $this->numTokens; $i++) { $this->pointer++; if ($this->tokens[$i][0] === T_WHITESPACE || $this->tokens[$i][0] === T_COMMENT || ($docCommentIsComment && $this->tokens[$i]...
[ "public", "function", "next", "(", "$", "docCommentIsComment", "=", "TRUE", ")", "{", "for", "(", "$", "i", "=", "$", "this", "->", "pointer", ";", "$", "i", "<", "$", "this", "->", "numTokens", ";", "$", "i", "++", ")", "{", "$", "this", "->", ...
Gets the next non whitespace and non comment token. @param boolean $docCommentIsComment If TRUE then a doc comment is considered a comment and skipped. If FALSE then only whitespace and normal comments are skipped. @return array|string|null The token if exists, null otherwise.
[ "Gets", "the", "next", "non", "whitespace", "and", "non", "comment", "token", "." ]
train
https://github.com/doctrine/annotations/blob/580f6eb30e375805c7dd8f739efd3b95a39a79f8/lib/Doctrine/Annotations/TokenParser.php#L61-L76
doctrine/annotations
lib/Doctrine/Annotations/TokenParser.php
TokenParser.parseUseStatements
public function parseUseStatements($namespaceName) { $statements = []; while (($token = $this->next())) { if ($token[0] === T_USE) { $statements = array_merge($statements, $this->parseUseStatement()); continue; } if ($token[0] !== T...
php
public function parseUseStatements($namespaceName) { $statements = []; while (($token = $this->next())) { if ($token[0] === T_USE) { $statements = array_merge($statements, $this->parseUseStatement()); continue; } if ($token[0] !== T...
[ "public", "function", "parseUseStatements", "(", "$", "namespaceName", ")", "{", "$", "statements", "=", "[", "]", ";", "while", "(", "(", "$", "token", "=", "$", "this", "->", "next", "(", ")", ")", ")", "{", "if", "(", "$", "token", "[", "0", "...
Gets all use statements. @param string $namespaceName The namespace name of the reflected class. @return array A list with all found use statements.
[ "Gets", "all", "use", "statements", "." ]
train
https://github.com/doctrine/annotations/blob/580f6eb30e375805c7dd8f739efd3b95a39a79f8/lib/Doctrine/Annotations/TokenParser.php#L129-L148
doctrine/annotations
lib/Doctrine/Annotations/TokenParser.php
TokenParser.parseNamespace
public function parseNamespace() { $name = ''; while (($token = $this->next()) && ($token[0] === T_STRING || $token[0] === T_NS_SEPARATOR)) { $name .= $token[1]; } return $name; }
php
public function parseNamespace() { $name = ''; while (($token = $this->next()) && ($token[0] === T_STRING || $token[0] === T_NS_SEPARATOR)) { $name .= $token[1]; } return $name; }
[ "public", "function", "parseNamespace", "(", ")", "{", "$", "name", "=", "''", ";", "while", "(", "(", "$", "token", "=", "$", "this", "->", "next", "(", ")", ")", "&&", "(", "$", "token", "[", "0", "]", "===", "T_STRING", "||", "$", "token", "...
Gets the namespace. @return string The found namespace.
[ "Gets", "the", "namespace", "." ]
train
https://github.com/doctrine/annotations/blob/580f6eb30e375805c7dd8f739efd3b95a39a79f8/lib/Doctrine/Annotations/TokenParser.php#L155-L163
doctrine/annotations
lib/Doctrine/Annotations/DocParser.php
DocParser.parse
public function parse($input, $context = '') { $pos = $this->findInitialTokenPosition($input); if ($pos === null) { return []; } $this->context = $context; $this->lexer->setInput(trim(substr($input, $pos), '* /')); $this->lexer->moveNext(); retu...
php
public function parse($input, $context = '') { $pos = $this->findInitialTokenPosition($input); if ($pos === null) { return []; } $this->context = $context; $this->lexer->setInput(trim(substr($input, $pos), '* /')); $this->lexer->moveNext(); retu...
[ "public", "function", "parse", "(", "$", "input", ",", "$", "context", "=", "''", ")", "{", "$", "pos", "=", "$", "this", "->", "findInitialTokenPosition", "(", "$", "input", ")", ";", "if", "(", "$", "pos", "===", "null", ")", "{", "return", "[", ...
Parses the given docblock string for annotations. @param string $input The docblock string to parse. @param string $context The parsing context. @return array Array of annotations. If no annotations are found, an empty array is returned.
[ "Parses", "the", "given", "docblock", "string", "for", "annotations", "." ]
train
https://github.com/doctrine/annotations/blob/580f6eb30e375805c7dd8f739efd3b95a39a79f8/lib/Doctrine/Annotations/DocParser.php#L260-L273
doctrine/annotations
lib/Doctrine/Annotations/DocParser.php
DocParser.findInitialTokenPosition
private function findInitialTokenPosition($input) { $pos = 0; // search for first valid annotation while (($pos = strpos($input, '@', $pos)) !== false) { $preceding = substr($input, $pos - 1, 1); // if the @ is preceded by a space, a tab or * it is valid ...
php
private function findInitialTokenPosition($input) { $pos = 0; // search for first valid annotation while (($pos = strpos($input, '@', $pos)) !== false) { $preceding = substr($input, $pos - 1, 1); // if the @ is preceded by a space, a tab or * it is valid ...
[ "private", "function", "findInitialTokenPosition", "(", "$", "input", ")", "{", "$", "pos", "=", "0", ";", "// search for first valid annotation", "while", "(", "(", "$", "pos", "=", "strpos", "(", "$", "input", ",", "'@'", ",", "$", "pos", ")", ")", "!=...
Finds the first valid annotation @param string $input The docblock string to parse @return int|null
[ "Finds", "the", "first", "valid", "annotation" ]
train
https://github.com/doctrine/annotations/blob/580f6eb30e375805c7dd8f739efd3b95a39a79f8/lib/Doctrine/Annotations/DocParser.php#L282-L299
doctrine/annotations
lib/Doctrine/Annotations/DocParser.php
DocParser.match
private function match($token) { if ( ! $this->lexer->isNextToken($token) ) { $this->syntaxError($this->lexer->getLiteral($token)); } return $this->lexer->moveNext(); }
php
private function match($token) { if ( ! $this->lexer->isNextToken($token) ) { $this->syntaxError($this->lexer->getLiteral($token)); } return $this->lexer->moveNext(); }
[ "private", "function", "match", "(", "$", "token", ")", "{", "if", "(", "!", "$", "this", "->", "lexer", "->", "isNextToken", "(", "$", "token", ")", ")", "{", "$", "this", "->", "syntaxError", "(", "$", "this", "->", "lexer", "->", "getLiteral", "...
Attempts to match the given token with the current lookahead token. If they match, updates the lookahead token; otherwise raises a syntax error. @param integer $token Type of token. @return boolean True if tokens match; false otherwise.
[ "Attempts", "to", "match", "the", "given", "token", "with", "the", "current", "lookahead", "token", ".", "If", "they", "match", "updates", "the", "lookahead", "token", ";", "otherwise", "raises", "a", "syntax", "error", "." ]
train
https://github.com/doctrine/annotations/blob/580f6eb30e375805c7dd8f739efd3b95a39a79f8/lib/Doctrine/Annotations/DocParser.php#L309-L316
doctrine/annotations
lib/Doctrine/Annotations/DocParser.php
DocParser.classExists
private function classExists($fqcn) { if (isset($this->classExists[$fqcn])) { return $this->classExists[$fqcn]; } // final check, does this class exist? return $this->classExists[$fqcn] = class_exists($fqcn); }
php
private function classExists($fqcn) { if (isset($this->classExists[$fqcn])) { return $this->classExists[$fqcn]; } // final check, does this class exist? return $this->classExists[$fqcn] = class_exists($fqcn); }
[ "private", "function", "classExists", "(", "$", "fqcn", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "classExists", "[", "$", "fqcn", "]", ")", ")", "{", "return", "$", "this", "->", "classExists", "[", "$", "fqcn", "]", ";", "}", "// fina...
Attempts to check if a class exists or not. This always uses PHP autoloading mechanism. @param string $fqcn @return boolean
[ "Attempts", "to", "check", "if", "a", "class", "exists", "or", "not", ".", "This", "always", "uses", "PHP", "autoloading", "mechanism", "." ]
train
https://github.com/doctrine/annotations/blob/580f6eb30e375805c7dd8f739efd3b95a39a79f8/lib/Doctrine/Annotations/DocParser.php#L374-L382
doctrine/annotations
lib/Doctrine/Annotations/DocParser.php
DocParser.collectAnnotationMetadata
private function collectAnnotationMetadata($name) { if (self::$metadataParser === null) { self::$metadataParser = new self(); self::$metadataParser->setIgnoreNotImportedAnnotations(true); self::$metadataParser->setIgnoredAnnotationNames($this->ignoredAnnotationNames); ...
php
private function collectAnnotationMetadata($name) { if (self::$metadataParser === null) { self::$metadataParser = new self(); self::$metadataParser->setIgnoreNotImportedAnnotations(true); self::$metadataParser->setIgnoredAnnotationNames($this->ignoredAnnotationNames); ...
[ "private", "function", "collectAnnotationMetadata", "(", "$", "name", ")", "{", "if", "(", "self", "::", "$", "metadataParser", "===", "null", ")", "{", "self", "::", "$", "metadataParser", "=", "new", "self", "(", ")", ";", "self", "::", "$", "metadataP...
Collects parsing metadata for a given annotation class @param string $name The annotation name @return void
[ "Collects", "parsing", "metadata", "for", "a", "given", "annotation", "class" ]
train
https://github.com/doctrine/annotations/blob/580f6eb30e375805c7dd8f739efd3b95a39a79f8/lib/Doctrine/Annotations/DocParser.php#L391-L494
doctrine/annotations
lib/Doctrine/Annotations/DocParser.php
DocParser.collectAttributeTypeMetadata
private function collectAttributeTypeMetadata( PropertyMetadataBuilder $metadata, Attribute $attribute ) : void { $type = $attribute->type; // handle the case if the property type is mixed if ('mixed' === $type) { return; } if ($attribute->requir...
php
private function collectAttributeTypeMetadata( PropertyMetadataBuilder $metadata, Attribute $attribute ) : void { $type = $attribute->type; // handle the case if the property type is mixed if ('mixed' === $type) { return; } if ($attribute->requir...
[ "private", "function", "collectAttributeTypeMetadata", "(", "PropertyMetadataBuilder", "$", "metadata", ",", "Attribute", "$", "attribute", ")", ":", "void", "{", "$", "type", "=", "$", "attribute", "->", "type", ";", "// handle the case if the property type is mixed", ...
Collects parsing metadata for a given attribute.
[ "Collects", "parsing", "metadata", "for", "a", "given", "attribute", "." ]
train
https://github.com/doctrine/annotations/blob/580f6eb30e375805c7dd8f739efd3b95a39a79f8/lib/Doctrine/Annotations/DocParser.php#L526-L562
doctrine/annotations
lib/Doctrine/Annotations/DocParser.php
DocParser.Annotations
private function Annotations() { $annotations = []; while (null !== $this->lexer->lookahead) { if (DocLexer::T_AT !== $this->lexer->lookahead['type']) { $this->lexer->moveNext(); continue; } // make sure the @ is preceded by non-c...
php
private function Annotations() { $annotations = []; while (null !== $this->lexer->lookahead) { if (DocLexer::T_AT !== $this->lexer->lookahead['type']) { $this->lexer->moveNext(); continue; } // make sure the @ is preceded by non-c...
[ "private", "function", "Annotations", "(", ")", "{", "$", "annotations", "=", "[", "]", ";", "while", "(", "null", "!==", "$", "this", "->", "lexer", "->", "lookahead", ")", "{", "if", "(", "DocLexer", "::", "T_AT", "!==", "$", "this", "->", "lexer",...
Annotations ::= Annotation {[ "*" ]* [Annotation]}* @return array
[ "Annotations", "::", "=", "Annotation", "{", "[", "*", "]", "*", "[", "Annotation", "]", "}", "*" ]
train
https://github.com/doctrine/annotations/blob/580f6eb30e375805c7dd8f739efd3b95a39a79f8/lib/Doctrine/Annotations/DocParser.php#L594-L626
doctrine/annotations
lib/Doctrine/Annotations/DocParser.php
DocParser.Annotation
private function Annotation() { $this->match(DocLexer::T_AT); // check if we have an annotation $name = $this->Identifier(); if ($this->lexer->isNextToken(DocLexer::T_MINUS) && $this->lexer->nextTokenIsAdjacent() ) { // Annotations with dashes, such ...
php
private function Annotation() { $this->match(DocLexer::T_AT); // check if we have an annotation $name = $this->Identifier(); if ($this->lexer->isNextToken(DocLexer::T_MINUS) && $this->lexer->nextTokenIsAdjacent() ) { // Annotations with dashes, such ...
[ "private", "function", "Annotation", "(", ")", "{", "$", "this", "->", "match", "(", "DocLexer", "::", "T_AT", ")", ";", "// check if we have an annotation", "$", "name", "=", "$", "this", "->", "Identifier", "(", ")", ";", "if", "(", "$", "this", "->", ...
Annotation ::= "@" AnnotationName MethodCall AnnotationName ::= QualifiedName | SimpleName QualifiedName ::= NameSpacePart "\" {NameSpacePart "\"}* SimpleName NameSpacePart ::= identifier | null | false | true SimpleName ::= identifier | null | false | true @return mixed False if it is not a valid annotation...
[ "Annotation", "::", "=", "@", "AnnotationName", "MethodCall", "AnnotationName", "::", "=", "QualifiedName", "|", "SimpleName", "QualifiedName", "::", "=", "NameSpacePart", "\\", "{", "NameSpacePart", "\\", "}", "*", "SimpleName", "NameSpacePart", "::", "=", "ident...
train
https://github.com/doctrine/annotations/blob/580f6eb30e375805c7dd8f739efd3b95a39a79f8/lib/Doctrine/Annotations/DocParser.php#L639-L829
doctrine/annotations
lib/Doctrine/Annotations/DocParser.php
DocParser.Constant
private function Constant() { $identifier = $this->Identifier(); if ( ! defined($identifier) && false !== strpos($identifier, '::') && '\\' !== $identifier[0]) { list($className, $const) = explode('::', $identifier); $pos = strpos($className, '\\'); $alias = (fa...
php
private function Constant() { $identifier = $this->Identifier(); if ( ! defined($identifier) && false !== strpos($identifier, '::') && '\\' !== $identifier[0]) { list($className, $const) = explode('::', $identifier); $pos = strpos($className, '\\'); $alias = (fa...
[ "private", "function", "Constant", "(", ")", "{", "$", "identifier", "=", "$", "this", "->", "Identifier", "(", ")", ";", "if", "(", "!", "defined", "(", "$", "identifier", ")", "&&", "false", "!==", "strpos", "(", "$", "identifier", ",", "'::'", ")"...
Constant ::= integer | string | float | boolean @return mixed @throws AnnotationException
[ "Constant", "::", "=", "integer", "|", "string", "|", "float", "|", "boolean" ]
train
https://github.com/doctrine/annotations/blob/580f6eb30e375805c7dd8f739efd3b95a39a79f8/lib/Doctrine/Annotations/DocParser.php#L907-L965
doctrine/annotations
lib/Doctrine/Annotations/DocParser.php
DocParser.Identifier
private function Identifier() { // check if we have an annotation if ( ! $this->lexer->isNextTokenAny(self::$classIdentifiers)) { $this->syntaxError('namespace separator or identifier'); } $this->lexer->moveNext(); $className = $this->lexer->token['value']; ...
php
private function Identifier() { // check if we have an annotation if ( ! $this->lexer->isNextTokenAny(self::$classIdentifiers)) { $this->syntaxError('namespace separator or identifier'); } $this->lexer->moveNext(); $className = $this->lexer->token['value']; ...
[ "private", "function", "Identifier", "(", ")", "{", "// check if we have an annotation", "if", "(", "!", "$", "this", "->", "lexer", "->", "isNextTokenAny", "(", "self", "::", "$", "classIdentifiers", ")", ")", "{", "$", "this", "->", "syntaxError", "(", "'n...
Identifier ::= string @return string
[ "Identifier", "::", "=", "string" ]
train
https://github.com/doctrine/annotations/blob/580f6eb30e375805c7dd8f739efd3b95a39a79f8/lib/Doctrine/Annotations/DocParser.php#L972-L993
doctrine/annotations
lib/Doctrine/Annotations/DocParser.php
DocParser.Value
private function Value() { $peek = $this->lexer->glimpse(); if (DocLexer::T_EQUALS === $peek['type']) { return $this->FieldAssignment(); } return $this->PlainValue(); }
php
private function Value() { $peek = $this->lexer->glimpse(); if (DocLexer::T_EQUALS === $peek['type']) { return $this->FieldAssignment(); } return $this->PlainValue(); }
[ "private", "function", "Value", "(", ")", "{", "$", "peek", "=", "$", "this", "->", "lexer", "->", "glimpse", "(", ")", ";", "if", "(", "DocLexer", "::", "T_EQUALS", "===", "$", "peek", "[", "'type'", "]", ")", "{", "return", "$", "this", "->", "...
Value ::= PlainValue | FieldAssignment @return mixed
[ "Value", "::", "=", "PlainValue", "|", "FieldAssignment" ]
train
https://github.com/doctrine/annotations/blob/580f6eb30e375805c7dd8f739efd3b95a39a79f8/lib/Doctrine/Annotations/DocParser.php#L1000-L1009
doctrine/annotations
lib/Doctrine/Annotations/DocParser.php
DocParser.PlainValue
private function PlainValue() { if ($this->lexer->isNextToken(DocLexer::T_OPEN_CURLY_BRACES)) { return $this->Arrayx(); } if ($this->lexer->isNextToken(DocLexer::T_AT)) { return $this->Annotation(); } if ($this->lexer->isNextToken(DocLexer::T_IDENTIF...
php
private function PlainValue() { if ($this->lexer->isNextToken(DocLexer::T_OPEN_CURLY_BRACES)) { return $this->Arrayx(); } if ($this->lexer->isNextToken(DocLexer::T_AT)) { return $this->Annotation(); } if ($this->lexer->isNextToken(DocLexer::T_IDENTIF...
[ "private", "function", "PlainValue", "(", ")", "{", "if", "(", "$", "this", "->", "lexer", "->", "isNextToken", "(", "DocLexer", "::", "T_OPEN_CURLY_BRACES", ")", ")", "{", "return", "$", "this", "->", "Arrayx", "(", ")", ";", "}", "if", "(", "$", "t...
PlainValue ::= integer | string | float | boolean | Array | Annotation @return mixed
[ "PlainValue", "::", "=", "integer", "|", "string", "|", "float", "|", "boolean", "|", "Array", "|", "Annotation" ]
train
https://github.com/doctrine/annotations/blob/580f6eb30e375805c7dd8f739efd3b95a39a79f8/lib/Doctrine/Annotations/DocParser.php#L1016-L1058
doctrine/annotations
lib/Doctrine/Annotations/DocParser.php
DocParser.FieldAssignment
private function FieldAssignment() { $this->match(DocLexer::T_IDENTIFIER); $fieldName = $this->lexer->token['value']; $this->match(DocLexer::T_EQUALS); $item = new \stdClass(); $item->name = $fieldName; $item->value = $this->PlainValue(); return $item; ...
php
private function FieldAssignment() { $this->match(DocLexer::T_IDENTIFIER); $fieldName = $this->lexer->token['value']; $this->match(DocLexer::T_EQUALS); $item = new \stdClass(); $item->name = $fieldName; $item->value = $this->PlainValue(); return $item; ...
[ "private", "function", "FieldAssignment", "(", ")", "{", "$", "this", "->", "match", "(", "DocLexer", "::", "T_IDENTIFIER", ")", ";", "$", "fieldName", "=", "$", "this", "->", "lexer", "->", "token", "[", "'value'", "]", ";", "$", "this", "->", "match"...
FieldAssignment ::= FieldName "=" PlainValue FieldName ::= identifier @return \stdClass
[ "FieldAssignment", "::", "=", "FieldName", "=", "PlainValue", "FieldName", "::", "=", "identifier" ]
train
https://github.com/doctrine/annotations/blob/580f6eb30e375805c7dd8f739efd3b95a39a79f8/lib/Doctrine/Annotations/DocParser.php#L1066-L1078
doctrine/annotations
lib/Doctrine/Annotations/DocParser.php
DocParser.Arrayx
private function Arrayx() { $array = $values = []; $this->match(DocLexer::T_OPEN_CURLY_BRACES); // If the array is empty, stop parsing and return. if ($this->lexer->isNextToken(DocLexer::T_CLOSE_CURLY_BRACES)) { $this->match(DocLexer::T_CLOSE_CURLY_BRACES); ...
php
private function Arrayx() { $array = $values = []; $this->match(DocLexer::T_OPEN_CURLY_BRACES); // If the array is empty, stop parsing and return. if ($this->lexer->isNextToken(DocLexer::T_CLOSE_CURLY_BRACES)) { $this->match(DocLexer::T_CLOSE_CURLY_BRACES); ...
[ "private", "function", "Arrayx", "(", ")", "{", "$", "array", "=", "$", "values", "=", "[", "]", ";", "$", "this", "->", "match", "(", "DocLexer", "::", "T_OPEN_CURLY_BRACES", ")", ";", "// If the array is empty, stop parsing and return.", "if", "(", "$", "t...
Array ::= "{" ArrayEntry {"," ArrayEntry}* [","] "}" @return array
[ "Array", "::", "=", "{", "ArrayEntry", "{", "ArrayEntry", "}", "*", "[", "]", "}" ]
train
https://github.com/doctrine/annotations/blob/580f6eb30e375805c7dd8f739efd3b95a39a79f8/lib/Doctrine/Annotations/DocParser.php#L1085-L1124
doctrine/annotations
lib/Doctrine/Annotations/DocParser.php
DocParser.isIgnoredAnnotation
private function isIgnoredAnnotation($name) { if ($this->ignoreNotImportedAnnotations || isset($this->ignoredAnnotationNames[$name])) { return true; } foreach (array_keys($this->ignoredAnnotationNamespaces) as $ignoredAnnotationNamespace) { $ignoredAnnotationNamespac...
php
private function isIgnoredAnnotation($name) { if ($this->ignoreNotImportedAnnotations || isset($this->ignoredAnnotationNames[$name])) { return true; } foreach (array_keys($this->ignoredAnnotationNamespaces) as $ignoredAnnotationNamespace) { $ignoredAnnotationNamespac...
[ "private", "function", "isIgnoredAnnotation", "(", "$", "name", ")", "{", "if", "(", "$", "this", "->", "ignoreNotImportedAnnotations", "||", "isset", "(", "$", "this", "->", "ignoredAnnotationNames", "[", "$", "name", "]", ")", ")", "{", "return", "true", ...
Checks whether the given $name matches any ignored annotation name or namespace @param string $name @return bool
[ "Checks", "whether", "the", "given", "$name", "matches", "any", "ignored", "annotation", "name", "or", "namespace" ]
train
https://github.com/doctrine/annotations/blob/580f6eb30e375805c7dd8f739efd3b95a39a79f8/lib/Doctrine/Annotations/DocParser.php#L1162-L1177
doctrine/annotations
lib/Doctrine/Annotations/DocLexer.php
DocLexer.nextTokenIsAdjacent
public function nextTokenIsAdjacent() : bool { return $this->token === null || ($this->lookahead !== null && ($this->lookahead['position'] - $this->token['position']) === strlen($this->token['value'])); }
php
public function nextTokenIsAdjacent() : bool { return $this->token === null || ($this->lookahead !== null && ($this->lookahead['position'] - $this->token['position']) === strlen($this->token['value'])); }
[ "public", "function", "nextTokenIsAdjacent", "(", ")", ":", "bool", "{", "return", "$", "this", "->", "token", "===", "null", "||", "(", "$", "this", "->", "lookahead", "!==", "null", "&&", "(", "$", "this", "->", "lookahead", "[", "'position'", "]", "...
Whether the next token starts immediately, or if there were non-captured symbols before that
[ "Whether", "the", "next", "token", "starts", "immediately", "or", "if", "there", "were", "non", "-", "captured", "symbols", "before", "that" ]
train
https://github.com/doctrine/annotations/blob/580f6eb30e375805c7dd8f739efd3b95a39a79f8/lib/Doctrine/Annotations/DocLexer.php#L68-L73
doctrine/annotations
lib/Doctrine/Annotations/DocLexer.php
DocLexer.getType
protected function getType(&$value) { $type = self::T_NONE; if ($value[0] === '"') { $value = str_replace('""', '"', substr($value, 1, strlen($value) - 2)); return self::T_STRING; } if (isset($this->noCase[$value])) { return $this->noCase[$value...
php
protected function getType(&$value) { $type = self::T_NONE; if ($value[0] === '"') { $value = str_replace('""', '"', substr($value, 1, strlen($value) - 2)); return self::T_STRING; } if (isset($this->noCase[$value])) { return $this->noCase[$value...
[ "protected", "function", "getType", "(", "&", "$", "value", ")", "{", "$", "type", "=", "self", "::", "T_NONE", ";", "if", "(", "$", "value", "[", "0", "]", "===", "'\"'", ")", "{", "$", "value", "=", "str_replace", "(", "'\"\"'", ",", "'\"'", ",...
{@inheritdoc}
[ "{" ]
train
https://github.com/doctrine/annotations/blob/580f6eb30e375805c7dd8f739efd3b95a39a79f8/lib/Doctrine/Annotations/DocLexer.php#L98-L129
krlove/eloquent-model-generator
src/Provider/GeneratorServiceProvider.php
GeneratorServiceProvider.register
public function register() { $this->commands([ GenerateModelCommand::class, ]); $this->app->tag([ ExistenceCheckerProcessor::class, FieldProcessor::class, NamespaceProcessor::class, RelationProcessor::class, CustomPrope...
php
public function register() { $this->commands([ GenerateModelCommand::class, ]); $this->app->tag([ ExistenceCheckerProcessor::class, FieldProcessor::class, NamespaceProcessor::class, RelationProcessor::class, CustomPrope...
[ "public", "function", "register", "(", ")", "{", "$", "this", "->", "commands", "(", "[", "GenerateModelCommand", "::", "class", ",", "]", ")", ";", "$", "this", "->", "app", "->", "tag", "(", "[", "ExistenceCheckerProcessor", "::", "class", ",", "FieldP...
{@inheritDoc}
[ "{" ]
train
https://github.com/krlove/eloquent-model-generator/blob/6073e7aecb5ccad286de70cc2a039bd84a037635/src/Provider/GeneratorServiceProvider.php#L27-L46
krlove/eloquent-model-generator
src/EloquentModelBuilder.php
EloquentModelBuilder.prepareProcessors
protected function prepareProcessors() { usort($this->processors, function (ProcessorInterface $one, ProcessorInterface $two) { if ($one->getPriority() == $two->getPriority()) { return 0; } return $one->getPriority() < $two->getPriority() ? 1 : -1; ...
php
protected function prepareProcessors() { usort($this->processors, function (ProcessorInterface $one, ProcessorInterface $two) { if ($one->getPriority() == $two->getPriority()) { return 0; } return $one->getPriority() < $two->getPriority() ? 1 : -1; ...
[ "protected", "function", "prepareProcessors", "(", ")", "{", "usort", "(", "$", "this", "->", "processors", ",", "function", "(", "ProcessorInterface", "$", "one", ",", "ProcessorInterface", "$", "two", ")", "{", "if", "(", "$", "one", "->", "getPriority", ...
Sort processors by priority
[ "Sort", "processors", "by", "priority" ]
train
https://github.com/krlove/eloquent-model-generator/blob/6073e7aecb5ccad286de70cc2a039bd84a037635/src/EloquentModelBuilder.php#L54-L63