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
41,800
opis/database
src/SQL/Compiler.php
Compiler.handleJoinConditions
protected function handleJoinConditions(array $conditions) { if (empty($conditions)) { return ''; } $sql[] = $this->{$conditions[0]['type']}($conditions[0]); $count = count($conditions); for ($i = 1; $i < $count; $i++) { $sql[] = $conditions[$i]['separator'] . ' ' . $this->{$conditions[$i]['type']}($conditions[$i]); } return implode(' ', $sql); }
php
protected function handleJoinConditions(array $conditions) { if (empty($conditions)) { return ''; } $sql[] = $this->{$conditions[0]['type']}($conditions[0]); $count = count($conditions); for ($i = 1; $i < $count; $i++) { $sql[] = $conditions[$i]['separator'] . ' ' . $this->{$conditions[$i]['type']}($conditions[$i]); } return implode(' ', $sql); }
[ "protected", "function", "handleJoinConditions", "(", "array", "$", "conditions", ")", "{", "if", "(", "empty", "(", "$", "conditions", ")", ")", "{", "return", "''", ";", "}", "$", "sql", "[", "]", "=", "$", "this", "->", "{", "$", "conditions", "["...
Handle JOIN conditions @param array $conditions @return string
[ "Handle", "JOIN", "conditions" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/SQL/Compiler.php#L414-L425
41,801
opis/database
src/SQL/Compiler.php
Compiler.handleHavings
protected function handleHavings(array $havings, $prefix = true) { if (empty($havings)) { return ''; } $sql[] = $this->{$havings[0]['type']}($havings[0]); $count = count($havings); for ($i = 1; $i < $count; $i++) { $sql[] = $havings[$i]['separator'] . ' ' . $this->{$havings[$i]['type']}($havings[$i]); } return ($prefix ? ' HAVING ' : '') . implode(' ', $sql); }
php
protected function handleHavings(array $havings, $prefix = true) { if (empty($havings)) { return ''; } $sql[] = $this->{$havings[0]['type']}($havings[0]); $count = count($havings); for ($i = 1; $i < $count; $i++) { $sql[] = $havings[$i]['separator'] . ' ' . $this->{$havings[$i]['type']}($havings[$i]); } return ($prefix ? ' HAVING ' : '') . implode(' ', $sql); }
[ "protected", "function", "handleHavings", "(", "array", "$", "havings", ",", "$", "prefix", "=", "true", ")", "{", "if", "(", "empty", "(", "$", "havings", ")", ")", "{", "return", "''", ";", "}", "$", "sql", "[", "]", "=", "$", "this", "->", "{"...
Handle HAVING clause @param array $havings @param bool $prefix (optional) @return string
[ "Handle", "HAVING", "clause" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/SQL/Compiler.php#L435-L451
41,802
codemix/yii2-streamlog
src/Target.php
Target.export
public function export() { $text = implode("\n", array_map([$this, 'formatMessage'], $this->messages)) . "\n"; fwrite($this->getFp(), $text); }
php
public function export() { $text = implode("\n", array_map([$this, 'formatMessage'], $this->messages)) . "\n"; fwrite($this->getFp(), $text); }
[ "public", "function", "export", "(", ")", "{", "$", "text", "=", "implode", "(", "\"\\n\"", ",", "array_map", "(", "[", "$", "this", ",", "'formatMessage'", "]", ",", "$", "this", "->", "messages", ")", ")", ".", "\"\\n\"", ";", "fwrite", "(", "$", ...
Writes a log message to the given target URL @throws InvalidConfigException if unable to open the stream for writing
[ "Writes", "a", "log", "message", "to", "the", "given", "target", "URL" ]
46717733b46a91dd323888349b323fb0bd989e2e
https://github.com/codemix/yii2-streamlog/blob/46717733b46a91dd323888349b323fb0bd989e2e/src/Target.php#L83-L87
41,803
philipbrown/signature-php
src/Auth.php
Auth.attempt
public function attempt(Token $token, $prefix = Request::PREFIX) { $auth = $this->getAuthParams($prefix); $body = $this->getBodyParams($prefix); $request = new Request($this->method, $this->uri, $body, $auth[$prefix . 'timestamp']); $signature = $request->sign($token, $prefix); foreach ($this->guards as $guard) { $guard->check($auth, $signature, $prefix); } return true; }
php
public function attempt(Token $token, $prefix = Request::PREFIX) { $auth = $this->getAuthParams($prefix); $body = $this->getBodyParams($prefix); $request = new Request($this->method, $this->uri, $body, $auth[$prefix . 'timestamp']); $signature = $request->sign($token, $prefix); foreach ($this->guards as $guard) { $guard->check($auth, $signature, $prefix); } return true; }
[ "public", "function", "attempt", "(", "Token", "$", "token", ",", "$", "prefix", "=", "Request", "::", "PREFIX", ")", "{", "$", "auth", "=", "$", "this", "->", "getAuthParams", "(", "$", "prefix", ")", ";", "$", "body", "=", "$", "this", "->", "get...
Attempt to authenticate a request @param Token $token @param string $prefix @return bool
[ "Attempt", "to", "authenticate", "a", "request" ]
2a8cecb1f63c3ae5fedb7ee6c1821af9548c233b
https://github.com/philipbrown/signature-php/blob/2a8cecb1f63c3ae5fedb7ee6c1821af9548c233b/src/Auth.php#L54-L67
41,804
philipbrown/signature-php
src/Auth.php
Auth.getAuthParams
private function getAuthParams($prefix) { return array_intersect_key($this->params, array_flip($this->addPrefix($this->auth, $prefix))); }
php
private function getAuthParams($prefix) { return array_intersect_key($this->params, array_flip($this->addPrefix($this->auth, $prefix))); }
[ "private", "function", "getAuthParams", "(", "$", "prefix", ")", "{", "return", "array_intersect_key", "(", "$", "this", "->", "params", ",", "array_flip", "(", "$", "this", "->", "addPrefix", "(", "$", "this", "->", "auth", ",", "$", "prefix", ")", ")",...
Get the auth params @param $prefix @return array
[ "Get", "the", "auth", "params" ]
2a8cecb1f63c3ae5fedb7ee6c1821af9548c233b
https://github.com/philipbrown/signature-php/blob/2a8cecb1f63c3ae5fedb7ee6c1821af9548c233b/src/Auth.php#L75-L78
41,805
philipbrown/signature-php
src/Auth.php
Auth.getBodyParams
private function getBodyParams($prefix) { return array_diff_key($this->params, array_flip($this->addPrefix($this->auth, $prefix))); }
php
private function getBodyParams($prefix) { return array_diff_key($this->params, array_flip($this->addPrefix($this->auth, $prefix))); }
[ "private", "function", "getBodyParams", "(", "$", "prefix", ")", "{", "return", "array_diff_key", "(", "$", "this", "->", "params", ",", "array_flip", "(", "$", "this", "->", "addPrefix", "(", "$", "this", "->", "auth", ",", "$", "prefix", ")", ")", ")...
Get the body params @param $prefix @return array
[ "Get", "the", "body", "params" ]
2a8cecb1f63c3ae5fedb7ee6c1821af9548c233b
https://github.com/philipbrown/signature-php/blob/2a8cecb1f63c3ae5fedb7ee6c1821af9548c233b/src/Auth.php#L86-L89
41,806
opis/database
src/SQL/Compiler/SQLServer.php
SQLServer.select
public function select(SQLStatement $select): string { $limit = $select->getLimit(); if ($limit <= 0) { return parent::select($select); } $offset = $select->getOffset(); if ($offset < 0) { $sql = $select->getDistinct() ? 'SELECT DISTINCT ' : 'SELECT '; $sql .= 'TOP ' . $limit . ' '; $sql .= $this->handleColumns($select->getColumns()); $sql .= $this->handleInto($select->getIntoTable(), $select->getIntoDatabase()); $sql .= ' FROM '; $sql .= $this->handleTables($select->getTables()); $sql .= $this->handleJoins($select->getJoins()); $sql .= $this->handleWheres($select->getWheres()); $sql .= $this->handleGroupings($select->getGroupBy()); $sql .= $this->handleOrderings($select->getOrder()); $sql .= $this->handleHavings($select->getHaving()); return $sql; } $order = trim($this->handleOrderings($select->getOrder())); if (empty($order)) { $order = 'ORDER BY (SELECT 0)'; } $sql = $select->getDistinct() ? 'SELECT DISTINCT ' : 'SELECT '; $sql .= $this->handleColumns($select->getColumns()); $sql .= ', ROW_NUMBER() OVER (' . $order . ') AS opis_rownum'; $sql .= ' FROM '; $sql .= $this->handleTables($select->getTables()); $sql .= $this->handleJoins($select->getJoins()); $sql .= $this->handleWheres($select->getWheres()); $sql .= $this->handleGroupings($select->getGroupBy()); $sql .= $this->handleHavings($select->getHaving()); $limit += $offset; $offset++; return 'SELECT * FROM (' . $sql . ') AS m1 WHERE opis_rownum BETWEEN ' . $offset . ' AND ' . $limit; }
php
public function select(SQLStatement $select): string { $limit = $select->getLimit(); if ($limit <= 0) { return parent::select($select); } $offset = $select->getOffset(); if ($offset < 0) { $sql = $select->getDistinct() ? 'SELECT DISTINCT ' : 'SELECT '; $sql .= 'TOP ' . $limit . ' '; $sql .= $this->handleColumns($select->getColumns()); $sql .= $this->handleInto($select->getIntoTable(), $select->getIntoDatabase()); $sql .= ' FROM '; $sql .= $this->handleTables($select->getTables()); $sql .= $this->handleJoins($select->getJoins()); $sql .= $this->handleWheres($select->getWheres()); $sql .= $this->handleGroupings($select->getGroupBy()); $sql .= $this->handleOrderings($select->getOrder()); $sql .= $this->handleHavings($select->getHaving()); return $sql; } $order = trim($this->handleOrderings($select->getOrder())); if (empty($order)) { $order = 'ORDER BY (SELECT 0)'; } $sql = $select->getDistinct() ? 'SELECT DISTINCT ' : 'SELECT '; $sql .= $this->handleColumns($select->getColumns()); $sql .= ', ROW_NUMBER() OVER (' . $order . ') AS opis_rownum'; $sql .= ' FROM '; $sql .= $this->handleTables($select->getTables()); $sql .= $this->handleJoins($select->getJoins()); $sql .= $this->handleWheres($select->getWheres()); $sql .= $this->handleGroupings($select->getGroupBy()); $sql .= $this->handleHavings($select->getHaving()); $limit += $offset; $offset++; return 'SELECT * FROM (' . $sql . ') AS m1 WHERE opis_rownum BETWEEN ' . $offset . ' AND ' . $limit; }
[ "public", "function", "select", "(", "SQLStatement", "$", "select", ")", ":", "string", "{", "$", "limit", "=", "$", "select", "->", "getLimit", "(", ")", ";", "if", "(", "$", "limit", "<=", "0", ")", "{", "return", "parent", "::", "select", "(", "...
Compiles a SELECT query @param SQLStatement $select @return string
[ "Compiles", "a", "SELECT", "query" ]
a750c8e58da37b23b70cc4b10fa5a97376db2bc7
https://github.com/opis/database/blob/a750c8e58da37b23b70cc4b10fa5a97376db2bc7/src/SQL/Compiler/SQLServer.php#L37-L83
41,807
thephpleague/shunt
src/League/Shunt/BaseObject.php
BaseObject.printVerbose
public function printVerbose($message) { if ($this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) { $this->printOut($message); } }
php
public function printVerbose($message) { if ($this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) { $this->printOut($message); } }
[ "public", "function", "printVerbose", "(", "$", "message", ")", "{", "if", "(", "$", "this", "->", "output", "->", "getVerbosity", "(", ")", ">=", "OutputInterface", "::", "VERBOSITY_VERBOSE", ")", "{", "$", "this", "->", "printOut", "(", "$", "message", ...
Print verbose information @param string
[ "Print", "verbose", "information" ]
518487136985e6c9147a0964e4fde84862f4017c
https://github.com/thephpleague/shunt/blob/518487136985e6c9147a0964e4fde84862f4017c/src/League/Shunt/BaseObject.php#L62-L67
41,808
thephpleague/shunt
src/League/Shunt/BaseObject.php
BaseObject.printDebug
public function printDebug($message) { if ($this->output->getVerbosity() == OutputInterface::VERBOSITY_DEBUG) { $this->printOut('[DEBUG] '.$message); } }
php
public function printDebug($message) { if ($this->output->getVerbosity() == OutputInterface::VERBOSITY_DEBUG) { $this->printOut('[DEBUG] '.$message); } }
[ "public", "function", "printDebug", "(", "$", "message", ")", "{", "if", "(", "$", "this", "->", "output", "->", "getVerbosity", "(", ")", "==", "OutputInterface", "::", "VERBOSITY_DEBUG", ")", "{", "$", "this", "->", "printOut", "(", "'[DEBUG] '", ".", ...
Print debug information @param string
[ "Print", "debug", "information" ]
518487136985e6c9147a0964e4fde84862f4017c
https://github.com/thephpleague/shunt/blob/518487136985e6c9147a0964e4fde84862f4017c/src/League/Shunt/BaseObject.php#L74-L79
41,809
thephpleague/shunt
src/League/Shunt/Auth.php
Auth.parse
public function parse($credential = array()) { if (array_key_exists(self::PUBKEY_FILE, $credential)) { $type = self::PUBKEY_FILE; $data = $credential[self::PUBKEY_FILE]; } elseif (array_key_exists(self::PASSWORD, $credential)) { $type = self::PASSWORD; $data = $credential[self::PASSWORD]; } else { $type = self::NONE; $data = isset($credential[self::NONE]) ? $credential[self::NONE] : array(); } return array($type, $data); }
php
public function parse($credential = array()) { if (array_key_exists(self::PUBKEY_FILE, $credential)) { $type = self::PUBKEY_FILE; $data = $credential[self::PUBKEY_FILE]; } elseif (array_key_exists(self::PASSWORD, $credential)) { $type = self::PASSWORD; $data = $credential[self::PASSWORD]; } else { $type = self::NONE; $data = isset($credential[self::NONE]) ? $credential[self::NONE] : array(); } return array($type, $data); }
[ "public", "function", "parse", "(", "$", "credential", "=", "array", "(", ")", ")", "{", "if", "(", "array_key_exists", "(", "self", "::", "PUBKEY_FILE", ",", "$", "credential", ")", ")", "{", "$", "type", "=", "self", "::", "PUBKEY_FILE", ";", "$", ...
Helper to parse the session @param array @return array
[ "Helper", "to", "parse", "the", "session" ]
518487136985e6c9147a0964e4fde84862f4017c
https://github.com/thephpleague/shunt/blob/518487136985e6c9147a0964e4fde84862f4017c/src/League/Shunt/Auth.php#L74-L88
41,810
rap2hpoutre/similar-text-finder
src/Finder.php
Finder.sortHaystack
protected function sortHaystack() { $sorted_haystack = []; foreach ($this->haystack as $string) { $sorted_haystack[$string] = $this->levenshteinUtf8($this->needle, $string); } // Apply threshold when set. if(!is_null($this->threshold)){ $sorted_haystack = array_filter($sorted_haystack, function ($score){ return $score <= $this->threshold; }); } asort($sorted_haystack); $this->sorted_haystack = $sorted_haystack; }
php
protected function sortHaystack() { $sorted_haystack = []; foreach ($this->haystack as $string) { $sorted_haystack[$string] = $this->levenshteinUtf8($this->needle, $string); } // Apply threshold when set. if(!is_null($this->threshold)){ $sorted_haystack = array_filter($sorted_haystack, function ($score){ return $score <= $this->threshold; }); } asort($sorted_haystack); $this->sorted_haystack = $sorted_haystack; }
[ "protected", "function", "sortHaystack", "(", ")", "{", "$", "sorted_haystack", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "haystack", "as", "$", "string", ")", "{", "$", "sorted_haystack", "[", "$", "string", "]", "=", "$", "this", "->", ...
Sort Haystack. @return void
[ "Sort", "Haystack", "." ]
8e9a5dfc0a35261c02f7f980a6d3cb391087576e
https://github.com/rap2hpoutre/similar-text-finder/blob/8e9a5dfc0a35261c02f7f980a6d3cb391087576e/src/Finder.php#L52-L69
41,811
rap2hpoutre/similar-text-finder
src/Finder.php
Finder.utf8ToExtendedAscii
protected function utf8ToExtendedAscii($str, &$map) { // Find all multi-byte characters (cf. utf-8 encoding specs). $matches = array(); if (!preg_match_all('/[\xC0-\xF7][\x80-\xBF]+/', $str, $matches)) { return $str; // plain ascii string } // Update the encoding map with the characters not already met. foreach ($matches[0] as $mbc) { if (!isset($map[$mbc])) { $map[$mbc] = chr(128 + count($map)); } } // Finally remap non-ascii characters. return strtr($str, $map); }
php
protected function utf8ToExtendedAscii($str, &$map) { // Find all multi-byte characters (cf. utf-8 encoding specs). $matches = array(); if (!preg_match_all('/[\xC0-\xF7][\x80-\xBF]+/', $str, $matches)) { return $str; // plain ascii string } // Update the encoding map with the characters not already met. foreach ($matches[0] as $mbc) { if (!isset($map[$mbc])) { $map[$mbc] = chr(128 + count($map)); } } // Finally remap non-ascii characters. return strtr($str, $map); }
[ "protected", "function", "utf8ToExtendedAscii", "(", "$", "str", ",", "&", "$", "map", ")", "{", "// Find all multi-byte characters (cf. utf-8 encoding specs).", "$", "matches", "=", "array", "(", ")", ";", "if", "(", "!", "preg_match_all", "(", "'/[\\xC0-\\xF7][\\x...
Ensure a string only uses ascii characters. @param string $str @param array $map @return string
[ "Ensure", "a", "string", "only", "uses", "ascii", "characters", "." ]
8e9a5dfc0a35261c02f7f980a6d3cb391087576e
https://github.com/rap2hpoutre/similar-text-finder/blob/8e9a5dfc0a35261c02f7f980a6d3cb391087576e/src/Finder.php#L125-L142
41,812
rap2hpoutre/similar-text-finder
src/Finder.php
Finder.levenshteinUtf8
protected function levenshteinUtf8($string1, $string2) { $charMap = array(); $string1 = $this->utf8ToExtendedAscii($string1, $charMap); $string2 = $this->utf8ToExtendedAscii($string2, $charMap); return levenshtein($string1, $string2); }
php
protected function levenshteinUtf8($string1, $string2) { $charMap = array(); $string1 = $this->utf8ToExtendedAscii($string1, $charMap); $string2 = $this->utf8ToExtendedAscii($string2, $charMap); return levenshtein($string1, $string2); }
[ "protected", "function", "levenshteinUtf8", "(", "$", "string1", ",", "$", "string2", ")", "{", "$", "charMap", "=", "array", "(", ")", ";", "$", "string1", "=", "$", "this", "->", "utf8ToExtendedAscii", "(", "$", "string1", ",", "$", "charMap", ")", "...
Calculate the levenshtein distance between two strings. @param string $string1 @param string $string2 @return int
[ "Calculate", "the", "levenshtein", "distance", "between", "two", "strings", "." ]
8e9a5dfc0a35261c02f7f980a6d3cb391087576e
https://github.com/rap2hpoutre/similar-text-finder/blob/8e9a5dfc0a35261c02f7f980a6d3cb391087576e/src/Finder.php#L151-L158
41,813
jbowens/jBBCode
JBBCode/CodeDefinition.php
CodeDefinition.construct
public static function construct($tagName, $replacementText, $useOption = false, $parseContent = true, $nestLimit = -1, $optionValidator = array(), $bodyValidator = null) { $def = new CodeDefinition(); $def->elCounter = 0; $def->setTagName($tagName); $def->setReplacementText($replacementText); $def->useOption = $useOption; $def->parseContent = $parseContent; $def->nestLimit = $nestLimit; $def->optionValidator = $optionValidator; $def->bodyValidator = $bodyValidator; return $def; }
php
public static function construct($tagName, $replacementText, $useOption = false, $parseContent = true, $nestLimit = -1, $optionValidator = array(), $bodyValidator = null) { $def = new CodeDefinition(); $def->elCounter = 0; $def->setTagName($tagName); $def->setReplacementText($replacementText); $def->useOption = $useOption; $def->parseContent = $parseContent; $def->nestLimit = $nestLimit; $def->optionValidator = $optionValidator; $def->bodyValidator = $bodyValidator; return $def; }
[ "public", "static", "function", "construct", "(", "$", "tagName", ",", "$", "replacementText", ",", "$", "useOption", "=", "false", ",", "$", "parseContent", "=", "true", ",", "$", "nestLimit", "=", "-", "1", ",", "$", "optionValidator", "=", "array", "(...
Constructs a new CodeDefinition.
[ "Constructs", "a", "new", "CodeDefinition", "." ]
740092873a687e61b980d2a094f6323b0d3b273c
https://github.com/jbowens/jBBCode/blob/740092873a687e61b980d2a094f6323b0d3b273c/JBBCode/CodeDefinition.php#L41-L55
41,814
jbowens/jBBCode
JBBCode/CodeDefinition.php
CodeDefinition.hasValidInputs
public function hasValidInputs(ElementNode $el) { if ($this->usesOption() && $this->optionValidator) { $att = $el->getAttribute(); foreach ($att as $name => $value) { if (isset($this->optionValidator[$name]) && !$this->optionValidator[$name]->validate($value)) { return false; } } } if (!$this->parseContent() && $this->bodyValidator) { /* We only evaluate the content if we're not parsing the content. */ $content = ""; foreach ($el->getChildren() as $child) { $content .= $child->getAsBBCode(); } if (!$this->bodyValidator->validate($content)) { /* The content of the element is not valid. */ return false; } } return true; }
php
public function hasValidInputs(ElementNode $el) { if ($this->usesOption() && $this->optionValidator) { $att = $el->getAttribute(); foreach ($att as $name => $value) { if (isset($this->optionValidator[$name]) && !$this->optionValidator[$name]->validate($value)) { return false; } } } if (!$this->parseContent() && $this->bodyValidator) { /* We only evaluate the content if we're not parsing the content. */ $content = ""; foreach ($el->getChildren() as $child) { $content .= $child->getAsBBCode(); } if (!$this->bodyValidator->validate($content)) { /* The content of the element is not valid. */ return false; } } return true; }
[ "public", "function", "hasValidInputs", "(", "ElementNode", "$", "el", ")", "{", "if", "(", "$", "this", "->", "usesOption", "(", ")", "&&", "$", "this", "->", "optionValidator", ")", "{", "$", "att", "=", "$", "el", "->", "getAttribute", "(", ")", "...
Determines if the arguments to the given element are valid based on any validators attached to this CodeDefinition. @param ElementNode $el the ElementNode to validate @return boolean true if the ElementNode's {option} and {param} are OK, false if they're not
[ "Determines", "if", "the", "arguments", "to", "the", "given", "element", "are", "valid", "based", "on", "any", "validators", "attached", "to", "this", "CodeDefinition", "." ]
740092873a687e61b980d2a094f6323b0d3b273c
https://github.com/jbowens/jBBCode/blob/740092873a687e61b980d2a094f6323b0d3b273c/JBBCode/CodeDefinition.php#L84-L109
41,815
jbowens/jBBCode
JBBCode/CodeDefinition.php
CodeDefinition.asText
public function asText(ElementNode $el) { if (!$this->hasValidInputs($el)) { return $el->getAsBBCode(); } $s = ""; foreach ($el->getChildren() as $child) { $s .= $child->getAsText(); } return $s; }
php
public function asText(ElementNode $el) { if (!$this->hasValidInputs($el)) { return $el->getAsBBCode(); } $s = ""; foreach ($el->getChildren() as $child) { $s .= $child->getAsText(); } return $s; }
[ "public", "function", "asText", "(", "ElementNode", "$", "el", ")", "{", "if", "(", "!", "$", "this", "->", "hasValidInputs", "(", "$", "el", ")", ")", "{", "return", "$", "el", "->", "getAsBBCode", "(", ")", ";", "}", "$", "s", "=", "\"\"", ";",...
Accepts an ElementNode that is defined by this CodeDefinition and returns the text representation of the element. This may be overridden by a custom CodeDefinition. @param ElementNode $el the element to return a text representation of @return string the text representation of $el
[ "Accepts", "an", "ElementNode", "that", "is", "defined", "by", "this", "CodeDefinition", "and", "returns", "the", "text", "representation", "of", "the", "element", ".", "This", "may", "be", "overridden", "by", "a", "custom", "CodeDefinition", "." ]
740092873a687e61b980d2a094f6323b0d3b273c
https://github.com/jbowens/jBBCode/blob/740092873a687e61b980d2a094f6323b0d3b273c/JBBCode/CodeDefinition.php#L171-L182
41,816
jbowens/jBBCode
JBBCode/Parser.php
Parser.addCodeDefinition
public function addCodeDefinition(CodeDefinition $definition) { $this->bbcodes[$definition->getTagName()][$definition->usesOption()] = $definition; return $this; }
php
public function addCodeDefinition(CodeDefinition $definition) { $this->bbcodes[$definition->getTagName()][$definition->usesOption()] = $definition; return $this; }
[ "public", "function", "addCodeDefinition", "(", "CodeDefinition", "$", "definition", ")", "{", "$", "this", "->", "bbcodes", "[", "$", "definition", "->", "getTagName", "(", ")", "]", "[", "$", "definition", "->", "usesOption", "(", ")", "]", "=", "$", "...
Adds a complex bbcode definition. You may subclass the CodeDefinition class, instantiate a definition of your new class and add it to the parser through this method. @param CodeDefinition $definition the bbcode definition to add @return Parser
[ "Adds", "a", "complex", "bbcode", "definition", ".", "You", "may", "subclass", "the", "CodeDefinition", "class", "instantiate", "a", "definition", "of", "your", "new", "class", "and", "add", "it", "to", "the", "parser", "through", "this", "method", "." ]
740092873a687e61b980d2a094f6323b0d3b273c
https://github.com/jbowens/jBBCode/blob/740092873a687e61b980d2a094f6323b0d3b273c/JBBCode/Parser.php#L92-L96
41,817
jbowens/jBBCode
JBBCode/Parser.php
Parser.addCodeDefinitionSet
public function addCodeDefinitionSet(CodeDefinitionSet $set) { foreach ($set->getCodeDefinitions() as $def) { $this->addCodeDefinition($def); } return $this; }
php
public function addCodeDefinitionSet(CodeDefinitionSet $set) { foreach ($set->getCodeDefinitions() as $def) { $this->addCodeDefinition($def); } return $this; }
[ "public", "function", "addCodeDefinitionSet", "(", "CodeDefinitionSet", "$", "set", ")", "{", "foreach", "(", "$", "set", "->", "getCodeDefinitions", "(", ")", "as", "$", "def", ")", "{", "$", "this", "->", "addCodeDefinition", "(", "$", "def", ")", ";", ...
Adds a set of CodeDefinitions. @param CodeDefinitionSet $set the set of definitions to add @return Parser
[ "Adds", "a", "set", "of", "CodeDefinitions", "." ]
740092873a687e61b980d2a094f6323b0d3b273c
https://github.com/jbowens/jBBCode/blob/740092873a687e61b980d2a094f6323b0d3b273c/JBBCode/Parser.php#L105-L112
41,818
jbowens/jBBCode
JBBCode/Parser.php
Parser.parseStartState
protected function parseStartState(ElementNode $parent, Tokenizer $tokenizer) { $next = $tokenizer->next(); if ('[' == $next) { return $this->parseTagOpen($parent, $tokenizer); } else { $this->createTextNode($parent, $next); /* Drop back into the main parse loop which will call this * same method again. */ return $parent; } }
php
protected function parseStartState(ElementNode $parent, Tokenizer $tokenizer) { $next = $tokenizer->next(); if ('[' == $next) { return $this->parseTagOpen($parent, $tokenizer); } else { $this->createTextNode($parent, $next); /* Drop back into the main parse loop which will call this * same method again. */ return $parent; } }
[ "protected", "function", "parseStartState", "(", "ElementNode", "$", "parent", ",", "Tokenizer", "$", "tokenizer", ")", "{", "$", "next", "=", "$", "tokenizer", "->", "next", "(", ")", ";", "if", "(", "'['", "==", "$", "next", ")", "{", "return", "$", ...
jBBCode parsing logic is loosely modelled after a FSM. While not every function maps to a unique DFSM state, each function handles the logic of one or more FSM states. This function handles the beginning parse state when we're not currently in a tag name. @param ElementNode $parent the current parent node we're under @param Tokenizer $tokenizer the tokenizer we're using @return ElementNode the new parent we should use for the next iteration.
[ "jBBCode", "parsing", "logic", "is", "loosely", "modelled", "after", "a", "FSM", ".", "While", "not", "every", "function", "maps", "to", "a", "unique", "DFSM", "state", "each", "function", "handles", "the", "logic", "of", "one", "or", "more", "FSM", "state...
740092873a687e61b980d2a094f6323b0d3b273c
https://github.com/jbowens/jBBCode/blob/740092873a687e61b980d2a094f6323b0d3b273c/JBBCode/Parser.php#L294-L306
41,819
jbowens/jBBCode
JBBCode/Parser.php
Parser.parseTagOpen
protected function parseTagOpen(ElementNode $parent, Tokenizer $tokenizer) { if (!$tokenizer->hasNext()) { /* The [ that sent us to this state was just a trailing [, not the * opening for a new tag. Treat it as such. */ $this->createTextNode($parent, '['); return $parent; } $next = $tokenizer->next(); /* This while loop could be replaced by a recursive call to this same method, * which would likely be a lot clearer but I decided to use a while loop to * prevent stack overflow with a string like [[[[[[[[[...[[[. */ while ('[' == $next) { /* The previous [ was just a random bracket that should be treated as text. * Continue until we get a non open bracket. */ $this->createTextNode($parent, '['); if (!$tokenizer->hasNext()) { $this->createTextNode($parent, '['); return $parent; } $next = $tokenizer->next(); } if (!$tokenizer->hasNext()) { $this->createTextNode($parent, '['.$next); return $parent; } $after_next = $tokenizer->next(); $tokenizer->stepBack(); if ($after_next != ']') { $this->createTextNode($parent, '['.$next); return $parent; } /* At this point $next is either ']' or plain text. */ if (']' == $next) { $this->createTextNode($parent, '['); $this->createTextNode($parent, ']'); return $parent; } else { /* $next is plain text... likely a tag name. */ return $this->parseTag($parent, $tokenizer, $next); } }
php
protected function parseTagOpen(ElementNode $parent, Tokenizer $tokenizer) { if (!$tokenizer->hasNext()) { /* The [ that sent us to this state was just a trailing [, not the * opening for a new tag. Treat it as such. */ $this->createTextNode($parent, '['); return $parent; } $next = $tokenizer->next(); /* This while loop could be replaced by a recursive call to this same method, * which would likely be a lot clearer but I decided to use a while loop to * prevent stack overflow with a string like [[[[[[[[[...[[[. */ while ('[' == $next) { /* The previous [ was just a random bracket that should be treated as text. * Continue until we get a non open bracket. */ $this->createTextNode($parent, '['); if (!$tokenizer->hasNext()) { $this->createTextNode($parent, '['); return $parent; } $next = $tokenizer->next(); } if (!$tokenizer->hasNext()) { $this->createTextNode($parent, '['.$next); return $parent; } $after_next = $tokenizer->next(); $tokenizer->stepBack(); if ($after_next != ']') { $this->createTextNode($parent, '['.$next); return $parent; } /* At this point $next is either ']' or plain text. */ if (']' == $next) { $this->createTextNode($parent, '['); $this->createTextNode($parent, ']'); return $parent; } else { /* $next is plain text... likely a tag name. */ return $this->parseTag($parent, $tokenizer, $next); } }
[ "protected", "function", "parseTagOpen", "(", "ElementNode", "$", "parent", ",", "Tokenizer", "$", "tokenizer", ")", "{", "if", "(", "!", "$", "tokenizer", "->", "hasNext", "(", ")", ")", "{", "/* The [ that sent us to this state was just a trailing [, not the\n ...
This function handles parsing the beginnings of an open tag. When we see a [ at an appropriate time, this function is entered. @param ElementNode $parent the current parent node @param Tokenizer $tokenizer the tokenizer we're using @return ElementNode the new parent node
[ "This", "function", "handles", "parsing", "the", "beginnings", "of", "an", "open", "tag", ".", "When", "we", "see", "a", "[", "at", "an", "appropriate", "time", "this", "function", "is", "entered", "." ]
740092873a687e61b980d2a094f6323b0d3b273c
https://github.com/jbowens/jBBCode/blob/740092873a687e61b980d2a094f6323b0d3b273c/JBBCode/Parser.php#L317-L365
41,820
jbowens/jBBCode
JBBCode/Parser.php
Parser.parseTag
protected function parseTag(ElementNode $parent, Tokenizer $tokenizer, $tagContent) { if (!$tokenizer->hasNext() || ($next = $tokenizer->next()) != ']') { /* This is a malformed tag. Both the previous [ and the tagContent * is really just plain text. */ $this->createTextNode($parent, '['); $this->createTextNode($parent, $tagContent); return $parent; } /* This is a well-formed tag consisting of [something] or [/something], but * we still need to ensure that 'something' is a valid tag name. Additionally, * if it's a closing tag, we need to ensure that there was a previous matching * opening tag. */ /* There could be attributes. */ list($tmpTagName, $options) = $this->parseOptions($tagContent); // $tagPieces = explode('=', $tagContent); // $tmpTagName = $tagPieces[0]; $actualTagName = $tmpTagName; if ('' != $tmpTagName && '/' == $tmpTagName[0]) { /* This is a closing tag name. */ $actualTagName = substr($tmpTagName, 1); } if ('' != $tmpTagName && '/' == $tmpTagName[0]) { /* This is attempting to close an open tag. We must verify that there exists an * open tag of the same type and that there is no option (options on closing * tags don't make any sense). */ $elToClose = $parent->closestParentOfType($actualTagName); if (null == $elToClose || count($options) > 1) { /* Closing an unopened tag or has an option. Treat everything as plain text. */ $this->createTextNode($parent, '['); $this->createTextNode($parent, $tagContent); $this->createTextNode($parent, ']'); return $parent; } else { /* We're closing $elToClose. In order to do that, we just need to return * $elToClose's parent, since that will change our effective parent to be * elToClose's parent. */ return $elToClose->getParent(); } } /* Verify that this is a known bbcode tag name. */ if ('' == $actualTagName || !$this->codeExists($actualTagName, !empty($options))) { /* This is an invalid tag name! Treat everything we've seen as plain text. */ $this->createTextNode($parent, '['); $this->createTextNode($parent, $tagContent); $this->createTextNode($parent, ']'); return $parent; } /* If we're here, this is a valid opening tag. Let's make a new node for it. */ $el = new ElementNode(); $code = $this->getCode($actualTagName, !empty($options)); $el->setCodeDefinition($code); if (!empty($options)) { /* We have an attribute we should save. */ $el->setAttribute($options); } $parent->addChild($el); return $el; }
php
protected function parseTag(ElementNode $parent, Tokenizer $tokenizer, $tagContent) { if (!$tokenizer->hasNext() || ($next = $tokenizer->next()) != ']') { /* This is a malformed tag. Both the previous [ and the tagContent * is really just plain text. */ $this->createTextNode($parent, '['); $this->createTextNode($parent, $tagContent); return $parent; } /* This is a well-formed tag consisting of [something] or [/something], but * we still need to ensure that 'something' is a valid tag name. Additionally, * if it's a closing tag, we need to ensure that there was a previous matching * opening tag. */ /* There could be attributes. */ list($tmpTagName, $options) = $this->parseOptions($tagContent); // $tagPieces = explode('=', $tagContent); // $tmpTagName = $tagPieces[0]; $actualTagName = $tmpTagName; if ('' != $tmpTagName && '/' == $tmpTagName[0]) { /* This is a closing tag name. */ $actualTagName = substr($tmpTagName, 1); } if ('' != $tmpTagName && '/' == $tmpTagName[0]) { /* This is attempting to close an open tag. We must verify that there exists an * open tag of the same type and that there is no option (options on closing * tags don't make any sense). */ $elToClose = $parent->closestParentOfType($actualTagName); if (null == $elToClose || count($options) > 1) { /* Closing an unopened tag or has an option. Treat everything as plain text. */ $this->createTextNode($parent, '['); $this->createTextNode($parent, $tagContent); $this->createTextNode($parent, ']'); return $parent; } else { /* We're closing $elToClose. In order to do that, we just need to return * $elToClose's parent, since that will change our effective parent to be * elToClose's parent. */ return $elToClose->getParent(); } } /* Verify that this is a known bbcode tag name. */ if ('' == $actualTagName || !$this->codeExists($actualTagName, !empty($options))) { /* This is an invalid tag name! Treat everything we've seen as plain text. */ $this->createTextNode($parent, '['); $this->createTextNode($parent, $tagContent); $this->createTextNode($parent, ']'); return $parent; } /* If we're here, this is a valid opening tag. Let's make a new node for it. */ $el = new ElementNode(); $code = $this->getCode($actualTagName, !empty($options)); $el->setCodeDefinition($code); if (!empty($options)) { /* We have an attribute we should save. */ $el->setAttribute($options); } $parent->addChild($el); return $el; }
[ "protected", "function", "parseTag", "(", "ElementNode", "$", "parent", ",", "Tokenizer", "$", "tokenizer", ",", "$", "tagContent", ")", "{", "if", "(", "!", "$", "tokenizer", "->", "hasNext", "(", ")", "||", "(", "$", "next", "=", "$", "tokenizer", "-...
This is the next step in parsing a tag. It's possible for it to still be invalid at this point but many of the basic invalid tag name conditions have already been handled. @param ElementNode $parent the current parent element @param Tokenizer $tokenizer the tokenizer we're using @param string $tagContent the text between the [ and the ], assuming there is actually a ] @return ElementNode the new parent element
[ "This", "is", "the", "next", "step", "in", "parsing", "a", "tag", ".", "It", "s", "possible", "for", "it", "to", "still", "be", "invalid", "at", "this", "point", "but", "many", "of", "the", "basic", "invalid", "tag", "name", "conditions", "have", "alre...
740092873a687e61b980d2a094f6323b0d3b273c
https://github.com/jbowens/jBBCode/blob/740092873a687e61b980d2a094f6323b0d3b273c/JBBCode/Parser.php#L530-L595
41,821
jbowens/jBBCode
JBBCode/Parser.php
Parser.parseAsTextUntilClose
protected function parseAsTextUntilClose(ElementNode $parent, Tokenizer $tokenizer) { /* $parent's code definition doesn't allow its contents to be parsed. Here we use * a sliding window of three tokens until we find [ /tagname ], signifying the * end of the parent. */ if (!$tokenizer->hasNext()) { return $parent; } $prevPrev = $tokenizer->next(); if (!$tokenizer->hasNext()) { $this->createTextNode($parent, $prevPrev); return $parent; } $prev = $tokenizer->next(); if (!$tokenizer->hasNext()) { $this->createTextNode($parent, $prevPrev); $this->createTextNode($parent, $prev); return $parent; } $curr = $tokenizer->next(); while ('[' != $prevPrev || '/'.$parent->getTagName() != strtolower($prev) || ']' != $curr) { $this->createTextNode($parent, $prevPrev); $prevPrev = $prev; $prev = $curr; if (!$tokenizer->hasNext()) { $this->createTextNode($parent, $prevPrev); $this->createTextNode($parent, $prev); return $parent; } $curr = $tokenizer->next(); } }
php
protected function parseAsTextUntilClose(ElementNode $parent, Tokenizer $tokenizer) { /* $parent's code definition doesn't allow its contents to be parsed. Here we use * a sliding window of three tokens until we find [ /tagname ], signifying the * end of the parent. */ if (!$tokenizer->hasNext()) { return $parent; } $prevPrev = $tokenizer->next(); if (!$tokenizer->hasNext()) { $this->createTextNode($parent, $prevPrev); return $parent; } $prev = $tokenizer->next(); if (!$tokenizer->hasNext()) { $this->createTextNode($parent, $prevPrev); $this->createTextNode($parent, $prev); return $parent; } $curr = $tokenizer->next(); while ('[' != $prevPrev || '/'.$parent->getTagName() != strtolower($prev) || ']' != $curr) { $this->createTextNode($parent, $prevPrev); $prevPrev = $prev; $prev = $curr; if (!$tokenizer->hasNext()) { $this->createTextNode($parent, $prevPrev); $this->createTextNode($parent, $prev); return $parent; } $curr = $tokenizer->next(); } }
[ "protected", "function", "parseAsTextUntilClose", "(", "ElementNode", "$", "parent", ",", "Tokenizer", "$", "tokenizer", ")", "{", "/* $parent's code definition doesn't allow its contents to be parsed. Here we use\n * a sliding window of three tokens until we find [ /tagname ], sig...
Handles parsing elements whose CodeDefinitions disable parsing of element contents. This function uses a rolling window of 3 tokens until it finds the appropriate closing tag or reaches the end of the token stream. @param ElementNode $parent the current parent element @param Tokenizer $tokenizer the tokenizer we're using @return ElementNode the new parent element
[ "Handles", "parsing", "elements", "whose", "CodeDefinitions", "disable", "parsing", "of", "element", "contents", ".", "This", "function", "uses", "a", "rolling", "window", "of", "3", "tokens", "until", "it", "finds", "the", "appropriate", "closing", "tag", "or",...
740092873a687e61b980d2a094f6323b0d3b273c
https://github.com/jbowens/jBBCode/blob/740092873a687e61b980d2a094f6323b0d3b273c/JBBCode/Parser.php#L607-L639
41,822
jbowens/jBBCode
JBBCode/CodeDefinitionBuilder.php
CodeDefinitionBuilder.setNestLimit
public function setNestLimit($limit) { if (!is_int($limit) || ($limit <= 0 && -1 != $limit)) { throw new \InvalidArgumentException("A nest limit must be a positive integer " . "or -1."); } $this->nestLimit = $limit; return $this; }
php
public function setNestLimit($limit) { if (!is_int($limit) || ($limit <= 0 && -1 != $limit)) { throw new \InvalidArgumentException("A nest limit must be a positive integer " . "or -1."); } $this->nestLimit = $limit; return $this; }
[ "public", "function", "setNestLimit", "(", "$", "limit", ")", "{", "if", "(", "!", "is_int", "(", "$", "limit", ")", "||", "(", "$", "limit", "<=", "0", "&&", "-", "1", "!=", "$", "limit", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentExcept...
Sets the nest limit for this code definition. @param integer $limit a positive integer, or -1 if there is no limit. @throws \InvalidArgumentException if the nest limit is invalid @return self
[ "Sets", "the", "nest", "limit", "for", "this", "code", "definition", "." ]
740092873a687e61b980d2a094f6323b0d3b273c
https://github.com/jbowens/jBBCode/blob/740092873a687e61b980d2a094f6323b0d3b273c/JBBCode/CodeDefinitionBuilder.php#L101-L109
41,823
jbowens/jBBCode
JBBCode/CodeDefinitionBuilder.php
CodeDefinitionBuilder.setOptionValidator
public function setOptionValidator(\JBBCode\InputValidator $validator, $option=null) { if (empty($option)) { $option = $this->tagName; } $this->optionValidator[$option] = $validator; return $this; }
php
public function setOptionValidator(\JBBCode\InputValidator $validator, $option=null) { if (empty($option)) { $option = $this->tagName; } $this->optionValidator[$option] = $validator; return $this; }
[ "public", "function", "setOptionValidator", "(", "\\", "JBBCode", "\\", "InputValidator", "$", "validator", ",", "$", "option", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "option", ")", ")", "{", "$", "option", "=", "$", "this", "->", "tagNam...
Sets the InputValidator that option arguments should be validated with. @param InputValidator $validator the InputValidator instance to use @return self
[ "Sets", "the", "InputValidator", "that", "option", "arguments", "should", "be", "validated", "with", "." ]
740092873a687e61b980d2a094f6323b0d3b273c
https://github.com/jbowens/jBBCode/blob/740092873a687e61b980d2a094f6323b0d3b273c/JBBCode/CodeDefinitionBuilder.php#L117-L124
41,824
jbowens/jBBCode
JBBCode/CodeDefinitionBuilder.php
CodeDefinitionBuilder.build
public function build() { $definition = CodeDefinition::construct($this->tagName, $this->replacementText, $this->useOption, $this->parseContent, $this->nestLimit, $this->optionValidator, $this->bodyValidator); return $definition; }
php
public function build() { $definition = CodeDefinition::construct($this->tagName, $this->replacementText, $this->useOption, $this->parseContent, $this->nestLimit, $this->optionValidator, $this->bodyValidator); return $definition; }
[ "public", "function", "build", "(", ")", "{", "$", "definition", "=", "CodeDefinition", "::", "construct", "(", "$", "this", "->", "tagName", ",", "$", "this", "->", "replacementText", ",", "$", "this", "->", "useOption", ",", "$", "this", "->", "parseCo...
Builds a CodeDefinition with the current state of the builder. @return CodeDefinition a new CodeDefinition instance
[ "Builds", "a", "CodeDefinition", "with", "the", "current", "state", "of", "the", "builder", "." ]
740092873a687e61b980d2a094f6323b0d3b273c
https://github.com/jbowens/jBBCode/blob/740092873a687e61b980d2a094f6323b0d3b273c/JBBCode/CodeDefinitionBuilder.php#L163-L173
41,825
cerbero90/query-filters
src/QueryFilters.php
QueryFilters.applyToQuery
public function applyToQuery(Builder $query) { $this->query = $query; foreach ($this->request->all() as $filter => $value) { $method = Str::camel($filter); if ($this->filterCanBeApplied($method, $value)) { call_user_func([$this, $method], $value); } } return $query; }
php
public function applyToQuery(Builder $query) { $this->query = $query; foreach ($this->request->all() as $filter => $value) { $method = Str::camel($filter); if ($this->filterCanBeApplied($method, $value)) { call_user_func([$this, $method], $value); } } return $query; }
[ "public", "function", "applyToQuery", "(", "Builder", "$", "query", ")", "{", "$", "this", "->", "query", "=", "$", "query", ";", "foreach", "(", "$", "this", "->", "request", "->", "all", "(", ")", "as", "$", "filter", "=>", "$", "value", ")", "{"...
Apply all the filters to the given query. @param Illuminate\Database\Eloquent\Builder $query @return Illuminate\Database\Eloquent\Builder
[ "Apply", "all", "the", "filters", "to", "the", "given", "query", "." ]
ce37f01330467b90ae1939802703d4b8a72e811f
https://github.com/cerbero90/query-filters/blob/ce37f01330467b90ae1939802703d4b8a72e811f/src/QueryFilters.php#L66-L79
41,826
cerbero90/query-filters
src/QueryFilters.php
QueryFilters.filterCanBeApplied
protected function filterCanBeApplied($filter, $value) { $filterExists = method_exists($this, $filter); $hasValue = $value !== '' && $value !== null; $valueIsLegit = $hasValue || in_array($filter, $this->implicitFilters); return $filterExists && $valueIsLegit; }
php
protected function filterCanBeApplied($filter, $value) { $filterExists = method_exists($this, $filter); $hasValue = $value !== '' && $value !== null; $valueIsLegit = $hasValue || in_array($filter, $this->implicitFilters); return $filterExists && $valueIsLegit; }
[ "protected", "function", "filterCanBeApplied", "(", "$", "filter", ",", "$", "value", ")", "{", "$", "filterExists", "=", "method_exists", "(", "$", "this", ",", "$", "filter", ")", ";", "$", "hasValue", "=", "$", "value", "!==", "''", "&&", "$", "valu...
Determine whether the given filter can be applied with the provided value. @param string $filter @param mixed $value @return boolean
[ "Determine", "whether", "the", "given", "filter", "can", "be", "applied", "with", "the", "provided", "value", "." ]
ce37f01330467b90ae1939802703d4b8a72e811f
https://github.com/cerbero90/query-filters/blob/ce37f01330467b90ae1939802703d4b8a72e811f/src/QueryFilters.php#L88-L95
41,827
eloquent/phony
src/Reflection/FunctionSignatureInspector.php
FunctionSignatureInspector.instance
public static function instance(): self { if (!self::$instance) { self::$instance = new self(FeatureDetector::instance()); } return self::$instance; }
php
public static function instance(): self { if (!self::$instance) { self::$instance = new self(FeatureDetector::instance()); } return self::$instance; }
[ "public", "static", "function", "instance", "(", ")", ":", "self", "{", "if", "(", "!", "self", "::", "$", "instance", ")", "{", "self", "::", "$", "instance", "=", "new", "self", "(", "FeatureDetector", "::", "instance", "(", ")", ")", ";", "}", "...
Get the static instance of this inspector. @return PhpFunctionSignatureInspector The static inspector.
[ "Get", "the", "static", "instance", "of", "this", "inspector", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Reflection/FunctionSignatureInspector.php#L19-L26
41,828
eloquent/phony
src/Reflection/FunctionSignatureInspector.php
FunctionSignatureInspector.signature
public function signature(ReflectionFunctionAbstract $function): array { $isMatch = preg_match_all( static::PARAMETER_PATTERN, (string) $function, $matches, PREG_SET_ORDER ); if (!$isMatch) { return []; } $parameters = $function->getParameters(); $signature = []; $index = -1; foreach ($matches as $match) { $parameter = $parameters[++$index]; $typehint = $match[2]; if ('self ' === $typehint) { $typehint = '\\' . $parameter->getDeclaringClass()->getName() . ' '; } elseif ( '' !== $typehint && 'array ' !== $typehint && 'bool ' !== $typehint && 'callable ' !== $typehint && 'int ' !== $typehint && 'iterable ' !== $typehint && ( !$this->isObjectTypeHintSupported || 'object ' !== $typehint ) ) { if ( 'integer ' === $typehint && $parameter->getType()->isBuiltin() ) { $typehint = 'int '; } elseif ( 'boolean ' === $typehint && $parameter->getType()->isBuiltin() ) { $typehint = 'bool '; } elseif ('float ' !== $typehint && 'string ' !== $typehint) { $typehint = '\\' . $typehint; } } $byReference = $match[4]; if ($parameter->isVariadic()) { $variadic = '...'; $optional = false; } else { $variadic = ''; $optional = 'optional' === $match[1]; } if (isset($match[6])) { if (' = NULL' === $match[6]) { $defaultValue = ' = null'; } else { $defaultValue = ' = ' . var_export($parameter->getDefaultValue(), true); } } elseif ($optional || $match[3]) { $defaultValue = ' = null'; } else { $defaultValue = ''; } $signature[$match[5]] = [$typehint, $byReference, $variadic, $defaultValue]; } return $signature; }
php
public function signature(ReflectionFunctionAbstract $function): array { $isMatch = preg_match_all( static::PARAMETER_PATTERN, (string) $function, $matches, PREG_SET_ORDER ); if (!$isMatch) { return []; } $parameters = $function->getParameters(); $signature = []; $index = -1; foreach ($matches as $match) { $parameter = $parameters[++$index]; $typehint = $match[2]; if ('self ' === $typehint) { $typehint = '\\' . $parameter->getDeclaringClass()->getName() . ' '; } elseif ( '' !== $typehint && 'array ' !== $typehint && 'bool ' !== $typehint && 'callable ' !== $typehint && 'int ' !== $typehint && 'iterable ' !== $typehint && ( !$this->isObjectTypeHintSupported || 'object ' !== $typehint ) ) { if ( 'integer ' === $typehint && $parameter->getType()->isBuiltin() ) { $typehint = 'int '; } elseif ( 'boolean ' === $typehint && $parameter->getType()->isBuiltin() ) { $typehint = 'bool '; } elseif ('float ' !== $typehint && 'string ' !== $typehint) { $typehint = '\\' . $typehint; } } $byReference = $match[4]; if ($parameter->isVariadic()) { $variadic = '...'; $optional = false; } else { $variadic = ''; $optional = 'optional' === $match[1]; } if (isset($match[6])) { if (' = NULL' === $match[6]) { $defaultValue = ' = null'; } else { $defaultValue = ' = ' . var_export($parameter->getDefaultValue(), true); } } elseif ($optional || $match[3]) { $defaultValue = ' = null'; } else { $defaultValue = ''; } $signature[$match[5]] = [$typehint, $byReference, $variadic, $defaultValue]; } return $signature; }
[ "public", "function", "signature", "(", "ReflectionFunctionAbstract", "$", "function", ")", ":", "array", "{", "$", "isMatch", "=", "preg_match_all", "(", "static", "::", "PARAMETER_PATTERN", ",", "(", "string", ")", "$", "function", ",", "$", "matches", ",", ...
Get the function signature of the supplied function. @param ReflectionFunctionAbstract $function The function. @return array<string,array<string>> The function signature.
[ "Get", "the", "function", "signature", "of", "the", "supplied", "function", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Reflection/FunctionSignatureInspector.php#L48-L128
41,829
eloquent/phony
src/Verification/IterableVerifier.php
IterableVerifier.firstCall
public function firstCall(): Call { if (isset($this->calls[0])) { return $this->callVerifierFactory->fromCall($this->calls[0]); } throw new UndefinedCallException(0); }
php
public function firstCall(): Call { if (isset($this->calls[0])) { return $this->callVerifierFactory->fromCall($this->calls[0]); } throw new UndefinedCallException(0); }
[ "public", "function", "firstCall", "(", ")", ":", "Call", "{", "if", "(", "isset", "(", "$", "this", "->", "calls", "[", "0", "]", ")", ")", "{", "return", "$", "this", "->", "callVerifierFactory", "->", "fromCall", "(", "$", "this", "->", "calls", ...
Get the first call. @return Call The call. @throws UndefinedCallException If there are no calls.
[ "Get", "the", "first", "call", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Verification/IterableVerifier.php#L186-L193
41,830
eloquent/phony
src/Verification/IterableVerifier.php
IterableVerifier.checkUsed
public function checkUsed(): ?EventCollection { $cardinality = $this->resetCardinality(); if ($this->subject instanceof Call) { $cardinality->assertSingular(); } $matchingEvents = []; $matchCount = 0; foreach ($this->calls as $call) { foreach ($call->iterableEvents() as $event) { if ($event instanceof UsedEvent) { $matchingEvents[] = $event; ++$matchCount; } } } if ($cardinality->matches($matchCount, $this->callCount)) { return $this->assertionRecorder->createSuccess($matchingEvents); } return null; }
php
public function checkUsed(): ?EventCollection { $cardinality = $this->resetCardinality(); if ($this->subject instanceof Call) { $cardinality->assertSingular(); } $matchingEvents = []; $matchCount = 0; foreach ($this->calls as $call) { foreach ($call->iterableEvents() as $event) { if ($event instanceof UsedEvent) { $matchingEvents[] = $event; ++$matchCount; } } } if ($cardinality->matches($matchCount, $this->callCount)) { return $this->assertionRecorder->createSuccess($matchingEvents); } return null; }
[ "public", "function", "checkUsed", "(", ")", ":", "?", "EventCollection", "{", "$", "cardinality", "=", "$", "this", "->", "resetCardinality", "(", ")", ";", "if", "(", "$", "this", "->", "subject", "instanceof", "Call", ")", "{", "$", "cardinality", "->...
Checks if iteration of the subject commenced. @return EventCollection|null The result.
[ "Checks", "if", "iteration", "of", "the", "subject", "commenced", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Verification/IterableVerifier.php#L246-L271
41,831
eloquent/phony
src/Verification/IterableVerifier.php
IterableVerifier.used
public function used(): ?EventCollection { $cardinality = $this->cardinality; if ($result = $this->checkUsed()) { return $result; } return $this->assertionRecorder->createFailure( $this->assertionRenderer->renderIterableUsed( $this->subject, $cardinality, $this->isGenerator ) ); }
php
public function used(): ?EventCollection { $cardinality = $this->cardinality; if ($result = $this->checkUsed()) { return $result; } return $this->assertionRecorder->createFailure( $this->assertionRenderer->renderIterableUsed( $this->subject, $cardinality, $this->isGenerator ) ); }
[ "public", "function", "used", "(", ")", ":", "?", "EventCollection", "{", "$", "cardinality", "=", "$", "this", "->", "cardinality", ";", "if", "(", "$", "result", "=", "$", "this", "->", "checkUsed", "(", ")", ")", "{", "return", "$", "result", ";",...
Throws an exception unless iteration of the subject commenced. @return EventCollection|null The result, or null if the assertion recorder does not throw exceptions. @throws Throwable If the assertion fails, and the assertion recorder throws exceptions.
[ "Throws", "an", "exception", "unless", "iteration", "of", "the", "subject", "commenced", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Verification/IterableVerifier.php#L279-L294
41,832
eloquent/phony
src/Verification/IterableVerifier.php
IterableVerifier.checkProduced
public function checkProduced( $keyOrValue = null, $value = null ): ?EventCollection { $cardinality = $this->resetCardinality(); $argumentCount = func_num_args(); if (0 === $argumentCount) { $checkKey = false; $checkValue = false; } elseif (1 === $argumentCount) { $checkKey = false; $checkValue = true; $value = $this->matcherFactory->adapt($keyOrValue); } else { $checkKey = true; $checkValue = true; $key = $this->matcherFactory->adapt($keyOrValue); $value = $this->matcherFactory->adapt($value); } $isCall = $this->subject instanceof Call; $matchingEvents = []; $matchCount = 0; $eventCount = 0; foreach ($this->calls as $call) { $isMatchingCall = false; foreach ($call->iterableEvents() as $event) { if ($event instanceof ProducedEvent) { ++$eventCount; if ($checkKey && !$key->matches($event->key())) { continue; } if ($checkValue && !$value->matches($event->value())) { continue; } $matchingEvents[] = $event; $isMatchingCall = true; if ($isCall) { ++$matchCount; } } } if (!$isCall && $isMatchingCall) { ++$matchCount; } } if ($isCall) { $totalCount = $eventCount; } else { $totalCount = $this->callCount; } if ($cardinality->matches($matchCount, $totalCount)) { return $this->assertionRecorder->createSuccess($matchingEvents); } return null; }
php
public function checkProduced( $keyOrValue = null, $value = null ): ?EventCollection { $cardinality = $this->resetCardinality(); $argumentCount = func_num_args(); if (0 === $argumentCount) { $checkKey = false; $checkValue = false; } elseif (1 === $argumentCount) { $checkKey = false; $checkValue = true; $value = $this->matcherFactory->adapt($keyOrValue); } else { $checkKey = true; $checkValue = true; $key = $this->matcherFactory->adapt($keyOrValue); $value = $this->matcherFactory->adapt($value); } $isCall = $this->subject instanceof Call; $matchingEvents = []; $matchCount = 0; $eventCount = 0; foreach ($this->calls as $call) { $isMatchingCall = false; foreach ($call->iterableEvents() as $event) { if ($event instanceof ProducedEvent) { ++$eventCount; if ($checkKey && !$key->matches($event->key())) { continue; } if ($checkValue && !$value->matches($event->value())) { continue; } $matchingEvents[] = $event; $isMatchingCall = true; if ($isCall) { ++$matchCount; } } } if (!$isCall && $isMatchingCall) { ++$matchCount; } } if ($isCall) { $totalCount = $eventCount; } else { $totalCount = $this->callCount; } if ($cardinality->matches($matchCount, $totalCount)) { return $this->assertionRecorder->createSuccess($matchingEvents); } return null; }
[ "public", "function", "checkProduced", "(", "$", "keyOrValue", "=", "null", ",", "$", "value", "=", "null", ")", ":", "?", "EventCollection", "{", "$", "cardinality", "=", "$", "this", "->", "resetCardinality", "(", ")", ";", "$", "argumentCount", "=", "...
Checks if the subject produced the supplied values. When called with no arguments, this method simply checks that the subject produced any value. With a single argument, it checks that a value matching the argument was produced. With two arguments, it checks that a key and value matching the respective arguments were produced together. @param mixed $keyOrValue The key or value. @param mixed $value The value. @return EventCollection|null The result.
[ "Checks", "if", "the", "subject", "produced", "the", "supplied", "values", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Verification/IterableVerifier.php#L313-L379
41,833
eloquent/phony
src/Verification/IterableVerifier.php
IterableVerifier.produced
public function produced( $keyOrValue = null, $value = null ): ?EventCollection { $cardinality = $this->cardinality; $argumentCount = func_num_args(); if (0 === $argumentCount) { $key = null; $arguments = []; } elseif (1 === $argumentCount) { $key = null; $value = $this->matcherFactory->adapt($keyOrValue); $arguments = [$value]; } else { $key = $this->matcherFactory->adapt($keyOrValue); $value = $this->matcherFactory->adapt($value); $arguments = [$key, $value]; } if ($result = $this->checkProduced(...$arguments)) { return $result; } return $this->assertionRecorder->createFailure( $this->assertionRenderer->renderIterableProduced( $this->subject, $cardinality, $this->isGenerator, $key, $value ) ); }
php
public function produced( $keyOrValue = null, $value = null ): ?EventCollection { $cardinality = $this->cardinality; $argumentCount = func_num_args(); if (0 === $argumentCount) { $key = null; $arguments = []; } elseif (1 === $argumentCount) { $key = null; $value = $this->matcherFactory->adapt($keyOrValue); $arguments = [$value]; } else { $key = $this->matcherFactory->adapt($keyOrValue); $value = $this->matcherFactory->adapt($value); $arguments = [$key, $value]; } if ($result = $this->checkProduced(...$arguments)) { return $result; } return $this->assertionRecorder->createFailure( $this->assertionRenderer->renderIterableProduced( $this->subject, $cardinality, $this->isGenerator, $key, $value ) ); }
[ "public", "function", "produced", "(", "$", "keyOrValue", "=", "null", ",", "$", "value", "=", "null", ")", ":", "?", "EventCollection", "{", "$", "cardinality", "=", "$", "this", "->", "cardinality", ";", "$", "argumentCount", "=", "func_num_args", "(", ...
Throws an exception unless the subject produced the supplied values. When called with no arguments, this method simply checks that the subject produced any value. With a single argument, it checks that a value matching the argument was produced. With two arguments, it checks that a key and value matching the respective arguments were produced together. @param mixed $keyOrValue The key or value. @param mixed $value The value. @return EventCollection|null The result, or null if the assertion recorder does not throw exceptions. @throws Throwable If the assertion fails, and the assertion recorder throws exceptions.
[ "Throws", "an", "exception", "unless", "the", "subject", "produced", "the", "supplied", "values", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Verification/IterableVerifier.php#L399-L432
41,834
eloquent/phony
src/Verification/IterableVerifier.php
IterableVerifier.checkConsumed
public function checkConsumed(): ?EventCollection { $cardinality = $this->resetCardinality(); if ($this->subject instanceof Call) { $cardinality->assertSingular(); } $matchingEvents = []; $matchCount = 0; foreach ($this->calls as $call) { if (!$endEvent = $call->endEvent()) { continue; } if (!$call->isIterable()) { continue; } ++$matchCount; $matchingEvents[] = $endEvent; } if ($cardinality->matches($matchCount, $this->callCount)) { return $this->assertionRecorder->createSuccess($matchingEvents); } return null; }
php
public function checkConsumed(): ?EventCollection { $cardinality = $this->resetCardinality(); if ($this->subject instanceof Call) { $cardinality->assertSingular(); } $matchingEvents = []; $matchCount = 0; foreach ($this->calls as $call) { if (!$endEvent = $call->endEvent()) { continue; } if (!$call->isIterable()) { continue; } ++$matchCount; $matchingEvents[] = $endEvent; } if ($cardinality->matches($matchCount, $this->callCount)) { return $this->assertionRecorder->createSuccess($matchingEvents); } return null; }
[ "public", "function", "checkConsumed", "(", ")", ":", "?", "EventCollection", "{", "$", "cardinality", "=", "$", "this", "->", "resetCardinality", "(", ")", ";", "if", "(", "$", "this", "->", "subject", "instanceof", "Call", ")", "{", "$", "cardinality", ...
Checks if the subject was completely consumed. @return EventCollection|null The result.
[ "Checks", "if", "the", "subject", "was", "completely", "consumed", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Verification/IterableVerifier.php#L439-L467
41,835
eloquent/phony
src/Verification/IterableVerifier.php
IterableVerifier.consumed
public function consumed(): ?EventCollection { $cardinality = $this->cardinality; if ($result = $this->checkConsumed()) { return $result; } return $this->assertionRecorder->createFailure( $this->assertionRenderer->renderIterableConsumed( $this->subject, $cardinality, $this->isGenerator ) ); }
php
public function consumed(): ?EventCollection { $cardinality = $this->cardinality; if ($result = $this->checkConsumed()) { return $result; } return $this->assertionRecorder->createFailure( $this->assertionRenderer->renderIterableConsumed( $this->subject, $cardinality, $this->isGenerator ) ); }
[ "public", "function", "consumed", "(", ")", ":", "?", "EventCollection", "{", "$", "cardinality", "=", "$", "this", "->", "cardinality", ";", "if", "(", "$", "result", "=", "$", "this", "->", "checkConsumed", "(", ")", ")", "{", "return", "$", "result"...
Throws an exception unless the subject was completely consumed. @return EventCollection|null The result, or null if the assertion recorder does not throw exceptions. @throws Throwable If the assertion fails, and the assertion recorder throws exceptions.
[ "Throws", "an", "exception", "unless", "the", "subject", "was", "completely", "consumed", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Verification/IterableVerifier.php#L475-L490
41,836
eloquent/phony
src/Hook/FunctionHookGenerator.php
FunctionHookGenerator.generateHook
public function generateHook( string $name, string $namespace, array $signature ): string { $source = "namespace $namespace;\n\nfunction $name"; $parameterCount = count($signature); if ($parameterCount > 0) { $index = -1; $isFirst = true; foreach ($signature as $parameter) { if ($isFirst) { $isFirst = false; $source .= "(\n "; } else { $source .= ",\n "; } $source .= $parameter[0] . $parameter[1] . $parameter[2] . '$a' . ++$index . $parameter[3]; } $source .= "\n) {\n"; } else { $source .= "()\n{\n"; } $variadicIndex = -1; $variadicReference = ''; if ($parameterCount > 0) { $argumentPacking = "\n"; $index = -1; foreach ($signature as $parameter) { if ($parameter[2]) { --$parameterCount; $variadicIndex = ++$index; $variadicReference = $parameter[1]; } else { $argumentPacking .= "\n if (\$argumentCount > " . ++$index . ") {\n \$arguments[] = " . $parameter[1] . '$a' . $index . ";\n }"; } } } else { $argumentPacking = ''; } $source .= " \$argumentCount = \\func_num_args();\n" . ' $arguments = [];' . $argumentPacking . "\n\n for (\$i = " . $parameterCount . "; \$i < \$argumentCount; ++\$i) {\n"; if ($variadicIndex > -1) { $source .= " \$arguments[] = $variadicReference\$a" . $variadicIndex . "[\$i - $variadicIndex];\n" . ' }'; } else { $source .= " \$arguments[] = \\func_get_arg(\$i);\n" . ' }'; } $ret = 'ret' . 'urn'; $renderedName = var_export(strtolower($namespace . '\\' . $name), true); $source .= "\n\n \$name = $renderedName;\n\n if (" . "\n !isset(\n " . '\Eloquent\Phony\Hook\FunctionHookManager::$hooks[$name]' . "['callback']\n )\n ) {\n " . "$ret \\$name(...\$arguments);" . "\n }\n\n \$callback =\n " . '\Eloquent\Phony\Hook\FunctionHookManager::$hooks' . "[\$name]['callback'];\n\n" . ' if ($callback instanceof ' . "\Eloquent\Phony\Invocation\Invocable) {\n" . " $ret \$callback->invokeWith(\$arguments);\n" . " }\n\n " . "$ret \$callback(...\$arguments);\n}\n"; // @codeCoverageIgnoreStart if ("\n" !== PHP_EOL) { $source = str_replace("\n", PHP_EOL, $source); } // @codeCoverageIgnoreEnd return $source; }
php
public function generateHook( string $name, string $namespace, array $signature ): string { $source = "namespace $namespace;\n\nfunction $name"; $parameterCount = count($signature); if ($parameterCount > 0) { $index = -1; $isFirst = true; foreach ($signature as $parameter) { if ($isFirst) { $isFirst = false; $source .= "(\n "; } else { $source .= ",\n "; } $source .= $parameter[0] . $parameter[1] . $parameter[2] . '$a' . ++$index . $parameter[3]; } $source .= "\n) {\n"; } else { $source .= "()\n{\n"; } $variadicIndex = -1; $variadicReference = ''; if ($parameterCount > 0) { $argumentPacking = "\n"; $index = -1; foreach ($signature as $parameter) { if ($parameter[2]) { --$parameterCount; $variadicIndex = ++$index; $variadicReference = $parameter[1]; } else { $argumentPacking .= "\n if (\$argumentCount > " . ++$index . ") {\n \$arguments[] = " . $parameter[1] . '$a' . $index . ";\n }"; } } } else { $argumentPacking = ''; } $source .= " \$argumentCount = \\func_num_args();\n" . ' $arguments = [];' . $argumentPacking . "\n\n for (\$i = " . $parameterCount . "; \$i < \$argumentCount; ++\$i) {\n"; if ($variadicIndex > -1) { $source .= " \$arguments[] = $variadicReference\$a" . $variadicIndex . "[\$i - $variadicIndex];\n" . ' }'; } else { $source .= " \$arguments[] = \\func_get_arg(\$i);\n" . ' }'; } $ret = 'ret' . 'urn'; $renderedName = var_export(strtolower($namespace . '\\' . $name), true); $source .= "\n\n \$name = $renderedName;\n\n if (" . "\n !isset(\n " . '\Eloquent\Phony\Hook\FunctionHookManager::$hooks[$name]' . "['callback']\n )\n ) {\n " . "$ret \\$name(...\$arguments);" . "\n }\n\n \$callback =\n " . '\Eloquent\Phony\Hook\FunctionHookManager::$hooks' . "[\$name]['callback'];\n\n" . ' if ($callback instanceof ' . "\Eloquent\Phony\Invocation\Invocable) {\n" . " $ret \$callback->invokeWith(\$arguments);\n" . " }\n\n " . "$ret \$callback(...\$arguments);\n}\n"; // @codeCoverageIgnoreStart if ("\n" !== PHP_EOL) { $source = str_replace("\n", PHP_EOL, $source); } // @codeCoverageIgnoreEnd return $source; }
[ "public", "function", "generateHook", "(", "string", "$", "name", ",", "string", "$", "namespace", ",", "array", "$", "signature", ")", ":", "string", "{", "$", "source", "=", "\"namespace $namespace;\\n\\nfunction $name\"", ";", "$", "parameterCount", "=", "cou...
Generate the source code for a function hook. @param string $name The function name. @param string $namespace The namespace. @param array<string,array<string>> $signature The function signature. @return string The source code.
[ "Generate", "the", "source", "code", "for", "a", "function", "hook", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Hook/FunctionHookGenerator.php#L35-L140
41,837
eloquent/phony
src/Verification/CardinalityVerifierTrait.php
CardinalityVerifierTrait.times
public function times(int $times): CardinalityVerifier { $this->cardinality = new Cardinality($times, $times); return $this; }
php
public function times(int $times): CardinalityVerifier { $this->cardinality = new Cardinality($times, $times); return $this; }
[ "public", "function", "times", "(", "int", "$", "times", ")", ":", "CardinalityVerifier", "{", "$", "this", "->", "cardinality", "=", "new", "Cardinality", "(", "$", "times", ",", "$", "times", ")", ";", "return", "$", "this", ";", "}" ]
Requires that the next verification matches an exact number of times. @param int $times The match count. @return $this This verifier.
[ "Requires", "that", "the", "next", "verification", "matches", "an", "exact", "number", "of", "times", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Verification/CardinalityVerifierTrait.php#L69-L74
41,838
eloquent/phony
src/Call/Arguments.php
Arguments.copy
public function copy(): self { $arguments = []; foreach ($this->arguments as $argument) { $arguments[] = $argument; } return new self($arguments); }
php
public function copy(): self { $arguments = []; foreach ($this->arguments as $argument) { $arguments[] = $argument; } return new self($arguments); }
[ "public", "function", "copy", "(", ")", ":", "self", "{", "$", "arguments", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "arguments", "as", "$", "argument", ")", "{", "$", "arguments", "[", "]", "=", "$", "argument", ";", "}", "return", ...
Copy these arguments, breaking any references. @return Arguments The copied arguments.
[ "Copy", "these", "arguments", "breaking", "any", "references", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Call/Arguments.php#L46-L55
41,839
eloquent/phony
src/Call/Arguments.php
Arguments.set
public function set($indexOrValue = null, $value = null): self { if (func_num_args() > 1) { $index = $indexOrValue; } else { $index = 0; $normalized = 0; $value = $indexOrValue; } if (!$this->normalizeIndex($this->count, $index, $normalized)) { throw new UndefinedArgumentException($index); } $this->arguments[$normalized] = $value; return $this; }
php
public function set($indexOrValue = null, $value = null): self { if (func_num_args() > 1) { $index = $indexOrValue; } else { $index = 0; $normalized = 0; $value = $indexOrValue; } if (!$this->normalizeIndex($this->count, $index, $normalized)) { throw new UndefinedArgumentException($index); } $this->arguments[$normalized] = $value; return $this; }
[ "public", "function", "set", "(", "$", "indexOrValue", "=", "null", ",", "$", "value", "=", "null", ")", ":", "self", "{", "if", "(", "func_num_args", "(", ")", ">", "1", ")", "{", "$", "index", "=", "$", "indexOrValue", ";", "}", "else", "{", "$...
Set an argument by index. If called with no arguments, sets the first argument to null. If called with one argument, sets the first argument to `$indexOrValue`. If called with two arguments, sets the argument at `$indexOrValue` to `$value`. @param mixed $indexOrValue The index, or value if no index is specified. @param mixed $value The value. @return $this This arguments object. @throws UndefinedArgumentException If the requested argument is undefined.
[ "Set", "an", "argument", "by", "index", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Call/Arguments.php#L85-L102
41,840
eloquent/phony
src/Call/Arguments.php
Arguments.has
public function has(int $index = 0): bool { if ($this->normalizeIndex($this->count, $index)) { return true; } return false; }
php
public function has(int $index = 0): bool { if ($this->normalizeIndex($this->count, $index)) { return true; } return false; }
[ "public", "function", "has", "(", "int", "$", "index", "=", "0", ")", ":", "bool", "{", "if", "(", "$", "this", "->", "normalizeIndex", "(", "$", "this", "->", "count", ",", "$", "index", ")", ")", "{", "return", "true", ";", "}", "return", "fals...
Returns true if the argument index exists. Negative indices are offset from the end of the list. That is, `-1` indicates the last element, and `-2` indicates the second last element. @param int $index The index. @return bool True if the argument exists.
[ "Returns", "true", "if", "the", "argument", "index", "exists", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Call/Arguments.php#L114-L121
41,841
eloquent/phony
src/Call/Arguments.php
Arguments.get
public function get(int $index = 0) { if (!$this->normalizeIndex($this->count, $index, $normalized)) { throw new UndefinedArgumentException($index); } return $this->arguments[$normalized]; }
php
public function get(int $index = 0) { if (!$this->normalizeIndex($this->count, $index, $normalized)) { throw new UndefinedArgumentException($index); } return $this->arguments[$normalized]; }
[ "public", "function", "get", "(", "int", "$", "index", "=", "0", ")", "{", "if", "(", "!", "$", "this", "->", "normalizeIndex", "(", "$", "this", "->", "count", ",", "$", "index", ",", "$", "normalized", ")", ")", "{", "throw", "new", "UndefinedArg...
Get an argument by index. Negative indices are offset from the end of the list. That is, `-1` indicates the last element, and `-2` indicates the second last element. @param int $index The index. @return mixed The argument. @throws UndefinedArgumentException If the requested argument is undefined.
[ "Get", "an", "argument", "by", "index", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Call/Arguments.php#L134-L141
41,842
eloquent/phony
src/Mock/Handle/HandleTrait.php
HandleTrait.stub
public function stub(string $name, bool $isNewRule = true): StubVerifier { $key = strtolower($name); if (isset($this->state->stubs->$key)) { $stub = $this->state->stubs->$key; } else { $stub = $this->state->stubs->$key = $this->createStub($name); } if ($isNewRule) { $stub->closeRule(); } return $stub; }
php
public function stub(string $name, bool $isNewRule = true): StubVerifier { $key = strtolower($name); if (isset($this->state->stubs->$key)) { $stub = $this->state->stubs->$key; } else { $stub = $this->state->stubs->$key = $this->createStub($name); } if ($isNewRule) { $stub->closeRule(); } return $stub; }
[ "public", "function", "stub", "(", "string", "$", "name", ",", "bool", "$", "isNewRule", "=", "true", ")", ":", "StubVerifier", "{", "$", "key", "=", "strtolower", "(", "$", "name", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "state", "->...
Get a stub verifier. @param string $name The method name. @param bool $isNewRule True if a new rule should be started. @return StubVerifier The stub verifier. @throws MockException If the stub does not exist.
[ "Get", "a", "stub", "verifier", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Mock/Handle/HandleTrait.php#L109-L124
41,843
eloquent/phony
src/Mock/Handle/HandleTrait.php
HandleTrait.checkNoInteraction
public function checkNoInteraction(): ?EventCollection { foreach (get_object_vars($this->state->stubs) as $stub) { if ($stub->checkCalled()) { return null; } } return $this->assertionRecorder->createSuccess(); }
php
public function checkNoInteraction(): ?EventCollection { foreach (get_object_vars($this->state->stubs) as $stub) { if ($stub->checkCalled()) { return null; } } return $this->assertionRecorder->createSuccess(); }
[ "public", "function", "checkNoInteraction", "(", ")", ":", "?", "EventCollection", "{", "foreach", "(", "get_object_vars", "(", "$", "this", "->", "state", "->", "stubs", ")", "as", "$", "stub", ")", "{", "if", "(", "$", "stub", "->", "checkCalled", "(",...
Checks if there was no interaction with the mock. @return EventCollection|null The result.
[ "Checks", "if", "there", "was", "no", "interaction", "with", "the", "mock", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Mock/Handle/HandleTrait.php#L167-L176
41,844
eloquent/phony
src/Mock/Handle/HandleTrait.php
HandleTrait.noInteraction
public function noInteraction(): ?EventCollection { if ($result = $this->checkNoInteraction()) { return $result; } $calls = []; foreach (get_object_vars($this->state->stubs) as $stub) { $calls = array_merge($calls, $stub->allCalls()); } return $this->assertionRecorder->createFailure( $this->assertionRenderer->renderNoInteraction($this, $calls) ); }
php
public function noInteraction(): ?EventCollection { if ($result = $this->checkNoInteraction()) { return $result; } $calls = []; foreach (get_object_vars($this->state->stubs) as $stub) { $calls = array_merge($calls, $stub->allCalls()); } return $this->assertionRecorder->createFailure( $this->assertionRenderer->renderNoInteraction($this, $calls) ); }
[ "public", "function", "noInteraction", "(", ")", ":", "?", "EventCollection", "{", "if", "(", "$", "result", "=", "$", "this", "->", "checkNoInteraction", "(", ")", ")", "{", "return", "$", "result", ";", "}", "$", "calls", "=", "[", "]", ";", "forea...
Record an assertion failure unless there was no interaction with the mock. @return EventCollection|null The result, or null if the assertion recorder does not throw exceptions. @throws Throwable If the assertion fails, and the assertion recorder throws exceptions.
[ "Record", "an", "assertion", "failure", "unless", "there", "was", "no", "interaction", "with", "the", "mock", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Mock/Handle/HandleTrait.php#L184-L199
41,845
eloquent/phony
src/Mock/Handle/HandleTrait.php
HandleTrait.stopRecording
public function stopRecording(): Handle { foreach (get_object_vars($this->state->stubs) as $stub) { $stub->stopRecording(); } $this->state->isRecording = false; return $this; }
php
public function stopRecording(): Handle { foreach (get_object_vars($this->state->stubs) as $stub) { $stub->stopRecording(); } $this->state->isRecording = false; return $this; }
[ "public", "function", "stopRecording", "(", ")", ":", "Handle", "{", "foreach", "(", "get_object_vars", "(", "$", "this", "->", "state", "->", "stubs", ")", "as", "$", "stub", ")", "{", "$", "stub", "->", "stopRecording", "(", ")", ";", "}", "$", "th...
Stop recording calls. @return $this This handle.
[ "Stop", "recording", "calls", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Mock/Handle/HandleTrait.php#L206-L215
41,846
eloquent/phony
src/Mock/Handle/HandleTrait.php
HandleTrait.startRecording
public function startRecording(): Handle { foreach (get_object_vars($this->state->stubs) as $stub) { $stub->startRecording(); } $this->state->isRecording = true; return $this; }
php
public function startRecording(): Handle { foreach (get_object_vars($this->state->stubs) as $stub) { $stub->startRecording(); } $this->state->isRecording = true; return $this; }
[ "public", "function", "startRecording", "(", ")", ":", "Handle", "{", "foreach", "(", "get_object_vars", "(", "$", "this", "->", "state", "->", "stubs", ")", "as", "$", "stub", ")", "{", "$", "stub", "->", "startRecording", "(", ")", ";", "}", "$", "...
Start recording calls. @return $this This handle.
[ "Start", "recording", "calls", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Mock/Handle/HandleTrait.php#L222-L231
41,847
eloquent/phony
src/Invocation/InvocableInspector.php
InvocableInspector.callbackReflector
public function callbackReflector($callback): ReflectionFunctionAbstract { while ($callback instanceof WrappedInvocable) { $callback = $callback->callback(); } if (is_array($callback)) { return new ReflectionMethod($callback[0], $callback[1]); } if (is_string($callback) && false !== strpos($callback, '::')) { list($className, $methodName) = explode('::', $callback); return new ReflectionMethod($className, $methodName); } if (is_object($callback) && !$callback instanceof Closure) { return new ReflectionMethod($callback, '__invoke'); } return new ReflectionFunction($callback); }
php
public function callbackReflector($callback): ReflectionFunctionAbstract { while ($callback instanceof WrappedInvocable) { $callback = $callback->callback(); } if (is_array($callback)) { return new ReflectionMethod($callback[0], $callback[1]); } if (is_string($callback) && false !== strpos($callback, '::')) { list($className, $methodName) = explode('::', $callback); return new ReflectionMethod($className, $methodName); } if (is_object($callback) && !$callback instanceof Closure) { return new ReflectionMethod($callback, '__invoke'); } return new ReflectionFunction($callback); }
[ "public", "function", "callbackReflector", "(", "$", "callback", ")", ":", "ReflectionFunctionAbstract", "{", "while", "(", "$", "callback", "instanceof", "WrappedInvocable", ")", "{", "$", "callback", "=", "$", "callback", "->", "callback", "(", ")", ";", "}"...
Get the appropriate reflector for the supplied callback. @param callable $callback The callback. @return ReflectionFunctionAbstract The reflector. @throws ReflectionException If the callback cannot be reflected.
[ "Get", "the", "appropriate", "reflector", "for", "the", "supplied", "callback", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Invocation/InvocableInspector.php#L41-L62
41,848
eloquent/phony
src/Difference/DifferenceEngine.php
DifferenceEngine.difference
public function difference(string $from, string $to): string { $flags = PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY; $from = preg_split('/(\W+)/u', $from, -1, $flags); $to = preg_split('/(\W+)/u', $to, -1, $flags); $matcher = new DifferenceSequenceMatcher($from, $to); $diff = ''; foreach ($matcher->getOpcodes() as $opcode) { list($tag, $i1, $i2, $j1, $j2) = $opcode; if ($tag === 'equal') { $diff .= implode(array_slice($from, $i1, $i2 - $i1)); } else { if ($tag === 'replace' || $tag === 'delete') { $diff .= $this->removeStart . implode(array_slice($from, $i1, $i2 - $i1)) . $this->removeEnd; } if ($tag === 'replace' || $tag === 'insert') { $diff .= $this->addStart . implode(array_slice($to, $j1, $j2 - $j1)) . $this->addEnd; } } } return $diff; }
php
public function difference(string $from, string $to): string { $flags = PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY; $from = preg_split('/(\W+)/u', $from, -1, $flags); $to = preg_split('/(\W+)/u', $to, -1, $flags); $matcher = new DifferenceSequenceMatcher($from, $to); $diff = ''; foreach ($matcher->getOpcodes() as $opcode) { list($tag, $i1, $i2, $j1, $j2) = $opcode; if ($tag === 'equal') { $diff .= implode(array_slice($from, $i1, $i2 - $i1)); } else { if ($tag === 'replace' || $tag === 'delete') { $diff .= $this->removeStart . implode(array_slice($from, $i1, $i2 - $i1)) . $this->removeEnd; } if ($tag === 'replace' || $tag === 'insert') { $diff .= $this->addStart . implode(array_slice($to, $j1, $j2 - $j1)) . $this->addEnd; } } } return $diff; }
[ "public", "function", "difference", "(", "string", "$", "from", ",", "string", "$", "to", ")", ":", "string", "{", "$", "flags", "=", "PREG_SPLIT_DELIM_CAPTURE", "|", "PREG_SPLIT_NO_EMPTY", ";", "$", "from", "=", "preg_split", "(", "'/(\\W+)/u'", ",", "$", ...
Get the difference between the supplied strings. @param string $from The from value. @param string $to The to value. @return string The difference.
[ "Get", "the", "difference", "between", "the", "supplied", "strings", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Difference/DifferenceEngine.php#L76-L108
41,849
eloquent/phony
src/Assertion/AssertionRenderer.php
AssertionRenderer.instance
public static function instance(): self { if (!self::$instance) { self::$instance = new self( MatcherVerifier::instance(), InlineExporter::instance(), DifferenceEngine::instance(), FeatureDetector::instance() ); } return self::$instance; }
php
public static function instance(): self { if (!self::$instance) { self::$instance = new self( MatcherVerifier::instance(), InlineExporter::instance(), DifferenceEngine::instance(), FeatureDetector::instance() ); } return self::$instance; }
[ "public", "static", "function", "instance", "(", ")", ":", "self", "{", "if", "(", "!", "self", "::", "$", "instance", ")", "{", "self", "::", "$", "instance", "=", "new", "self", "(", "MatcherVerifier", "::", "instance", "(", ")", ",", "InlineExporter...
Get the static instance of this renderer. @return AssertionRenderer The static renderer.
[ "Get", "the", "static", "instance", "of", "this", "renderer", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Assertion/AssertionRenderer.php#L47-L59
41,850
eloquent/phony
src/Assertion/AssertionRenderer.php
AssertionRenderer.renderMatchers
public function renderMatchers(array $matchers): string { if (count($matchers) < 1) { return '<none>'; } $rendered = []; foreach ($matchers as $matcher) { $rendered[] = $matcher->describe($this->exporter); } return implode(', ', $rendered); }
php
public function renderMatchers(array $matchers): string { if (count($matchers) < 1) { return '<none>'; } $rendered = []; foreach ($matchers as $matcher) { $rendered[] = $matcher->describe($this->exporter); } return implode(', ', $rendered); }
[ "public", "function", "renderMatchers", "(", "array", "$", "matchers", ")", ":", "string", "{", "if", "(", "count", "(", "$", "matchers", ")", "<", "1", ")", "{", "return", "'<none>'", ";", "}", "$", "rendered", "=", "[", "]", ";", "foreach", "(", ...
Render a sequence of matchers. @param array<Matchable> $matchers The matchers. @return string The rendered matchers.
[ "Render", "a", "sequence", "of", "matchers", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Assertion/AssertionRenderer.php#L3655-L3668
41,851
eloquent/phony
src/Call/CallVerifier.php
CallVerifier.duration
public function duration(): ?float { $endTime = $this->call->endTime(); if (null === $endTime) { return null; } return $endTime - $this->call->time(); }
php
public function duration(): ?float { $endTime = $this->call->endTime(); if (null === $endTime) { return null; } return $endTime - $this->call->time(); }
[ "public", "function", "duration", "(", ")", ":", "?", "float", "{", "$", "endTime", "=", "$", "this", "->", "call", "->", "endTime", "(", ")", ";", "if", "(", "null", "===", "$", "endTime", ")", "{", "return", "null", ";", "}", "return", "$", "en...
Get the call duration. @return float|null The call duration in seconds, or null if the call has not yet completed.
[ "Get", "the", "call", "duration", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Call/CallVerifier.php#L535-L544
41,852
eloquent/phony
src/Call/CallVerifier.php
CallVerifier.responseDuration
public function responseDuration(): ?float { $responseTime = $this->call->responseTime(); if (null === $responseTime) { return null; } return $responseTime - $this->call->time(); }
php
public function responseDuration(): ?float { $responseTime = $this->call->responseTime(); if (null === $responseTime) { return null; } return $responseTime - $this->call->time(); }
[ "public", "function", "responseDuration", "(", ")", ":", "?", "float", "{", "$", "responseTime", "=", "$", "this", "->", "call", "->", "responseTime", "(", ")", ";", "if", "(", "null", "===", "$", "responseTime", ")", "{", "return", "null", ";", "}", ...
Get the call response duration. @return float|null The call response duration in seconds, or null if the call has not yet responded.
[ "Get", "the", "call", "response", "duration", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Call/CallVerifier.php#L551-L560
41,853
eloquent/phony
src/Call/CallVerifier.php
CallVerifier.calledWith
public function calledWith(...$arguments): ?EventCollection { $cardinality = $this->cardinality; $matchers = $this->matcherFactory->adaptAll($arguments); if ($result = $this->checkCalledWith(...$matchers)) { return $result; } return $this->assertionRecorder->createFailure( $this->assertionRenderer ->renderCalledWith($this->call, $cardinality, $matchers) ); }
php
public function calledWith(...$arguments): ?EventCollection { $cardinality = $this->cardinality; $matchers = $this->matcherFactory->adaptAll($arguments); if ($result = $this->checkCalledWith(...$matchers)) { return $result; } return $this->assertionRecorder->createFailure( $this->assertionRenderer ->renderCalledWith($this->call, $cardinality, $matchers) ); }
[ "public", "function", "calledWith", "(", "...", "$", "arguments", ")", ":", "?", "EventCollection", "{", "$", "cardinality", "=", "$", "this", "->", "cardinality", ";", "$", "matchers", "=", "$", "this", "->", "matcherFactory", "->", "adaptAll", "(", "$", ...
Throws an exception unless called with the supplied arguments. @param mixed ...$argument The arguments. @return EventCollection|null The result, or null if the assertion recorder does not throw exceptions. @throws InvalidCardinalityException If the cardinality is invalid. @throws Throwable If the assertion fails, and the assertion recorder throws exceptions.
[ "Throws", "an", "exception", "unless", "called", "with", "the", "supplied", "arguments", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Call/CallVerifier.php#L607-L620
41,854
eloquent/phony
src/Call/CallVerifier.php
CallVerifier.checkResponded
public function checkResponded(): ?EventCollection { $cardinality = $this->resetCardinality()->assertSingular(); $responseEvent = $this->call->responseEvent(); list($matchCount, $matchingEvents) = $this->matchIf($responseEvent, $responseEvent); if ($cardinality->matches($matchCount, 1)) { return $this->assertionRecorder->createSuccess($matchingEvents); } return null; }
php
public function checkResponded(): ?EventCollection { $cardinality = $this->resetCardinality()->assertSingular(); $responseEvent = $this->call->responseEvent(); list($matchCount, $matchingEvents) = $this->matchIf($responseEvent, $responseEvent); if ($cardinality->matches($matchCount, 1)) { return $this->assertionRecorder->createSuccess($matchingEvents); } return null; }
[ "public", "function", "checkResponded", "(", ")", ":", "?", "EventCollection", "{", "$", "cardinality", "=", "$", "this", "->", "resetCardinality", "(", ")", "->", "assertSingular", "(", ")", ";", "$", "responseEvent", "=", "$", "this", "->", "call", "->",...
Checks if this call responded. @return EventCollection|null The result. @throws InvalidCardinalityException If the cardinality is invalid.
[ "Checks", "if", "this", "call", "responded", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Call/CallVerifier.php#L628-L641
41,855
eloquent/phony
src/Call/CallVerifier.php
CallVerifier.checkCompleted
public function checkCompleted(): ?EventCollection { $cardinality = $this->resetCardinality()->assertSingular(); $endEvent = $this->call->endEvent(); list($matchCount, $matchingEvents) = $this->matchIf($endEvent, $endEvent); if ($cardinality->matches($matchCount, 1)) { return $this->assertionRecorder->createSuccess($matchingEvents); } return null; }
php
public function checkCompleted(): ?EventCollection { $cardinality = $this->resetCardinality()->assertSingular(); $endEvent = $this->call->endEvent(); list($matchCount, $matchingEvents) = $this->matchIf($endEvent, $endEvent); if ($cardinality->matches($matchCount, 1)) { return $this->assertionRecorder->createSuccess($matchingEvents); } return null; }
[ "public", "function", "checkCompleted", "(", ")", ":", "?", "EventCollection", "{", "$", "cardinality", "=", "$", "this", "->", "resetCardinality", "(", ")", "->", "assertSingular", "(", ")", ";", "$", "endEvent", "=", "$", "this", "->", "call", "->", "e...
Checks if this call completed. @return EventCollection|null The result. @throws InvalidCardinalityException If the cardinality is invalid.
[ "Checks", "if", "this", "call", "completed", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Call/CallVerifier.php#L669-L682
41,856
eloquent/phony
src/Call/CallVerifier.php
CallVerifier.completed
public function completed(): ?EventCollection { $cardinality = $this->cardinality; if ($result = $this->checkCompleted()) { return $result; } return $this->assertionRecorder->createFailure( $this->assertionRenderer->renderCompleted($this->call, $cardinality) ); }
php
public function completed(): ?EventCollection { $cardinality = $this->cardinality; if ($result = $this->checkCompleted()) { return $result; } return $this->assertionRecorder->createFailure( $this->assertionRenderer->renderCompleted($this->call, $cardinality) ); }
[ "public", "function", "completed", "(", ")", ":", "?", "EventCollection", "{", "$", "cardinality", "=", "$", "this", "->", "cardinality", ";", "if", "(", "$", "result", "=", "$", "this", "->", "checkCompleted", "(", ")", ")", "{", "return", "$", "resul...
Throws an exception unless this call completed. @return EventCollection|null The result, or null if the assertion recorder does not throw exceptions. @throws InvalidCardinalityException If the cardinality is invalid. @throws Throwable If the assertion fails, and the assertion recorder throws exceptions.
[ "Throws", "an", "exception", "unless", "this", "call", "completed", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Call/CallVerifier.php#L691-L702
41,857
eloquent/phony
src/Call/CallVerifier.php
CallVerifier.checkReturned
public function checkReturned($value = null): ?EventCollection { $cardinality = $this->resetCardinality()->assertSingular(); if ($responseEvent = $this->call->responseEvent()) { list($exception, $returnValue) = $this->call->response(); $hasReturned = !$exception; } else { $returnValue = null; $hasReturned = false; } if (0 === func_num_args()) { list($matchCount, $matchingEvents) = $this->matchIf($responseEvent, $hasReturned); if ($cardinality->matches($matchCount, 1)) { return $this->assertionRecorder->createSuccess($matchingEvents); } return null; } $value = $this->matcherFactory->adapt($value); list($matchCount, $matchingEvents) = $this->matchIf( $responseEvent, $hasReturned && $value->matches($returnValue) ); if ($cardinality->matches($matchCount, 1)) { return $this->assertionRecorder->createSuccess($matchingEvents); } return null; }
php
public function checkReturned($value = null): ?EventCollection { $cardinality = $this->resetCardinality()->assertSingular(); if ($responseEvent = $this->call->responseEvent()) { list($exception, $returnValue) = $this->call->response(); $hasReturned = !$exception; } else { $returnValue = null; $hasReturned = false; } if (0 === func_num_args()) { list($matchCount, $matchingEvents) = $this->matchIf($responseEvent, $hasReturned); if ($cardinality->matches($matchCount, 1)) { return $this->assertionRecorder->createSuccess($matchingEvents); } return null; } $value = $this->matcherFactory->adapt($value); list($matchCount, $matchingEvents) = $this->matchIf( $responseEvent, $hasReturned && $value->matches($returnValue) ); if ($cardinality->matches($matchCount, 1)) { return $this->assertionRecorder->createSuccess($matchingEvents); } return null; }
[ "public", "function", "checkReturned", "(", "$", "value", "=", "null", ")", ":", "?", "EventCollection", "{", "$", "cardinality", "=", "$", "this", "->", "resetCardinality", "(", ")", "->", "assertSingular", "(", ")", ";", "if", "(", "$", "responseEvent", ...
Checks if this call returned the supplied value. When called with no arguments, this method simply checks that the call returned any value. @param mixed $value The value. @return EventCollection|null The result. @throws InvalidCardinalityException If the cardinality is invalid.
[ "Checks", "if", "this", "call", "returned", "the", "supplied", "value", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Call/CallVerifier.php#L715-L751
41,858
eloquent/phony
src/Call/CallVerifier.php
CallVerifier.returned
public function returned($value = null): ?EventCollection { $cardinality = $this->cardinality; $argumentCount = func_num_args(); if (0 === $argumentCount) { $arguments = []; } else { $value = $this->matcherFactory->adapt($value); $arguments = [$value]; } if ($result = $this->checkReturned(...$arguments)) { return $result; } return $this->assertionRecorder->createFailure( $this->assertionRenderer ->renderReturned($this->call, $cardinality, $value) ); }
php
public function returned($value = null): ?EventCollection { $cardinality = $this->cardinality; $argumentCount = func_num_args(); if (0 === $argumentCount) { $arguments = []; } else { $value = $this->matcherFactory->adapt($value); $arguments = [$value]; } if ($result = $this->checkReturned(...$arguments)) { return $result; } return $this->assertionRecorder->createFailure( $this->assertionRenderer ->renderReturned($this->call, $cardinality, $value) ); }
[ "public", "function", "returned", "(", "$", "value", "=", "null", ")", ":", "?", "EventCollection", "{", "$", "cardinality", "=", "$", "this", "->", "cardinality", ";", "$", "argumentCount", "=", "func_num_args", "(", ")", ";", "if", "(", "0", "===", "...
Throws an exception unless this call returned the supplied value. When called with no arguments, this method simply checks that the call returned any value. @param mixed $value The value. @return EventCollection|null The result, or null if the assertion recorder does not throw exceptions. @throws InvalidCardinalityException If the cardinality is invalid. @throws Throwable If the assertion fails, and the assertion recorder throws exceptions.
[ "Throws", "an", "exception", "unless", "this", "call", "returned", "the", "supplied", "value", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Call/CallVerifier.php#L765-L785
41,859
eloquent/phony
src/Call/CallVerifier.php
CallVerifier.threw
public function threw($type = null): ?EventCollection { $cardinality = $this->cardinality; if ($type instanceof InstanceHandle) { $type = $type->get(); } if ($type instanceof Throwable) { $type = $this->matcherFactory->equalTo($type, true); } elseif ($this->matcherFactory->isMatcher($type)) { $type = $this->matcherFactory->adapt($type); } if ($result = $this->checkThrew($type)) { return $result; } return $this->assertionRecorder->createFailure( $this->assertionRenderer ->renderThrew($this->call, $cardinality, $type) ); }
php
public function threw($type = null): ?EventCollection { $cardinality = $this->cardinality; if ($type instanceof InstanceHandle) { $type = $type->get(); } if ($type instanceof Throwable) { $type = $this->matcherFactory->equalTo($type, true); } elseif ($this->matcherFactory->isMatcher($type)) { $type = $this->matcherFactory->adapt($type); } if ($result = $this->checkThrew($type)) { return $result; } return $this->assertionRecorder->createFailure( $this->assertionRenderer ->renderThrew($this->call, $cardinality, $type) ); }
[ "public", "function", "threw", "(", "$", "type", "=", "null", ")", ":", "?", "EventCollection", "{", "$", "cardinality", "=", "$", "this", "->", "cardinality", ";", "if", "(", "$", "type", "instanceof", "InstanceHandle", ")", "{", "$", "type", "=", "$"...
Throws an exception unless this call threw an exception of the supplied type. @param Matcher|Throwable|string|null $type An exception to match, the type of exception, or null for any exception. @return EventCollection|null The result, or null if the assertion recorder does not throw exceptions. @throws InvalidCardinalityException If the cardinality is invalid. @throws InvalidArgumentException If the type is invalid. @throws Throwable If the assertion fails, and the assertion recorder throws exceptions.
[ "Throws", "an", "exception", "unless", "this", "call", "threw", "an", "exception", "of", "the", "supplied", "type", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Call/CallVerifier.php#L875-L897
41,860
eloquent/phony
src/Call/CallVerifier.php
CallVerifier.checkGenerated
public function checkGenerated(): ?GeneratorVerifier { $cardinality = $this->resetCardinality()->assertSingular(); if ($this->call->responseEvent()) { list(, $returnValue) = $this->call->response(); $isMatch = $returnValue instanceof Generator; } else { $isMatch = false; } list($matchCount, $matchingEvents) = $this->matchIf($this->call, $isMatch); if ($cardinality->matches($matchCount, 1)) { return $this->assertionRecorder->createSuccessFromEventCollection( $this->generatorVerifierFactory ->create($this->call, $matchingEvents) ); } return null; }
php
public function checkGenerated(): ?GeneratorVerifier { $cardinality = $this->resetCardinality()->assertSingular(); if ($this->call->responseEvent()) { list(, $returnValue) = $this->call->response(); $isMatch = $returnValue instanceof Generator; } else { $isMatch = false; } list($matchCount, $matchingEvents) = $this->matchIf($this->call, $isMatch); if ($cardinality->matches($matchCount, 1)) { return $this->assertionRecorder->createSuccessFromEventCollection( $this->generatorVerifierFactory ->create($this->call, $matchingEvents) ); } return null; }
[ "public", "function", "checkGenerated", "(", ")", ":", "?", "GeneratorVerifier", "{", "$", "cardinality", "=", "$", "this", "->", "resetCardinality", "(", ")", "->", "assertSingular", "(", ")", ";", "if", "(", "$", "this", "->", "call", "->", "responseEven...
Checks if this call returned a generator. @return GeneratorVerifier|null The result. @throws InvalidCardinalityException If the cardinality is invalid.
[ "Checks", "if", "this", "call", "returned", "a", "generator", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Call/CallVerifier.php#L905-L928
41,861
eloquent/phony
src/Call/CallVerifier.php
CallVerifier.checkIterated
public function checkIterated(): ?IterableVerifier { $cardinality = $this->resetCardinality()->assertSingular(); if ($this->call->responseEvent()) { list(, $returnValue) = $this->call->response(); $isMatch = $returnValue instanceof Traversable || is_array($returnValue); } else { $isMatch = false; } list($matchCount, $matchingEvents) = $this->matchIf($this->call, $isMatch); if ($cardinality->matches($matchCount, 1)) { return $this->assertionRecorder->createSuccessFromEventCollection( $this->iterableVerifierFactory ->create($this->call, $matchingEvents) ); } return null; }
php
public function checkIterated(): ?IterableVerifier { $cardinality = $this->resetCardinality()->assertSingular(); if ($this->call->responseEvent()) { list(, $returnValue) = $this->call->response(); $isMatch = $returnValue instanceof Traversable || is_array($returnValue); } else { $isMatch = false; } list($matchCount, $matchingEvents) = $this->matchIf($this->call, $isMatch); if ($cardinality->matches($matchCount, 1)) { return $this->assertionRecorder->createSuccessFromEventCollection( $this->iterableVerifierFactory ->create($this->call, $matchingEvents) ); } return null; }
[ "public", "function", "checkIterated", "(", ")", ":", "?", "IterableVerifier", "{", "$", "cardinality", "=", "$", "this", "->", "resetCardinality", "(", ")", "->", "assertSingular", "(", ")", ";", "if", "(", "$", "this", "->", "call", "->", "responseEvent"...
Checks if this call returned an iterable. @return IterableVerifier|null The result. @throws InvalidCardinalityException If the cardinality is invalid.
[ "Checks", "if", "this", "call", "returned", "an", "iterable", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Call/CallVerifier.php#L956-L980
41,862
eloquent/phony
src/Call/CallVerifier.php
CallVerifier.iterated
public function iterated(): ?IterableVerifier { $cardinality = $this->cardinality; if ($result = $this->checkIterated()) { return $result; } return $this->assertionRecorder->createFailure( $this->assertionRenderer->renderIterated($this->call, $cardinality) ); }
php
public function iterated(): ?IterableVerifier { $cardinality = $this->cardinality; if ($result = $this->checkIterated()) { return $result; } return $this->assertionRecorder->createFailure( $this->assertionRenderer->renderIterated($this->call, $cardinality) ); }
[ "public", "function", "iterated", "(", ")", ":", "?", "IterableVerifier", "{", "$", "cardinality", "=", "$", "this", "->", "cardinality", ";", "if", "(", "$", "result", "=", "$", "this", "->", "checkIterated", "(", ")", ")", "{", "return", "$", "result...
Throws an exception unless this call returned an iterable. @return IterableVerifier The result, or null if the assertion recorder does not throw exceptions. @throws InvalidCardinalityException If the cardinality is invalid. @throws Throwable If the assertion fails, and the assertion recorder throws exceptions.
[ "Throws", "an", "exception", "unless", "this", "call", "returned", "an", "iterable", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Call/CallVerifier.php#L989-L1000
41,863
eloquent/phony
src/Assertion/Exception/AssertionException.php
AssertionException.tracePhonyCall
public static function tracePhonyCall(array $trace): array { $prefix = 'Eloquent\Phony\\'; for ($i = count($trace) - 1; $i >= 0; --$i) { $entry = $trace[$i]; if (isset($entry['class'])) { if (0 === strpos($entry['class'], $prefix)) { return $entry; } } elseif (0 === strpos($entry['function'], $prefix)) { return $entry; } } return []; }
php
public static function tracePhonyCall(array $trace): array { $prefix = 'Eloquent\Phony\\'; for ($i = count($trace) - 1; $i >= 0; --$i) { $entry = $trace[$i]; if (isset($entry['class'])) { if (0 === strpos($entry['class'], $prefix)) { return $entry; } } elseif (0 === strpos($entry['function'], $prefix)) { return $entry; } } return []; }
[ "public", "static", "function", "tracePhonyCall", "(", "array", "$", "trace", ")", ":", "array", "{", "$", "prefix", "=", "'Eloquent\\Phony\\\\'", ";", "for", "(", "$", "i", "=", "count", "(", "$", "trace", ")", "-", "1", ";", "$", "i", ">=", "0", ...
Find the Phony entry point call in a stack trace. @param array $trace The stack trace. @return array The call, or an empty array if unable to determine the entry point.
[ "Find", "the", "Phony", "entry", "point", "call", "in", "a", "stack", "trace", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Assertion/Exception/AssertionException.php#L54-L71
41,864
iiifx-production/yii2-autocomplete-helper
source/Controller.php
Controller.actionIndex
public function actionIndex() { $this->showDescription(); try { $component = $this->getComponent(); $configList = $this->getConfig($component); $config = new Config([ 'files' => $configList, ]); $builder = new Builder([ 'components' => $config->getComponents(), 'template' => require __DIR__ . '/template.php', ]); if ($component->result === null) { $component->result = ($this->getDetector()->detect() === 'basic') ? '@app/_ide_components.php' : '@console/../_ide_components.php'; } $result = Yii::getAlias($component->result); $result = FileHelper::normalizePath($result); if ($builder->build($result)) { $this->stdout("Success: {$result}\n", Console::FG_GREEN); } else { $this->stdout("Fail!\n", Console::FG_RED); } } catch (Exception $exception) { $this->stdout($exception->getMessage() . "\n\n", Console::FG_RED); $this->stdout("Please read the package documentation: https://github.com/iiifx-production/yii2-autocomplete-helper\n"); $this->stdout("or create new issue: https://github.com/iiifx-production/yii2-autocomplete-helper/issues/new\n"); } }
php
public function actionIndex() { $this->showDescription(); try { $component = $this->getComponent(); $configList = $this->getConfig($component); $config = new Config([ 'files' => $configList, ]); $builder = new Builder([ 'components' => $config->getComponents(), 'template' => require __DIR__ . '/template.php', ]); if ($component->result === null) { $component->result = ($this->getDetector()->detect() === 'basic') ? '@app/_ide_components.php' : '@console/../_ide_components.php'; } $result = Yii::getAlias($component->result); $result = FileHelper::normalizePath($result); if ($builder->build($result)) { $this->stdout("Success: {$result}\n", Console::FG_GREEN); } else { $this->stdout("Fail!\n", Console::FG_RED); } } catch (Exception $exception) { $this->stdout($exception->getMessage() . "\n\n", Console::FG_RED); $this->stdout("Please read the package documentation: https://github.com/iiifx-production/yii2-autocomplete-helper\n"); $this->stdout("or create new issue: https://github.com/iiifx-production/yii2-autocomplete-helper/issues/new\n"); } }
[ "public", "function", "actionIndex", "(", ")", "{", "$", "this", "->", "showDescription", "(", ")", ";", "try", "{", "$", "component", "=", "$", "this", "->", "getComponent", "(", ")", ";", "$", "configList", "=", "$", "this", "->", "getConfig", "(", ...
Generate IDE auto-completion file
[ "Generate", "IDE", "auto", "-", "completion", "file" ]
b8acae313bf14e13d6e2bd58cbc89ef0ad451d4c
https://github.com/iiifx-production/yii2-autocomplete-helper/blob/b8acae313bf14e13d6e2bd58cbc89ef0ad451d4c/source/Controller.php#L71-L101
41,865
eloquent/phony
src/Call/Event/CallEventFactory.php
CallEventFactory.createCalled
public function createCalled( $callback, Arguments $arguments ): CalledEvent { return new CalledEvent( $this->sequencer->next(), $this->clock->time(), $callback, $arguments ); }
php
public function createCalled( $callback, Arguments $arguments ): CalledEvent { return new CalledEvent( $this->sequencer->next(), $this->clock->time(), $callback, $arguments ); }
[ "public", "function", "createCalled", "(", "$", "callback", ",", "Arguments", "$", "arguments", ")", ":", "CalledEvent", "{", "return", "new", "CalledEvent", "(", "$", "this", "->", "sequencer", "->", "next", "(", ")", ",", "$", "this", "->", "clock", "-...
Create a new 'called' event. @param callable $callback The callback. @param Arguments $arguments The arguments. @return CalledEvent The newly created event.
[ "Create", "a", "new", "called", "event", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Call/Event/CallEventFactory.php#L55-L65
41,866
eloquent/phony
src/Call/Event/CallEventFactory.php
CallEventFactory.createReturned
public function createReturned($value): ReturnedEvent { return new ReturnedEvent( $this->sequencer->next(), $this->clock->time(), $value ); }
php
public function createReturned($value): ReturnedEvent { return new ReturnedEvent( $this->sequencer->next(), $this->clock->time(), $value ); }
[ "public", "function", "createReturned", "(", "$", "value", ")", ":", "ReturnedEvent", "{", "return", "new", "ReturnedEvent", "(", "$", "this", "->", "sequencer", "->", "next", "(", ")", ",", "$", "this", "->", "clock", "->", "time", "(", ")", ",", "$",...
Create a new 'returned' event. @param mixed $value The return value. @return ReturnedEvent The newly created event.
[ "Create", "a", "new", "returned", "event", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Call/Event/CallEventFactory.php#L74-L81
41,867
eloquent/phony
src/Call/Event/CallEventFactory.php
CallEventFactory.createThrew
public function createThrew(Throwable $exception): ThrewEvent { return new ThrewEvent( $this->sequencer->next(), $this->clock->time(), $exception ); }
php
public function createThrew(Throwable $exception): ThrewEvent { return new ThrewEvent( $this->sequencer->next(), $this->clock->time(), $exception ); }
[ "public", "function", "createThrew", "(", "Throwable", "$", "exception", ")", ":", "ThrewEvent", "{", "return", "new", "ThrewEvent", "(", "$", "this", "->", "sequencer", "->", "next", "(", ")", ",", "$", "this", "->", "clock", "->", "time", "(", ")", "...
Create a new 'thrown' event. @param Throwable $exception The thrown exception. @return ThrewEvent The newly created event.
[ "Create", "a", "new", "thrown", "event", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Call/Event/CallEventFactory.php#L90-L97
41,868
eloquent/phony
src/Call/Event/CallEventFactory.php
CallEventFactory.createProduced
public function createProduced($key, $value): ProducedEvent { return new ProducedEvent( $this->sequencer->next(), $this->clock->time(), $key, $value ); }
php
public function createProduced($key, $value): ProducedEvent { return new ProducedEvent( $this->sequencer->next(), $this->clock->time(), $key, $value ); }
[ "public", "function", "createProduced", "(", "$", "key", ",", "$", "value", ")", ":", "ProducedEvent", "{", "return", "new", "ProducedEvent", "(", "$", "this", "->", "sequencer", "->", "next", "(", ")", ",", "$", "this", "->", "clock", "->", "time", "(...
Create a new 'produced' event. @param mixed $key The produced key. @param mixed $value The produced value. @return ProducedEvent The newly created event.
[ "Create", "a", "new", "produced", "event", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Call/Event/CallEventFactory.php#L117-L125
41,869
eloquent/phony
src/Call/Event/CallEventFactory.php
CallEventFactory.createReceived
public function createReceived($value): ReceivedEvent { return new ReceivedEvent( $this->sequencer->next(), $this->clock->time(), $value ); }
php
public function createReceived($value): ReceivedEvent { return new ReceivedEvent( $this->sequencer->next(), $this->clock->time(), $value ); }
[ "public", "function", "createReceived", "(", "$", "value", ")", ":", "ReceivedEvent", "{", "return", "new", "ReceivedEvent", "(", "$", "this", "->", "sequencer", "->", "next", "(", ")", ",", "$", "this", "->", "clock", "->", "time", "(", ")", ",", "$",...
Create a new 'received' event. @param mixed $value The received value. @return ReceivedEvent The newly created event.
[ "Create", "a", "new", "received", "event", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Call/Event/CallEventFactory.php#L134-L141
41,870
eloquent/phony
src/Call/Event/CallEventFactory.php
CallEventFactory.createReceivedException
public function createReceivedException( Throwable $exception ): ReceivedExceptionEvent { return new ReceivedExceptionEvent( $this->sequencer->next(), $this->clock->time(), $exception ); }
php
public function createReceivedException( Throwable $exception ): ReceivedExceptionEvent { return new ReceivedExceptionEvent( $this->sequencer->next(), $this->clock->time(), $exception ); }
[ "public", "function", "createReceivedException", "(", "Throwable", "$", "exception", ")", ":", "ReceivedExceptionEvent", "{", "return", "new", "ReceivedExceptionEvent", "(", "$", "this", "->", "sequencer", "->", "next", "(", ")", ",", "$", "this", "->", "clock",...
Create a new 'received exception' event. @param Throwable $exception The received exception. @return ReceivedExceptionEvent The newly created event.
[ "Create", "a", "new", "received", "exception", "event", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Call/Event/CallEventFactory.php#L150-L158
41,871
eloquent/phony
src/Sequencer/Sequencer.php
Sequencer.sequence
public static function sequence(string $name): self { if (!isset(self::$instances[$name])) { self::$instances[$name] = new self(); } return self::$instances[$name]; }
php
public static function sequence(string $name): self { if (!isset(self::$instances[$name])) { self::$instances[$name] = new self(); } return self::$instances[$name]; }
[ "public", "static", "function", "sequence", "(", "string", "$", "name", ")", ":", "self", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "instances", "[", "$", "name", "]", ")", ")", "{", "self", "::", "$", "instances", "[", "$", "name", "...
Get a sequencer for a named sequence. @param string $name The sequence name. @return Sequencer The sequencer.
[ "Get", "a", "sequencer", "for", "a", "named", "sequence", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Sequencer/Sequencer.php#L19-L26
41,872
eloquent/phony
src/Facade/FacadeTrait.php
FacadeTrait.mock
public static function mock($types = []): InstanceHandle { $container = self::$globals::$container; return $container->handleFactory->instanceHandle( $container->mockBuilderFactory->create($types)->full() ); }
php
public static function mock($types = []): InstanceHandle { $container = self::$globals::$container; return $container->handleFactory->instanceHandle( $container->mockBuilderFactory->create($types)->full() ); }
[ "public", "static", "function", "mock", "(", "$", "types", "=", "[", "]", ")", ":", "InstanceHandle", "{", "$", "container", "=", "self", "::", "$", "globals", "::", "$", "container", ";", "return", "$", "container", "->", "handleFactory", "->", "instanc...
Create a new full mock, and return a handle. Each value in `$types` can be either a class name, or an ad hoc mock definition. If only a single type is being mocked, the class name or definition can be passed without being wrapped in an array. @param mixed $types The types to mock. @return InstanceHandle A handle around the new mock.
[ "Create", "a", "new", "full", "mock", "and", "return", "a", "handle", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Facade/FacadeTrait.php#L59-L66
41,873
eloquent/phony
src/Facade/FacadeTrait.php
FacadeTrait.partialMock
public static function partialMock( $types = [], $arguments = [] ): InstanceHandle { $container = self::$globals::$container; return $container->handleFactory->instanceHandle( $container->mockBuilderFactory->create($types) ->partialWith($arguments) ); }
php
public static function partialMock( $types = [], $arguments = [] ): InstanceHandle { $container = self::$globals::$container; return $container->handleFactory->instanceHandle( $container->mockBuilderFactory->create($types) ->partialWith($arguments) ); }
[ "public", "static", "function", "partialMock", "(", "$", "types", "=", "[", "]", ",", "$", "arguments", "=", "[", "]", ")", ":", "InstanceHandle", "{", "$", "container", "=", "self", "::", "$", "globals", "::", "$", "container", ";", "return", "$", "...
Create a new partial mock, and return a handle. Each value in `$types` can be either a class name, or an ad hoc mock definition. If only a single type is being mocked, the class name or definition can be passed without being wrapped in an array. Omitting `$arguments` will cause the original constructor to be called with an empty argument list. However, if a `null` value is supplied for `$arguments`, the original constructor will not be called at all. @param mixed $types The types to mock. @param Arguments|array|null $arguments The constructor arguments, or null to bypass the constructor. @return InstanceHandle A handle around the new mock.
[ "Create", "a", "new", "partial", "mock", "and", "return", "a", "handle", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Facade/FacadeTrait.php#L84-L94
41,874
eloquent/phony
src/Facade/FacadeTrait.php
FacadeTrait.spyGlobal
public static function spyGlobal( string $function, string $namespace ): SpyVerifier { $container = self::$globals::$container; return $container->spyVerifierFactory ->createGlobal($function, $namespace); }
php
public static function spyGlobal( string $function, string $namespace ): SpyVerifier { $container = self::$globals::$container; return $container->spyVerifierFactory ->createGlobal($function, $namespace); }
[ "public", "static", "function", "spyGlobal", "(", "string", "$", "function", ",", "string", "$", "namespace", ")", ":", "SpyVerifier", "{", "$", "container", "=", "self", "::", "$", "globals", "::", "$", "container", ";", "return", "$", "container", "->", ...
Create a spy of a function in the global namespace, and declare it as a function in another namespace. @param string $function The name of the function in the global namespace. @param string $namespace The namespace in which to create the new function. @return SpyVerifier The new spy.
[ "Create", "a", "spy", "of", "a", "function", "in", "the", "global", "namespace", "and", "declare", "it", "as", "a", "function", "in", "another", "namespace", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Facade/FacadeTrait.php#L149-L157
41,875
eloquent/phony
src/Facade/FacadeTrait.php
FacadeTrait.stubGlobal
public static function stubGlobal( string $function, string $namespace ): StubVerifier { $container = self::$globals::$container; return $container->stubVerifierFactory ->createGlobal($function, $namespace); }
php
public static function stubGlobal( string $function, string $namespace ): StubVerifier { $container = self::$globals::$container; return $container->stubVerifierFactory ->createGlobal($function, $namespace); }
[ "public", "static", "function", "stubGlobal", "(", "string", "$", "function", ",", "string", "$", "namespace", ")", ":", "StubVerifier", "{", "$", "container", "=", "self", "::", "$", "globals", "::", "$", "container", ";", "return", "$", "container", "->"...
Create a stub of a function in the global namespace, and declare it as a function in another namespace. Stubs created via this function do not forward to the original function by default. This differs from stubs created by other methods. @param string $function The name of the function in the global namespace. @param string $namespace The namespace in which to create the new function. @return StubVerifier The new stub.
[ "Create", "a", "stub", "of", "a", "function", "in", "the", "global", "namespace", "and", "declare", "it", "as", "a", "function", "in", "another", "namespace", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Facade/FacadeTrait.php#L185-L193
41,876
eloquent/phony
src/Facade/FacadeTrait.php
FacadeTrait.emptyValue
public static function emptyValue(ReflectionType $type) { $container = self::$globals::$container; return $container->emptyValueFactory->fromType($type); }
php
public static function emptyValue(ReflectionType $type) { $container = self::$globals::$container; return $container->emptyValueFactory->fromType($type); }
[ "public", "static", "function", "emptyValue", "(", "ReflectionType", "$", "type", ")", "{", "$", "container", "=", "self", "::", "$", "globals", "::", "$", "container", ";", "return", "$", "container", "->", "emptyValueFactory", "->", "fromType", "(", "$", ...
Get an "empty" value for the supplied type. @param ReflectionType $type The type. @return mixed An "empty" value of the supplied type.
[ "Get", "an", "empty", "value", "for", "the", "supplied", "type", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Facade/FacadeTrait.php#L336-L341
41,877
eloquent/phony
src/Facade/FacadeTrait.php
FacadeTrait.setExportDepth
public static function setExportDepth(int $depth): int { $container = self::$globals::$container; return $container->exporter->setDepth($depth); }
php
public static function setExportDepth(int $depth): int { $container = self::$globals::$container; return $container->exporter->setDepth($depth); }
[ "public", "static", "function", "setExportDepth", "(", "int", "$", "depth", ")", ":", "int", "{", "$", "container", "=", "self", "::", "$", "globals", "::", "$", "container", ";", "return", "$", "container", "->", "exporter", "->", "setDepth", "(", "$", ...
Set the default export depth. Negative depths are treated as infinite depth. @param int $depth The depth. @return int The previous depth.
[ "Set", "the", "default", "export", "depth", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Facade/FacadeTrait.php#L352-L357
41,878
eloquent/phony
src/Stub/StubRule.php
StubRule.next
public function next(): Answer { if ($this->calledCount > $this->lastIndex) { $index = $this->lastIndex; } else { $index = $this->calledCount; } ++$this->calledCount; if ( !isset($this->answers[$index]) || !$this->answers[$index]->primaryRequest() ) { throw new UndefinedAnswerException(); } return $this->answers[$index]; }
php
public function next(): Answer { if ($this->calledCount > $this->lastIndex) { $index = $this->lastIndex; } else { $index = $this->calledCount; } ++$this->calledCount; if ( !isset($this->answers[$index]) || !$this->answers[$index]->primaryRequest() ) { throw new UndefinedAnswerException(); } return $this->answers[$index]; }
[ "public", "function", "next", "(", ")", ":", "Answer", "{", "if", "(", "$", "this", "->", "calledCount", ">", "$", "this", "->", "lastIndex", ")", "{", "$", "index", "=", "$", "this", "->", "lastIndex", ";", "}", "else", "{", "$", "index", "=", "...
Get the next answer. @return Answer The answer. @throws UndefinedAnswerException If an undefined or incomplete answer is encountered.
[ "Get", "the", "next", "answer", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Stub/StubRule.php#L57-L75
41,879
eloquent/phony
src/Matcher/WildcardMatcher.php
WildcardMatcher.instance
public static function instance(): self { if (!self::$instance) { self::$instance = new self(AnyMatcher::instance(), 0, -1); } return self::$instance; }
php
public static function instance(): self { if (!self::$instance) { self::$instance = new self(AnyMatcher::instance(), 0, -1); } return self::$instance; }
[ "public", "static", "function", "instance", "(", ")", ":", "self", "{", "if", "(", "!", "self", "::", "$", "instance", ")", "{", "self", "::", "$", "instance", "=", "new", "self", "(", "AnyMatcher", "::", "instance", "(", ")", ",", "0", ",", "-", ...
Get the static instance of this matcher. @return WildcardMatcher The static matcher.
[ "Get", "the", "static", "instance", "of", "this", "matcher", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Matcher/WildcardMatcher.php#L19-L26
41,880
eloquent/phony
src/Mock/MockGenerator.php
MockGenerator.instance
public static function instance(): self { if (!self::$instance) { self::$instance = new self( Sequencer::sequence('mock-class-label'), FunctionSignatureInspector::instance(), FeatureDetector::instance() ); } return self::$instance; }
php
public static function instance(): self { if (!self::$instance) { self::$instance = new self( Sequencer::sequence('mock-class-label'), FunctionSignatureInspector::instance(), FeatureDetector::instance() ); } return self::$instance; }
[ "public", "static", "function", "instance", "(", ")", ":", "self", "{", "if", "(", "!", "self", "::", "$", "instance", ")", "{", "self", "::", "$", "instance", "=", "new", "self", "(", "Sequencer", "::", "sequence", "(", "'mock-class-label'", ")", ",",...
Get the static instance of this generator. @return MockGenerator The static generator.
[ "Get", "the", "static", "instance", "of", "this", "generator", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Mock/MockGenerator.php#L23-L34
41,881
eloquent/phony
src/Mock/MockGenerator.php
MockGenerator.generateClassName
public function generateClassName(MockDefinition $definition): string { $className = $definition->className(); if ('' !== $className) { return $className; } $className = 'PhonyMock'; $parentClassName = $definition->parentClassName(); if ('' !== $parentClassName) { $subject = $parentClassName; } elseif ($interfaceNames = $definition->interfaceNames()) { $subject = $interfaceNames[0]; } elseif ($traitNames = $definition->traitNames()) { $subject = $traitNames[0]; } else { $subject = null; } if (null !== $subject) { $subjectAtoms = preg_split('/[_\\\\]/', $subject); $className .= '_' . array_pop($subjectAtoms); } $className .= '_' . $this->labelSequencer->next(); return $className; }
php
public function generateClassName(MockDefinition $definition): string { $className = $definition->className(); if ('' !== $className) { return $className; } $className = 'PhonyMock'; $parentClassName = $definition->parentClassName(); if ('' !== $parentClassName) { $subject = $parentClassName; } elseif ($interfaceNames = $definition->interfaceNames()) { $subject = $interfaceNames[0]; } elseif ($traitNames = $definition->traitNames()) { $subject = $traitNames[0]; } else { $subject = null; } if (null !== $subject) { $subjectAtoms = preg_split('/[_\\\\]/', $subject); $className .= '_' . array_pop($subjectAtoms); } $className .= '_' . $this->labelSequencer->next(); return $className; }
[ "public", "function", "generateClassName", "(", "MockDefinition", "$", "definition", ")", ":", "string", "{", "$", "className", "=", "$", "definition", "->", "className", "(", ")", ";", "if", "(", "''", "!==", "$", "className", ")", "{", "return", "$", "...
Generate a mock class name. @param MockDefinition $definition The definition. @return string The mock class name.
[ "Generate", "a", "mock", "class", "name", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Mock/MockGenerator.php#L60-L89
41,882
eloquent/phony
src/Mock/MockGenerator.php
MockGenerator.generate
public function generate( MockDefinition $definition, string $className = '' ): string { if ('' === $className) { $className = $this->generateClassName($definition); } $source = $this->generateHeader($definition, $className) . $this->generateConstants($definition) . $this->generateMethods( $definition->methods()->publicStaticMethods() ) . $this->generateMagicCallStatic($definition) . $this->generateStructors($definition) . $this->generateMethods($definition->methods()->publicMethods()) . $this->generateMagicCall($definition) . $this->generateMethods( $definition->methods()->protectedStaticMethods() ) . $this->generateMethods($definition->methods()->protectedMethods()) . $this->generateCallParentMethods($definition) . $this->generateProperties($definition) . "\n}\n"; // @codeCoverageIgnoreStart if (PHP_EOL !== "\n") { $source = str_replace("\n", PHP_EOL, $source); } // @codeCoverageIgnoreEnd return $source; }
php
public function generate( MockDefinition $definition, string $className = '' ): string { if ('' === $className) { $className = $this->generateClassName($definition); } $source = $this->generateHeader($definition, $className) . $this->generateConstants($definition) . $this->generateMethods( $definition->methods()->publicStaticMethods() ) . $this->generateMagicCallStatic($definition) . $this->generateStructors($definition) . $this->generateMethods($definition->methods()->publicMethods()) . $this->generateMagicCall($definition) . $this->generateMethods( $definition->methods()->protectedStaticMethods() ) . $this->generateMethods($definition->methods()->protectedMethods()) . $this->generateCallParentMethods($definition) . $this->generateProperties($definition) . "\n}\n"; // @codeCoverageIgnoreStart if (PHP_EOL !== "\n") { $source = str_replace("\n", PHP_EOL, $source); } // @codeCoverageIgnoreEnd return $source; }
[ "public", "function", "generate", "(", "MockDefinition", "$", "definition", ",", "string", "$", "className", "=", "''", ")", ":", "string", "{", "if", "(", "''", "===", "$", "className", ")", "{", "$", "className", "=", "$", "this", "->", "generateClassN...
Generate a mock class and return the source code. @param MockDefinition $definition The definition. @param string $className The class name. @return string The source code.
[ "Generate", "a", "mock", "class", "and", "return", "the", "source", "code", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Mock/MockGenerator.php#L99-L131
41,883
eloquent/phony
src/Matcher/MatcherVerifier.php
MatcherVerifier.matches
public function matches(array $matchers, array $arguments): bool { $argumentCount = count($arguments); $index = 0; foreach ($matchers as $matcher) { if ($matcher instanceof WildcardMatcher) { $matchCount = 0; $innerMatcher = $matcher->matcher(); while ( $index < $argumentCount && $innerMatcher->matches($arguments[$index]) ) { ++$matchCount; ++$index; } $maximumArguments = $matcher->maximumArguments(); $isMatch = ( $maximumArguments < 0 || $matchCount <= $maximumArguments ) && $matchCount >= $matcher->minimumArguments(); if (!$isMatch) { return false; } continue; } if ( $index >= $argumentCount || !$matcher->matches($arguments[$index]) ) { return false; } ++$index; } return $index === $argumentCount; }
php
public function matches(array $matchers, array $arguments): bool { $argumentCount = count($arguments); $index = 0; foreach ($matchers as $matcher) { if ($matcher instanceof WildcardMatcher) { $matchCount = 0; $innerMatcher = $matcher->matcher(); while ( $index < $argumentCount && $innerMatcher->matches($arguments[$index]) ) { ++$matchCount; ++$index; } $maximumArguments = $matcher->maximumArguments(); $isMatch = ( $maximumArguments < 0 || $matchCount <= $maximumArguments ) && $matchCount >= $matcher->minimumArguments(); if (!$isMatch) { return false; } continue; } if ( $index >= $argumentCount || !$matcher->matches($arguments[$index]) ) { return false; } ++$index; } return $index === $argumentCount; }
[ "public", "function", "matches", "(", "array", "$", "matchers", ",", "array", "$", "arguments", ")", ":", "bool", "{", "$", "argumentCount", "=", "count", "(", "$", "arguments", ")", ";", "$", "index", "=", "0", ";", "foreach", "(", "$", "matchers", ...
Verify that the supplied arguments match the supplied matchers. @param array<Matchable> $matchers The matchers. @param array $arguments The arguments. @return bool True if the arguments match.
[ "Verify", "that", "the", "supplied", "arguments", "match", "the", "supplied", "matchers", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Matcher/MatcherVerifier.php#L34-L79
41,884
eloquent/phony
src/Matcher/MatcherVerifier.php
MatcherVerifier.explain
public function explain(array $matchers, array $arguments): MatcherResult { $isMatch = true; $matcherMatches = []; $argumentMatches = []; $argumentCount = count($arguments); $index = 0; foreach ($matchers as $matcher) { if ($matcher instanceof WildcardMatcher) { $matcherIsMatch = true; $innerMatcher = $matcher->matcher(); $minimumArguments = $matcher->minimumArguments(); $maximumArguments = $matcher->maximumArguments(); for ($count = 0; $count < $minimumArguments; ++$count) { if ($index >= $argumentCount) { $matcherIsMatch = false; $argumentMatches[] = false; break; } if ($innerMatcher->matches($arguments[$index])) { $argumentMatches[] = true; } else { $matcherIsMatch = false; $argumentMatches[] = false; } ++$index; } if ($maximumArguments < 0) { while ( $index < $argumentCount && $innerMatcher->matches($arguments[$index]) ) { $argumentMatches[] = true; ++$index; } } else { for (; $count < $maximumArguments; ++$count) { if ( $index >= $argumentCount || !$innerMatcher->matches($arguments[$index]) ) { break; } $argumentMatches[] = true; ++$index; } } $isMatch = $isMatch && $matcherIsMatch; $matcherMatches[] = $matcherIsMatch; continue; } $matcherIsMatch = $index < $argumentCount && $matcher->matches($arguments[$index]); $isMatch = $isMatch && $matcherIsMatch; $matcherMatches[] = $matcherIsMatch; $argumentMatches[] = $matcherIsMatch; ++$index; } for (; $index < $argumentCount; ++$index) { $argumentMatches[] = false; $isMatch = false; } return new MatcherResult($isMatch, $matcherMatches, $argumentMatches); }
php
public function explain(array $matchers, array $arguments): MatcherResult { $isMatch = true; $matcherMatches = []; $argumentMatches = []; $argumentCount = count($arguments); $index = 0; foreach ($matchers as $matcher) { if ($matcher instanceof WildcardMatcher) { $matcherIsMatch = true; $innerMatcher = $matcher->matcher(); $minimumArguments = $matcher->minimumArguments(); $maximumArguments = $matcher->maximumArguments(); for ($count = 0; $count < $minimumArguments; ++$count) { if ($index >= $argumentCount) { $matcherIsMatch = false; $argumentMatches[] = false; break; } if ($innerMatcher->matches($arguments[$index])) { $argumentMatches[] = true; } else { $matcherIsMatch = false; $argumentMatches[] = false; } ++$index; } if ($maximumArguments < 0) { while ( $index < $argumentCount && $innerMatcher->matches($arguments[$index]) ) { $argumentMatches[] = true; ++$index; } } else { for (; $count < $maximumArguments; ++$count) { if ( $index >= $argumentCount || !$innerMatcher->matches($arguments[$index]) ) { break; } $argumentMatches[] = true; ++$index; } } $isMatch = $isMatch && $matcherIsMatch; $matcherMatches[] = $matcherIsMatch; continue; } $matcherIsMatch = $index < $argumentCount && $matcher->matches($arguments[$index]); $isMatch = $isMatch && $matcherIsMatch; $matcherMatches[] = $matcherIsMatch; $argumentMatches[] = $matcherIsMatch; ++$index; } for (; $index < $argumentCount; ++$index) { $argumentMatches[] = false; $isMatch = false; } return new MatcherResult($isMatch, $matcherMatches, $argumentMatches); }
[ "public", "function", "explain", "(", "array", "$", "matchers", ",", "array", "$", "arguments", ")", ":", "MatcherResult", "{", "$", "isMatch", "=", "true", ";", "$", "matcherMatches", "=", "[", "]", ";", "$", "argumentMatches", "=", "[", "]", ";", "$"...
Explain which of the supplied arguments match which of the supplied matchers. @param array<Matchable> $matchers The matchers. @param array $arguments The arguments. @return MatcherResult The result of matching.
[ "Explain", "which", "of", "the", "supplied", "arguments", "match", "which", "of", "the", "supplied", "matchers", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Matcher/MatcherVerifier.php#L90-L167
41,885
eloquent/phony
src/Exporter/InlineExporter.php
InlineExporter.instance
public static function instance(): self { if (!self::$instance) { self::$instance = new self( 1, Sequencer::sequence('exporter-object-id'), InvocableInspector::instance() ); } return self::$instance; }
php
public static function instance(): self { if (!self::$instance) { self::$instance = new self( 1, Sequencer::sequence('exporter-object-id'), InvocableInspector::instance() ); } return self::$instance; }
[ "public", "static", "function", "instance", "(", ")", ":", "self", "{", "if", "(", "!", "self", "::", "$", "instance", ")", "{", "self", "::", "$", "instance", "=", "new", "self", "(", "1", ",", "Sequencer", "::", "sequence", "(", "'exporter-object-id'...
Get the static instance of this exporter. @return Exporter The static exporter.
[ "Get", "the", "static", "instance", "of", "this", "exporter", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Exporter/InlineExporter.php#L38-L49
41,886
eloquent/phony
src/Exporter/InlineExporter.php
InlineExporter.setDepth
public function setDepth(int $depth): int { $oldDepth = $this->depth; $this->depth = $depth; return $oldDepth; }
php
public function setDepth(int $depth): int { $oldDepth = $this->depth; $this->depth = $depth; return $oldDepth; }
[ "public", "function", "setDepth", "(", "int", "$", "depth", ")", ":", "int", "{", "$", "oldDepth", "=", "$", "this", "->", "depth", ";", "$", "this", "->", "depth", "=", "$", "depth", ";", "return", "$", "oldDepth", ";", "}" ]
Set the default depth. Negative depths are treated as infinite depth. @param int $depth The depth. @return int The previous depth.
[ "Set", "the", "default", "depth", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Exporter/InlineExporter.php#L86-L92
41,887
eloquent/phony
src/Exporter/InlineExporter.php
InlineExporter.exportCallable
public function exportCallable($callback): string { $wrappedCallback = null; while ($callback instanceof WrappedInvocable) { $wrappedCallback = $callback; $callback = $callback->callback(); } $label = ''; if ($wrappedCallback) { if ($wrappedCallback->isAnonymous()) { return $this->export($wrappedCallback); } $label = $wrappedCallback->label(); if ('' !== $label) { $label = '[' . $label . ']'; } } if ($callback instanceof Closure) { return $this->export($callback) . $label; } $reflector = $this->invocableInspector->callbackReflector($callback); if (!$reflector instanceof ReflectionMethod) { return $reflector->getName() . $label; } $class = $reflector->getDeclaringClass(); $name = $reflector->getName(); if ($class->implementsInterface(Mock::class)) { if ( ($parentClass = $class->getParentClass()) && $parentClass->hasMethod($name) ) { $class = $parentClass; } else { try { $prototype = $reflector->getPrototype(); $class = $prototype->getDeclaringClass(); } catch (ReflectionException $e) { // ignore } } } $atoms = explode('\\', $class->getName()); $rendered = array_pop($atoms); if ($wrappedCallback instanceof WrappedMethod) { $name = $wrappedCallback->name(); $handle = $wrappedCallback->handle(); if ($handle instanceof InstanceHandle) { $label = $handle->label(); if ('' !== $label) { $rendered .= '[' . $label . ']'; } } } if ($reflector->isStatic()) { $callOperator = '::'; } else { $callOperator = '->'; } return $rendered . $callOperator . $name; }
php
public function exportCallable($callback): string { $wrappedCallback = null; while ($callback instanceof WrappedInvocable) { $wrappedCallback = $callback; $callback = $callback->callback(); } $label = ''; if ($wrappedCallback) { if ($wrappedCallback->isAnonymous()) { return $this->export($wrappedCallback); } $label = $wrappedCallback->label(); if ('' !== $label) { $label = '[' . $label . ']'; } } if ($callback instanceof Closure) { return $this->export($callback) . $label; } $reflector = $this->invocableInspector->callbackReflector($callback); if (!$reflector instanceof ReflectionMethod) { return $reflector->getName() . $label; } $class = $reflector->getDeclaringClass(); $name = $reflector->getName(); if ($class->implementsInterface(Mock::class)) { if ( ($parentClass = $class->getParentClass()) && $parentClass->hasMethod($name) ) { $class = $parentClass; } else { try { $prototype = $reflector->getPrototype(); $class = $prototype->getDeclaringClass(); } catch (ReflectionException $e) { // ignore } } } $atoms = explode('\\', $class->getName()); $rendered = array_pop($atoms); if ($wrappedCallback instanceof WrappedMethod) { $name = $wrappedCallback->name(); $handle = $wrappedCallback->handle(); if ($handle instanceof InstanceHandle) { $label = $handle->label(); if ('' !== $label) { $rendered .= '[' . $label . ']'; } } } if ($reflector->isStatic()) { $callOperator = '::'; } else { $callOperator = '->'; } return $rendered . $callOperator . $name; }
[ "public", "function", "exportCallable", "(", "$", "callback", ")", ":", "string", "{", "$", "wrappedCallback", "=", "null", ";", "while", "(", "$", "callback", "instanceof", "WrappedInvocable", ")", "{", "$", "wrappedCallback", "=", "$", "callback", ";", "$"...
Export a string representation of a callable value. @param callable $callback The callable. @return string The exported callable.
[ "Export", "a", "string", "representation", "of", "a", "callable", "value", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Exporter/InlineExporter.php#L642-L717
41,888
eloquent/phony
src/Stub/StubData.php
StubData.with
public function with(...$arguments): Stub { $this->closeRule(); if (empty($this->rules)) { $defaultAnswerCallback = $this->defaultAnswerCallback; $defaultAnswerCallback($this); $this->closeRule(); } $this->criteria = $this->matcherFactory->adaptAll($arguments); return $this; }
php
public function with(...$arguments): Stub { $this->closeRule(); if (empty($this->rules)) { $defaultAnswerCallback = $this->defaultAnswerCallback; $defaultAnswerCallback($this); $this->closeRule(); } $this->criteria = $this->matcherFactory->adaptAll($arguments); return $this; }
[ "public", "function", "with", "(", "...", "$", "arguments", ")", ":", "Stub", "{", "$", "this", "->", "closeRule", "(", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "rules", ")", ")", "{", "$", "defaultAnswerCallback", "=", "$", "this", "-...
Modify the current criteria to match the supplied arguments. @param mixed ...$arguments The arguments. @return $this This stub.
[ "Modify", "the", "current", "criteria", "to", "match", "the", "supplied", "arguments", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Stub/StubData.php#L161-L174
41,889
eloquent/phony
src/Stub/StubData.php
StubData.returns
public function returns(...$values): Stub { if (empty($values)) { $callback = $this->callback; $invocableInspector = $this->invocableInspector; $emptyValueFactory = $this->emptyValueFactory; $value = null; $valueIsSet = false; return $this->doesWith( function () use ( &$value, &$valueIsSet, $callback, $invocableInspector, $emptyValueFactory ) { if (!$valueIsSet) { if ( $type = $invocableInspector ->callbackReturnType($callback) ) { try { $value = $emptyValueFactory->fromType($type); } catch (FinalClassException $e){ throw new FinalReturnTypeException( $this->exporter->exportCallable($callback), strval($type), $e ); } } else { $value = null; } $valueIsSet = true; } return $value; }, [], false, false, false ); } foreach ($values as $value) { if ($value instanceof InstanceHandle) { $value = $value->get(); } $this->doesWith( function () use ($value) { return $value; }, [], false, false, false ); } return $this; }
php
public function returns(...$values): Stub { if (empty($values)) { $callback = $this->callback; $invocableInspector = $this->invocableInspector; $emptyValueFactory = $this->emptyValueFactory; $value = null; $valueIsSet = false; return $this->doesWith( function () use ( &$value, &$valueIsSet, $callback, $invocableInspector, $emptyValueFactory ) { if (!$valueIsSet) { if ( $type = $invocableInspector ->callbackReturnType($callback) ) { try { $value = $emptyValueFactory->fromType($type); } catch (FinalClassException $e){ throw new FinalReturnTypeException( $this->exporter->exportCallable($callback), strval($type), $e ); } } else { $value = null; } $valueIsSet = true; } return $value; }, [], false, false, false ); } foreach ($values as $value) { if ($value instanceof InstanceHandle) { $value = $value->get(); } $this->doesWith( function () use ($value) { return $value; }, [], false, false, false ); } return $this; }
[ "public", "function", "returns", "(", "...", "$", "values", ")", ":", "Stub", "{", "if", "(", "empty", "(", "$", "values", ")", ")", "{", "$", "callback", "=", "$", "this", "->", "callback", ";", "$", "invocableInspector", "=", "$", "this", "->", "...
Add an answer that returns a value. Calling this method with no arguments is equivalent to calling it with a single argument of `null`. @param mixed ...$values The return values. @return $this This stub.
[ "Add", "an", "answer", "that", "returns", "a", "value", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Stub/StubData.php#L497-L562
41,890
eloquent/phony
src/Stub/StubData.php
StubData.returnsArgument
public function returnsArgument(int $index = 0): Stub { return $this->doesWith( function ($arguments) use ($index) { return $arguments->get($index); }, [], false, true, false ); }
php
public function returnsArgument(int $index = 0): Stub { return $this->doesWith( function ($arguments) use ($index) { return $arguments->get($index); }, [], false, true, false ); }
[ "public", "function", "returnsArgument", "(", "int", "$", "index", "=", "0", ")", ":", "Stub", "{", "return", "$", "this", "->", "doesWith", "(", "function", "(", "$", "arguments", ")", "use", "(", "$", "index", ")", "{", "return", "$", "arguments", ...
Add an answer that returns an argument. Negative indices are offset from the end of the list. That is, `-1` indicates the last element, and `-2` indicates the second last element. @param int $index The argument index. @return $this This stub.
[ "Add", "an", "answer", "that", "returns", "an", "argument", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Stub/StubData.php#L574-L585
41,891
eloquent/phony
src/Stub/StubData.php
StubData.throws
public function throws(...$exceptions): Stub { if (empty($exceptions)) { return $this->doesWith( function () { throw new Exception(); }, [], false, false, false ); } foreach ($exceptions as $exception) { if (is_string($exception)) { $exception = new Exception($exception); } elseif ($exception instanceof InstanceHandle) { $exception = $exception->get(); } $this->doesWith( function () use ($exception) { throw $exception; }, [], false, false, false ); } return $this; }
php
public function throws(...$exceptions): Stub { if (empty($exceptions)) { return $this->doesWith( function () { throw new Exception(); }, [], false, false, false ); } foreach ($exceptions as $exception) { if (is_string($exception)) { $exception = new Exception($exception); } elseif ($exception instanceof InstanceHandle) { $exception = $exception->get(); } $this->doesWith( function () use ($exception) { throw $exception; }, [], false, false, false ); } return $this; }
[ "public", "function", "throws", "(", "...", "$", "exceptions", ")", ":", "Stub", "{", "if", "(", "empty", "(", "$", "exceptions", ")", ")", "{", "return", "$", "this", "->", "doesWith", "(", "function", "(", ")", "{", "throw", "new", "Exception", "("...
Add an answer that throws an exception. Calling this method with no arguments is equivalent to calling it with a single argument of `null`. @param Throwable|string|null ...$exceptions The exceptions, or messages, or nulls to throw generic exceptions. @return $this This stub.
[ "Add", "an", "answer", "that", "throws", "an", "exception", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Stub/StubData.php#L615-L648
41,892
eloquent/phony
src/Stub/StubData.php
StubData.generates
public function generates(...$values): GeneratorAnswerBuilder { $builder = $this->generatorAnswerBuilderFactory->create($this); $this->doesWith($builder->answer(), [], true, true, false); foreach ($values as $index => $subValues) { if ($index > 0) { $builder->returns(); $builder = $this->generatorAnswerBuilderFactory->create($this); $this->doesWith($builder->answer(), [], true, true, false); } $builder->yieldsFrom($subValues); } return $builder; }
php
public function generates(...$values): GeneratorAnswerBuilder { $builder = $this->generatorAnswerBuilderFactory->create($this); $this->doesWith($builder->answer(), [], true, true, false); foreach ($values as $index => $subValues) { if ($index > 0) { $builder->returns(); $builder = $this->generatorAnswerBuilderFactory->create($this); $this->doesWith($builder->answer(), [], true, true, false); } $builder->yieldsFrom($subValues); } return $builder; }
[ "public", "function", "generates", "(", "...", "$", "values", ")", ":", "GeneratorAnswerBuilder", "{", "$", "builder", "=", "$", "this", "->", "generatorAnswerBuilderFactory", "->", "create", "(", "$", "this", ")", ";", "$", "this", "->", "doesWith", "(", ...
Add an answer that returns a generator, and return a builder for customizing the generator's behavior. @param mixed<mixed,mixed> ...$values Sets of keys and values to yield. @return GeneratorAnswerBuilder The answer builder.
[ "Add", "an", "answer", "that", "returns", "a", "generator", "and", "return", "a", "builder", "for", "customizing", "the", "generator", "s", "behavior", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Stub/StubData.php#L658-L675
41,893
eloquent/phony
src/Stub/StubData.php
StubData.closeRule
public function closeRule(): Stub { if (!empty($this->secondaryRequests)) { $defaultAnswerCallback = $this->defaultAnswerCallback; $defaultAnswerCallback($this); $this->secondaryRequests = []; } if (!empty($this->answers)) { if (null !== $this->criteria) { $rule = new StubRule($this->criteria, $this->answers); $this->criteria = null; } else { $rule = new StubRule( [$this->matcherFactory->wildcard()], $this->answers ); } array_unshift($this->rules, $rule); $this->answers = []; } if (null !== $this->criteria) { $criteria = $this->criteria; $this->criteria = null; throw new UnusedStubCriteriaException($criteria); } return $this; }
php
public function closeRule(): Stub { if (!empty($this->secondaryRequests)) { $defaultAnswerCallback = $this->defaultAnswerCallback; $defaultAnswerCallback($this); $this->secondaryRequests = []; } if (!empty($this->answers)) { if (null !== $this->criteria) { $rule = new StubRule($this->criteria, $this->answers); $this->criteria = null; } else { $rule = new StubRule( [$this->matcherFactory->wildcard()], $this->answers ); } array_unshift($this->rules, $rule); $this->answers = []; } if (null !== $this->criteria) { $criteria = $this->criteria; $this->criteria = null; throw new UnusedStubCriteriaException($criteria); } return $this; }
[ "public", "function", "closeRule", "(", ")", ":", "Stub", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "secondaryRequests", ")", ")", "{", "$", "defaultAnswerCallback", "=", "$", "this", "->", "defaultAnswerCallback", ";", "$", "defaultAnswerCallbac...
Close any existing rule. @return $this This stub.
[ "Close", "any", "existing", "rule", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Stub/StubData.php#L682-L714
41,894
eloquent/phony
src/Hook/FunctionHookManager.php
FunctionHookManager.instance
public static function instance(): self { if (!self::$instance) { self::$instance = new self( InvocableInspector::instance(), FunctionSignatureInspector::instance(), FunctionHookGenerator::instance() ); } return self::$instance; }
php
public static function instance(): self { if (!self::$instance) { self::$instance = new self( InvocableInspector::instance(), FunctionSignatureInspector::instance(), FunctionHookGenerator::instance() ); } return self::$instance; }
[ "public", "static", "function", "instance", "(", ")", ":", "self", "{", "if", "(", "!", "self", "::", "$", "instance", ")", "{", "self", "::", "$", "instance", "=", "new", "self", "(", "InvocableInspector", "::", "instance", "(", ")", ",", "FunctionSig...
Get the static instance of this manager. @return FunctionHookManager The static manager.
[ "Get", "the", "static", "instance", "of", "this", "manager", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Hook/FunctionHookManager.php#L25-L36
41,895
eloquent/phony
src/Hook/FunctionHookManager.php
FunctionHookManager.defineFunction
public function defineFunction( string $name, string $namespace, $callback ) { $signature = $this->signatureInspector->signature( $this->invocableInspector->callbackReflector($callback) ); $fullName = $namespace . '\\' . $name; $key = strtolower($fullName); if (isset(self::$hooks[$key])) { if ($signature !== self::$hooks[$key]['signature']) { throw new FunctionSignatureMismatchException($fullName); } $replaced = self::$hooks[$key]['callback']; } else { $replaced = null; if (function_exists($fullName)) { throw new FunctionExistsException($fullName); } $source = $this->hookGenerator ->generateHook($name, $namespace, $signature); $reporting = error_reporting(E_ERROR | E_COMPILE_ERROR); try { eval($source); } catch (ParseError $e) { throw new FunctionHookGenerationFailedException( $fullName, $callback, $source, error_get_last(), $e ); } finally { error_reporting($reporting); } if (!function_exists($fullName)) { // @codeCoverageIgnoreStart throw new FunctionHookGenerationFailedException( $fullName, $callback, $source, error_get_last() ); // @codeCoverageIgnoreEnd } } self::$hooks[$key] = ['callback' => $callback, 'signature' => $signature]; return $replaced; }
php
public function defineFunction( string $name, string $namespace, $callback ) { $signature = $this->signatureInspector->signature( $this->invocableInspector->callbackReflector($callback) ); $fullName = $namespace . '\\' . $name; $key = strtolower($fullName); if (isset(self::$hooks[$key])) { if ($signature !== self::$hooks[$key]['signature']) { throw new FunctionSignatureMismatchException($fullName); } $replaced = self::$hooks[$key]['callback']; } else { $replaced = null; if (function_exists($fullName)) { throw new FunctionExistsException($fullName); } $source = $this->hookGenerator ->generateHook($name, $namespace, $signature); $reporting = error_reporting(E_ERROR | E_COMPILE_ERROR); try { eval($source); } catch (ParseError $e) { throw new FunctionHookGenerationFailedException( $fullName, $callback, $source, error_get_last(), $e ); } finally { error_reporting($reporting); } if (!function_exists($fullName)) { // @codeCoverageIgnoreStart throw new FunctionHookGenerationFailedException( $fullName, $callback, $source, error_get_last() ); // @codeCoverageIgnoreEnd } } self::$hooks[$key] = ['callback' => $callback, 'signature' => $signature]; return $replaced; }
[ "public", "function", "defineFunction", "(", "string", "$", "name", ",", "string", "$", "namespace", ",", "$", "callback", ")", "{", "$", "signature", "=", "$", "this", "->", "signatureInspector", "->", "signature", "(", "$", "this", "->", "invocableInspecto...
Define the behavior of a function hook. @param string $name The function name. @param string $namespace The namespace. @param callable $callback The callback. @return callable|null The replaced callback, or null if no callback was set. @throws FunctionHookException If the function hook generation fails.
[ "Define", "the", "behavior", "of", "a", "function", "hook", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Hook/FunctionHookManager.php#L65-L123
41,896
eloquent/phony
src/Hook/FunctionHookManager.php
FunctionHookManager.restoreGlobalFunctions
public function restoreGlobalFunctions(): void { foreach (self::$hooks as $key => $data) { self::$hooks[$key]['callback'] = null; } }
php
public function restoreGlobalFunctions(): void { foreach (self::$hooks as $key => $data) { self::$hooks[$key]['callback'] = null; } }
[ "public", "function", "restoreGlobalFunctions", "(", ")", ":", "void", "{", "foreach", "(", "self", "::", "$", "hooks", "as", "$", "key", "=>", "$", "data", ")", "{", "self", "::", "$", "hooks", "[", "$", "key", "]", "[", "'callback'", "]", "=", "n...
Effectively removes any function hooks for functions in the global namespace.
[ "Effectively", "removes", "any", "function", "hooks", "for", "functions", "in", "the", "global", "namespace", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Hook/FunctionHookManager.php#L129-L134
41,897
eloquent/phony
src/Stub/StubVerifier.php
StubVerifier.setsArgument
public function setsArgument($indexOrValue = null, $value = null): Stub { if (func_num_args() > 1) { $this->stub->setsArgument($indexOrValue, $value); } else { $this->stub->setsArgument($indexOrValue); } return $this; }
php
public function setsArgument($indexOrValue = null, $value = null): Stub { if (func_num_args() > 1) { $this->stub->setsArgument($indexOrValue, $value); } else { $this->stub->setsArgument($indexOrValue); } return $this; }
[ "public", "function", "setsArgument", "(", "$", "indexOrValue", "=", "null", ",", "$", "value", "=", "null", ")", ":", "Stub", "{", "if", "(", "func_num_args", "(", ")", ">", "1", ")", "{", "$", "this", "->", "stub", "->", "setsArgument", "(", "$", ...
Set the value of an argument passed by reference as part of an answer. If called with no arguments, sets the first argument to null. If called with one argument, sets the first argument to $indexOrValue. If called with two arguments, sets the argument at $indexOrValue to $value. @param mixed $indexOrValue The index, or value if no index is specified. @param mixed $value The value. @return $this This stub.
[ "Set", "the", "value", "of", "an", "argument", "passed", "by", "reference", "as", "part", "of", "an", "answer", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Stub/StubVerifier.php#L286-L295
41,898
eloquent/phony
src/Difference/DifferenceSequenceMatcher.php
DifferenceSequenceMatcher.tupleSort
private function tupleSort($a, $b) { $aLength = count($a); $bLength = count($b); if ($aLength > $bLength) { $max = $aLength; } else { $max = $bLength; } for ($i = 0; $i < $max; ++$i) { if ($a[$i] < $b[$i]) { return -1; } if ($a[$i] > $b[$i]) { return 1; } } return $aLength <=> $bLength; }
php
private function tupleSort($a, $b) { $aLength = count($a); $bLength = count($b); if ($aLength > $bLength) { $max = $aLength; } else { $max = $bLength; } for ($i = 0; $i < $max; ++$i) { if ($a[$i] < $b[$i]) { return -1; } if ($a[$i] > $b[$i]) { return 1; } } return $aLength <=> $bLength; }
[ "private", "function", "tupleSort", "(", "$", "a", ",", "$", "b", ")", "{", "$", "aLength", "=", "count", "(", "$", "a", ")", ";", "$", "bLength", "=", "count", "(", "$", "b", ")", ";", "if", "(", "$", "aLength", ">", "$", "bLength", ")", "{"...
Sort an array by the nested arrays it contains. Helper function for getMatchingBlocks. @param array $a First array to compare. @param array $b Second array to compare. @return int -1, 0 or 1, as expected by the usort function.
[ "Sort", "an", "array", "by", "the", "nested", "arrays", "it", "contains", ".", "Helper", "function", "for", "getMatchingBlocks", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Difference/DifferenceSequenceMatcher.php#L326-L348
41,899
eloquent/phony
src/Verification/Cardinality.php
Cardinality.setIsAlways
public function setIsAlways(bool $isAlways): void { if ($isAlways && $this->isNever()) { throw new InvalidCardinalityStateException(); } $this->isAlways = $isAlways; }
php
public function setIsAlways(bool $isAlways): void { if ($isAlways && $this->isNever()) { throw new InvalidCardinalityStateException(); } $this->isAlways = $isAlways; }
[ "public", "function", "setIsAlways", "(", "bool", "$", "isAlways", ")", ":", "void", "{", "if", "(", "$", "isAlways", "&&", "$", "this", "->", "isNever", "(", ")", ")", "{", "throw", "new", "InvalidCardinalityStateException", "(", ")", ";", "}", "$", "...
Turn 'always' on or off. @param bool $isAlways True to enable 'always'. @throws InvalidCardinalityException If the cardinality is invalid.
[ "Turn", "always", "on", "or", "off", "." ]
54ac8a937079da0d818d82aaf5edd61501c48f2c
https://github.com/eloquent/phony/blob/54ac8a937079da0d818d82aaf5edd61501c48f2c/src/Verification/Cardinality.php#L86-L93