id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
45,800
joomla-framework/ldap
src/LdapClient.php
LdapClient.remove
public function remove($dn, $attribute) { if (!$this->isBound || !$this->isConnected()) { return false; } return ldap_mod_del($this->resource, $dn, $attribute); }
php
public function remove($dn, $attribute) { if (!$this->isBound || !$this->isConnected()) { return false; } return ldap_mod_del($this->resource, $dn, $attribute); }
[ "public", "function", "remove", "(", "$", "dn", ",", "$", "attribute", ")", "{", "if", "(", "!", "$", "this", "->", "isBound", "||", "!", "$", "this", "->", "isConnected", "(", ")", ")", "{", "return", "false", ";", "}", "return", "ldap_mod_del", "...
Delete attribute values from current attributes @param string $dn The DN which contains the attribute you want to remove @param string $attribute The attribute values you want to remove @return boolean @since 1.0
[ "Delete", "attribute", "values", "from", "current", "attributes" ]
2b81fb2bb0a95b66d8aa1e3a4b6875990f5adf46
https://github.com/joomla-framework/ldap/blob/2b81fb2bb0a95b66d8aa1e3a4b6875990f5adf46/src/LdapClient.php#L511-L519
45,801
joomla-framework/ldap
src/LdapClient.php
LdapClient.compare
public function compare($dn, $attribute, $value) { if (!$this->isBound || !$this->isConnected()) { return false; } return ldap_compare($this->resource, $dn, $attribute, $value); }
php
public function compare($dn, $attribute, $value) { if (!$this->isBound || !$this->isConnected()) { return false; } return ldap_compare($this->resource, $dn, $attribute, $value); }
[ "public", "function", "compare", "(", "$", "dn", ",", "$", "attribute", ",", "$", "value", ")", "{", "if", "(", "!", "$", "this", "->", "isBound", "||", "!", "$", "this", "->", "isConnected", "(", ")", ")", "{", "return", "false", ";", "}", "retu...
Compare value of attribute found in entry specified with DN @param string $dn The DN which contains the attribute you want to compare @param string $attribute The attribute whose value you want to compare @param string $value The value you want to check against the LDAP attribute @return boolean|integer Boolean result of the comparison or -1 on error @since 1.0
[ "Compare", "value", "of", "attribute", "found", "in", "entry", "specified", "with", "DN" ]
2b81fb2bb0a95b66d8aa1e3a4b6875990f5adf46
https://github.com/joomla-framework/ldap/blob/2b81fb2bb0a95b66d8aa1e3a4b6875990f5adf46/src/LdapClient.php#L532-L540
45,802
joomla-framework/ldap
src/LdapClient.php
LdapClient.read
public function read($dn) { if (!$this->isBound || !$this->isConnected()) { return false; } $base = substr($dn, strpos($dn, ',') + 1); $cn = substr($dn, 0, strpos($dn, ',')); $result = ldap_read($this->resource, $base, $cn); if ($result === false) { return false; } return ldap_get_entries($this->resource, $result); }
php
public function read($dn) { if (!$this->isBound || !$this->isConnected()) { return false; } $base = substr($dn, strpos($dn, ',') + 1); $cn = substr($dn, 0, strpos($dn, ',')); $result = ldap_read($this->resource, $base, $cn); if ($result === false) { return false; } return ldap_get_entries($this->resource, $result); }
[ "public", "function", "read", "(", "$", "dn", ")", "{", "if", "(", "!", "$", "this", "->", "isBound", "||", "!", "$", "this", "->", "isConnected", "(", ")", ")", "{", "return", "false", ";", "}", "$", "base", "=", "substr", "(", "$", "dn", ",",...
Read attributes of a given DN @param string $dn The DN of the object you want to read @return array|boolean Array of attributes for the given DN or boolean false on failure @since 1.0
[ "Read", "attributes", "of", "a", "given", "DN" ]
2b81fb2bb0a95b66d8aa1e3a4b6875990f5adf46
https://github.com/joomla-framework/ldap/blob/2b81fb2bb0a95b66d8aa1e3a4b6875990f5adf46/src/LdapClient.php#L551-L568
45,803
joomla-framework/ldap
src/LdapClient.php
LdapClient.delete
public function delete($dn) { if (!$this->isBound || !$this->isConnected()) { return false; } return ldap_delete($this->resource, $dn); }
php
public function delete($dn) { if (!$this->isBound || !$this->isConnected()) { return false; } return ldap_delete($this->resource, $dn); }
[ "public", "function", "delete", "(", "$", "dn", ")", "{", "if", "(", "!", "$", "this", "->", "isBound", "||", "!", "$", "this", "->", "isConnected", "(", ")", ")", "{", "return", "false", ";", "}", "return", "ldap_delete", "(", "$", "this", "->", ...
Delete an entry from a directory @param string $dn The DN of the object you want to delete @return boolean @since 1.0
[ "Delete", "an", "entry", "from", "a", "directory" ]
2b81fb2bb0a95b66d8aa1e3a4b6875990f5adf46
https://github.com/joomla-framework/ldap/blob/2b81fb2bb0a95b66d8aa1e3a4b6875990f5adf46/src/LdapClient.php#L579-L587
45,804
joomla-framework/ldap
src/LdapClient.php
LdapClient.create
public function create($dn, array $entries) { if (!$this->isBound || !$this->isConnected()) { return false; } return ldap_add($this->resource, $dn, $entries); }
php
public function create($dn, array $entries) { if (!$this->isBound || !$this->isConnected()) { return false; } return ldap_add($this->resource, $dn, $entries); }
[ "public", "function", "create", "(", "$", "dn", ",", "array", "$", "entries", ")", "{", "if", "(", "!", "$", "this", "->", "isBound", "||", "!", "$", "this", "->", "isConnected", "(", ")", ")", "{", "return", "false", ";", "}", "return", "ldap_add"...
Add entries to LDAP directory @param string $dn The DN where you want to put the object @param array $entries An array of arrays describing the object to add @return boolean @since 1.0
[ "Add", "entries", "to", "LDAP", "directory" ]
2b81fb2bb0a95b66d8aa1e3a4b6875990f5adf46
https://github.com/joomla-framework/ldap/blob/2b81fb2bb0a95b66d8aa1e3a4b6875990f5adf46/src/LdapClient.php#L599-L607
45,805
joomla-framework/ldap
src/LdapClient.php
LdapClient.add
public function add($dn, array $entry) { if (!$this->isBound || !$this->isConnected()) { return false; } return ldap_mod_add($this->resource, $dn, $entry); }
php
public function add($dn, array $entry) { if (!$this->isBound || !$this->isConnected()) { return false; } return ldap_mod_add($this->resource, $dn, $entry); }
[ "public", "function", "add", "(", "$", "dn", ",", "array", "$", "entry", ")", "{", "if", "(", "!", "$", "this", "->", "isBound", "||", "!", "$", "this", "->", "isConnected", "(", ")", ")", "{", "return", "false", ";", "}", "return", "ldap_mod_add",...
Add attribute values to current attributes @param string $dn The DN of the entry to add the attribute @param array $entry An array of arrays with attributes to add @return boolean @since 1.0
[ "Add", "attribute", "values", "to", "current", "attributes" ]
2b81fb2bb0a95b66d8aa1e3a4b6875990f5adf46
https://github.com/joomla-framework/ldap/blob/2b81fb2bb0a95b66d8aa1e3a4b6875990f5adf46/src/LdapClient.php#L619-L627
45,806
joomla-framework/ldap
src/LdapClient.php
LdapClient.rename
public function rename($dn, $newdn, $newparent, $deleteolddn) { if (!$this->isBound || !$this->isConnected()) { return false; } return ldap_rename($this->resource, $dn, $newdn, $newparent, $deleteolddn); }
php
public function rename($dn, $newdn, $newparent, $deleteolddn) { if (!$this->isBound || !$this->isConnected()) { return false; } return ldap_rename($this->resource, $dn, $newdn, $newparent, $deleteolddn); }
[ "public", "function", "rename", "(", "$", "dn", ",", "$", "newdn", ",", "$", "newparent", ",", "$", "deleteolddn", ")", "{", "if", "(", "!", "$", "this", "->", "isBound", "||", "!", "$", "this", "->", "isConnected", "(", ")", ")", "{", "return", ...
Modify the name of an entry @param string $dn The DN of the entry at the moment @param string $newdn The DN of the entry should be (only cn=newvalue) @param string $newparent The full DN of the parent (null by default) @param boolean $deleteolddn Delete the old values (default) @return boolean @since 1.0
[ "Modify", "the", "name", "of", "an", "entry" ]
2b81fb2bb0a95b66d8aa1e3a4b6875990f5adf46
https://github.com/joomla-framework/ldap/blob/2b81fb2bb0a95b66d8aa1e3a4b6875990f5adf46/src/LdapClient.php#L641-L649
45,807
bestit/PHP_CodeSniffer
src/Standards/BestIt/CodeSniffer/Helper/ExceptionHelper.php
ExceptionHelper.handleException
public function handleException(CodeWarning $exception): bool { $isError = $exception instanceof CodeError; $isFixable = $exception->isFixable(); $method = 'add'; if ($isFixable) { $method .= 'Fixable'; } $method .= $isError ? 'Error' : 'Warning'; return $this->file->$method( $exception->getMessage(), $exception->getStackPosition(), $exception->getCode(), $exception->getPayload() ); }
php
public function handleException(CodeWarning $exception): bool { $isError = $exception instanceof CodeError; $isFixable = $exception->isFixable(); $method = 'add'; if ($isFixable) { $method .= 'Fixable'; } $method .= $isError ? 'Error' : 'Warning'; return $this->file->$method( $exception->getMessage(), $exception->getStackPosition(), $exception->getCode(), $exception->getPayload() ); }
[ "public", "function", "handleException", "(", "CodeWarning", "$", "exception", ")", ":", "bool", "{", "$", "isError", "=", "$", "exception", "instanceof", "CodeError", ";", "$", "isFixable", "=", "$", "exception", "->", "isFixable", "(", ")", ";", "$", "me...
Registers the exception as an error or warning on the file. @param CodeWarning $exception The error which should be handled. @return bool Should this error be fixed?
[ "Registers", "the", "exception", "as", "an", "error", "or", "warning", "on", "the", "file", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/CodeSniffer/Helper/ExceptionHelper.php#L43-L61
45,808
mimmi20/BrowserDetector
src/Parser/BrowserParser.php
BrowserParser.parse
public function parse(string $useragent): array { $mode = $this->fileParser->parseFile( new \SplFileInfo(self::GENERIC_FILE), $useragent, 'unknown' ); $key = $this->fileParser->parseFile( new \SplFileInfo(sprintf(self::SPECIFIC_FILE, $mode)), $useragent, 'unknown' ); return $this->load($key, $useragent); }
php
public function parse(string $useragent): array { $mode = $this->fileParser->parseFile( new \SplFileInfo(self::GENERIC_FILE), $useragent, 'unknown' ); $key = $this->fileParser->parseFile( new \SplFileInfo(sprintf(self::SPECIFIC_FILE, $mode)), $useragent, 'unknown' ); return $this->load($key, $useragent); }
[ "public", "function", "parse", "(", "string", "$", "useragent", ")", ":", "array", "{", "$", "mode", "=", "$", "this", "->", "fileParser", "->", "parseFile", "(", "new", "\\", "SplFileInfo", "(", "self", "::", "GENERIC_FILE", ")", ",", "$", "useragent", ...
Gets the information about the browser by User Agent @param string $useragent @throws \ExceptionalJSON\DecodeErrorException @return array
[ "Gets", "the", "information", "about", "the", "browser", "by", "User", "Agent" ]
1b90d994fcee01344a36bbe39afb14622bc8df9c
https://github.com/mimmi20/BrowserDetector/blob/1b90d994fcee01344a36bbe39afb14622bc8df9c/src/Parser/BrowserParser.php#L55-L70
45,809
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php
AlphabeticallySortedUsesSniff.areRequirementsMet
protected function areRequirementsMet(): bool { return (bool) $this->useStatements = UseStatementHelper::getUseStatements( $this->getFile()->getBaseFile(), $this->getStackPos() ); }
php
protected function areRequirementsMet(): bool { return (bool) $this->useStatements = UseStatementHelper::getUseStatements( $this->getFile()->getBaseFile(), $this->getStackPos() ); }
[ "protected", "function", "areRequirementsMet", "(", ")", ":", "bool", "{", "return", "(", "bool", ")", "$", "this", "->", "useStatements", "=", "UseStatementHelper", "::", "getUseStatements", "(", "$", "this", "->", "getFile", "(", ")", "->", "getBaseFile", ...
Returns true if we have use statements. @return bool
[ "Returns", "true", "if", "we", "have", "use", "statements", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php#L46-L52
45,810
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php
AlphabeticallySortedUsesSniff.compareUseStatements
private function compareUseStatements(UseStatement $prevStatement, UseStatement $nextStatement): int { $callbacks = [ 'compareUseStatementsByType', 'compareUseStatementsByContent', // This will return something in any case! 'compareUseStatementsByNamespaceCount' ]; foreach ($callbacks as $callback) { $compared = $this->$callback($prevStatement, $nextStatement); if ($compared !== null) { return $compared; } } }
php
private function compareUseStatements(UseStatement $prevStatement, UseStatement $nextStatement): int { $callbacks = [ 'compareUseStatementsByType', 'compareUseStatementsByContent', // This will return something in any case! 'compareUseStatementsByNamespaceCount' ]; foreach ($callbacks as $callback) { $compared = $this->$callback($prevStatement, $nextStatement); if ($compared !== null) { return $compared; } } }
[ "private", "function", "compareUseStatements", "(", "UseStatement", "$", "prevStatement", ",", "UseStatement", "$", "nextStatement", ")", ":", "int", "{", "$", "callbacks", "=", "[", "'compareUseStatementsByType'", ",", "'compareUseStatementsByContent'", ",", "// This w...
Will removing a compare marker for the given use statements. @param UseStatement $prevStatement @param UseStatement $nextStatement @return int 1 <=> -1 To move statements in a direction.
[ "Will", "removing", "a", "compare", "marker", "for", "the", "given", "use", "statements", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php#L62-L78
45,811
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php
AlphabeticallySortedUsesSniff.compareUseStatementsByContent
private function compareUseStatementsByContent(UseStatement $prevStatement, UseStatement $nextStatement): ?int { $compareByContent = null; $prevParts = explode(NamespaceHelper::NAMESPACE_SEPARATOR, $prevStatement->getFullyQualifiedTypeName()); $nextParts = explode(NamespaceHelper::NAMESPACE_SEPARATOR, $nextStatement->getFullyQualifiedTypeName()); $minPartsCount = min(count($prevParts), count($nextParts)); for ($i = 0; $i < $minPartsCount; ++$i) { $comparison = strcasecmp($prevParts[$i], $nextParts[$i]); if ($comparison) { $compareByContent = $comparison; break; } } return $compareByContent; }
php
private function compareUseStatementsByContent(UseStatement $prevStatement, UseStatement $nextStatement): ?int { $compareByContent = null; $prevParts = explode(NamespaceHelper::NAMESPACE_SEPARATOR, $prevStatement->getFullyQualifiedTypeName()); $nextParts = explode(NamespaceHelper::NAMESPACE_SEPARATOR, $nextStatement->getFullyQualifiedTypeName()); $minPartsCount = min(count($prevParts), count($nextParts)); for ($i = 0; $i < $minPartsCount; ++$i) { $comparison = strcasecmp($prevParts[$i], $nextParts[$i]); if ($comparison) { $compareByContent = $comparison; break; } } return $compareByContent; }
[ "private", "function", "compareUseStatementsByContent", "(", "UseStatement", "$", "prevStatement", ",", "UseStatement", "$", "nextStatement", ")", ":", "?", "int", "{", "$", "compareByContent", "=", "null", ";", "$", "prevParts", "=", "explode", "(", "NamespaceHel...
Compares the given use statements by their string content. @SuppressWarnings(PHPMD.UnusedPrivateMethod) @param UseStatement $prevStatement @param UseStatement $nextStatement @return int|null 1 <=> -1 To move statements in a direction.
[ "Compares", "the", "given", "use", "statements", "by", "their", "string", "content", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php#L90-L109
45,812
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php
AlphabeticallySortedUsesSniff.compareUseStatementsByNamespaceCount
private function compareUseStatementsByNamespaceCount( UseStatement $prevStatement, UseStatement $nextStatement ): int { $aNameParts = explode(NamespaceHelper::NAMESPACE_SEPARATOR, $prevStatement->getFullyQualifiedTypeName()); $bNameParts = explode(NamespaceHelper::NAMESPACE_SEPARATOR, $nextStatement->getFullyQualifiedTypeName()); return count($aNameParts) <=> count($bNameParts); }
php
private function compareUseStatementsByNamespaceCount( UseStatement $prevStatement, UseStatement $nextStatement ): int { $aNameParts = explode(NamespaceHelper::NAMESPACE_SEPARATOR, $prevStatement->getFullyQualifiedTypeName()); $bNameParts = explode(NamespaceHelper::NAMESPACE_SEPARATOR, $nextStatement->getFullyQualifiedTypeName()); return count($aNameParts) <=> count($bNameParts); }
[ "private", "function", "compareUseStatementsByNamespaceCount", "(", "UseStatement", "$", "prevStatement", ",", "UseStatement", "$", "nextStatement", ")", ":", "int", "{", "$", "aNameParts", "=", "explode", "(", "NamespaceHelper", "::", "NAMESPACE_SEPARATOR", ",", "$",...
The shorted usage comes at top. @SuppressWarnings(PHPMD.UnusedPrivateMethod) @param UseStatement $prevStatement @param UseStatement $nextStatement @return int 1 <=> -1 To move statements in a direction.
[ "The", "shorted", "usage", "comes", "at", "top", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php#L121-L129
45,813
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php
AlphabeticallySortedUsesSniff.compareUseStatementsByType
private function compareUseStatementsByType(UseStatement $prevStatement, UseStatement $nextStatement): ?int { $comparedByType = null; if (!$prevStatement->hasSameType($nextStatement)) { $order = [ UseStatement::TYPE_DEFAULT => 1, UseStatement::TYPE_FUNCTION => 2, UseStatement::TYPE_CONSTANT => 3, ]; $file = $this->getFile(); $comparedByType = $order[UseStatementHelper::getType($file, $prevStatement)] <=> $order[UseStatementHelper::getType($file, $nextStatement)]; } return $comparedByType; }
php
private function compareUseStatementsByType(UseStatement $prevStatement, UseStatement $nextStatement): ?int { $comparedByType = null; if (!$prevStatement->hasSameType($nextStatement)) { $order = [ UseStatement::TYPE_DEFAULT => 1, UseStatement::TYPE_FUNCTION => 2, UseStatement::TYPE_CONSTANT => 3, ]; $file = $this->getFile(); $comparedByType = $order[UseStatementHelper::getType($file, $prevStatement)] <=> $order[UseStatementHelper::getType($file, $nextStatement)]; } return $comparedByType; }
[ "private", "function", "compareUseStatementsByType", "(", "UseStatement", "$", "prevStatement", ",", "UseStatement", "$", "nextStatement", ")", ":", "?", "int", "{", "$", "comparedByType", "=", "null", ";", "if", "(", "!", "$", "prevStatement", "->", "hasSameTyp...
Classes to the top, functions next, constants last. @SuppressWarnings(PHPMD.UnusedPrivateMethod) @param UseStatement $prevStatement @param UseStatement $nextStatement @return int|null 1 <=> -1 To move statements in a direction.
[ "Classes", "to", "the", "top", "functions", "next", "constants", "last", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php#L141-L158
45,814
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php
AlphabeticallySortedUsesSniff.fixDefaultProblem
protected function fixDefaultProblem(CodeWarning $error): void { // Satisfy phpmd unset($error); $firstUseStatement = reset($this->useStatements); $file = $this->getFile()->getBaseFile(); $file->fixer->beginChangeset(); $this->removeOldUseStatements($firstUseStatement); $file->fixer->addContent( $firstUseStatement->getPointer(), $this->getNewUseStatements() ); $file->fixer->endChangeset(); }
php
protected function fixDefaultProblem(CodeWarning $error): void { // Satisfy phpmd unset($error); $firstUseStatement = reset($this->useStatements); $file = $this->getFile()->getBaseFile(); $file->fixer->beginChangeset(); $this->removeOldUseStatements($firstUseStatement); $file->fixer->addContent( $firstUseStatement->getPointer(), $this->getNewUseStatements() ); $file->fixer->endChangeset(); }
[ "protected", "function", "fixDefaultProblem", "(", "CodeWarning", "$", "error", ")", ":", "void", "{", "// Satisfy phpmd", "unset", "(", "$", "error", ")", ";", "$", "firstUseStatement", "=", "reset", "(", "$", "this", "->", "useStatements", ")", ";", "$", ...
Sorts the uses correctly and saves them in the file. @param CodeWarning $error @return void
[ "Sorts", "the", "uses", "correctly", "and", "saves", "them", "in", "the", "file", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php#L167-L186
45,815
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php
AlphabeticallySortedUsesSniff.getNewUseStatements
private function getNewUseStatements(): string { $this->sortUseStatements(); $file = $this->getFile()->getBaseFile(); return implode( $file->eolChar, array_map( function (UseStatement $useStatement) use ($file): string { $unqualifiedName = NamespaceHelper::getUnqualifiedNameFromFullyQualifiedName( $useStatement->getFullyQualifiedTypeName() ); $useTypeName = UseStatementHelper::getTypeName($file, $useStatement); $useTypeFormatted = $useTypeName ? sprintf('%s ', $useTypeName) : ''; return ($unqualifiedName === $useStatement->getNameAsReferencedInFile()) ? sprintf( 'use %s%s;', $useTypeFormatted, $useStatement->getFullyQualifiedTypeName() ) : sprintf( 'use %s%s as %s;', $useTypeFormatted, $useStatement->getFullyQualifiedTypeName(), $useStatement->getNameAsReferencedInFile() ); }, $this->useStatements ) ); }
php
private function getNewUseStatements(): string { $this->sortUseStatements(); $file = $this->getFile()->getBaseFile(); return implode( $file->eolChar, array_map( function (UseStatement $useStatement) use ($file): string { $unqualifiedName = NamespaceHelper::getUnqualifiedNameFromFullyQualifiedName( $useStatement->getFullyQualifiedTypeName() ); $useTypeName = UseStatementHelper::getTypeName($file, $useStatement); $useTypeFormatted = $useTypeName ? sprintf('%s ', $useTypeName) : ''; return ($unqualifiedName === $useStatement->getNameAsReferencedInFile()) ? sprintf( 'use %s%s;', $useTypeFormatted, $useStatement->getFullyQualifiedTypeName() ) : sprintf( 'use %s%s as %s;', $useTypeFormatted, $useStatement->getFullyQualifiedTypeName(), $useStatement->getNameAsReferencedInFile() ); }, $this->useStatements ) ); }
[ "private", "function", "getNewUseStatements", "(", ")", ":", "string", "{", "$", "this", "->", "sortUseStatements", "(", ")", ";", "$", "file", "=", "$", "this", "->", "getFile", "(", ")", "->", "getBaseFile", "(", ")", ";", "return", "implode", "(", "...
Returns the new statements as a string for fixing. @return string
[ "Returns", "the", "new", "statements", "as", "a", "string", "for", "fixing", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php#L193-L226
45,816
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php
AlphabeticallySortedUsesSniff.processToken
protected function processToken(): void { $prevStatement = null; foreach ($this->useStatements as $useStatement) { if ($prevStatement && ($this->compareUseStatements($prevStatement, $useStatement) > 0)) { $exception = new CodeError( static::CODE_INCORRECT_ORDER, 'Use statements should be sorted alphabetically. The first wrong one is %s.', $useStatement->getPointer() ); $exception ->setPayload([$useStatement->getFullyQualifiedTypeName()]) ->isFixable(true); throw $exception; } $prevStatement = $useStatement; } }
php
protected function processToken(): void { $prevStatement = null; foreach ($this->useStatements as $useStatement) { if ($prevStatement && ($this->compareUseStatements($prevStatement, $useStatement) > 0)) { $exception = new CodeError( static::CODE_INCORRECT_ORDER, 'Use statements should be sorted alphabetically. The first wrong one is %s.', $useStatement->getPointer() ); $exception ->setPayload([$useStatement->getFullyQualifiedTypeName()]) ->isFixable(true); throw $exception; } $prevStatement = $useStatement; } }
[ "protected", "function", "processToken", "(", ")", ":", "void", "{", "$", "prevStatement", "=", "null", ";", "foreach", "(", "$", "this", "->", "useStatements", "as", "$", "useStatement", ")", "{", "if", "(", "$", "prevStatement", "&&", "(", "$", "this",...
Checks if the uses are in the correct order. @throws CodeError @return void
[ "Checks", "if", "the", "uses", "are", "in", "the", "correct", "order", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php#L235-L256
45,817
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php
AlphabeticallySortedUsesSniff.removeOldUseStatements
private function removeOldUseStatements(UseStatement $firstUseStatement): void { $file = $this->getFile()->getBaseFile(); $lastUseStatement = end($this->useStatements); $lastSemicolonPointer = TokenHelper::findNext($file, T_SEMICOLON, $lastUseStatement->getPointer()); for ($i = $firstUseStatement->getPointer(); $i <= $lastSemicolonPointer; $i++) { $file->fixer->replaceToken($i, ''); } }
php
private function removeOldUseStatements(UseStatement $firstUseStatement): void { $file = $this->getFile()->getBaseFile(); $lastUseStatement = end($this->useStatements); $lastSemicolonPointer = TokenHelper::findNext($file, T_SEMICOLON, $lastUseStatement->getPointer()); for ($i = $firstUseStatement->getPointer(); $i <= $lastSemicolonPointer; $i++) { $file->fixer->replaceToken($i, ''); } }
[ "private", "function", "removeOldUseStatements", "(", "UseStatement", "$", "firstUseStatement", ")", ":", "void", "{", "$", "file", "=", "$", "this", "->", "getFile", "(", ")", "->", "getBaseFile", "(", ")", ";", "$", "lastUseStatement", "=", "end", "(", "...
Removes the lines of the old statements. @param UseStatement $firstUseStatement @return void
[ "Removes", "the", "lines", "of", "the", "old", "statements", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php#L286-L295
45,818
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php
AlphabeticallySortedUsesSniff.sortUseStatements
private function sortUseStatements(): void { uasort($this->useStatements, function (UseStatement $prevStatement, UseStatement $nextStatement) { return $this->compareUseStatements($prevStatement, $nextStatement); }); }
php
private function sortUseStatements(): void { uasort($this->useStatements, function (UseStatement $prevStatement, UseStatement $nextStatement) { return $this->compareUseStatements($prevStatement, $nextStatement); }); }
[ "private", "function", "sortUseStatements", "(", ")", ":", "void", "{", "uasort", "(", "$", "this", "->", "useStatements", ",", "function", "(", "UseStatement", "$", "prevStatement", ",", "UseStatement", "$", "nextStatement", ")", "{", "return", "$", "this", ...
Saves the use-property by the compare function. @return void
[ "Saves", "the", "use", "-", "property", "by", "the", "compare", "function", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/AlphabeticallySortedUsesSniff.php#L302-L307
45,819
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/OpenTagSniff.php
OpenTagSniff.handleOpenTagNotFirstStatement
private function handleOpenTagNotFirstStatement(File $phpcsFile, int $stackPtr): void { $fixNotFirstStatement = $phpcsFile->addFixableError( self::ERROR_NOT_FIRST_STATEMENT, $stackPtr, static::CODE_NOT_FIRST_STATEMENT ); if ($fixNotFirstStatement) { $phpcsFile->fixer->beginChangeset(); for ($i = 0; $i < $stackPtr; $i++) { $phpcsFile->fixer->replaceToken($i, ''); } $phpcsFile->fixer->endChangeset(); } }
php
private function handleOpenTagNotFirstStatement(File $phpcsFile, int $stackPtr): void { $fixNotFirstStatement = $phpcsFile->addFixableError( self::ERROR_NOT_FIRST_STATEMENT, $stackPtr, static::CODE_NOT_FIRST_STATEMENT ); if ($fixNotFirstStatement) { $phpcsFile->fixer->beginChangeset(); for ($i = 0; $i < $stackPtr; $i++) { $phpcsFile->fixer->replaceToken($i, ''); } $phpcsFile->fixer->endChangeset(); } }
[ "private", "function", "handleOpenTagNotFirstStatement", "(", "File", "$", "phpcsFile", ",", "int", "$", "stackPtr", ")", ":", "void", "{", "$", "fixNotFirstStatement", "=", "$", "phpcsFile", "->", "addFixableError", "(", "self", "::", "ERROR_NOT_FIRST_STATEMENT", ...
Handles open tag not first statement error. @param File $phpcsFile The php cs file @param int $stackPtr Pointer to the open tag token @return void
[ "Handles", "open", "tag", "not", "first", "statement", "error", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/OpenTagSniff.php#L103-L118
45,820
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/OpenTagSniff.php
OpenTagSniff.handleNoSpaceAfterOpenTag
private function handleNoSpaceAfterOpenTag(File $phpcsFile, int $stackPtr, int $whitespacePtr): void { $fixNoSpaceAfterTag = $phpcsFile->addFixableError( self::ERROR_NO_SPACE_AFTER_OPEN_TAG, $whitespacePtr, static::CODE_NO_SPACE_AFTER_OPEN_TAG ); if ($fixNoSpaceAfterTag) { $phpcsFile->fixer->beginChangeset(); $phpcsFile->fixer->addNewline($stackPtr); $phpcsFile->fixer->endChangeset(); } }
php
private function handleNoSpaceAfterOpenTag(File $phpcsFile, int $stackPtr, int $whitespacePtr): void { $fixNoSpaceAfterTag = $phpcsFile->addFixableError( self::ERROR_NO_SPACE_AFTER_OPEN_TAG, $whitespacePtr, static::CODE_NO_SPACE_AFTER_OPEN_TAG ); if ($fixNoSpaceAfterTag) { $phpcsFile->fixer->beginChangeset(); $phpcsFile->fixer->addNewline($stackPtr); $phpcsFile->fixer->endChangeset(); } }
[ "private", "function", "handleNoSpaceAfterOpenTag", "(", "File", "$", "phpcsFile", ",", "int", "$", "stackPtr", ",", "int", "$", "whitespacePtr", ")", ":", "void", "{", "$", "fixNoSpaceAfterTag", "=", "$", "phpcsFile", "->", "addFixableError", "(", "self", "::...
Handles no space after open tag error. @param File $phpcsFile The php cs file @param int $stackPtr Pointer to the open tag token @param int $whitespacePtr Pointer to the line after the open tag @return void
[ "Handles", "no", "space", "after", "open", "tag", "error", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/OpenTagSniff.php#L129-L142
45,821
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/OpenTagSniff.php
OpenTagSniff.handleLineNotEmpty
private function handleLineNotEmpty(File $phpcsFile, int $whitespacePtr): void { $fixSpaceNotScndLine = $phpcsFile->addFixableError( self::ERROR_LINE_NOT_EMPTY, $whitespacePtr, static::CODE_LINE_NOT_EMPTY ); if ($fixSpaceNotScndLine) { $phpcsFile->fixer->beginChangeset(); $phpcsFile->fixer->replaceToken( $whitespacePtr, '' ); $phpcsFile->fixer->endChangeset(); } }
php
private function handleLineNotEmpty(File $phpcsFile, int $whitespacePtr): void { $fixSpaceNotScndLine = $phpcsFile->addFixableError( self::ERROR_LINE_NOT_EMPTY, $whitespacePtr, static::CODE_LINE_NOT_EMPTY ); if ($fixSpaceNotScndLine) { $phpcsFile->fixer->beginChangeset(); $phpcsFile->fixer->replaceToken( $whitespacePtr, '' ); $phpcsFile->fixer->endChangeset(); } }
[ "private", "function", "handleLineNotEmpty", "(", "File", "$", "phpcsFile", ",", "int", "$", "whitespacePtr", ")", ":", "void", "{", "$", "fixSpaceNotScndLine", "=", "$", "phpcsFile", "->", "addFixableError", "(", "self", "::", "ERROR_LINE_NOT_EMPTY", ",", "$", ...
Handles line after open tag not empty. @param File $phpcsFile The php cs file @param int $whitespacePtr Pointer to the line after the open tag @return void
[ "Handles", "line", "after", "open", "tag", "not", "empty", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/OpenTagSniff.php#L152-L168
45,822
mimmi20/BrowserDetector
src/Parser/EngineParser.php
EngineParser.parse
public function parse(string $useragent): EngineInterface { $key = $this->fileParser->parseFile( new \SplFileInfo(self::GENERIC_FILE), $useragent, 'unknown' ); return $this->load($key, $useragent); }
php
public function parse(string $useragent): EngineInterface { $key = $this->fileParser->parseFile( new \SplFileInfo(self::GENERIC_FILE), $useragent, 'unknown' ); return $this->load($key, $useragent); }
[ "public", "function", "parse", "(", "string", "$", "useragent", ")", ":", "EngineInterface", "{", "$", "key", "=", "$", "this", "->", "fileParser", "->", "parseFile", "(", "new", "\\", "SplFileInfo", "(", "self", "::", "GENERIC_FILE", ")", ",", "$", "use...
Gets the information about the engine by User Agent @param string $useragent @throws \ExceptionalJSON\DecodeErrorException @return \UaResult\Engine\EngineInterface
[ "Gets", "the", "information", "about", "the", "engine", "by", "User", "Agent" ]
1b90d994fcee01344a36bbe39afb14622bc8df9c
https://github.com/mimmi20/BrowserDetector/blob/1b90d994fcee01344a36bbe39afb14622bc8df9c/src/Parser/EngineParser.php#L55-L64
45,823
mimmi20/BrowserDetector
src/Version/Helper/MicrosoftOffice.php
MicrosoftOffice.mapOfficeVersion
public function mapOfficeVersion(string $version): string { $intVersion = (int) $version; if (in_array($intVersion, [2007, 2010, 2013, 2016])) { return (string) $intVersion; } if (16 === $intVersion) { return '2016'; } if (15 === $intVersion) { return '2013'; } if (14 === $intVersion) { return '2010'; } if (12 === $intVersion) { return '2007'; } return '0'; }
php
public function mapOfficeVersion(string $version): string { $intVersion = (int) $version; if (in_array($intVersion, [2007, 2010, 2013, 2016])) { return (string) $intVersion; } if (16 === $intVersion) { return '2016'; } if (15 === $intVersion) { return '2013'; } if (14 === $intVersion) { return '2010'; } if (12 === $intVersion) { return '2007'; } return '0'; }
[ "public", "function", "mapOfficeVersion", "(", "string", "$", "version", ")", ":", "string", "{", "$", "intVersion", "=", "(", "int", ")", "$", "version", ";", "if", "(", "in_array", "(", "$", "intVersion", ",", "[", "2007", ",", "2010", ",", "2013", ...
maps the version @param string $version @return string
[ "maps", "the", "version" ]
1b90d994fcee01344a36bbe39afb14622bc8df9c
https://github.com/mimmi20/BrowserDetector/blob/1b90d994fcee01344a36bbe39afb14622bc8df9c/src/Version/Helper/MicrosoftOffice.php#L23-L48
45,824
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php
AbstractDocSniff.fixDocCommentUcFirst
private function fixDocCommentUcFirst(int $position, array $token): void { $this->file->fixer->beginChangeset(); $this->file->fixer->replaceToken($position, ucfirst($token['content'])); $this->file->fixer->endChangeset(); }
php
private function fixDocCommentUcFirst(int $position, array $token): void { $this->file->fixer->beginChangeset(); $this->file->fixer->replaceToken($position, ucfirst($token['content'])); $this->file->fixer->endChangeset(); }
[ "private", "function", "fixDocCommentUcFirst", "(", "int", "$", "position", ",", "array", "$", "token", ")", ":", "void", "{", "$", "this", "->", "file", "->", "fixer", "->", "beginChangeset", "(", ")", ";", "$", "this", "->", "file", "->", "fixer", "-...
Fixes the first letter of the doc comment, which must be uppercase. @param int $position @param array $token @return void
[ "Fixes", "the", "first", "letter", "of", "the", "doc", "comment", "which", "must", "be", "uppercase", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php#L93-L98
45,825
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php
AbstractDocSniff.fixNoLineAfterDocComment
private function fixNoLineAfterDocComment(int $position, array $token): void { $this->file->fixer->beginChangeset(); $this->file->fixer->addContent( $position, $this->file->getEolChar() . str_repeat(' ', $token['level']) . ' *' ); $this->file->fixer->endChangeset(); }
php
private function fixNoLineAfterDocComment(int $position, array $token): void { $this->file->fixer->beginChangeset(); $this->file->fixer->addContent( $position, $this->file->getEolChar() . str_repeat(' ', $token['level']) . ' *' ); $this->file->fixer->endChangeset(); }
[ "private", "function", "fixNoLineAfterDocComment", "(", "int", "$", "position", ",", "array", "$", "token", ")", ":", "void", "{", "$", "this", "->", "file", "->", "fixer", "->", "beginChangeset", "(", ")", ";", "$", "this", "->", "file", "->", "fixer", ...
Fixes no line after doc comment. @param int $position @param array $token @return void
[ "Fixes", "no", "line", "after", "doc", "comment", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php#L108-L118
45,826
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php
AbstractDocSniff.getSummaryPosition
private function getSummaryPosition(): ?int { if ($this->summaryPosition === -1) { $this->summaryPosition = $this->loadSummaryPosition(); } return $this->summaryPosition; }
php
private function getSummaryPosition(): ?int { if ($this->summaryPosition === -1) { $this->summaryPosition = $this->loadSummaryPosition(); } return $this->summaryPosition; }
[ "private", "function", "getSummaryPosition", "(", ")", ":", "?", "int", "{", "if", "(", "$", "this", "->", "summaryPosition", "===", "-", "1", ")", "{", "$", "this", "->", "summaryPosition", "=", "$", "this", "->", "loadSummaryPosition", "(", ")", ";", ...
Returns the position of the summary or null. @return int|null
[ "Returns", "the", "position", "of", "the", "summary", "or", "null", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php#L125-L132
45,827
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php
AbstractDocSniff.isNextLineEmpty
private function isNextLineEmpty(int $startPosition): bool { $istNextLineEmpty = true; $nextRelevantPos = $this->loadNextDocBlockContent($startPosition); if ($nextRelevantPos !== -1) { $istNextLineEmpty = $this->tokens[$startPosition]['line'] + 1 < $this->tokens[$nextRelevantPos]['line']; } return $istNextLineEmpty; }
php
private function isNextLineEmpty(int $startPosition): bool { $istNextLineEmpty = true; $nextRelevantPos = $this->loadNextDocBlockContent($startPosition); if ($nextRelevantPos !== -1) { $istNextLineEmpty = $this->tokens[$startPosition]['line'] + 1 < $this->tokens[$nextRelevantPos]['line']; } return $istNextLineEmpty; }
[ "private", "function", "isNextLineEmpty", "(", "int", "$", "startPosition", ")", ":", "bool", "{", "$", "istNextLineEmpty", "=", "true", ";", "$", "nextRelevantPos", "=", "$", "this", "->", "loadNextDocBlockContent", "(", "$", "startPosition", ")", ";", "if", ...
Returns true if the next line of the comment is empty. @param int $startPosition The position where to start the search. @return bool
[ "Returns", "true", "if", "the", "next", "line", "of", "the", "comment", "is", "empty", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php#L141-L151
45,828
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php
AbstractDocSniff.isPrevLineEmpty
private function isPrevLineEmpty(int $startPosition): bool { $isPrevLineEmpty = true; $posPrevContentPos = $this->loadPrevDocBlockContent($startPosition); if ($posPrevContentPos !== -1) { $isPrevLineEmpty = $this->tokens[$startPosition]['line'] - 1 > $this->tokens[$posPrevContentPos]['line']; } return $isPrevLineEmpty; }
php
private function isPrevLineEmpty(int $startPosition): bool { $isPrevLineEmpty = true; $posPrevContentPos = $this->loadPrevDocBlockContent($startPosition); if ($posPrevContentPos !== -1) { $isPrevLineEmpty = $this->tokens[$startPosition]['line'] - 1 > $this->tokens[$posPrevContentPos]['line']; } return $isPrevLineEmpty; }
[ "private", "function", "isPrevLineEmpty", "(", "int", "$", "startPosition", ")", ":", "bool", "{", "$", "isPrevLineEmpty", "=", "true", ";", "$", "posPrevContentPos", "=", "$", "this", "->", "loadPrevDocBlockContent", "(", "$", "startPosition", ")", ";", "if",...
Returns true if the prev line of the comment is empty. @param int $startPosition The position where to start the search. @return bool
[ "Returns", "true", "if", "the", "prev", "line", "of", "the", "comment", "is", "empty", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php#L160-L170
45,829
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php
AbstractDocSniff.loadNextDocBlockContent
private function loadNextDocBlockContent(int $startPosition): int { return $this->file->findNext( [ T_DOC_COMMENT_WHITESPACE, T_DOC_COMMENT_STAR ], $startPosition + 1, $this->getDocHelper()->getBlockEndPosition(), true ); }
php
private function loadNextDocBlockContent(int $startPosition): int { return $this->file->findNext( [ T_DOC_COMMENT_WHITESPACE, T_DOC_COMMENT_STAR ], $startPosition + 1, $this->getDocHelper()->getBlockEndPosition(), true ); }
[ "private", "function", "loadNextDocBlockContent", "(", "int", "$", "startPosition", ")", ":", "int", "{", "return", "$", "this", "->", "file", "->", "findNext", "(", "[", "T_DOC_COMMENT_WHITESPACE", ",", "T_DOC_COMMENT_STAR", "]", ",", "$", "startPosition", "+",...
Returns the position of the next whitespace or star of the comment for checking the line after that. @param int $startPosition @return int
[ "Returns", "the", "position", "of", "the", "next", "whitespace", "or", "star", "of", "the", "comment", "for", "checking", "the", "line", "after", "that", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php#L191-L202
45,830
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php
AbstractDocSniff.loadPrevDocBlockContent
private function loadPrevDocBlockContent(int $startPosition): int { return $this->file->findPrevious( [ T_DOC_COMMENT_OPEN_TAG, T_DOC_COMMENT_STAR, T_DOC_COMMENT_WHITESPACE, ], $startPosition - 1, $this->getDocCommentPos(), true ); }
php
private function loadPrevDocBlockContent(int $startPosition): int { return $this->file->findPrevious( [ T_DOC_COMMENT_OPEN_TAG, T_DOC_COMMENT_STAR, T_DOC_COMMENT_WHITESPACE, ], $startPosition - 1, $this->getDocCommentPos(), true ); }
[ "private", "function", "loadPrevDocBlockContent", "(", "int", "$", "startPosition", ")", ":", "int", "{", "return", "$", "this", "->", "file", "->", "findPrevious", "(", "[", "T_DOC_COMMENT_OPEN_TAG", ",", "T_DOC_COMMENT_STAR", ",", "T_DOC_COMMENT_WHITESPACE", ",", ...
Returns the position of the previous whitespace or star of the comment for checking the line after that. @param int $startPosition @return int
[ "Returns", "the", "position", "of", "the", "previous", "whitespace", "or", "star", "of", "the", "comment", "for", "checking", "the", "line", "after", "that", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php#L211-L223
45,831
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php
AbstractDocSniff.loadSummaryPosition
private function loadSummaryPosition(): ?int { $return = null; $possSummaryPos = $this->loadNextDocBlockContent($this->getDocCommentPos()); if ((int) $possSummaryPos > 0) { $possSummaryToken = $this->tokens[$possSummaryPos]; $return = $this->isSimpleText($possSummaryToken) ? $possSummaryPos : null; } return $return; }
php
private function loadSummaryPosition(): ?int { $return = null; $possSummaryPos = $this->loadNextDocBlockContent($this->getDocCommentPos()); if ((int) $possSummaryPos > 0) { $possSummaryToken = $this->tokens[$possSummaryPos]; $return = $this->isSimpleText($possSummaryToken) ? $possSummaryPos : null; } return $return; }
[ "private", "function", "loadSummaryPosition", "(", ")", ":", "?", "int", "{", "$", "return", "=", "null", ";", "$", "possSummaryPos", "=", "$", "this", "->", "loadNextDocBlockContent", "(", "$", "this", "->", "getDocCommentPos", "(", ")", ")", ";", "if", ...
Loads the position of the summary token if possible. @return int|null
[ "Loads", "the", "position", "of", "the", "summary", "token", "if", "possible", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php#L230-L242
45,832
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php
AbstractDocSniff.validateDescriptions
private function validateDescriptions(): self { $commentPoss = TokenHelper::findNextAll( $this->file->getBaseFile(), [T_DOC_COMMENT_STRING, T_DOC_COMMENT_TAG], $this->getDocCommentPos(), $this->getDocHelper()->getBlockEndPosition() ); foreach ($commentPoss as $index => $commentPos) { $commentToken = $this->tokens[$commentPos]; $skipNewLineCheck = false; // We only search till the tags. if ($commentToken['code'] === T_DOC_COMMENT_TAG) { break; } if ($isFirstDocString = $index === 0) { $skipNewLineCheck = !$this->validateOneLineSummary(); } $this->validateUCFirstDocComment($commentPos, $commentToken); if (!$skipNewLineCheck) { $this->validateNewLineAfterDocComment($commentPos, $commentToken, $isFirstDocString); } } return $this; ; }
php
private function validateDescriptions(): self { $commentPoss = TokenHelper::findNextAll( $this->file->getBaseFile(), [T_DOC_COMMENT_STRING, T_DOC_COMMENT_TAG], $this->getDocCommentPos(), $this->getDocHelper()->getBlockEndPosition() ); foreach ($commentPoss as $index => $commentPos) { $commentToken = $this->tokens[$commentPos]; $skipNewLineCheck = false; // We only search till the tags. if ($commentToken['code'] === T_DOC_COMMENT_TAG) { break; } if ($isFirstDocString = $index === 0) { $skipNewLineCheck = !$this->validateOneLineSummary(); } $this->validateUCFirstDocComment($commentPos, $commentToken); if (!$skipNewLineCheck) { $this->validateNewLineAfterDocComment($commentPos, $commentToken, $isFirstDocString); } } return $this; ; }
[ "private", "function", "validateDescriptions", "(", ")", ":", "self", "{", "$", "commentPoss", "=", "TokenHelper", "::", "findNextAll", "(", "$", "this", "->", "file", "->", "getBaseFile", "(", ")", ",", "[", "T_DOC_COMMENT_STRING", ",", "T_DOC_COMMENT_TAG", "...
Validates the descriptions in the file. @return AbstractDocSniff
[ "Validates", "the", "descriptions", "in", "the", "file", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php#L274-L306
45,833
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php
AbstractDocSniff.validateNewLineAfterDocComment
private function validateNewLineAfterDocComment(int $position, array $token, bool $asSingleLine = true): void { if (!$this->isNextLineEmpty($position)) { $nextRelevantPos = $this->loadNextDocBlockContent($position); $nextToken = $this->tokens[$nextRelevantPos]; // Register an error if we force a single line or this is no long description with more then one line. if ($asSingleLine || ($nextToken['code'] !== T_DOC_COMMENT_STRING)) { $isFixing = $this->file->addFixableWarning( self::MESSAGE_NO_LINE_AFTER_DOC_COMMENT, $position, static::CODE_NO_LINE_AFTER_DOC_COMMENT ); if ($isFixing) { $this->fixNoLineAfterDocComment($position, $token); } } } }
php
private function validateNewLineAfterDocComment(int $position, array $token, bool $asSingleLine = true): void { if (!$this->isNextLineEmpty($position)) { $nextRelevantPos = $this->loadNextDocBlockContent($position); $nextToken = $this->tokens[$nextRelevantPos]; // Register an error if we force a single line or this is no long description with more then one line. if ($asSingleLine || ($nextToken['code'] !== T_DOC_COMMENT_STRING)) { $isFixing = $this->file->addFixableWarning( self::MESSAGE_NO_LINE_AFTER_DOC_COMMENT, $position, static::CODE_NO_LINE_AFTER_DOC_COMMENT ); if ($isFixing) { $this->fixNoLineAfterDocComment($position, $token); } } } }
[ "private", "function", "validateNewLineAfterDocComment", "(", "int", "$", "position", ",", "array", "$", "token", ",", "bool", "$", "asSingleLine", "=", "true", ")", ":", "void", "{", "if", "(", "!", "$", "this", "->", "isNextLineEmpty", "(", "$", "positio...
Checks if there is a line break after the comment block.. @param int $position @param array $token @param bool $asSingleLine @return void
[ "Checks", "if", "there", "is", "a", "line", "break", "after", "the", "comment", "block", ".." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php#L317-L336
45,834
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php
AbstractDocSniff.validateOneLineSummary
private function validateOneLineSummary(): bool { $isValid = true; $summaryPos = $this->getSummaryPosition(); $nextPossiblePos = $this->loadNextDocBlockContent($summaryPos); if ($nextPossiblePos > -1) { $nextToken = $this->tokens[$nextPossiblePos]; if (($nextToken['code'] === T_DOC_COMMENT_STRING) && !$this->isNextLineEmpty($summaryPos)) { $isValid = false; $this->file->addWarning( self::MESSAGE_SUMMARY_TOO_LONG, $nextPossiblePos, static::CODE_SUMMARY_TOO_LONG ); } } return $isValid; }
php
private function validateOneLineSummary(): bool { $isValid = true; $summaryPos = $this->getSummaryPosition(); $nextPossiblePos = $this->loadNextDocBlockContent($summaryPos); if ($nextPossiblePos > -1) { $nextToken = $this->tokens[$nextPossiblePos]; if (($nextToken['code'] === T_DOC_COMMENT_STRING) && !$this->isNextLineEmpty($summaryPos)) { $isValid = false; $this->file->addWarning( self::MESSAGE_SUMMARY_TOO_LONG, $nextPossiblePos, static::CODE_SUMMARY_TOO_LONG ); } } return $isValid; }
[ "private", "function", "validateOneLineSummary", "(", ")", ":", "bool", "{", "$", "isValid", "=", "true", ";", "$", "summaryPos", "=", "$", "this", "->", "getSummaryPosition", "(", ")", ";", "$", "nextPossiblePos", "=", "$", "this", "->", "loadNextDocBlockCo...
Checks if the summary is on line or registers a warning. @return bool We can skip the new line error, so return true if the one line summary is true.
[ "Checks", "if", "the", "summary", "is", "on", "line", "or", "registers", "a", "warning", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php#L343-L364
45,835
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php
AbstractDocSniff.validateSummaryExistence
private function validateSummaryExistence(): self { $summaryPos = $this->getSummaryPosition(); if (!$summaryPos) { throw new CodeWarning( static::CODE_NO_SUMMARY, self::MESSAGE_NO_SUMMARY, $this->getDocCommentPos() ); } return $this; }
php
private function validateSummaryExistence(): self { $summaryPos = $this->getSummaryPosition(); if (!$summaryPos) { throw new CodeWarning( static::CODE_NO_SUMMARY, self::MESSAGE_NO_SUMMARY, $this->getDocCommentPos() ); } return $this; }
[ "private", "function", "validateSummaryExistence", "(", ")", ":", "self", "{", "$", "summaryPos", "=", "$", "this", "->", "getSummaryPosition", "(", ")", ";", "if", "(", "!", "$", "summaryPos", ")", "{", "throw", "new", "CodeWarning", "(", "static", "::", ...
Returns position to the comment summary or null. @throws CodeWarning If there is no summary. @return $this
[ "Returns", "position", "to", "the", "comment", "summary", "or", "null", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php#L373-L386
45,836
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php
AbstractDocSniff.validateUCFirstDocComment
private function validateUCFirstDocComment(int $position, array $token): void { $commentText = $token['content']; if (ucfirst($commentText) !== $commentText && $this->isPrevLineEmpty($position)) { $isFixing = $this->file->addFixableWarning( self::MESSAGE_DOC_COMMENT_UC_FIRST, $position, static::CODE_DOC_COMMENT_UC_FIRST ); if ($isFixing) { $this->fixDocCommentUcFirst($position, $token); } } }
php
private function validateUCFirstDocComment(int $position, array $token): void { $commentText = $token['content']; if (ucfirst($commentText) !== $commentText && $this->isPrevLineEmpty($position)) { $isFixing = $this->file->addFixableWarning( self::MESSAGE_DOC_COMMENT_UC_FIRST, $position, static::CODE_DOC_COMMENT_UC_FIRST ); if ($isFixing) { $this->fixDocCommentUcFirst($position, $token); } } }
[ "private", "function", "validateUCFirstDocComment", "(", "int", "$", "position", ",", "array", "$", "token", ")", ":", "void", "{", "$", "commentText", "=", "$", "token", "[", "'content'", "]", ";", "if", "(", "ucfirst", "(", "$", "commentText", ")", "!=...
Checks if the first char of the doc comment is ucfirst. @param int $position @param array $token @return void
[ "Checks", "if", "the", "first", "char", "of", "the", "doc", "comment", "is", "ucfirst", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Commenting/AbstractDocSniff.php#L396-L411
45,837
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/DocTags/AbstractDisallowedTagsSniff.php
AbstractDisallowedTagsSniff.checkAndRegisterDisallowedTagsError
private function checkAndRegisterDisallowedTagsError(): void { $disallowedTags = $this->getDisallowedTags(); $tags = $this->getAllTags(); foreach ($tags as $tagPos => $tag) { $tagContent = $tag['content']; if (in_array(substr($tagContent, 1), $disallowedTags)) { $this->file->addError( self::MESSAGE_TAG_NOT_ALLOWED, $tagPos, static::CODE_TAG_NOT_ALLOWED, [$tagContent] ); } } }
php
private function checkAndRegisterDisallowedTagsError(): void { $disallowedTags = $this->getDisallowedTags(); $tags = $this->getAllTags(); foreach ($tags as $tagPos => $tag) { $tagContent = $tag['content']; if (in_array(substr($tagContent, 1), $disallowedTags)) { $this->file->addError( self::MESSAGE_TAG_NOT_ALLOWED, $tagPos, static::CODE_TAG_NOT_ALLOWED, [$tagContent] ); } } }
[ "private", "function", "checkAndRegisterDisallowedTagsError", "(", ")", ":", "void", "{", "$", "disallowedTags", "=", "$", "this", "->", "getDisallowedTags", "(", ")", ";", "$", "tags", "=", "$", "this", "->", "getAllTags", "(", ")", ";", "foreach", "(", "...
Checks and registers errors for the disallowed tags. @return void
[ "Checks", "and", "registers", "errors", "for", "the", "disallowed", "tags", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/DocTags/AbstractDisallowedTagsSniff.php#L62-L79
45,838
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/DocTags/AbstractDisallowedTagsSniff.php
AbstractDisallowedTagsSniff.getAllTags
private function getAllTags(): array { if ($this->tags === null) { $this->tags = $this->loadAllTags(); } return $this->tags; }
php
private function getAllTags(): array { if ($this->tags === null) { $this->tags = $this->loadAllTags(); } return $this->tags; }
[ "private", "function", "getAllTags", "(", ")", ":", "array", "{", "if", "(", "$", "this", "->", "tags", "===", "null", ")", "{", "$", "this", "->", "tags", "=", "$", "this", "->", "loadAllTags", "(", ")", ";", "}", "return", "$", "this", "->", "t...
Returns all tag tokens for this doc block. @return array
[ "Returns", "all", "tag", "tokens", "for", "this", "doc", "block", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/DocTags/AbstractDisallowedTagsSniff.php#L86-L93
45,839
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/TraitUseSpacingSniff.php
TraitUseSpacingSniff.areRequirementsMet
protected function areRequirementsMet(): bool { return (bool) $this->uses = ClassHelper::getTraitUsePointers($this->getFile(), $this->getStackPos()); }
php
protected function areRequirementsMet(): bool { return (bool) $this->uses = ClassHelper::getTraitUsePointers($this->getFile(), $this->getStackPos()); }
[ "protected", "function", "areRequirementsMet", "(", ")", ":", "bool", "{", "return", "(", "bool", ")", "$", "this", "->", "uses", "=", "ClassHelper", "::", "getTraitUsePointers", "(", "$", "this", "->", "getFile", "(", ")", ",", "$", "this", "->", "getSt...
Returns false if there are no uses. @return bool
[ "Returns", "false", "if", "there", "are", "no", "uses", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/TraitUseSpacingSniff.php#L94-L97
45,840
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/TraitUseSpacingSniff.php
TraitUseSpacingSniff.checkLinesAfterLastUse
private function checkLinesAfterLastUse(int $lastUsePos): void { $lastUseEndPos = $this->getLastUseEndPos($lastUsePos); list($realLinesAfterUse, $whitespaceEnd) = $this->getRealLinesAfterLastUse($lastUseEndPos); $requiredLinesAfter = $this->isEndOfClass($lastUseEndPos) ? self::LINES_AFTER_LAST_USE_WHEN_LAST_IN_CLASS : self::LINES_AFTER_LAST_USE; if ($realLinesAfterUse !== $requiredLinesAfter) { $fix = $this->getFile()->addFixableError( self::MESSAGE_INCORRECT_LINES_COUNT_AFTER_LAST_USE, $lastUsePos, self::CODE_INCORRECT_LINES_COUNT_AFTER_LAST_USE, [ $requiredLinesAfter, $realLinesAfterUse ] ); if ($fix) { $this->fixLineAfterLastUse($lastUseEndPos, $whitespaceEnd, $requiredLinesAfter); } } }
php
private function checkLinesAfterLastUse(int $lastUsePos): void { $lastUseEndPos = $this->getLastUseEndPos($lastUsePos); list($realLinesAfterUse, $whitespaceEnd) = $this->getRealLinesAfterLastUse($lastUseEndPos); $requiredLinesAfter = $this->isEndOfClass($lastUseEndPos) ? self::LINES_AFTER_LAST_USE_WHEN_LAST_IN_CLASS : self::LINES_AFTER_LAST_USE; if ($realLinesAfterUse !== $requiredLinesAfter) { $fix = $this->getFile()->addFixableError( self::MESSAGE_INCORRECT_LINES_COUNT_AFTER_LAST_USE, $lastUsePos, self::CODE_INCORRECT_LINES_COUNT_AFTER_LAST_USE, [ $requiredLinesAfter, $realLinesAfterUse ] ); if ($fix) { $this->fixLineAfterLastUse($lastUseEndPos, $whitespaceEnd, $requiredLinesAfter); } } }
[ "private", "function", "checkLinesAfterLastUse", "(", "int", "$", "lastUsePos", ")", ":", "void", "{", "$", "lastUseEndPos", "=", "$", "this", "->", "getLastUseEndPos", "(", "$", "lastUsePos", ")", ";", "list", "(", "$", "realLinesAfterUse", ",", "$", "white...
Checks the line after the last use and registers an error if needed. @param int $lastUsePos @return void
[ "Checks", "the", "line", "after", "the", "last", "use", "and", "registers", "an", "error", "if", "needed", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/TraitUseSpacingSniff.php#L106-L131
45,841
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/TraitUseSpacingSniff.php
TraitUseSpacingSniff.checkLinesBeforeFirstUse
private function checkLinesBeforeFirstUse(int $firstUsePos): void { $posBeforeFirstUse = TokenHelper::findPreviousExcluding($this->getFile(), T_WHITESPACE, $firstUsePos - 1); $realLinesBeforeUse = $this->getRealLinesBeforeFirstUse($firstUsePos, $posBeforeFirstUse); if ($realLinesBeforeUse !== self::LINES_BEFORE_FIRST_USE) { $fix = $this->getFile()->addFixableError( self::MESSAGE_INCORRECT_LINES_COUNT_BEFORE_FIRST_USE, $firstUsePos, self::CODE_INCORRECT_LINES_COUNT_BEFORE_FIRST_USE, [ self::LINES_BEFORE_FIRST_USE, $realLinesBeforeUse ] ); if ($fix) { $this->fixLinesBeforeFirstUse($firstUsePos, $posBeforeFirstUse, self::LINES_BEFORE_FIRST_USE); } } }
php
private function checkLinesBeforeFirstUse(int $firstUsePos): void { $posBeforeFirstUse = TokenHelper::findPreviousExcluding($this->getFile(), T_WHITESPACE, $firstUsePos - 1); $realLinesBeforeUse = $this->getRealLinesBeforeFirstUse($firstUsePos, $posBeforeFirstUse); if ($realLinesBeforeUse !== self::LINES_BEFORE_FIRST_USE) { $fix = $this->getFile()->addFixableError( self::MESSAGE_INCORRECT_LINES_COUNT_BEFORE_FIRST_USE, $firstUsePos, self::CODE_INCORRECT_LINES_COUNT_BEFORE_FIRST_USE, [ self::LINES_BEFORE_FIRST_USE, $realLinesBeforeUse ] ); if ($fix) { $this->fixLinesBeforeFirstUse($firstUsePos, $posBeforeFirstUse, self::LINES_BEFORE_FIRST_USE); } } }
[ "private", "function", "checkLinesBeforeFirstUse", "(", "int", "$", "firstUsePos", ")", ":", "void", "{", "$", "posBeforeFirstUse", "=", "TokenHelper", "::", "findPreviousExcluding", "(", "$", "this", "->", "getFile", "(", ")", ",", "T_WHITESPACE", ",", "$", "...
Checks the lines before the first usage and registers an error if needed. @param int $firstUsePos @return void
[ "Checks", "the", "lines", "before", "the", "first", "usage", "and", "registers", "an", "error", "if", "needed", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/TraitUseSpacingSniff.php#L140-L160
45,842
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/TraitUseSpacingSniff.php
TraitUseSpacingSniff.checkLinesBetweenUses
private function checkLinesBetweenUses(): void { $file = $this->getFile(); $previousUsePos = null; foreach ($this->uses as $usePos) { if ($previousUsePos === null) { $previousUsePos = $usePos; continue; } $posBeforeUse = TokenHelper::findPreviousEffective($file, $usePos - 1); $previousUseEndPos = TokenHelper::findNextLocal( $file, [T_SEMICOLON, T_OPEN_CURLY_BRACKET], $previousUsePos + 1 ); $realLinesBetweenUse = $this->getRealLinesBetweenUses( $previousUseEndPos, $usePos ); $previousUsePos = $usePos; if ($realLinesBetweenUse !== self::LINES_BETWEEN_USES) { $errorParameters = [ self::MESSAGE_INCORRECT_LINES_COUNT_BETWEEN_USES, $usePos, self::CODE_INCORRECT_LINES_COUNT_BETWEEN_USES, [ self::LINES_BETWEEN_USES, $realLinesBetweenUse ] ]; if ($previousUseEndPos !== $posBeforeUse) { $file->addError(...$errorParameters); } else { $fix = $file->addFixableError(...$errorParameters); if ($fix) { $this->fixLinesBetweenUses($usePos, $previousUseEndPos, self::LINES_BETWEEN_USES); } } } } }
php
private function checkLinesBetweenUses(): void { $file = $this->getFile(); $previousUsePos = null; foreach ($this->uses as $usePos) { if ($previousUsePos === null) { $previousUsePos = $usePos; continue; } $posBeforeUse = TokenHelper::findPreviousEffective($file, $usePos - 1); $previousUseEndPos = TokenHelper::findNextLocal( $file, [T_SEMICOLON, T_OPEN_CURLY_BRACKET], $previousUsePos + 1 ); $realLinesBetweenUse = $this->getRealLinesBetweenUses( $previousUseEndPos, $usePos ); $previousUsePos = $usePos; if ($realLinesBetweenUse !== self::LINES_BETWEEN_USES) { $errorParameters = [ self::MESSAGE_INCORRECT_LINES_COUNT_BETWEEN_USES, $usePos, self::CODE_INCORRECT_LINES_COUNT_BETWEEN_USES, [ self::LINES_BETWEEN_USES, $realLinesBetweenUse ] ]; if ($previousUseEndPos !== $posBeforeUse) { $file->addError(...$errorParameters); } else { $fix = $file->addFixableError(...$errorParameters); if ($fix) { $this->fixLinesBetweenUses($usePos, $previousUseEndPos, self::LINES_BETWEEN_USES); } } } } }
[ "private", "function", "checkLinesBetweenUses", "(", ")", ":", "void", "{", "$", "file", "=", "$", "this", "->", "getFile", "(", ")", ";", "$", "previousUsePos", "=", "null", ";", "foreach", "(", "$", "this", "->", "uses", "as", "$", "usePos", ")", "...
Checks the lines between uses and registers an erro rif needed. @return void
[ "Checks", "the", "lines", "between", "uses", "and", "registers", "an", "erro", "rif", "needed", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/TraitUseSpacingSniff.php#L167-L214
45,843
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/TraitUseSpacingSniff.php
TraitUseSpacingSniff.fixLineAfterLastUse
private function fixLineAfterLastUse( int $lastUseEndPos, int $whitespaceEnd, int $requiredLinesAfter ): void { $file = $this->getFile(); $file->fixer->beginChangeset(); for ($i = $lastUseEndPos + 1; $i <= $whitespaceEnd; $i++) { $file->fixer->replaceToken($i, ''); } for ($i = 0; $i <= $requiredLinesAfter; $i++) { $file->fixer->addNewline($lastUseEndPos); } $file->fixer->endChangeset(); }
php
private function fixLineAfterLastUse( int $lastUseEndPos, int $whitespaceEnd, int $requiredLinesAfter ): void { $file = $this->getFile(); $file->fixer->beginChangeset(); for ($i = $lastUseEndPos + 1; $i <= $whitespaceEnd; $i++) { $file->fixer->replaceToken($i, ''); } for ($i = 0; $i <= $requiredLinesAfter; $i++) { $file->fixer->addNewline($lastUseEndPos); } $file->fixer->endChangeset(); }
[ "private", "function", "fixLineAfterLastUse", "(", "int", "$", "lastUseEndPos", ",", "int", "$", "whitespaceEnd", ",", "int", "$", "requiredLinesAfter", ")", ":", "void", "{", "$", "file", "=", "$", "this", "->", "getFile", "(", ")", ";", "$", "file", "-...
Fixes the lines which are allowed after the last use. @param int $lastUseEndPos @param int $whitespaceEnd @param int $requiredLinesAfter @return void
[ "Fixes", "the", "lines", "which", "are", "allowed", "after", "the", "last", "use", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/TraitUseSpacingSniff.php#L225-L243
45,844
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/TraitUseSpacingSniff.php
TraitUseSpacingSniff.fixLinesBeforeFirstUse
private function fixLinesBeforeFirstUse( int $firstUsePos, int $posBeforeFirstUse ): void { $file = $this->getFile(); $file->fixer->beginChangeset(); $posBeforeIndentation = TokenHelper::findPreviousContent( $file, T_WHITESPACE, $file->eolChar, $firstUsePos, $posBeforeFirstUse ); if ($posBeforeIndentation !== null) { for ($i = $posBeforeFirstUse + 1; $i <= $posBeforeIndentation; $i++) { $file->fixer->replaceToken($i, ''); } } for ($i = 0; $i <= self::LINES_BEFORE_FIRST_USE; $i++) { $file->fixer->addNewline($posBeforeFirstUse); } $file->fixer->endChangeset(); }
php
private function fixLinesBeforeFirstUse( int $firstUsePos, int $posBeforeFirstUse ): void { $file = $this->getFile(); $file->fixer->beginChangeset(); $posBeforeIndentation = TokenHelper::findPreviousContent( $file, T_WHITESPACE, $file->eolChar, $firstUsePos, $posBeforeFirstUse ); if ($posBeforeIndentation !== null) { for ($i = $posBeforeFirstUse + 1; $i <= $posBeforeIndentation; $i++) { $file->fixer->replaceToken($i, ''); } } for ($i = 0; $i <= self::LINES_BEFORE_FIRST_USE; $i++) { $file->fixer->addNewline($posBeforeFirstUse); } $file->fixer->endChangeset(); }
[ "private", "function", "fixLinesBeforeFirstUse", "(", "int", "$", "firstUsePos", ",", "int", "$", "posBeforeFirstUse", ")", ":", "void", "{", "$", "file", "=", "$", "this", "->", "getFile", "(", ")", ";", "$", "file", "->", "fixer", "->", "beginChangeset",...
Fixes the lines before the first use. @param int $firstUsePos @param int $posBeforeFirstUse @return void
[ "Fixes", "the", "lines", "before", "the", "first", "use", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/TraitUseSpacingSniff.php#L253-L278
45,845
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/TraitUseSpacingSniff.php
TraitUseSpacingSniff.fixLinesBetweenUses
private function fixLinesBetweenUses(int $usePos, int $previousUseEndPos): void { $file = $this->getFile(); $posBeforeIndentation = TokenHelper::findPreviousContent( $file, T_WHITESPACE, $file->eolChar, $usePos, $previousUseEndPos ); $file->fixer->beginChangeset(); if ($posBeforeIndentation !== null) { for ($i = $previousUseEndPos + 1; $i <= $posBeforeIndentation; $i++) { $file->fixer->replaceToken($i, ''); } } for ($i = 0; $i <= self::LINES_BETWEEN_USES; $i++) { $file->fixer->addNewline($previousUseEndPos); } $file->fixer->endChangeset(); }
php
private function fixLinesBetweenUses(int $usePos, int $previousUseEndPos): void { $file = $this->getFile(); $posBeforeIndentation = TokenHelper::findPreviousContent( $file, T_WHITESPACE, $file->eolChar, $usePos, $previousUseEndPos ); $file->fixer->beginChangeset(); if ($posBeforeIndentation !== null) { for ($i = $previousUseEndPos + 1; $i <= $posBeforeIndentation; $i++) { $file->fixer->replaceToken($i, ''); } } for ($i = 0; $i <= self::LINES_BETWEEN_USES; $i++) { $file->fixer->addNewline($previousUseEndPos); } $file->fixer->endChangeset(); }
[ "private", "function", "fixLinesBetweenUses", "(", "int", "$", "usePos", ",", "int", "$", "previousUseEndPos", ")", ":", "void", "{", "$", "file", "=", "$", "this", "->", "getFile", "(", ")", ";", "$", "posBeforeIndentation", "=", "TokenHelper", "::", "fin...
Fixes the lines between the uses. @param int $usePos @param int $previousUseEndPos @return void
[ "Fixes", "the", "lines", "between", "the", "uses", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/TraitUseSpacingSniff.php#L288-L310
45,846
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/TraitUseSpacingSniff.php
TraitUseSpacingSniff.getLastUseEndPos
private function getLastUseEndPos(int $lastUsePos): int { $file = $this->getFile(); $tokens = $file->getTokens(); $lastUseEndPos = TokenHelper::findNextLocal( $file, [T_SEMICOLON, T_OPEN_CURLY_BRACKET], $lastUsePos + 1 ); if ($tokens[$lastUseEndPos]['code'] === T_OPEN_CURLY_BRACKET) { $lastUseEndPos = $tokens[$lastUseEndPos]['bracket_closer']; } return $lastUseEndPos; }
php
private function getLastUseEndPos(int $lastUsePos): int { $file = $this->getFile(); $tokens = $file->getTokens(); $lastUseEndPos = TokenHelper::findNextLocal( $file, [T_SEMICOLON, T_OPEN_CURLY_BRACKET], $lastUsePos + 1 ); if ($tokens[$lastUseEndPos]['code'] === T_OPEN_CURLY_BRACKET) { $lastUseEndPos = $tokens[$lastUseEndPos]['bracket_closer']; } return $lastUseEndPos; }
[ "private", "function", "getLastUseEndPos", "(", "int", "$", "lastUsePos", ")", ":", "int", "{", "$", "file", "=", "$", "this", "->", "getFile", "(", ")", ";", "$", "tokens", "=", "$", "file", "->", "getTokens", "(", ")", ";", "$", "lastUseEndPos", "=...
Gets the position on which the last use ends. @param int $lastUsePos @return int
[ "Gets", "the", "position", "on", "which", "the", "last", "use", "ends", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/TraitUseSpacingSniff.php#L319-L335
45,847
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/TraitUseSpacingSniff.php
TraitUseSpacingSniff.getRealLinesAfterLastUse
private function getRealLinesAfterLastUse(int $lastUseEndPos): array { $file = $this->getFile(); $tokens = $file->getTokens(); $whitespaceEnd = TokenHelper::findNextExcluding($file, T_WHITESPACE, $lastUseEndPos + 1) - 1; if ($lastUseEndPos !== $whitespaceEnd && $tokens[$whitespaceEnd]['content'] !== $file->eolChar) { $lastEolPos = TokenHelper::findPreviousContent( $file, T_WHITESPACE, $file->eolChar, $whitespaceEnd - 1, $lastUseEndPos ); $whitespaceEnd = $lastEolPos ?? $lastUseEndPos; } $whitespaceAfterLastUse = TokenHelper::getContent($file, $lastUseEndPos + 1, $whitespaceEnd); $realLinesAfterUse = substr_count($whitespaceAfterLastUse, $file->eolChar) - 1; return [$realLinesAfterUse, $whitespaceEnd]; }
php
private function getRealLinesAfterLastUse(int $lastUseEndPos): array { $file = $this->getFile(); $tokens = $file->getTokens(); $whitespaceEnd = TokenHelper::findNextExcluding($file, T_WHITESPACE, $lastUseEndPos + 1) - 1; if ($lastUseEndPos !== $whitespaceEnd && $tokens[$whitespaceEnd]['content'] !== $file->eolChar) { $lastEolPos = TokenHelper::findPreviousContent( $file, T_WHITESPACE, $file->eolChar, $whitespaceEnd - 1, $lastUseEndPos ); $whitespaceEnd = $lastEolPos ?? $lastUseEndPos; } $whitespaceAfterLastUse = TokenHelper::getContent($file, $lastUseEndPos + 1, $whitespaceEnd); $realLinesAfterUse = substr_count($whitespaceAfterLastUse, $file->eolChar) - 1; return [$realLinesAfterUse, $whitespaceEnd]; }
[ "private", "function", "getRealLinesAfterLastUse", "(", "int", "$", "lastUseEndPos", ")", ":", "array", "{", "$", "file", "=", "$", "this", "->", "getFile", "(", ")", ";", "$", "tokens", "=", "$", "file", "->", "getTokens", "(", ")", ";", "$", "whitesp...
Gets the real lines after the last use. @param int $lastUseEndPos @return array The first element is the line count, and the second element is when the whitespace ends.
[ "Gets", "the", "real", "lines", "after", "the", "last", "use", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/TraitUseSpacingSniff.php#L344-L366
45,848
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/TraitUseSpacingSniff.php
TraitUseSpacingSniff.getRealLinesBeforeFirstUse
private function getRealLinesBeforeFirstUse(int $firstUsePos, int $posBeforeFirstUse): int { $file = $this->getFile(); $whitespaceBeforeFirstUse = ''; if ($posBeforeFirstUse + 1 !== $firstUsePos) { $whitespaceBeforeFirstUse .= TokenHelper::getContent( $file, $posBeforeFirstUse + 1, $firstUsePos - 1 ); } return substr_count($whitespaceBeforeFirstUse, $file->eolChar) - 1; }
php
private function getRealLinesBeforeFirstUse(int $firstUsePos, int $posBeforeFirstUse): int { $file = $this->getFile(); $whitespaceBeforeFirstUse = ''; if ($posBeforeFirstUse + 1 !== $firstUsePos) { $whitespaceBeforeFirstUse .= TokenHelper::getContent( $file, $posBeforeFirstUse + 1, $firstUsePos - 1 ); } return substr_count($whitespaceBeforeFirstUse, $file->eolChar) - 1; }
[ "private", "function", "getRealLinesBeforeFirstUse", "(", "int", "$", "firstUsePos", ",", "int", "$", "posBeforeFirstUse", ")", ":", "int", "{", "$", "file", "=", "$", "this", "->", "getFile", "(", ")", ";", "$", "whitespaceBeforeFirstUse", "=", "''", ";", ...
Returns the real lines before the first use. @param int $firstUsePos @param int $posBeforeFirstUse @return int
[ "Returns", "the", "real", "lines", "before", "the", "first", "use", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/TraitUseSpacingSniff.php#L376-L390
45,849
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/TraitUseSpacingSniff.php
TraitUseSpacingSniff.getRealLinesBetweenUses
private function getRealLinesBetweenUses(int &$previousUseEndPos, int $usePos): int { $tokens = $this->getFile()->getTokens(); if ($tokens[$previousUseEndPos]['code'] === T_OPEN_CURLY_BRACKET) { $previousUseEndPos = $tokens[$previousUseEndPos]['bracket_closer']; } return $tokens[$usePos]['line'] - $tokens[$previousUseEndPos]['line'] - 1; }
php
private function getRealLinesBetweenUses(int &$previousUseEndPos, int $usePos): int { $tokens = $this->getFile()->getTokens(); if ($tokens[$previousUseEndPos]['code'] === T_OPEN_CURLY_BRACKET) { $previousUseEndPos = $tokens[$previousUseEndPos]['bracket_closer']; } return $tokens[$usePos]['line'] - $tokens[$previousUseEndPos]['line'] - 1; }
[ "private", "function", "getRealLinesBetweenUses", "(", "int", "&", "$", "previousUseEndPos", ",", "int", "$", "usePos", ")", ":", "int", "{", "$", "tokens", "=", "$", "this", "->", "getFile", "(", ")", "->", "getTokens", "(", ")", ";", "if", "(", "$", ...
Returns the real lines between the uses. @param int $previousUseEndPos @param int $usePos @return int
[ "Returns", "the", "real", "lines", "between", "the", "uses", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/TraitUseSpacingSniff.php#L400-L409
45,850
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/TraitUseSpacingSniff.php
TraitUseSpacingSniff.isEndOfClass
private function isEndOfClass(int $lastUseEndPos): bool { $file = $this->getFile(); $tokens = $file->getTokens(); $posAfterLastUse = TokenHelper::findNextEffective($file, $lastUseEndPos + 1); return $tokens[$posAfterLastUse]['code'] === T_CLOSE_CURLY_BRACKET; }
php
private function isEndOfClass(int $lastUseEndPos): bool { $file = $this->getFile(); $tokens = $file->getTokens(); $posAfterLastUse = TokenHelper::findNextEffective($file, $lastUseEndPos + 1); return $tokens[$posAfterLastUse]['code'] === T_CLOSE_CURLY_BRACKET; }
[ "private", "function", "isEndOfClass", "(", "int", "$", "lastUseEndPos", ")", ":", "bool", "{", "$", "file", "=", "$", "this", "->", "getFile", "(", ")", ";", "$", "tokens", "=", "$", "file", "->", "getTokens", "(", ")", ";", "$", "posAfterLastUse", ...
Is the given Position the end of the class. @param int $lastUseEndPos @return bool
[ "Is", "the", "given", "Position", "the", "end", "of", "the", "class", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/TraitUseSpacingSniff.php#L418-L426
45,851
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/TypeHints/ReturnTypeDeclarationSniff.php
ReturnTypeDeclarationSniff.addReturnType
private function addReturnType(): void { $file = $this->getFile(); $returnTypeHint = $this->createReturnType(); $file->fixer->beginChangeset(); if ($this->isCustomArrayType($returnTypeHint)) { $returnTypeHint = ($returnTypeHint[0] === '?' ? '?' : '') . 'array'; } $file->fixer->addContent( $this->token['parenthesis_closer'], ': ' . $returnTypeHint ); $file->fixer->endChangeset(); }
php
private function addReturnType(): void { $file = $this->getFile(); $returnTypeHint = $this->createReturnType(); $file->fixer->beginChangeset(); if ($this->isCustomArrayType($returnTypeHint)) { $returnTypeHint = ($returnTypeHint[0] === '?' ? '?' : '') . 'array'; } $file->fixer->addContent( $this->token['parenthesis_closer'], ': ' . $returnTypeHint ); $file->fixer->endChangeset(); }
[ "private", "function", "addReturnType", "(", ")", ":", "void", "{", "$", "file", "=", "$", "this", "->", "getFile", "(", ")", ";", "$", "returnTypeHint", "=", "$", "this", "->", "createReturnType", "(", ")", ";", "$", "file", "->", "fixer", "->", "be...
Adds the return type to fix the error. @return void
[ "Adds", "the", "return", "type", "to", "fix", "the", "error", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/TypeHints/ReturnTypeDeclarationSniff.php#L95-L112
45,852
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/TypeHints/ReturnTypeDeclarationSniff.php
ReturnTypeDeclarationSniff.areRequirementsMet
protected function areRequirementsMet(): bool { return !$this->isSniffSuppressed(static::CODE_MISSING_RETURN_TYPE) && !$this->hasReturnType() && !in_array($this->getFunctionName(), $this->methodsWithoutVoid); }
php
protected function areRequirementsMet(): bool { return !$this->isSniffSuppressed(static::CODE_MISSING_RETURN_TYPE) && !$this->hasReturnType() && !in_array($this->getFunctionName(), $this->methodsWithoutVoid); }
[ "protected", "function", "areRequirementsMet", "(", ")", ":", "bool", "{", "return", "!", "$", "this", "->", "isSniffSuppressed", "(", "static", "::", "CODE_MISSING_RETURN_TYPE", ")", "&&", "!", "$", "this", "->", "hasReturnType", "(", ")", "&&", "!", "in_ar...
Returns true if this sniff may run. @return bool
[ "Returns", "true", "if", "this", "sniff", "may", "run", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/TypeHints/ReturnTypeDeclarationSniff.php#L119-L123
45,853
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/TypeHints/ReturnTypeDeclarationSniff.php
ReturnTypeDeclarationSniff.createReturnType
private function createReturnType(): string { $returnTypeHint = ''; $typeCount = count($this->typesForFix); foreach ($this->typesForFix as $type) { // We add the default value if only null is used (which has no real native return type). if ($type === 'null' && ($typeCount === 1)) { $returnTypeHint = $this->defaultNullReturn; break; // We still need this break to prevent further execution of the default value. } // We add the question mark if there is a nullable type. if (in_array($type, self::NULL_TYPES, true) && ($typeCount > 1)) { $returnTypeHint = '?' . $returnTypeHint; continue; // We still need this continue to prevent further execution of the questionmark. } // We add a fixable "native" type. We do not fix custom classes (because it would have side effects to the // imported usage of classes. $returnTypeHint .= (TypeHintHelper::isSimpleTypeHint($type)) ? TypeHintHelper::convertLongSimpleTypeHintToShort($type) : $type; } return $returnTypeHint; }
php
private function createReturnType(): string { $returnTypeHint = ''; $typeCount = count($this->typesForFix); foreach ($this->typesForFix as $type) { // We add the default value if only null is used (which has no real native return type). if ($type === 'null' && ($typeCount === 1)) { $returnTypeHint = $this->defaultNullReturn; break; // We still need this break to prevent further execution of the default value. } // We add the question mark if there is a nullable type. if (in_array($type, self::NULL_TYPES, true) && ($typeCount > 1)) { $returnTypeHint = '?' . $returnTypeHint; continue; // We still need this continue to prevent further execution of the questionmark. } // We add a fixable "native" type. We do not fix custom classes (because it would have side effects to the // imported usage of classes. $returnTypeHint .= (TypeHintHelper::isSimpleTypeHint($type)) ? TypeHintHelper::convertLongSimpleTypeHintToShort($type) : $type; } return $returnTypeHint; }
[ "private", "function", "createReturnType", "(", ")", ":", "string", "{", "$", "returnTypeHint", "=", "''", ";", "$", "typeCount", "=", "count", "(", "$", "this", "->", "typesForFix", ")", ";", "foreach", "(", "$", "this", "->", "typesForFix", "as", "$", ...
Creates the new return type for fixing or returns a null if not possible. @return string
[ "Creates", "the", "new", "return", "type", "for", "fixing", "or", "returns", "a", "null", "if", "not", "possible", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/TypeHints/ReturnTypeDeclarationSniff.php#L130-L156
45,854
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/TypeHints/ReturnTypeDeclarationSniff.php
ReturnTypeDeclarationSniff.getFunctionName
private function getFunctionName(): string { if (!$this->functionName) { $this->functionName = $this->loadFunctionName(); } return $this->functionName; }
php
private function getFunctionName(): string { if (!$this->functionName) { $this->functionName = $this->loadFunctionName(); } return $this->functionName; }
[ "private", "function", "getFunctionName", "(", ")", ":", "string", "{", "if", "(", "!", "$", "this", "->", "functionName", ")", "{", "$", "this", "->", "functionName", "=", "$", "this", "->", "loadFunctionName", "(", ")", ";", "}", "return", "$", "this...
Returns the name of the function. @return string
[ "Returns", "the", "name", "of", "the", "function", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/TypeHints/ReturnTypeDeclarationSniff.php#L181-L188
45,855
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/TypeHints/ReturnTypeDeclarationSniff.php
ReturnTypeDeclarationSniff.getReturnsFromAnnotation
private function getReturnsFromAnnotation(?Annotation $annotation): array { return $this->isFilledReturnAnnotation($annotation) ? explode('|', preg_split('~\\s+~', $annotation->getContent())[0]) : []; }
php
private function getReturnsFromAnnotation(?Annotation $annotation): array { return $this->isFilledReturnAnnotation($annotation) ? explode('|', preg_split('~\\s+~', $annotation->getContent())[0]) : []; }
[ "private", "function", "getReturnsFromAnnotation", "(", "?", "Annotation", "$", "annotation", ")", ":", "array", "{", "return", "$", "this", "->", "isFilledReturnAnnotation", "(", "$", "annotation", ")", "?", "explode", "(", "'|'", ",", "preg_split", "(", "'~\...
Returns the return types of the annotation. @param null|Annotation $annotation @return array
[ "Returns", "the", "return", "types", "of", "the", "annotation", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/TypeHints/ReturnTypeDeclarationSniff.php#L197-L202
45,856
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/TypeHints/ReturnTypeDeclarationSniff.php
ReturnTypeDeclarationSniff.getUsableReturnTypes
private function getUsableReturnTypes(Annotation $annotation): ?array { $return = null; $returnTypes = $this->getReturnsFromAnnotation($annotation); $returnTypeCount = count($returnTypes); $justOneReturn = $returnTypeCount === 1; if (!$justOneReturn || strtolower($returnTypes[0]) !== 'mixed') { $isNullableType = ($returnTypeCount === 2) && version_compare(phpversion(), '7.1.0', '>=') && (count(array_intersect($returnTypes, self::NULL_TYPES)) === 1); $return = ($justOneReturn || $isNullableType) ? $returnTypes : null; } return $return; }
php
private function getUsableReturnTypes(Annotation $annotation): ?array { $return = null; $returnTypes = $this->getReturnsFromAnnotation($annotation); $returnTypeCount = count($returnTypes); $justOneReturn = $returnTypeCount === 1; if (!$justOneReturn || strtolower($returnTypes[0]) !== 'mixed') { $isNullableType = ($returnTypeCount === 2) && version_compare(phpversion(), '7.1.0', '>=') && (count(array_intersect($returnTypes, self::NULL_TYPES)) === 1); $return = ($justOneReturn || $isNullableType) ? $returnTypes : null; } return $return; }
[ "private", "function", "getUsableReturnTypes", "(", "Annotation", "$", "annotation", ")", ":", "?", "array", "{", "$", "return", "=", "null", ";", "$", "returnTypes", "=", "$", "this", "->", "getReturnsFromAnnotation", "(", "$", "annotation", ")", ";", "$", ...
Returns the types of the annotation, if the types are usable. Usable means, that there should be one type != mixed in the return-annotation or a nullable type, which means 2 types like null|$ANYTYPE. @param Annotation $annotation @return array|null Null if there are no usable types or the usable types.
[ "Returns", "the", "types", "of", "the", "annotation", "if", "the", "types", "are", "usable", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/TypeHints/ReturnTypeDeclarationSniff.php#L214-L231
45,857
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/TypeHints/ReturnTypeDeclarationSniff.php
ReturnTypeDeclarationSniff.hasReturnType
private function hasReturnType(): bool { if ($this->hasReturnType === null) { $this->hasReturnType = FunctionHelper::hasReturnTypeHint($this->file->getBaseFile(), $this->stackPos); } return $this->hasReturnType; }
php
private function hasReturnType(): bool { if ($this->hasReturnType === null) { $this->hasReturnType = FunctionHelper::hasReturnTypeHint($this->file->getBaseFile(), $this->stackPos); } return $this->hasReturnType; }
[ "private", "function", "hasReturnType", "(", ")", ":", "bool", "{", "if", "(", "$", "this", "->", "hasReturnType", "===", "null", ")", "{", "$", "this", "->", "hasReturnType", "=", "FunctionHelper", "::", "hasReturnTypeHint", "(", "$", "this", "->", "file"...
Check if there is a return type. @return bool
[ "Check", "if", "there", "is", "a", "return", "type", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/TypeHints/ReturnTypeDeclarationSniff.php#L238-L245
45,858
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/TypeHints/ReturnTypeDeclarationSniff.php
ReturnTypeDeclarationSniff.isFixableReturnType
private function isFixableReturnType(string $type): bool { // $type === null is not valid in our slevomat helper. return TypeHintHelper::isSimpleTypeHint($type) || $type === 'null' || $this->isCustomArrayType($type); }
php
private function isFixableReturnType(string $type): bool { // $type === null is not valid in our slevomat helper. return TypeHintHelper::isSimpleTypeHint($type) || $type === 'null' || $this->isCustomArrayType($type); }
[ "private", "function", "isFixableReturnType", "(", "string", "$", "type", ")", ":", "bool", "{", "// $type === null is not valid in our slevomat helper.", "return", "TypeHintHelper", "::", "isSimpleTypeHint", "(", "$", "type", ")", "||", "$", "type", "===", "'null'", ...
Check if the return annotation type is valid. @param string $type The type value of the return annotation @return bool Type is valid
[ "Check", "if", "the", "return", "annotation", "type", "is", "valid", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/TypeHints/ReturnTypeDeclarationSniff.php#L278-L282
45,859
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/TypeHints/ReturnTypeDeclarationSniff.php
ReturnTypeDeclarationSniff.loadFixableTypes
private function loadFixableTypes(?array $returnTypes): array { return array_filter($returnTypes ?? [], function (string $returnType): bool { return $this->isFixableReturnType($returnType); }); }
php
private function loadFixableTypes(?array $returnTypes): array { return array_filter($returnTypes ?? [], function (string $returnType): bool { return $this->isFixableReturnType($returnType); }); }
[ "private", "function", "loadFixableTypes", "(", "?", "array", "$", "returnTypes", ")", ":", "array", "{", "return", "array_filter", "(", "$", "returnTypes", "??", "[", "]", ",", "function", "(", "string", "$", "returnType", ")", ":", "bool", "{", "return",...
Removes the return types from the given array, which are not compatible with our fix. @param array|null $returnTypes @return array The cleaned array.
[ "Removes", "the", "return", "types", "from", "the", "given", "array", "which", "are", "not", "compatible", "with", "our", "fix", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/TypeHints/ReturnTypeDeclarationSniff.php#L291-L296
45,860
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/TypeHints/ReturnTypeDeclarationSniff.php
ReturnTypeDeclarationSniff.processToken
protected function processToken(): void { $this->getFile()->recordMetric($this->stackPos, 'Has return type', 'no'); $returnAnnotation = $this->loadReturnAnnotation(); if (!$this->isFilledReturnAnnotation($returnAnnotation) || ($returnTypes = $this->getUsableReturnTypes($returnAnnotation))) { $this->validateReturnType($returnTypes ?? null); } }
php
protected function processToken(): void { $this->getFile()->recordMetric($this->stackPos, 'Has return type', 'no'); $returnAnnotation = $this->loadReturnAnnotation(); if (!$this->isFilledReturnAnnotation($returnAnnotation) || ($returnTypes = $this->getUsableReturnTypes($returnAnnotation))) { $this->validateReturnType($returnTypes ?? null); } }
[ "protected", "function", "processToken", "(", ")", ":", "void", "{", "$", "this", "->", "getFile", "(", ")", "->", "recordMetric", "(", "$", "this", "->", "stackPos", ",", "'Has return type'", ",", "'no'", ")", ";", "$", "returnAnnotation", "=", "$", "th...
Check method return type based with its return annotation. @throws CodeWarning @return void
[ "Check", "method", "return", "type", "based", "with", "its", "return", "annotation", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/TypeHints/ReturnTypeDeclarationSniff.php#L325-L335
45,861
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/TypeHints/ReturnTypeDeclarationSniff.php
ReturnTypeDeclarationSniff.setUp
protected function setUp(): void { parent::setUp(); if ($this->hasReturnType()) { $this->getFile()->recordMetric($this->stackPos, 'Has return type', 'yes'); } }
php
protected function setUp(): void { parent::setUp(); if ($this->hasReturnType()) { $this->getFile()->recordMetric($this->stackPos, 'Has return type', 'yes'); } }
[ "protected", "function", "setUp", "(", ")", ":", "void", "{", "parent", "::", "setUp", "(", ")", ";", "if", "(", "$", "this", "->", "hasReturnType", "(", ")", ")", "{", "$", "this", "->", "getFile", "(", ")", "->", "recordMetric", "(", "$", "this",...
Sets up the test. @return void
[ "Sets", "up", "the", "test", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/TypeHints/ReturnTypeDeclarationSniff.php#L342-L349
45,862
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/TypeHints/ReturnTypeDeclarationSniff.php
ReturnTypeDeclarationSniff.tearDown
protected function tearDown(): void { $this->resetDocCommentPos(); $this->hasReturnType = null; $this->functionName = null; $this->typesForFix = null; }
php
protected function tearDown(): void { $this->resetDocCommentPos(); $this->hasReturnType = null; $this->functionName = null; $this->typesForFix = null; }
[ "protected", "function", "tearDown", "(", ")", ":", "void", "{", "$", "this", "->", "resetDocCommentPos", "(", ")", ";", "$", "this", "->", "hasReturnType", "=", "null", ";", "$", "this", "->", "functionName", "=", "null", ";", "$", "this", "->", "type...
Resets the data of this sniff. @return void
[ "Resets", "the", "data", "of", "this", "sniff", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/TypeHints/ReturnTypeDeclarationSniff.php#L356-L363
45,863
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/TypeHints/ReturnTypeDeclarationSniff.php
ReturnTypeDeclarationSniff.validateReturnType
private function validateReturnType(?array $returnTypes): void { if (!$returnTypes) { $returnTypes = []; } $fixableTypes = $this->loadFixableTypes($returnTypes); if (count($returnTypes) === count($fixableTypes)) { // Make sure this var is only filled, if it really is fixable for us. $this->typesForFix = $fixableTypes; } $exception = (new CodeError(static::CODE_MISSING_RETURN_TYPE, self::MESSAGE_MISSING_RETURN_TYPE, $this->stackPos)) ->setPayload([$this->getFunctionName()]); $exception->isFixable((bool) $this->typesForFix); throw $exception; }
php
private function validateReturnType(?array $returnTypes): void { if (!$returnTypes) { $returnTypes = []; } $fixableTypes = $this->loadFixableTypes($returnTypes); if (count($returnTypes) === count($fixableTypes)) { // Make sure this var is only filled, if it really is fixable for us. $this->typesForFix = $fixableTypes; } $exception = (new CodeError(static::CODE_MISSING_RETURN_TYPE, self::MESSAGE_MISSING_RETURN_TYPE, $this->stackPos)) ->setPayload([$this->getFunctionName()]); $exception->isFixable((bool) $this->typesForFix); throw $exception; }
[ "private", "function", "validateReturnType", "(", "?", "array", "$", "returnTypes", ")", ":", "void", "{", "if", "(", "!", "$", "returnTypes", ")", "{", "$", "returnTypes", "=", "[", "]", ";", "}", "$", "fixableTypes", "=", "$", "this", "->", "loadFixa...
Validates the return type and registers an error if there is one. @param array|null $returnTypes @throws CodeWarning @return void
[ "Validates", "the", "return", "type", "and", "registers", "an", "error", "if", "there", "is", "one", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/TypeHints/ReturnTypeDeclarationSniff.php#L373-L393
45,864
bestit/PHP_CodeSniffer
src/Standards/BestIt/CodeSniffer/Helper/PropertyHelper.php
PropertyHelper.getProperties
public function getProperties(array $classToken, ?File $file = null): array { if (!$file) { $file = $this->file; } $properties = []; $startPos = $classToken['scope_opener'] ?? 0; $tokens = $file->getTokens(); while (($propertyPos = $file->findNext([T_VARIABLE], $startPos, $classToken['scope_closer'])) > 0) { if ($this->isProperty($propertyPos)) { $properties[] = substr($tokens[$propertyPos]['content'], 1); } $startPos = $propertyPos + 1; } return $properties; }
php
public function getProperties(array $classToken, ?File $file = null): array { if (!$file) { $file = $this->file; } $properties = []; $startPos = $classToken['scope_opener'] ?? 0; $tokens = $file->getTokens(); while (($propertyPos = $file->findNext([T_VARIABLE], $startPos, $classToken['scope_closer'])) > 0) { if ($this->isProperty($propertyPos)) { $properties[] = substr($tokens[$propertyPos]['content'], 1); } $startPos = $propertyPos + 1; } return $properties; }
[ "public", "function", "getProperties", "(", "array", "$", "classToken", ",", "?", "File", "$", "file", "=", "null", ")", ":", "array", "{", "if", "(", "!", "$", "file", ")", "{", "$", "file", "=", "$", "this", "->", "file", ";", "}", "$", "proper...
Returns the names of the class' properties. @param array $classToken The token array for the class like structure. @param File|null $file The used file. If not given then the file from the construct is used. @return array The names of the properties.
[ "Returns", "the", "names", "of", "the", "class", "properties", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/CodeSniffer/Helper/PropertyHelper.php#L43-L62
45,865
bestit/PHP_CodeSniffer
src/Standards/BestIt/CodeSniffer/Helper/PropertyHelper.php
PropertyHelper.isProperty
public function isProperty(int $variablePtr): bool { $tokens = $this->file->getTokens(); $propertyPointer = $this->file->findPrevious( [T_STATIC, T_WHITESPACE, T_COMMENT], $variablePtr - 1, null, true ); $propertyToken = $tokens[$propertyPointer]; $propertyCode = $propertyToken['code']; return in_array( $propertyCode, [ T_PRIVATE, T_PROTECTED, T_PUBLIC, T_VAR ], true ); }
php
public function isProperty(int $variablePtr): bool { $tokens = $this->file->getTokens(); $propertyPointer = $this->file->findPrevious( [T_STATIC, T_WHITESPACE, T_COMMENT], $variablePtr - 1, null, true ); $propertyToken = $tokens[$propertyPointer]; $propertyCode = $propertyToken['code']; return in_array( $propertyCode, [ T_PRIVATE, T_PROTECTED, T_PUBLIC, T_VAR ], true ); }
[ "public", "function", "isProperty", "(", "int", "$", "variablePtr", ")", ":", "bool", "{", "$", "tokens", "=", "$", "this", "->", "file", "->", "getTokens", "(", ")", ";", "$", "propertyPointer", "=", "$", "this", "->", "file", "->", "findPrevious", "(...
Determines if the given variable is a property of a class. @param int $variablePtr Pointer to the current variable @return bool Indicator if the current T_VARIABLE is a property of a class
[ "Determines", "if", "the", "given", "variable", "is", "a", "property", "of", "a", "class", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/CodeSniffer/Helper/PropertyHelper.php#L71-L94
45,866
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/SuppressingTrait.php
SuppressingTrait.getSniffName
private function getSniffName(?string $sniffName = null): string { $sniffClassName = preg_replace( '/Sniff$/', '', str_replace(['\\', '.Sniffs'], ['.', ''], static::class) ); if ($sniffName) { $sniffClassName .= '.' . $sniffName; } return $sniffClassName; }
php
private function getSniffName(?string $sniffName = null): string { $sniffClassName = preg_replace( '/Sniff$/', '', str_replace(['\\', '.Sniffs'], ['.', ''], static::class) ); if ($sniffName) { $sniffClassName .= '.' . $sniffName; } return $sniffClassName; }
[ "private", "function", "getSniffName", "(", "?", "string", "$", "sniffName", "=", "null", ")", ":", "string", "{", "$", "sniffClassName", "=", "preg_replace", "(", "'/Sniff$/'", ",", "''", ",", "str_replace", "(", "[", "'\\\\'", ",", "'.Sniffs'", "]", ",",...
Get the sniff name. @param string|null $sniffName If there is an optional sniff name. @return string Returns the special sniff name in the code sniffer context.
[ "Get", "the", "sniff", "name", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/SuppressingTrait.php#L39-L52
45,867
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/SuppressingTrait.php
SuppressingTrait.isSniffSuppressed
protected function isSniffSuppressed(?string $rule = null, ?int $stackPos = null): bool { return $this->getSuppressHelper()->isSniffSuppressed( $this->getFile(), $stackPos ?? $this->getStackPos(), $this->getSniffName($rule) ); }
php
protected function isSniffSuppressed(?string $rule = null, ?int $stackPos = null): bool { return $this->getSuppressHelper()->isSniffSuppressed( $this->getFile(), $stackPos ?? $this->getStackPos(), $this->getSniffName($rule) ); }
[ "protected", "function", "isSniffSuppressed", "(", "?", "string", "$", "rule", "=", "null", ",", "?", "int", "$", "stackPos", "=", "null", ")", ":", "bool", "{", "return", "$", "this", "->", "getSuppressHelper", "(", ")", "->", "isSniffSuppressed", "(", ...
Returns true if this sniff or a rule of this sniff is suppressed with the slevomat suppress annotation. @param null|string $rule The optional rule. @param int|null $stackPos Do you want ot overload the position for the which position the sniff is suppressed. @return bool Returns true if the sniff is suppressed.
[ "Returns", "true", "if", "this", "sniff", "or", "a", "rule", "of", "this", "sniff", "is", "suppressed", "with", "the", "slevomat", "suppress", "annotation", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/SuppressingTrait.php#L83-L90
45,868
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Commenting/RequiredDocBlockSniff.php
RequiredDocBlockSniff.areRequirementsMet
protected function areRequirementsMet(): bool { return ($this->token['code'] !== T_VARIABLE) || (new PropertyHelper($this->file))->isProperty($this->stackPos); }
php
protected function areRequirementsMet(): bool { return ($this->token['code'] !== T_VARIABLE) || (new PropertyHelper($this->file))->isProperty($this->stackPos); }
[ "protected", "function", "areRequirementsMet", "(", ")", ":", "bool", "{", "return", "(", "$", "this", "->", "token", "[", "'code'", "]", "!==", "T_VARIABLE", ")", "||", "(", "new", "PropertyHelper", "(", "$", "this", "->", "file", ")", ")", "->", "isP...
Ignore normal variables for this sniff. @return bool
[ "Ignore", "normal", "variables", "for", "this", "sniff", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Commenting/RequiredDocBlockSniff.php#L73-L76
45,869
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Commenting/RequiredDocBlockSniff.php
RequiredDocBlockSniff.checkAndRegisterMissingDocBlock
private function checkAndRegisterMissingDocBlock(): void { if (!$this->getDocCommentPos()) { $tokenIdent = $this->getTokenName(); $exception = (new CodeError( static::CODE_MISSING_DOC_BLOCK_PREFIX . ucfirst($tokenIdent), self::MESSAGE_MISSING_DOC_BLOCK, $this->stackPos ))->setPayload([lcfirst($tokenIdent)]); throw $exception; } }
php
private function checkAndRegisterMissingDocBlock(): void { if (!$this->getDocCommentPos()) { $tokenIdent = $this->getTokenName(); $exception = (new CodeError( static::CODE_MISSING_DOC_BLOCK_PREFIX . ucfirst($tokenIdent), self::MESSAGE_MISSING_DOC_BLOCK, $this->stackPos ))->setPayload([lcfirst($tokenIdent)]); throw $exception; } }
[ "private", "function", "checkAndRegisterMissingDocBlock", "(", ")", ":", "void", "{", "if", "(", "!", "$", "this", "->", "getDocCommentPos", "(", ")", ")", "{", "$", "tokenIdent", "=", "$", "this", "->", "getTokenName", "(", ")", ";", "$", "exception", "...
Checks for a missing doc block and throws an error if the doc is missing. @throws CodeWarning @return void
[ "Checks", "for", "a", "missing", "doc", "block", "and", "throws", "an", "error", "if", "the", "doc", "is", "missing", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Commenting/RequiredDocBlockSniff.php#L85-L98
45,870
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Commenting/RequiredDocBlockSniff.php
RequiredDocBlockSniff.checkAndRegisterNoMultiLine
private function checkAndRegisterNoMultiLine(): void { $docCommentPos = $this->getDocCommentPos(); $openingToken = $this->tokens[$docCommentPos]; $closingToken = $this->tokens[$openingToken['comment_closer']]; if ($openingToken['line'] === $closingToken['line']) { $tokenIdent = $this->getTokenName(); $exception = (new CodeError( static::CODE_NO_MULTI_LINE_DOC_BLOCK_PREFIX . ucfirst($tokenIdent), self::MESSAGE_NO_MULTI_LINE_DOC_BLOCK_PREFIX, $docCommentPos ))->setPayload([lcfirst($tokenIdent)]); throw $exception; } }
php
private function checkAndRegisterNoMultiLine(): void { $docCommentPos = $this->getDocCommentPos(); $openingToken = $this->tokens[$docCommentPos]; $closingToken = $this->tokens[$openingToken['comment_closer']]; if ($openingToken['line'] === $closingToken['line']) { $tokenIdent = $this->getTokenName(); $exception = (new CodeError( static::CODE_NO_MULTI_LINE_DOC_BLOCK_PREFIX . ucfirst($tokenIdent), self::MESSAGE_NO_MULTI_LINE_DOC_BLOCK_PREFIX, $docCommentPos ))->setPayload([lcfirst($tokenIdent)]); throw $exception; } }
[ "private", "function", "checkAndRegisterNoMultiLine", "(", ")", ":", "void", "{", "$", "docCommentPos", "=", "$", "this", "->", "getDocCommentPos", "(", ")", ";", "$", "openingToken", "=", "$", "this", "->", "tokens", "[", "$", "docCommentPos", "]", ";", "...
Checks and registers a multi line error. @throws CodeWarning @return void
[ "Checks", "and", "registers", "a", "multi", "line", "error", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Commenting/RequiredDocBlockSniff.php#L107-L124
45,871
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/SpaceAfterDeclareSniff.php
SpaceAfterDeclareSniff.handleNoWhitespaceFound
private function handleNoWhitespaceFound(File $phpcsFile, int $semicolonPtr): void { $fixNoWhitespace = $phpcsFile->addFixableError( self::MESSAGE_NO_WHITESPACE_FOUND, $semicolonPtr, static::CODE_NO_WHITESPACE_FOUND ); if ($fixNoWhitespace) { $phpcsFile->fixer->beginChangeset(); $phpcsFile->fixer->addNewline($semicolonPtr); $phpcsFile->fixer->endChangeset(); } }
php
private function handleNoWhitespaceFound(File $phpcsFile, int $semicolonPtr): void { $fixNoWhitespace = $phpcsFile->addFixableError( self::MESSAGE_NO_WHITESPACE_FOUND, $semicolonPtr, static::CODE_NO_WHITESPACE_FOUND ); if ($fixNoWhitespace) { $phpcsFile->fixer->beginChangeset(); $phpcsFile->fixer->addNewline($semicolonPtr); $phpcsFile->fixer->endChangeset(); } }
[ "private", "function", "handleNoWhitespaceFound", "(", "File", "$", "phpcsFile", ",", "int", "$", "semicolonPtr", ")", ":", "void", "{", "$", "fixNoWhitespace", "=", "$", "phpcsFile", "->", "addFixableError", "(", "self", "::", "MESSAGE_NO_WHITESPACE_FOUND", ",", ...
Handles when no whitespace is found. @param File $phpcsFile The php cs file @param int $semicolonPtr Pointer to the semicolon token @return void
[ "Handles", "when", "no", "whitespace", "is", "found", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/SpaceAfterDeclareSniff.php#L126-L139
45,872
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/SpaceAfterDeclareSniff.php
SpaceAfterDeclareSniff.handleMuchWhitespacesFound
private function handleMuchWhitespacesFound( File $phpcsFile, int $semicolonPtr, int $secondSpacePtr, int $nextNonSpacePtr ): void { $fixMuchWhitespaces = $phpcsFile->addFixableError( self::MESSAGE_MUCH_WHITESPACE_FOUND, $semicolonPtr, static::CODE_MUCH_WHITESPACE_FOUND ); if ($fixMuchWhitespaces) { $phpcsFile->fixer->beginChangeset(); for ($i = $secondSpacePtr; $i < $nextNonSpacePtr; $i++) { $phpcsFile->fixer->replaceToken($i, ''); } $phpcsFile->fixer->endChangeset(); } }
php
private function handleMuchWhitespacesFound( File $phpcsFile, int $semicolonPtr, int $secondSpacePtr, int $nextNonSpacePtr ): void { $fixMuchWhitespaces = $phpcsFile->addFixableError( self::MESSAGE_MUCH_WHITESPACE_FOUND, $semicolonPtr, static::CODE_MUCH_WHITESPACE_FOUND ); if ($fixMuchWhitespaces) { $phpcsFile->fixer->beginChangeset(); for ($i = $secondSpacePtr; $i < $nextNonSpacePtr; $i++) { $phpcsFile->fixer->replaceToken($i, ''); } $phpcsFile->fixer->endChangeset(); } }
[ "private", "function", "handleMuchWhitespacesFound", "(", "File", "$", "phpcsFile", ",", "int", "$", "semicolonPtr", ",", "int", "$", "secondSpacePtr", ",", "int", "$", "nextNonSpacePtr", ")", ":", "void", "{", "$", "fixMuchWhitespaces", "=", "$", "phpcsFile", ...
Handles when more than one whitespaces are found. @param File $phpcsFile The php cs file @param int $semicolonPtr Pointer to the semicolon @param int $secondSpacePtr Pointer to the second space @param int $nextNonSpacePtr Pointer to the next non space token @return void
[ "Handles", "when", "more", "than", "one", "whitespaces", "are", "found", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/SpaceAfterDeclareSniff.php#L151-L170
45,873
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/SpaceAfterDeclareSniff.php
SpaceAfterDeclareSniff.handleBlankLineInGroup
private function handleBlankLineInGroup( File $phpcsFile, int $semicolonPtr, int $secondSpacePtr, int $nextNonSpacePtr ): void { $fixGroupBlankLines = $phpcsFile->addFixableError( self::MESSAGE_GROUP_BLANK_LINE_FOUND, $semicolonPtr, static::CODE_GROUP_BLANK_LINE_FOUND ); if ($fixGroupBlankLines) { $phpcsFile->fixer->beginChangeset(); for ($i = $secondSpacePtr; $i < $nextNonSpacePtr; $i++) { $phpcsFile->fixer->replaceToken($i, ''); } $phpcsFile->fixer->endChangeset(); } }
php
private function handleBlankLineInGroup( File $phpcsFile, int $semicolonPtr, int $secondSpacePtr, int $nextNonSpacePtr ): void { $fixGroupBlankLines = $phpcsFile->addFixableError( self::MESSAGE_GROUP_BLANK_LINE_FOUND, $semicolonPtr, static::CODE_GROUP_BLANK_LINE_FOUND ); if ($fixGroupBlankLines) { $phpcsFile->fixer->beginChangeset(); for ($i = $secondSpacePtr; $i < $nextNonSpacePtr; $i++) { $phpcsFile->fixer->replaceToken($i, ''); } $phpcsFile->fixer->endChangeset(); } }
[ "private", "function", "handleBlankLineInGroup", "(", "File", "$", "phpcsFile", ",", "int", "$", "semicolonPtr", ",", "int", "$", "secondSpacePtr", ",", "int", "$", "nextNonSpacePtr", ")", ":", "void", "{", "$", "fixGroupBlankLines", "=", "$", "phpcsFile", "->...
Handles blank lines found in declare group. @param File $phpcsFile The php cs file @param int $semicolonPtr Pointer to the semicolon @param int $secondSpacePtr Pointer to the second space @param int $nextNonSpacePtr Pointer to the next non space token @return void
[ "Handles", "blank", "lines", "found", "in", "declare", "group", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/SpaceAfterDeclareSniff.php#L182-L201
45,874
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/UCVFSortingSniff.php
UCVFSortingSniff.loadTokensForPositions
private function loadTokensForPositions(array $subTokenPoss): array { $subTokens = array_map(function (int $position): array { return $this->tokens[$position]; }, $subTokenPoss); return array_combine($subTokenPoss, $subTokens); }
php
private function loadTokensForPositions(array $subTokenPoss): array { $subTokens = array_map(function (int $position): array { return $this->tokens[$position]; }, $subTokenPoss); return array_combine($subTokenPoss, $subTokens); }
[ "private", "function", "loadTokensForPositions", "(", "array", "$", "subTokenPoss", ")", ":", "array", "{", "$", "subTokens", "=", "array_map", "(", "function", "(", "int", "$", "position", ")", ":", "array", "{", "return", "$", "this", "->", "tokens", "["...
Loads the tokens for the positions. @param array $subTokenPoss @return array
[ "Loads", "the", "tokens", "for", "the", "positions", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/UCVFSortingSniff.php#L94-L101
45,875
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/UCVFSortingSniff.php
UCVFSortingSniff.removeUnwantedTokens
private function removeUnwantedTokens(array $subTokens): array { return array_filter($subTokens, function (array $subToken): bool { switch ($subToken['code']) { case T_VARIABLE: $return = (new PropertyHelper($this->file))->isProperty($subToken['pointer']); break; case T_USE: $return = UseStatementHelper::isTraitUse($this->file, $subToken['pointer']); break; default: $return = true; } return $return; }); }
php
private function removeUnwantedTokens(array $subTokens): array { return array_filter($subTokens, function (array $subToken): bool { switch ($subToken['code']) { case T_VARIABLE: $return = (new PropertyHelper($this->file))->isProperty($subToken['pointer']); break; case T_USE: $return = UseStatementHelper::isTraitUse($this->file, $subToken['pointer']); break; default: $return = true; } return $return; }); }
[ "private", "function", "removeUnwantedTokens", "(", "array", "$", "subTokens", ")", ":", "array", "{", "return", "array_filter", "(", "$", "subTokens", ",", "function", "(", "array", "$", "subToken", ")", ":", "bool", "{", "switch", "(", "$", "subToken", "...
Removes inline vars and uses for anon-functions. @param array $subTokens @return array
[ "Removes", "inline", "vars", "and", "uses", "for", "anon", "-", "functions", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/UCVFSortingSniff.php#L123-L141
45,876
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Formatting/UCVFSortingSniff.php
UCVFSortingSniff.validateSorting
private function validateSorting(array $originalTokens, array $sortedTokens): void { $sortedPositions = array_keys($sortedTokens); $sortedIndex = 0; foreach ($originalTokens as $originalPosition => $originalToken) { $sortedPosition = $sortedPositions[$sortedIndex++]; $sortedToken = $sortedTokens[$sortedPosition]; // We don't need an error if the "type block" is the same, so check the code additionally. if (($sortedPosition !== $originalPosition) && ($originalToken['code'] !== $sortedToken['code'])) { $this->file->addError( self::MESSAGE_WRONG_POSITION, $originalPosition, static::CODE_WRONG_POSITION, [ $sortedToken['type'], $sortedToken['content'] ] ); } } }
php
private function validateSorting(array $originalTokens, array $sortedTokens): void { $sortedPositions = array_keys($sortedTokens); $sortedIndex = 0; foreach ($originalTokens as $originalPosition => $originalToken) { $sortedPosition = $sortedPositions[$sortedIndex++]; $sortedToken = $sortedTokens[$sortedPosition]; // We don't need an error if the "type block" is the same, so check the code additionally. if (($sortedPosition !== $originalPosition) && ($originalToken['code'] !== $sortedToken['code'])) { $this->file->addError( self::MESSAGE_WRONG_POSITION, $originalPosition, static::CODE_WRONG_POSITION, [ $sortedToken['type'], $sortedToken['content'] ] ); } } }
[ "private", "function", "validateSorting", "(", "array", "$", "originalTokens", ",", "array", "$", "sortedTokens", ")", ":", "void", "{", "$", "sortedPositions", "=", "array_keys", "(", "$", "sortedTokens", ")", ";", "$", "sortedIndex", "=", "0", ";", "foreac...
Validates the sorting of the tokens and registers an error if wrong sorted. @param array $originalTokens @param array $sortedTokens @return void
[ "Validates", "the", "sorting", "of", "the", "tokens", "and", "registers", "an", "error", "if", "wrong", "sorted", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Formatting/UCVFSortingSniff.php#L190-L212
45,877
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Functions/FluentSetterSniff.php
FluentSetterSniff.checkForFluentSetterErrors
private function checkForFluentSetterErrors(File $phpcsFile, int $functionPos, int $classPos): void { $tokens = $phpcsFile->getTokens(); $errorData = $phpcsFile->getDeclarationName($classPos) . '::' . $phpcsFile->getDeclarationName($functionPos); $functionToken = $tokens[$functionPos]; $openBracePtr = $functionToken['scope_opener']; $closeBracePtr = $functionToken['scope_closer']; $returnPtr = $phpcsFile->findNext(T_RETURN, $openBracePtr, $closeBracePtr); if ($returnPtr === false) { $fixNoReturnFound = $phpcsFile->addFixableError( self::ERROR_NO_RETURN_FOUND, $functionPos, static::CODE_NO_RETURN_FOUND, $errorData ); if ($fixNoReturnFound) { $this->fixNoReturnFound($phpcsFile, $closeBracePtr); } return; } $this->checkAndRegisterEmptyReturnErrors($phpcsFile, $functionPos, $returnPtr, $errorData); }
php
private function checkForFluentSetterErrors(File $phpcsFile, int $functionPos, int $classPos): void { $tokens = $phpcsFile->getTokens(); $errorData = $phpcsFile->getDeclarationName($classPos) . '::' . $phpcsFile->getDeclarationName($functionPos); $functionToken = $tokens[$functionPos]; $openBracePtr = $functionToken['scope_opener']; $closeBracePtr = $functionToken['scope_closer']; $returnPtr = $phpcsFile->findNext(T_RETURN, $openBracePtr, $closeBracePtr); if ($returnPtr === false) { $fixNoReturnFound = $phpcsFile->addFixableError( self::ERROR_NO_RETURN_FOUND, $functionPos, static::CODE_NO_RETURN_FOUND, $errorData ); if ($fixNoReturnFound) { $this->fixNoReturnFound($phpcsFile, $closeBracePtr); } return; } $this->checkAndRegisterEmptyReturnErrors($phpcsFile, $functionPos, $returnPtr, $errorData); }
[ "private", "function", "checkForFluentSetterErrors", "(", "File", "$", "phpcsFile", ",", "int", "$", "functionPos", ",", "int", "$", "classPos", ")", ":", "void", "{", "$", "tokens", "=", "$", "phpcsFile", "->", "getTokens", "(", ")", ";", "$", "errorData"...
Checks if there are fluent setter errors and registers errors if needed. @param File $phpcsFile The file for this sniff. @param int $functionPos The position of the used token. @param int $classPos The position of the class. @return void
[ "Checks", "if", "there", "are", "fluent", "setter", "errors", "and", "registers", "errors", "if", "needed", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Functions/FluentSetterSniff.php#L110-L137
45,878
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Functions/FluentSetterSniff.php
FluentSetterSniff.processTokenWithinScope
protected function processTokenWithinScope( File $file, $functionPos, $classPos ): void { $this->file = new FileDecorator($file); $this->stackPos = $functionPos; $isSuppressed = $this->isSniffSuppressed(static::CODE_NO_RETURN_FOUND); if (!$isSuppressed && $this->checkIfSetterFunction($classPos, $file, $functionPos)) { $this->checkForFluentSetterErrors($file, $functionPos, $classPos); } }
php
protected function processTokenWithinScope( File $file, $functionPos, $classPos ): void { $this->file = new FileDecorator($file); $this->stackPos = $functionPos; $isSuppressed = $this->isSniffSuppressed(static::CODE_NO_RETURN_FOUND); if (!$isSuppressed && $this->checkIfSetterFunction($classPos, $file, $functionPos)) { $this->checkForFluentSetterErrors($file, $functionPos, $classPos); } }
[ "protected", "function", "processTokenWithinScope", "(", "File", "$", "file", ",", "$", "functionPos", ",", "$", "classPos", ")", ":", "void", "{", "$", "this", "->", "file", "=", "new", "FileDecorator", "(", "$", "file", ")", ";", "$", "this", "->", "...
Processes the tokens that this test is listening for. @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint @param File $file The file where this token was found. @param int $functionPos The position in the stack where this token was found. @param int $classPos The position in the tokens array that opened the scope that this test is listening for. @return void
[ "Processes", "the", "tokens", "that", "this", "test", "is", "listening", "for", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Functions/FluentSetterSniff.php#L169-L182
45,879
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Functions/FluentSetterSniff.php
FluentSetterSniff.checkIfSetterFunction
private function checkIfSetterFunction(int $classPosition, File $file, int $methodPosition): bool { $isSetter = false; $methodName = $file->getDeclarationName($methodPosition); if (substr($methodName, 0, 3) === 'set') { // We define in our styleguide, that there is only one class per file! $properties = (new PropertyHelper(new FileDecorator($file)))->getProperties( $file->getTokens()[$classPosition] ); // We require camelCase for methods and properties, // so there should be an "lcfirst-Method" without set-prefix. $isSetter = in_array(lcfirst(substr($methodName, 3)), $properties, true); } return $isSetter; }
php
private function checkIfSetterFunction(int $classPosition, File $file, int $methodPosition): bool { $isSetter = false; $methodName = $file->getDeclarationName($methodPosition); if (substr($methodName, 0, 3) === 'set') { // We define in our styleguide, that there is only one class per file! $properties = (new PropertyHelper(new FileDecorator($file)))->getProperties( $file->getTokens()[$classPosition] ); // We require camelCase for methods and properties, // so there should be an "lcfirst-Method" without set-prefix. $isSetter = in_array(lcfirst(substr($methodName, 3)), $properties, true); } return $isSetter; }
[ "private", "function", "checkIfSetterFunction", "(", "int", "$", "classPosition", ",", "File", "$", "file", ",", "int", "$", "methodPosition", ")", ":", "bool", "{", "$", "isSetter", "=", "false", ";", "$", "methodName", "=", "$", "file", "->", "getDeclara...
Checks if the given method name relates to a setter function of a property. @param int $classPosition The position of the class token. @param File $file The file of the sniff. @param int $methodPosition The position of the method token. @return bool Indicator if the given method is a setter function
[ "Checks", "if", "the", "given", "method", "name", "relates", "to", "a", "setter", "function", "of", "a", "property", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Functions/FluentSetterSniff.php#L193-L210
45,880
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Functions/FluentSetterSniff.php
FluentSetterSniff.fixNoReturnFound
private function fixNoReturnFound(File $phpcsFile, int $closingBracePtr): void { $tokens = $phpcsFile->getTokens(); $closingBraceToken = $tokens[$closingBracePtr]; $expectedReturnSpaces = str_repeat($this->identation, $closingBraceToken['level'] + 1); $phpcsFile->fixer->beginChangeset(); $phpcsFile->fixer->addNewlineBefore($closingBracePtr - 1); $phpcsFile->fixer->addContentBefore($closingBracePtr - 1, $expectedReturnSpaces . 'return $this;'); $phpcsFile->fixer->addNewlineBefore($closingBracePtr - 1); $phpcsFile->fixer->endChangeset(); }
php
private function fixNoReturnFound(File $phpcsFile, int $closingBracePtr): void { $tokens = $phpcsFile->getTokens(); $closingBraceToken = $tokens[$closingBracePtr]; $expectedReturnSpaces = str_repeat($this->identation, $closingBraceToken['level'] + 1); $phpcsFile->fixer->beginChangeset(); $phpcsFile->fixer->addNewlineBefore($closingBracePtr - 1); $phpcsFile->fixer->addContentBefore($closingBracePtr - 1, $expectedReturnSpaces . 'return $this;'); $phpcsFile->fixer->addNewlineBefore($closingBracePtr - 1); $phpcsFile->fixer->endChangeset(); }
[ "private", "function", "fixNoReturnFound", "(", "File", "$", "phpcsFile", ",", "int", "$", "closingBracePtr", ")", ":", "void", "{", "$", "tokens", "=", "$", "phpcsFile", "->", "getTokens", "(", ")", ";", "$", "closingBraceToken", "=", "$", "tokens", "[", ...
Fixes if no return statement is found. @param File $phpcsFile The php cs file @param int $closingBracePtr Pointer to the closing curly brace of the function @return void
[ "Fixes", "if", "no", "return", "statement", "is", "found", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Functions/FluentSetterSniff.php#L220-L232
45,881
bestit/PHP_CodeSniffer
src/Standards/BestIt/CodeSniffer/CodeWarning.php
CodeWarning.isFixable
public function isFixable(?bool $newStatus = null): bool { $oldStatus = $this->isFixable; if ($newStatus !== null) { $this->isFixable = $newStatus; } return $oldStatus; }
php
public function isFixable(?bool $newStatus = null): bool { $oldStatus = $this->isFixable; if ($newStatus !== null) { $this->isFixable = $newStatus; } return $oldStatus; }
[ "public", "function", "isFixable", "(", "?", "bool", "$", "newStatus", "=", "null", ")", ":", "bool", "{", "$", "oldStatus", "=", "$", "this", "->", "isFixable", ";", "if", "(", "$", "newStatus", "!==", "null", ")", "{", "$", "this", "->", "isFixable...
Is this topic fixable? @param bool|null $newStatus If given the new status. @return bool Returns the "old" status if this is fixable.
[ "Is", "this", "topic", "fixable?" ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/CodeSniffer/CodeWarning.php#L101-L110
45,882
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Functions/MultipleReturnSniff.php
MultipleReturnSniff.loadReturnsOfThisFunction
private function loadReturnsOfThisFunction(): array { $returnPositions = TokenHelper::findNextAll( $this->file->getBaseFile(), [T_RETURN], $this->stackPos + 1, $this->token['scope_closer'] ); return array_filter($returnPositions, function (int $returnPos): bool { $possibleClosure = $this->file->findPrevious([T_CLOSURE, T_FUNCTION], $returnPos - 1, $this->stackPos); return $possibleClosure === $this->stackPos; }); }
php
private function loadReturnsOfThisFunction(): array { $returnPositions = TokenHelper::findNextAll( $this->file->getBaseFile(), [T_RETURN], $this->stackPos + 1, $this->token['scope_closer'] ); return array_filter($returnPositions, function (int $returnPos): bool { $possibleClosure = $this->file->findPrevious([T_CLOSURE, T_FUNCTION], $returnPos - 1, $this->stackPos); return $possibleClosure === $this->stackPos; }); }
[ "private", "function", "loadReturnsOfThisFunction", "(", ")", ":", "array", "{", "$", "returnPositions", "=", "TokenHelper", "::", "findNextAll", "(", "$", "this", "->", "file", "->", "getBaseFile", "(", ")", ",", "[", "T_RETURN", "]", ",", "$", "this", "-...
Returns the returns of this function. We check the "token level" to exclude the returns of nested closures. @return int[] The positions of the returns from the same function-scope.
[ "Returns", "the", "returns", "of", "this", "function", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Functions/MultipleReturnSniff.php#L55-L69
45,883
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/Functions/MultipleReturnSniff.php
MultipleReturnSniff.processToken
protected function processToken(): void { $returnPositions = $this->loadReturnsOfThisFunction(); if (count($returnPositions) > 1) { array_shift($returnPositions); array_walk($returnPositions, function (int $returnPos): void { $this->file->addWarning( self::WARNING_MULTIPLE_RETURNS_FOUND, $returnPos, static::CODE_MULTIPLE_RETURNS_FOUND ); }); } }
php
protected function processToken(): void { $returnPositions = $this->loadReturnsOfThisFunction(); if (count($returnPositions) > 1) { array_shift($returnPositions); array_walk($returnPositions, function (int $returnPos): void { $this->file->addWarning( self::WARNING_MULTIPLE_RETURNS_FOUND, $returnPos, static::CODE_MULTIPLE_RETURNS_FOUND ); }); } }
[ "protected", "function", "processToken", "(", ")", ":", "void", "{", "$", "returnPositions", "=", "$", "this", "->", "loadReturnsOfThisFunction", "(", ")", ";", "if", "(", "count", "(", "$", "returnPositions", ")", ">", "1", ")", "{", "array_shift", "(", ...
Iterates through the returns of this function and registers warnings if there is more then one relevant return. @return void
[ "Iterates", "through", "the", "returns", "of", "this", "function", "and", "registers", "warnings", "if", "there", "is", "more", "then", "one", "relevant", "return", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/Functions/MultipleReturnSniff.php#L76-L91
45,884
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/NamingConventions/CamelCaseVariableSniff.php
CamelCaseVariableSniff.areRequirementsMet
protected function areRequirementsMet(): bool { $var = $this->token['content']; // We need to check everything != $this. if ($return = $var !== '$this') { $nextPos = (int) TokenHelper::findNextEffective($this->file->getBaseFile(), $this->stackPos + 1); if ($nextPos > 0) { $isProperty = PropertyHelper::isProperty($this->file->getBaseFile(), $this->stackPos); $nextTokenCode = $this->tokens[$nextPos]['code']; // The var should be followed by an "=" or can be followed by a semicolon if its a property. $return = ($nextTokenCode === T_EQUAL) || ($nextTokenCode === T_SEMICOLON && $isProperty); } } return $return; }
php
protected function areRequirementsMet(): bool { $var = $this->token['content']; // We need to check everything != $this. if ($return = $var !== '$this') { $nextPos = (int) TokenHelper::findNextEffective($this->file->getBaseFile(), $this->stackPos + 1); if ($nextPos > 0) { $isProperty = PropertyHelper::isProperty($this->file->getBaseFile(), $this->stackPos); $nextTokenCode = $this->tokens[$nextPos]['code']; // The var should be followed by an "=" or can be followed by a semicolon if its a property. $return = ($nextTokenCode === T_EQUAL) || ($nextTokenCode === T_SEMICOLON && $isProperty); } } return $return; }
[ "protected", "function", "areRequirementsMet", "(", ")", ":", "bool", "{", "$", "var", "=", "$", "this", "->", "token", "[", "'content'", "]", ";", "// We need to check everything != $this.", "if", "(", "$", "return", "=", "$", "var", "!==", "'$this'", ")", ...
Returns true if there is a value assignment or a property declaration, but which can be without an assignment. @return bool
[ "Returns", "true", "if", "there", "is", "a", "value", "assignment", "or", "a", "property", "declaration", "but", "which", "can", "be", "without", "an", "assignment", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/NamingConventions/CamelCaseVariableSniff.php#L60-L78
45,885
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/NamingConventions/CamelCaseVariableSniff.php
CamelCaseVariableSniff.tearDown
protected function tearDown(): void { parent::tearDown(); if ($this->prevSniffedFile && $this->prevSniffedFile !== $this->file->getFilename()) { $this->sniffedVars = []; $this->prevSniffedFile = ''; } }
php
protected function tearDown(): void { parent::tearDown(); if ($this->prevSniffedFile && $this->prevSniffedFile !== $this->file->getFilename()) { $this->sniffedVars = []; $this->prevSniffedFile = ''; } }
[ "protected", "function", "tearDown", "(", ")", ":", "void", "{", "parent", "::", "tearDown", "(", ")", ";", "if", "(", "$", "this", "->", "prevSniffedFile", "&&", "$", "this", "->", "prevSniffedFile", "!==", "$", "this", "->", "file", "->", "getFilename"...
Cleans the cache of this sniff. @return void
[ "Cleans", "the", "cache", "of", "this", "sniff", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/NamingConventions/CamelCaseVariableSniff.php#L130-L138
45,886
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/DocTags/ParamTagSniff.php
ParamTagSniff.checkAgainstPattern
private function checkAgainstPattern(?string $tagContent = null): bool { if (!$return = $this->isValidContent($tagContent)) { throw (new CodeError(static::CODE_TAG_MISSING_VARIABLE, self::MESSAGE_TAG_MISSING_VARIABLE, $this->stackPos)) ->setPayload([$tagContent]) ->setToken($this->token); } return $return; }
php
private function checkAgainstPattern(?string $tagContent = null): bool { if (!$return = $this->isValidContent($tagContent)) { throw (new CodeError(static::CODE_TAG_MISSING_VARIABLE, self::MESSAGE_TAG_MISSING_VARIABLE, $this->stackPos)) ->setPayload([$tagContent]) ->setToken($this->token); } return $return; }
[ "private", "function", "checkAgainstPattern", "(", "?", "string", "$", "tagContent", "=", "null", ")", ":", "bool", "{", "if", "(", "!", "$", "return", "=", "$", "this", "->", "isValidContent", "(", "$", "tagContent", ")", ")", "{", "throw", "(", "new"...
Simple check if the pattern is correct. @param string|null $tagContent @throws CodeWarning @return bool True if it matches.
[ "Simple", "check", "if", "the", "pattern", "is", "correct", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/DocTags/ParamTagSniff.php#L109-L118
45,887
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/DocTags/ParamTagSniff.php
ParamTagSniff.checkArgumentItself
private function checkArgumentItself(?string $tagContent = null): void { if (!$this->getArgumentTokenOfTag()) { throw (new CodeError( static::CODE_TAG_MISSING_VARIABLE, self::MESSAGE_TAG_MISSING_VARIABLE, $this->stackPos )) ->setPayload([$tagContent]) ->setToken($this->token); } }
php
private function checkArgumentItself(?string $tagContent = null): void { if (!$this->getArgumentTokenOfTag()) { throw (new CodeError( static::CODE_TAG_MISSING_VARIABLE, self::MESSAGE_TAG_MISSING_VARIABLE, $this->stackPos )) ->setPayload([$tagContent]) ->setToken($this->token); } }
[ "private", "function", "checkArgumentItself", "(", "?", "string", "$", "tagContent", "=", "null", ")", ":", "void", "{", "if", "(", "!", "$", "this", "->", "getArgumentTokenOfTag", "(", ")", ")", "{", "throw", "(", "new", "CodeError", "(", "static", "::"...
Checks if the argument of the function itself exists. @param null|string $tagContent @throws CodeWarning @return void
[ "Checks", "if", "the", "argument", "of", "the", "function", "itself", "exists", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/DocTags/ParamTagSniff.php#L128-L139
45,888
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/DocTags/ParamTagSniff.php
ParamTagSniff.checkDescription
private function checkDescription(): bool { if (($hasNoDesc = !@$this->matches['desc']) && ($this->descAsWarning)) { throw (new CodeWarning(static::CODE_TAG_MISSING_DESC, self::MESSAGE_TAG_MISSING_DESC, $this->stackPos)) ->setPayload([$this->matches['var']]) ->setToken($this->token); } return !$hasNoDesc; }
php
private function checkDescription(): bool { if (($hasNoDesc = !@$this->matches['desc']) && ($this->descAsWarning)) { throw (new CodeWarning(static::CODE_TAG_MISSING_DESC, self::MESSAGE_TAG_MISSING_DESC, $this->stackPos)) ->setPayload([$this->matches['var']]) ->setToken($this->token); } return !$hasNoDesc; }
[ "private", "function", "checkDescription", "(", ")", ":", "bool", "{", "if", "(", "(", "$", "hasNoDesc", "=", "!", "@", "$", "this", "->", "matches", "[", "'desc'", "]", ")", "&&", "(", "$", "this", "->", "descAsWarning", ")", ")", "{", "throw", "(...
Checks if the param contains a description. @throws CodeWarning @return bool|null Returns true if there is a desc.
[ "Checks", "if", "the", "param", "contains", "a", "description", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/DocTags/ParamTagSniff.php#L148-L157
45,889
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/DocTags/ParamTagSniff.php
ParamTagSniff.checkType
private function checkType(): bool { if (!@$this->matches['type']) { throw (new CodeError(static::CODE_TAG_MISSING_TYPE, self::MESSAGE_TAG_MISSING_TYPE, $this->stackPos)) ->setPayload([$this->matches['var']]) ->setToken($this->token); } if (strtolower($this->matches['type']) === 'mixed') { throw (new CodeWarning(static::CODE_TAG_MIXED_TYPE, self::MESSAGE_TAG_MIXED_TYPE, $this->stackPos)) ->setToken($this->token); } return true; }
php
private function checkType(): bool { if (!@$this->matches['type']) { throw (new CodeError(static::CODE_TAG_MISSING_TYPE, self::MESSAGE_TAG_MISSING_TYPE, $this->stackPos)) ->setPayload([$this->matches['var']]) ->setToken($this->token); } if (strtolower($this->matches['type']) === 'mixed') { throw (new CodeWarning(static::CODE_TAG_MIXED_TYPE, self::MESSAGE_TAG_MIXED_TYPE, $this->stackPos)) ->setToken($this->token); } return true; }
[ "private", "function", "checkType", "(", ")", ":", "bool", "{", "if", "(", "!", "@", "$", "this", "->", "matches", "[", "'type'", "]", ")", "{", "throw", "(", "new", "CodeError", "(", "static", "::", "CODE_TAG_MISSING_TYPE", ",", "self", "::", "MESSAGE...
Checks if the param tag contains a valid type. @throws CodeWarning @return bool True if the type is valid.
[ "Checks", "if", "the", "param", "tag", "contains", "a", "valid", "type", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/DocTags/ParamTagSniff.php#L166-L181
45,890
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/DocTags/ParamTagSniff.php
ParamTagSniff.findAllVariablePositions
protected function findAllVariablePositions(): array { return TokenHelper::findNextAll( $this->file->getBaseFile(), [T_VARIABLE], $this->stackPos + 1, $this->file->findNext([T_CLOSE_PARENTHESIS], $this->stackPos + 1) ); }
php
protected function findAllVariablePositions(): array { return TokenHelper::findNextAll( $this->file->getBaseFile(), [T_VARIABLE], $this->stackPos + 1, $this->file->findNext([T_CLOSE_PARENTHESIS], $this->stackPos + 1) ); }
[ "protected", "function", "findAllVariablePositions", "(", ")", ":", "array", "{", "return", "TokenHelper", "::", "findNextAll", "(", "$", "this", "->", "file", "->", "getBaseFile", "(", ")", ",", "[", "T_VARIABLE", "]", ",", "$", "this", "->", "stackPos", ...
Loads all variables of the following method. @return array
[ "Loads", "all", "variables", "of", "the", "following", "method", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/DocTags/ParamTagSniff.php#L188-L196
45,891
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/DocTags/ParamTagSniff.php
ParamTagSniff.getArgumentTokenOfTag
private function getArgumentTokenOfTag(): array { if ($this->argumentToken === null) { $this->argumentToken = $this->loadArgumentTokenOfTag(); } return $this->argumentToken; }
php
private function getArgumentTokenOfTag(): array { if ($this->argumentToken === null) { $this->argumentToken = $this->loadArgumentTokenOfTag(); } return $this->argumentToken; }
[ "private", "function", "getArgumentTokenOfTag", "(", ")", ":", "array", "{", "if", "(", "$", "this", "->", "argumentToken", "===", "null", ")", "{", "$", "this", "->", "argumentToken", "=", "$", "this", "->", "loadArgumentTokenOfTag", "(", ")", ";", "}", ...
Returns the name of the real function argument for this parameter tag. @return array Null if there is no matching function argument.
[ "Returns", "the", "name", "of", "the", "real", "function", "argument", "for", "this", "parameter", "tag", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/DocTags/ParamTagSniff.php#L216-L223
45,892
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/DocTags/ParamTagSniff.php
ParamTagSniff.loadAndCheckVarPositions
private function loadAndCheckVarPositions(): array { $varPositions = $this->findAllVariablePositions(); if (!$varPositions) { throw (new CodeError( static::CODE_TAG_MISSING_VARIABLES, self::MESSAGE_TAG_MISSING_VARIABLES, $this->stackPos ))->setToken($this->token); } $this->varTokens = array_filter($this->tokens, function (array $token) use ($varPositions): bool { return in_array($token['pointer'], $varPositions, true); }); return $varPositions; }
php
private function loadAndCheckVarPositions(): array { $varPositions = $this->findAllVariablePositions(); if (!$varPositions) { throw (new CodeError( static::CODE_TAG_MISSING_VARIABLES, self::MESSAGE_TAG_MISSING_VARIABLES, $this->stackPos ))->setToken($this->token); } $this->varTokens = array_filter($this->tokens, function (array $token) use ($varPositions): bool { return in_array($token['pointer'], $varPositions, true); }); return $varPositions; }
[ "private", "function", "loadAndCheckVarPositions", "(", ")", ":", "array", "{", "$", "varPositions", "=", "$", "this", "->", "findAllVariablePositions", "(", ")", ";", "if", "(", "!", "$", "varPositions", ")", "{", "throw", "(", "new", "CodeError", "(", "s...
Loads and checks the variables of the following method. @throws CodeWarning We have param tags, so there should be variables in the method. @return array The positions of the methods variables if there are any.
[ "Loads", "and", "checks", "the", "variables", "of", "the", "following", "method", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/DocTags/ParamTagSniff.php#L232-L249
45,893
bestit/PHP_CodeSniffer
src/Standards/BestIt/Sniffs/DocTags/ParamTagSniff.php
ParamTagSniff.loadArgumentTokenOfTag
private function loadArgumentTokenOfTag(): array { // Give me the other tags of this doc block before this one. $tagPosBeforeThis = TokenHelper::findNextAll( $this->file->getBaseFile(), $this->register(), $this->file->findPrevious([T_DOC_COMMENT_OPEN_TAG], $this->stackPos), $this->stackPos - 1 ); $tagPosBeforeThis = array_filter($tagPosBeforeThis, function (int $position) { return $this->tokens[$position]['content'] === '@param'; }); return (array_values($this->varTokens)[count($tagPosBeforeThis)]) ?? []; }
php
private function loadArgumentTokenOfTag(): array { // Give me the other tags of this doc block before this one. $tagPosBeforeThis = TokenHelper::findNextAll( $this->file->getBaseFile(), $this->register(), $this->file->findPrevious([T_DOC_COMMENT_OPEN_TAG], $this->stackPos), $this->stackPos - 1 ); $tagPosBeforeThis = array_filter($tagPosBeforeThis, function (int $position) { return $this->tokens[$position]['content'] === '@param'; }); return (array_values($this->varTokens)[count($tagPosBeforeThis)]) ?? []; }
[ "private", "function", "loadArgumentTokenOfTag", "(", ")", ":", "array", "{", "// Give me the other tags of this doc block before this one.", "$", "tagPosBeforeThis", "=", "TokenHelper", "::", "findNextAll", "(", "$", "this", "->", "file", "->", "getBaseFile", "(", ")",...
Loads the function argument of this tag. @return array
[ "Loads", "the", "function", "argument", "of", "this", "tag", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/Sniffs/DocTags/ParamTagSniff.php#L256-L271
45,894
bestit/PHP_CodeSniffer
src/Standards/BestIt/CodeSniffer/Helper/DocDescriptionHelper.php
DocDescriptionHelper.checkCommentDescription
public function checkCommentDescription(bool $descriptionRequired): void { $this->descriptionRequired = $descriptionRequired; $commentStartToken = $this->docHelper->getBlockStartToken(); $commentEndToken = $this->docHelper->getBlockEndToken(); $summaryPtr = $this->summaryHelper->getCommentSummaryPosition(); if ($summaryPtr === -1) { return; } $hasTags = count($commentStartToken['comment_tags']) > 0; $descriptionStartPtr = $this->getCommentDescriptionStartPointer(); if ($descriptionStartPtr === -1) { $this->addDescriptionNotFoundError($summaryPtr); return; } $descriptionEndPtr = $this->getCommentDescriptionEndPointer(); $descEndToken = $this->tokens[$descriptionEndPtr]; $this->checkCommentDescriptionUcFirst($descriptionStartPtr); //Fix no or too much lines after description. $toLine = $commentEndToken['line']; $expectedLines = 0; if ($hasTags) { $firstTagPtr = array_shift($commentStartToken['comment_tags']); $firstTagToken = $this->tokens[$firstTagPtr]; $toLine = $firstTagToken['line']; $expectedLines = 1; } $diffLines = $toLine - $descEndToken['line'] - 1; if ($diffLines === $expectedLines) { return; } if ($diffLines < $expectedLines && $hasTags) { $fixNoLine = $this->file->addFixableError( AbstractDocSniff::MESSAGE_NO_LINE_AFTER_DESCRIPTION, $descriptionEndPtr, AbstractDocSniff::CODE_NO_LINE_AFTER_DESCRIPTION ); if ($fixNoLine) { $this->fixNoLineAfterDescription(); } return; } $fixMuchLines = $this->file->addFixableError( AbstractDocSniff::MESSAGE_MUCH_LINES_AFTER_DESCRIPTION, $descriptionEndPtr, AbstractDocSniff::CODE_MUCH_LINES_AFTER_DESCRIPTION ); if ($fixMuchLines) { $this->fixMuchLinesAfterDescription($descEndToken['line'] + 1, $toLine - 1); } }
php
public function checkCommentDescription(bool $descriptionRequired): void { $this->descriptionRequired = $descriptionRequired; $commentStartToken = $this->docHelper->getBlockStartToken(); $commentEndToken = $this->docHelper->getBlockEndToken(); $summaryPtr = $this->summaryHelper->getCommentSummaryPosition(); if ($summaryPtr === -1) { return; } $hasTags = count($commentStartToken['comment_tags']) > 0; $descriptionStartPtr = $this->getCommentDescriptionStartPointer(); if ($descriptionStartPtr === -1) { $this->addDescriptionNotFoundError($summaryPtr); return; } $descriptionEndPtr = $this->getCommentDescriptionEndPointer(); $descEndToken = $this->tokens[$descriptionEndPtr]; $this->checkCommentDescriptionUcFirst($descriptionStartPtr); //Fix no or too much lines after description. $toLine = $commentEndToken['line']; $expectedLines = 0; if ($hasTags) { $firstTagPtr = array_shift($commentStartToken['comment_tags']); $firstTagToken = $this->tokens[$firstTagPtr]; $toLine = $firstTagToken['line']; $expectedLines = 1; } $diffLines = $toLine - $descEndToken['line'] - 1; if ($diffLines === $expectedLines) { return; } if ($diffLines < $expectedLines && $hasTags) { $fixNoLine = $this->file->addFixableError( AbstractDocSniff::MESSAGE_NO_LINE_AFTER_DESCRIPTION, $descriptionEndPtr, AbstractDocSniff::CODE_NO_LINE_AFTER_DESCRIPTION ); if ($fixNoLine) { $this->fixNoLineAfterDescription(); } return; } $fixMuchLines = $this->file->addFixableError( AbstractDocSniff::MESSAGE_MUCH_LINES_AFTER_DESCRIPTION, $descriptionEndPtr, AbstractDocSniff::CODE_MUCH_LINES_AFTER_DESCRIPTION ); if ($fixMuchLines) { $this->fixMuchLinesAfterDescription($descEndToken['line'] + 1, $toLine - 1); } }
[ "public", "function", "checkCommentDescription", "(", "bool", "$", "descriptionRequired", ")", ":", "void", "{", "$", "this", "->", "descriptionRequired", "=", "$", "descriptionRequired", ";", "$", "commentStartToken", "=", "$", "this", "->", "docHelper", "->", ...
Checks for comment description. @param bool $descriptionRequired Indicator if the description is required. @return void
[ "Checks", "for", "comment", "description", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/CodeSniffer/Helper/DocDescriptionHelper.php#L75-L144
45,895
bestit/PHP_CodeSniffer
src/Standards/BestIt/CodeSniffer/Helper/DocDescriptionHelper.php
DocDescriptionHelper.checkCommentDescriptionUcFirst
private function checkCommentDescriptionUcFirst(int $descriptionStartPtr): void { $descStartToken = $this->tokens[$descriptionStartPtr]; $descriptionContent = $descStartToken['content']; if (ucfirst($descriptionContent) === $descriptionContent) { return; } $fixUcFirst = $this->file->addFixableError( AbstractDocSniff::MESSAGE_DESCRIPTION_UC_FIRST, $descriptionStartPtr, AbstractDocSniff::CODE_DESCRIPTION_UC_FIRST ); if ($fixUcFirst) { $this->fixDescriptionUcFirst($descriptionStartPtr); } }
php
private function checkCommentDescriptionUcFirst(int $descriptionStartPtr): void { $descStartToken = $this->tokens[$descriptionStartPtr]; $descriptionContent = $descStartToken['content']; if (ucfirst($descriptionContent) === $descriptionContent) { return; } $fixUcFirst = $this->file->addFixableError( AbstractDocSniff::MESSAGE_DESCRIPTION_UC_FIRST, $descriptionStartPtr, AbstractDocSniff::CODE_DESCRIPTION_UC_FIRST ); if ($fixUcFirst) { $this->fixDescriptionUcFirst($descriptionStartPtr); } }
[ "private", "function", "checkCommentDescriptionUcFirst", "(", "int", "$", "descriptionStartPtr", ")", ":", "void", "{", "$", "descStartToken", "=", "$", "this", "->", "tokens", "[", "$", "descriptionStartPtr", "]", ";", "$", "descriptionContent", "=", "$", "desc...
Checks if the description starts with a capital letter. @param int $descriptionStartPtr Pointer to the start of the description. @return void
[ "Checks", "if", "the", "description", "starts", "with", "a", "capital", "letter", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/CodeSniffer/Helper/DocDescriptionHelper.php#L153-L172
45,896
bestit/PHP_CodeSniffer
src/Standards/BestIt/CodeSniffer/Helper/DocDescriptionHelper.php
DocDescriptionHelper.getCommentDescriptionEndPointer
private function getCommentDescriptionEndPointer(): int { $descriptionStartPtr = $this->getCommentDescriptionStartPointer(); $commentStartToken = $this->docHelper->getBlockStartToken(); $commentEndPtr = $this->docHelper->getBlockEndPosition(); //If no tags found, possible end of search is the starting tag of the doc comment. if (count($commentStartToken['comment_tags']) === 0) { return $this->file->findPrevious( [T_DOC_COMMENT_STRING], $commentEndPtr - 1, $descriptionStartPtr ); } //else its the pointer of the first comment tag found. $firstTagPtr = array_shift($commentStartToken['comment_tags']); return $this->file->findPrevious( [T_DOC_COMMENT_STRING], $firstTagPtr - 1, $descriptionStartPtr ); }
php
private function getCommentDescriptionEndPointer(): int { $descriptionStartPtr = $this->getCommentDescriptionStartPointer(); $commentStartToken = $this->docHelper->getBlockStartToken(); $commentEndPtr = $this->docHelper->getBlockEndPosition(); //If no tags found, possible end of search is the starting tag of the doc comment. if (count($commentStartToken['comment_tags']) === 0) { return $this->file->findPrevious( [T_DOC_COMMENT_STRING], $commentEndPtr - 1, $descriptionStartPtr ); } //else its the pointer of the first comment tag found. $firstTagPtr = array_shift($commentStartToken['comment_tags']); return $this->file->findPrevious( [T_DOC_COMMENT_STRING], $firstTagPtr - 1, $descriptionStartPtr ); }
[ "private", "function", "getCommentDescriptionEndPointer", "(", ")", ":", "int", "{", "$", "descriptionStartPtr", "=", "$", "this", "->", "getCommentDescriptionStartPointer", "(", ")", ";", "$", "commentStartToken", "=", "$", "this", "->", "docHelper", "->", "getBl...
Returns pointer to the end of the description. @return int Pointer to the end of the description or false
[ "Returns", "pointer", "to", "the", "end", "of", "the", "description", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/CodeSniffer/Helper/DocDescriptionHelper.php#L179-L203
45,897
bestit/PHP_CodeSniffer
src/Standards/BestIt/CodeSniffer/Helper/DocDescriptionHelper.php
DocDescriptionHelper.getCommentDescriptionStartPointer
private function getCommentDescriptionStartPointer(): int { $commentStartToken = $this->docHelper->getBlockStartToken(); $commentEndPtr = $this->docHelper->getBlockEndPosition(); $summaryPtr = $this->summaryHelper->getCommentSummaryPosition(); //If no tags the possible end of search is the closing tag of the doc comment. if (count($commentStartToken['comment_tags']) === 0) { return $this->file->findNext( [T_DOC_COMMENT_STRING], $summaryPtr + 1, $commentEndPtr ); } //else its the pointer of the first comment tag found. $firstTagPtr = array_shift($commentStartToken['comment_tags']); return $this->file->findNext( [T_DOC_COMMENT_STRING], $summaryPtr + 1, $firstTagPtr - 1 ); }
php
private function getCommentDescriptionStartPointer(): int { $commentStartToken = $this->docHelper->getBlockStartToken(); $commentEndPtr = $this->docHelper->getBlockEndPosition(); $summaryPtr = $this->summaryHelper->getCommentSummaryPosition(); //If no tags the possible end of search is the closing tag of the doc comment. if (count($commentStartToken['comment_tags']) === 0) { return $this->file->findNext( [T_DOC_COMMENT_STRING], $summaryPtr + 1, $commentEndPtr ); } //else its the pointer of the first comment tag found. $firstTagPtr = array_shift($commentStartToken['comment_tags']); return $this->file->findNext( [T_DOC_COMMENT_STRING], $summaryPtr + 1, $firstTagPtr - 1 ); }
[ "private", "function", "getCommentDescriptionStartPointer", "(", ")", ":", "int", "{", "$", "commentStartToken", "=", "$", "this", "->", "docHelper", "->", "getBlockStartToken", "(", ")", ";", "$", "commentEndPtr", "=", "$", "this", "->", "docHelper", "->", "g...
Returns pointer to the start of the long description or false if not found. @return int Pointer to the start of the description or -1
[ "Returns", "pointer", "to", "the", "start", "of", "the", "long", "description", "or", "false", "if", "not", "found", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/CodeSniffer/Helper/DocDescriptionHelper.php#L210-L234
45,898
bestit/PHP_CodeSniffer
src/Standards/BestIt/CodeSniffer/Helper/DocDescriptionHelper.php
DocDescriptionHelper.addDescriptionNotFoundError
private function addDescriptionNotFoundError(int $summaryPtr): void { if ($this->descriptionRequired) { $this->file->addError( AbstractDocSniff::MESSAGE_DESCRIPTION_NOT_FOUND, $summaryPtr, AbstractDocSniff::CODE_DESCRIPTION_NOT_FOUND ); } }
php
private function addDescriptionNotFoundError(int $summaryPtr): void { if ($this->descriptionRequired) { $this->file->addError( AbstractDocSniff::MESSAGE_DESCRIPTION_NOT_FOUND, $summaryPtr, AbstractDocSniff::CODE_DESCRIPTION_NOT_FOUND ); } }
[ "private", "function", "addDescriptionNotFoundError", "(", "int", "$", "summaryPtr", ")", ":", "void", "{", "if", "(", "$", "this", "->", "descriptionRequired", ")", "{", "$", "this", "->", "file", "->", "addError", "(", "AbstractDocSniff", "::", "MESSAGE_DESC...
Adds error when description is not found. @param int $summaryPtr Pointer to summary token. @return void
[ "Adds", "error", "when", "description", "is", "not", "found", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/CodeSniffer/Helper/DocDescriptionHelper.php#L243-L252
45,899
bestit/PHP_CodeSniffer
src/Standards/BestIt/CodeSniffer/Helper/DocDescriptionHelper.php
DocDescriptionHelper.fixNoLineAfterDescription
private function fixNoLineAfterDescription(): void { $descEndPtr = $this->getCommentDescriptionEndPointer(); $descEndToken = $this->tokens[$descEndPtr]; $this->file->getFixer()->beginChangeset(); $this->file->getFixer()->addContent( $descEndPtr, $this->file->getEolChar() . str_repeat(' ', $descEndToken['level']) . ' *' ); $this->file->getFixer()->endChangeset(); }
php
private function fixNoLineAfterDescription(): void { $descEndPtr = $this->getCommentDescriptionEndPointer(); $descEndToken = $this->tokens[$descEndPtr]; $this->file->getFixer()->beginChangeset(); $this->file->getFixer()->addContent( $descEndPtr, $this->file->getEolChar() . str_repeat(' ', $descEndToken['level']) . ' *' ); $this->file->getFixer()->endChangeset(); }
[ "private", "function", "fixNoLineAfterDescription", "(", ")", ":", "void", "{", "$", "descEndPtr", "=", "$", "this", "->", "getCommentDescriptionEndPointer", "(", ")", ";", "$", "descEndToken", "=", "$", "this", "->", "tokens", "[", "$", "descEndPtr", "]", "...
Fixes no line after description. @return void
[ "Fixes", "no", "line", "after", "description", "." ]
a80e1f24642858a0ad20301661037c321128d021
https://github.com/bestit/PHP_CodeSniffer/blob/a80e1f24642858a0ad20301661037c321128d021/src/Standards/BestIt/CodeSniffer/Helper/DocDescriptionHelper.php#L259-L272