repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
TimeToogo/Pinq
Source/Iterators/Common/OrderedMap.php
OrderedMap.map
public function map(callable $function) { $function = Functions::allowExcessiveArguments($function); $clone = clone $this; foreach ($clone->keyIdentityPositionMap as $position) { $keyCopy = $this->keys[$position]; $valueCopy = $this->values[$position]; $clone->values[$position] = $function($valueCopy, $keyCopy); } return $clone; }
php
public function map(callable $function) { $function = Functions::allowExcessiveArguments($function); $clone = clone $this; foreach ($clone->keyIdentityPositionMap as $position) { $keyCopy = $this->keys[$position]; $valueCopy = $this->values[$position]; $clone->values[$position] = $function($valueCopy, $keyCopy); } return $clone; }
[ "public", "function", "map", "(", "callable", "$", "function", ")", "{", "$", "function", "=", "Functions", "::", "allowExcessiveArguments", "(", "$", "function", ")", ";", "$", "clone", "=", "clone", "$", "this", ";", "foreach", "(", "$", "clone", "->", "keyIdentityPositionMap", "as", "$", "position", ")", "{", "$", "keyCopy", "=", "$", "this", "->", "keys", "[", "$", "position", "]", ";", "$", "valueCopy", "=", "$", "this", "->", "values", "[", "$", "position", "]", ";", "$", "clone", "->", "values", "[", "$", "position", "]", "=", "$", "function", "(", "$", "valueCopy", ",", "$", "keyCopy", ")", ";", "}", "return", "$", "clone", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Iterators/Common/OrderedMap.php#L56-L69
TimeToogo/Pinq
Source/Iterators/Common/OrderedMap.php
OrderedMap.walk
public function walk(callable $function) { $function = Functions::allowExcessiveArguments($function); foreach ($this->keys as $position => $key) { $function($this->values[$position], $key); } }
php
public function walk(callable $function) { $function = Functions::allowExcessiveArguments($function); foreach ($this->keys as $position => $key) { $function($this->values[$position], $key); } }
[ "public", "function", "walk", "(", "callable", "$", "function", ")", "{", "$", "function", "=", "Functions", "::", "allowExcessiveArguments", "(", "$", "function", ")", ";", "foreach", "(", "$", "this", "->", "keys", "as", "$", "position", "=>", "$", "key", ")", "{", "$", "function", "(", "$", "this", "->", "values", "[", "$", "position", "]", ",", "$", "key", ")", ";", "}", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Iterators/Common/OrderedMap.php#L74-L81
TimeToogo/Pinq
Source/Iterators/Common/OrderedMap.php
OrderedMap.groupBy
public function groupBy(callable $groupKeyFunction) { $groupedMap = new self(); foreach ($this->keyIdentityPositionMap as $identityHash => $position) { $keyCopy = $key = $this->keys[$position]; $valueCopy = $value =& $this->values[$position]; $groupKey = $groupKeyFunction($valueCopy, $keyCopy); if ($groupedMap->contains($groupKey)) { $groupMap = $groupedMap->get($groupKey); } else { $groupMap = new self(); $groupedMap->set($groupKey, $groupMap); } $groupMap->setInternal($key, $value, $identityHash, true); } return $groupedMap; }
php
public function groupBy(callable $groupKeyFunction) { $groupedMap = new self(); foreach ($this->keyIdentityPositionMap as $identityHash => $position) { $keyCopy = $key = $this->keys[$position]; $valueCopy = $value =& $this->values[$position]; $groupKey = $groupKeyFunction($valueCopy, $keyCopy); if ($groupedMap->contains($groupKey)) { $groupMap = $groupedMap->get($groupKey); } else { $groupMap = new self(); $groupedMap->set($groupKey, $groupMap); } $groupMap->setInternal($key, $value, $identityHash, true); } return $groupedMap; }
[ "public", "function", "groupBy", "(", "callable", "$", "groupKeyFunction", ")", "{", "$", "groupedMap", "=", "new", "self", "(", ")", ";", "foreach", "(", "$", "this", "->", "keyIdentityPositionMap", "as", "$", "identityHash", "=>", "$", "position", ")", "{", "$", "keyCopy", "=", "$", "key", "=", "$", "this", "->", "keys", "[", "$", "position", "]", ";", "$", "valueCopy", "=", "$", "value", "=", "&", "$", "this", "->", "values", "[", "$", "position", "]", ";", "$", "groupKey", "=", "$", "groupKeyFunction", "(", "$", "valueCopy", ",", "$", "keyCopy", ")", ";", "if", "(", "$", "groupedMap", "->", "contains", "(", "$", "groupKey", ")", ")", "{", "$", "groupMap", "=", "$", "groupedMap", "->", "get", "(", "$", "groupKey", ")", ";", "}", "else", "{", "$", "groupMap", "=", "new", "self", "(", ")", ";", "$", "groupedMap", "->", "set", "(", "$", "groupKey", ",", "$", "groupMap", ")", ";", "}", "$", "groupMap", "->", "setInternal", "(", "$", "key", ",", "$", "value", ",", "$", "identityHash", ",", "true", ")", ";", "}", "return", "$", "groupedMap", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Iterators/Common/OrderedMap.php#L86-L107
TimeToogo/Pinq
Source/Iterators/Common/OrderedMap.php
OrderedMap.multisort
public function multisort(array $orderByFunctions, array $isAscending) { $positionKeyIdentityMap = []; $multisortArguments = []; foreach ($this->keyIdentityPositionMap as $keyIdentityHash => $position) { $positionKeyIdentityMap['0' . $position] = $keyIdentityHash; } foreach ($orderByFunctions as $key => $function) { $orderByValues = []; foreach ($this->keyIdentityPositionMap as $position) { $orderByValues['0' . $position] = $function($this->values[$position], $this->keys[$position]); } $multisortArguments[] =& $orderByValues; $multisortArguments[] = $isAscending[$key] ? SORT_ASC : SORT_DESC; $multisortArguments[] = SORT_REGULAR; unset($orderByValues); } $multisortArguments[] =& $positionKeyIdentityMap; call_user_func_array('array_multisort', $multisortArguments); $sortedMap = new self(); $newPosition = 0; foreach ($positionKeyIdentityMap as $stringPosition => $keyIdentityHash) { $originalPosition = (int) $stringPosition; $sortedMap->keyIdentityPositionMap[$keyIdentityHash] = $newPosition; $sortedMap->keys[$newPosition] = $this->keys[$originalPosition]; $sortedMap->values[$newPosition] =& $this->values[$originalPosition]; $newPosition++; } return $sortedMap; }
php
public function multisort(array $orderByFunctions, array $isAscending) { $positionKeyIdentityMap = []; $multisortArguments = []; foreach ($this->keyIdentityPositionMap as $keyIdentityHash => $position) { $positionKeyIdentityMap['0' . $position] = $keyIdentityHash; } foreach ($orderByFunctions as $key => $function) { $orderByValues = []; foreach ($this->keyIdentityPositionMap as $position) { $orderByValues['0' . $position] = $function($this->values[$position], $this->keys[$position]); } $multisortArguments[] =& $orderByValues; $multisortArguments[] = $isAscending[$key] ? SORT_ASC : SORT_DESC; $multisortArguments[] = SORT_REGULAR; unset($orderByValues); } $multisortArguments[] =& $positionKeyIdentityMap; call_user_func_array('array_multisort', $multisortArguments); $sortedMap = new self(); $newPosition = 0; foreach ($positionKeyIdentityMap as $stringPosition => $keyIdentityHash) { $originalPosition = (int) $stringPosition; $sortedMap->keyIdentityPositionMap[$keyIdentityHash] = $newPosition; $sortedMap->keys[$newPosition] = $this->keys[$originalPosition]; $sortedMap->values[$newPosition] =& $this->values[$originalPosition]; $newPosition++; } return $sortedMap; }
[ "public", "function", "multisort", "(", "array", "$", "orderByFunctions", ",", "array", "$", "isAscending", ")", "{", "$", "positionKeyIdentityMap", "=", "[", "]", ";", "$", "multisortArguments", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "keyIdentityPositionMap", "as", "$", "keyIdentityHash", "=>", "$", "position", ")", "{", "$", "positionKeyIdentityMap", "[", "'0'", ".", "$", "position", "]", "=", "$", "keyIdentityHash", ";", "}", "foreach", "(", "$", "orderByFunctions", "as", "$", "key", "=>", "$", "function", ")", "{", "$", "orderByValues", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "keyIdentityPositionMap", "as", "$", "position", ")", "{", "$", "orderByValues", "[", "'0'", ".", "$", "position", "]", "=", "$", "function", "(", "$", "this", "->", "values", "[", "$", "position", "]", ",", "$", "this", "->", "keys", "[", "$", "position", "]", ")", ";", "}", "$", "multisortArguments", "[", "]", "=", "&", "$", "orderByValues", ";", "$", "multisortArguments", "[", "]", "=", "$", "isAscending", "[", "$", "key", "]", "?", "SORT_ASC", ":", "SORT_DESC", ";", "$", "multisortArguments", "[", "]", "=", "SORT_REGULAR", ";", "unset", "(", "$", "orderByValues", ")", ";", "}", "$", "multisortArguments", "[", "]", "=", "&", "$", "positionKeyIdentityMap", ";", "call_user_func_array", "(", "'array_multisort'", ",", "$", "multisortArguments", ")", ";", "$", "sortedMap", "=", "new", "self", "(", ")", ";", "$", "newPosition", "=", "0", ";", "foreach", "(", "$", "positionKeyIdentityMap", "as", "$", "stringPosition", "=>", "$", "keyIdentityHash", ")", "{", "$", "originalPosition", "=", "(", "int", ")", "$", "stringPosition", ";", "$", "sortedMap", "->", "keyIdentityPositionMap", "[", "$", "keyIdentityHash", "]", "=", "$", "newPosition", ";", "$", "sortedMap", "->", "keys", "[", "$", "newPosition", "]", "=", "$", "this", "->", "keys", "[", "$", "originalPosition", "]", ";", "$", "sortedMap", "->", "values", "[", "$", "newPosition", "]", "=", "&", "$", "this", "->", "values", "[", "$", "originalPosition", "]", ";", "$", "newPosition", "++", ";", "}", "return", "$", "sortedMap", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Iterators/Common/OrderedMap.php#L112-L153
TimeToogo/Pinq
Source/Iterators/Common/OrderedMap.php
OrderedMap.&
public function &get($key) { $identityHash = Identity::hash($key); if (isset($this->keyIdentityPositionMap[$identityHash])) { return $this->values[$this->keyIdentityPositionMap[$identityHash]]; } else { $null = null; return $null; } }
php
public function &get($key) { $identityHash = Identity::hash($key); if (isset($this->keyIdentityPositionMap[$identityHash])) { return $this->values[$this->keyIdentityPositionMap[$identityHash]]; } else { $null = null; return $null; } }
[ "public", "function", "&", "get", "(", "$", "key", ")", "{", "$", "identityHash", "=", "Identity", "::", "hash", "(", "$", "key", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "keyIdentityPositionMap", "[", "$", "identityHash", "]", ")", ")", "{", "return", "$", "this", "->", "values", "[", "$", "this", "->", "keyIdentityPositionMap", "[", "$", "identityHash", "]", "]", ";", "}", "else", "{", "$", "null", "=", "null", ";", "return", "$", "null", ";", "}", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Iterators/Common/OrderedMap.php#L173-L184
TimeToogo/Pinq
Source/Iterators/Common/OrderedMap.php
OrderedMap.set
public function set($key, $value) { $this->setInternal($key, $value, Identity::hash($key)); }
php
public function set($key, $value) { $this->setInternal($key, $value, Identity::hash($key)); }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", ")", "{", "$", "this", "->", "setInternal", "(", "$", "key", ",", "$", "value", ",", "Identity", "::", "hash", "(", "$", "key", ")", ")", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Iterators/Common/OrderedMap.php#L197-L200
TimeToogo/Pinq
Source/Iterators/Common/OrderedMap.php
OrderedMap.setRef
public function setRef($key, &$value) { $this->setInternal($key, $value, Identity::hash($key), true); }
php
public function setRef($key, &$value) { $this->setInternal($key, $value, Identity::hash($key), true); }
[ "public", "function", "setRef", "(", "$", "key", ",", "&", "$", "value", ")", "{", "$", "this", "->", "setInternal", "(", "$", "key", ",", "$", "value", ",", "Identity", "::", "hash", "(", "$", "key", ")", ",", "true", ")", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Iterators/Common/OrderedMap.php#L205-L208
TimeToogo/Pinq
Source/Iterators/Common/OrderedMap.php
OrderedMap.remove
public function remove($key) { $identityHash = Identity::hash($key); if (isset($this->keyIdentityPositionMap[$identityHash])) { $position = $this->keyIdentityPositionMap[$identityHash]; unset($this->keys[$position], $this->values[$position], $this->keyIdentityPositionMap[$identityHash]); if ($position !== $this->length) { $this->keys = array_values($this->keys); $this->values = array_values($this->values); } $this->length--; if ($key === $this->largestIntKey) { $this->loadLargestIntKey(); } return true; } return false; }
php
public function remove($key) { $identityHash = Identity::hash($key); if (isset($this->keyIdentityPositionMap[$identityHash])) { $position = $this->keyIdentityPositionMap[$identityHash]; unset($this->keys[$position], $this->values[$position], $this->keyIdentityPositionMap[$identityHash]); if ($position !== $this->length) { $this->keys = array_values($this->keys); $this->values = array_values($this->values); } $this->length--; if ($key === $this->largestIntKey) { $this->loadLargestIntKey(); } return true; } return false; }
[ "public", "function", "remove", "(", "$", "key", ")", "{", "$", "identityHash", "=", "Identity", "::", "hash", "(", "$", "key", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "keyIdentityPositionMap", "[", "$", "identityHash", "]", ")", ")", "{", "$", "position", "=", "$", "this", "->", "keyIdentityPositionMap", "[", "$", "identityHash", "]", ";", "unset", "(", "$", "this", "->", "keys", "[", "$", "position", "]", ",", "$", "this", "->", "values", "[", "$", "position", "]", ",", "$", "this", "->", "keyIdentityPositionMap", "[", "$", "identityHash", "]", ")", ";", "if", "(", "$", "position", "!==", "$", "this", "->", "length", ")", "{", "$", "this", "->", "keys", "=", "array_values", "(", "$", "this", "->", "keys", ")", ";", "$", "this", "->", "values", "=", "array_values", "(", "$", "this", "->", "values", ")", ";", "}", "$", "this", "->", "length", "--", ";", "if", "(", "$", "key", "===", "$", "this", "->", "largestIntKey", ")", "{", "$", "this", "->", "loadLargestIntKey", "(", ")", ";", "}", "return", "true", ";", "}", "return", "false", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Iterators/Common/OrderedMap.php#L233-L258
TimeToogo/Pinq
Source/Iterators/Common/OrderedMap.php
OrderedMap.clear
public function clear() { $this->keyIdentityPositionMap = []; $this->keys = []; $this->values = []; $this->length = 0; $this->largestIntKey = -1; }
php
public function clear() { $this->keyIdentityPositionMap = []; $this->keys = []; $this->values = []; $this->length = 0; $this->largestIntKey = -1; }
[ "public", "function", "clear", "(", ")", "{", "$", "this", "->", "keyIdentityPositionMap", "=", "[", "]", ";", "$", "this", "->", "keys", "=", "[", "]", ";", "$", "this", "->", "values", "=", "[", "]", ";", "$", "this", "->", "length", "=", "0", ";", "$", "this", "->", "largestIntKey", "=", "-", "1", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Iterators/Common/OrderedMap.php#L263-L270
TimeToogo/Pinq
Source/Expressions/CastExpression.php
CastExpression.update
public function update($castType, Expression $castValue) { if ($this->castType === $castType && $this->castValue === $castValue) { return $this; } return new self($castType, $castValue); }
php
public function update($castType, Expression $castValue) { if ($this->castType === $castType && $this->castValue === $castValue) { return $this; } return new self($castType, $castValue); }
[ "public", "function", "update", "(", "$", "castType", ",", "Expression", "$", "castValue", ")", "{", "if", "(", "$", "this", "->", "castType", "===", "$", "castType", "&&", "$", "this", "->", "castValue", "===", "$", "castValue", ")", "{", "return", "$", "this", ";", "}", "return", "new", "self", "(", "$", "castType", ",", "$", "castValue", ")", ";", "}" ]
@param string $castType @param Expression $castValue @return self
[ "@param", "string", "$castType", "@param", "Expression", "$castValue" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Expressions/CastExpression.php#L57-L64
TimeToogo/Pinq
Source/QueryBuilder.php
QueryBuilder.newMethod
protected function newMethod($name, array $arguments = []) { return O\Expression::methodCall( $this->expression, O\Expression::value($name), array_map([O\Expression::getType(), 'argument'], array_map([O\Expression::getType(), 'value'], $arguments)) ); }
php
protected function newMethod($name, array $arguments = []) { return O\Expression::methodCall( $this->expression, O\Expression::value($name), array_map([O\Expression::getType(), 'argument'], array_map([O\Expression::getType(), 'value'], $arguments)) ); }
[ "protected", "function", "newMethod", "(", "$", "name", ",", "array", "$", "arguments", "=", "[", "]", ")", "{", "return", "O", "\\", "Expression", "::", "methodCall", "(", "$", "this", "->", "expression", ",", "O", "\\", "Expression", "::", "value", "(", "$", "name", ")", ",", "array_map", "(", "[", "O", "\\", "Expression", "::", "getType", "(", ")", ",", "'argument'", "]", ",", "array_map", "(", "[", "O", "\\", "Expression", "::", "getType", "(", ")", ",", "'value'", "]", ",", "$", "arguments", ")", ")", ")", ";", "}" ]
@param string $name @param mixed[] $arguments @return O\MethodCallExpression
[ "@param", "string", "$name", "@param", "mixed", "[]", "$arguments" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/QueryBuilder.php#L40-L47
TimeToogo/Pinq
Source/QueryBuilder.php
QueryBuilder.newMethodSegment
protected function newMethodSegment($name, array $arguments = []) { return $this->provider->createQueryable($this->newMethod($name, $arguments)); }
php
protected function newMethodSegment($name, array $arguments = []) { return $this->provider->createQueryable($this->newMethod($name, $arguments)); }
[ "protected", "function", "newMethodSegment", "(", "$", "name", ",", "array", "$", "arguments", "=", "[", "]", ")", "{", "return", "$", "this", "->", "provider", "->", "createQueryable", "(", "$", "this", "->", "newMethod", "(", "$", "name", ",", "$", "arguments", ")", ")", ";", "}" ]
Returns a new queryable instance with the supplied query segment appended to the current scope @param string $name @param mixed[] $arguments @return IQueryable
[ "Returns", "a", "new", "queryable", "instance", "with", "the", "supplied", "query", "segment", "appended", "to", "the", "current", "scope" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/QueryBuilder.php#L58-L61
TimeToogo/Pinq
Source/Expressions/ValueExpression.php
ValueExpression.isValueType
public static function isValueType($value) { if (is_scalar($value) || $value === null) { return true; } elseif (is_array($value)) { $isScalar = true; array_walk_recursive($value, function ($value) use (&$isScalar) { if ($isScalar && !(is_scalar($value) || $value === null)) { $isScalar = false; } }); return $isScalar; } else { return false; } }
php
public static function isValueType($value) { if (is_scalar($value) || $value === null) { return true; } elseif (is_array($value)) { $isScalar = true; array_walk_recursive($value, function ($value) use (&$isScalar) { if ($isScalar && !(is_scalar($value) || $value === null)) { $isScalar = false; } }); return $isScalar; } else { return false; } }
[ "public", "static", "function", "isValueType", "(", "$", "value", ")", "{", "if", "(", "is_scalar", "(", "$", "value", ")", "||", "$", "value", "===", "null", ")", "{", "return", "true", ";", "}", "elseif", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "isScalar", "=", "true", ";", "array_walk_recursive", "(", "$", "value", ",", "function", "(", "$", "value", ")", "use", "(", "&", "$", "isScalar", ")", "{", "if", "(", "$", "isScalar", "&&", "!", "(", "is_scalar", "(", "$", "value", ")", "||", "$", "value", "===", "null", ")", ")", "{", "$", "isScalar", "=", "false", ";", "}", "}", ")", ";", "return", "$", "isScalar", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Returns whether the supplied value is a value type. @param mixed $value @return bool
[ "Returns", "whether", "the", "supplied", "value", "is", "a", "value", "type", "." ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Expressions/ValueExpression.php#L88-L105
TimeToogo/Pinq
Source/Expressions/TernaryExpression.php
TernaryExpression.update
public function update(Expression $condition, Expression $ifTrue = null, Expression $ifFalse) { if ($this->condition === $condition && $this->ifTrue === $ifTrue && $this->ifFalse === $ifFalse ) { return $this; } return new self($condition, $ifTrue, $ifFalse); }
php
public function update(Expression $condition, Expression $ifTrue = null, Expression $ifFalse) { if ($this->condition === $condition && $this->ifTrue === $ifTrue && $this->ifFalse === $ifFalse ) { return $this; } return new self($condition, $ifTrue, $ifFalse); }
[ "public", "function", "update", "(", "Expression", "$", "condition", ",", "Expression", "$", "ifTrue", "=", "null", ",", "Expression", "$", "ifFalse", ")", "{", "if", "(", "$", "this", "->", "condition", "===", "$", "condition", "&&", "$", "this", "->", "ifTrue", "===", "$", "ifTrue", "&&", "$", "this", "->", "ifFalse", "===", "$", "ifFalse", ")", "{", "return", "$", "this", ";", "}", "return", "new", "self", "(", "$", "condition", ",", "$", "ifTrue", ",", "$", "ifFalse", ")", ";", "}" ]
@param Expression $condition @param Expression|null $ifTrue @param Expression $ifFalse @return self
[ "@param", "Expression", "$condition", "@param", "Expression|null", "$ifTrue", "@param", "Expression", "$ifFalse" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Expressions/TernaryExpression.php#L79-L89
TimeToogo/Pinq
Source/Expressions/BinaryOperationExpression.php
BinaryOperationExpression.update
public function update(Expression $leftOperand, $operator, Expression $rightOperand) { if ($this->leftOperand === $leftOperand && $this->operator === $operator && $this->rightOperand === $rightOperand ) { return $this; } return new self($leftOperand, $operator, $rightOperand); }
php
public function update(Expression $leftOperand, $operator, Expression $rightOperand) { if ($this->leftOperand === $leftOperand && $this->operator === $operator && $this->rightOperand === $rightOperand ) { return $this; } return new self($leftOperand, $operator, $rightOperand); }
[ "public", "function", "update", "(", "Expression", "$", "leftOperand", ",", "$", "operator", ",", "Expression", "$", "rightOperand", ")", "{", "if", "(", "$", "this", "->", "leftOperand", "===", "$", "leftOperand", "&&", "$", "this", "->", "operator", "===", "$", "operator", "&&", "$", "this", "->", "rightOperand", "===", "$", "rightOperand", ")", "{", "return", "$", "this", ";", "}", "return", "new", "self", "(", "$", "leftOperand", ",", "$", "operator", ",", "$", "rightOperand", ")", ";", "}" ]
@param Expression $leftOperand @param int $operator @param Expression $rightOperand @return self
[ "@param", "Expression", "$leftOperand", "@param", "int", "$operator", "@param", "Expression", "$rightOperand" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Expressions/BinaryOperationExpression.php#L73-L83
TimeToogo/Pinq
Source/Parsing/FunctionReflection.php
FunctionReflection.fromCallable
public static function fromCallable(callable $callable) { $reflection = Reflection::fromCallable($callable); return new self( $callable, $reflection, FunctionSignature::fromReflection($reflection), FunctionLocation::fromReflection($reflection), FunctionScope::fromReflection($reflection, $callable)); }
php
public static function fromCallable(callable $callable) { $reflection = Reflection::fromCallable($callable); return new self( $callable, $reflection, FunctionSignature::fromReflection($reflection), FunctionLocation::fromReflection($reflection), FunctionScope::fromReflection($reflection, $callable)); }
[ "public", "static", "function", "fromCallable", "(", "callable", "$", "callable", ")", "{", "$", "reflection", "=", "Reflection", "::", "fromCallable", "(", "$", "callable", ")", ";", "return", "new", "self", "(", "$", "callable", ",", "$", "reflection", ",", "FunctionSignature", "::", "fromReflection", "(", "$", "reflection", ")", ",", "FunctionLocation", "::", "fromReflection", "(", "$", "reflection", ")", ",", "FunctionScope", "::", "fromReflection", "(", "$", "reflection", ",", "$", "callable", ")", ")", ";", "}" ]
Creates a new function reflection instance from the supplied callable. @param callable $callable @return self
[ "Creates", "a", "new", "function", "reflection", "instance", "from", "the", "supplied", "callable", "." ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Parsing/FunctionReflection.php#L66-L76
TimeToogo/Pinq
Source/Expressions/ClosureUsedVariableExpression.php
ClosureUsedVariableExpression.update
public function update($name, $isReference) { if ($this->name === $name && $this->isReference === $isReference) { return $this; } return new self($name, $isReference); }
php
public function update($name, $isReference) { if ($this->name === $name && $this->isReference === $isReference) { return $this; } return new self($name, $isReference); }
[ "public", "function", "update", "(", "$", "name", ",", "$", "isReference", ")", "{", "if", "(", "$", "this", "->", "name", "===", "$", "name", "&&", "$", "this", "->", "isReference", "===", "$", "isReference", ")", "{", "return", "$", "this", ";", "}", "return", "new", "self", "(", "$", "name", ",", "$", "isReference", ")", ";", "}" ]
@param string $name @param boolean $isReference @return ClosureUsedVariableExpression
[ "@param", "string", "$name", "@param", "boolean", "$isReference" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Expressions/ClosureUsedVariableExpression.php#L44-L51
TimeToogo/Pinq
Source/Queries/Segments/Ordering.php
Ordering.update
public function update(Functions\ElementProjection $projectionFunction) { if ($this->projectionFunction === $projectionFunction) { return $this; } return new self($projectionFunction, $this->isAscendingId); }
php
public function update(Functions\ElementProjection $projectionFunction) { if ($this->projectionFunction === $projectionFunction) { return $this; } return new self($projectionFunction, $this->isAscendingId); }
[ "public", "function", "update", "(", "Functions", "\\", "ElementProjection", "$", "projectionFunction", ")", "{", "if", "(", "$", "this", "->", "projectionFunction", "===", "$", "projectionFunction", ")", "{", "return", "$", "this", ";", "}", "return", "new", "self", "(", "$", "projectionFunction", ",", "$", "this", "->", "isAscendingId", ")", ";", "}" ]
@param Functions\ElementProjection $projectionFunction @return Ordering
[ "@param", "Functions", "\\", "ElementProjection", "$projectionFunction" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Queries/Segments/Ordering.php#L61-L68
TimeToogo/Pinq
Source/Parsing/Resolvers/FunctionMagicResolver.php
FunctionMagicResolver.resolve
public static function resolve(IFunctionMagic $functionMagic, array $expressions) { $self = new self($functionMagic); return $self->walkAll($expressions); }
php
public static function resolve(IFunctionMagic $functionMagic, array $expressions) { $self = new self($functionMagic); return $self->walkAll($expressions); }
[ "public", "static", "function", "resolve", "(", "IFunctionMagic", "$", "functionMagic", ",", "array", "$", "expressions", ")", "{", "$", "self", "=", "new", "self", "(", "$", "functionMagic", ")", ";", "return", "$", "self", "->", "walkAll", "(", "$", "expressions", ")", ";", "}" ]
Resolves any magic constants / scopes with the supplied resolved values. @param IFunctionMagic $functionMagic @param O\Expression[] $expressions @return O\Expression[]
[ "Resolves", "any", "magic", "constants", "/", "scopes", "with", "the", "supplied", "resolved", "values", "." ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Parsing/Resolvers/FunctionMagicResolver.php#L48-L53
bearsunday/BEAR.Sunday
src/Module/Constant/NamedModule.php
NamedModule.configure
protected function configure() { foreach ($this->names as $annotatedWith => $instance) { $this->bind()->annotatedWith($annotatedWith)->toInstance($instance); } }
php
protected function configure() { foreach ($this->names as $annotatedWith => $instance) { $this->bind()->annotatedWith($annotatedWith)->toInstance($instance); } }
[ "protected", "function", "configure", "(", ")", "{", "foreach", "(", "$", "this", "->", "names", "as", "$", "annotatedWith", "=>", "$", "instance", ")", "{", "$", "this", "->", "bind", "(", ")", "->", "annotatedWith", "(", "$", "annotatedWith", ")", "->", "toInstance", "(", "$", "instance", ")", ";", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/bearsunday/BEAR.Sunday/blob/4c7e5d735ba0902bf8cceb2d6cebe192521bd80a/src/Module/Constant/NamedModule.php#L25-L30
sebastiaanluca/laravel-helpers
src/Collections/CollectionMacrosServiceProvider.php
CollectionMacrosServiceProvider.boot
public function boot() { /** * Create Carbon instances from items in a collection. */ Collection::macro('carbonize', function () { return collect($this->items)->map(function ($time) { return new Carbon($time); }); }); /** * Reduce each collection item to the value found between a given start and end string. */ Collection::macro('between', function ($start, $end = null) { $end = $end ?? $start; return collect($this->items)->reduce(function ($items, $value) use ($start, $end) { if (preg_match('/^' . $start . '(.*)' . $end . '$/', $value, $matches)) { $items[] = $matches[1]; } return collect($items); }); }); /** * Perform an operation on the collection's keys. */ Collection::macro('transformKeys', function (callable $operation) { return collect($this->items)->mapWithKeys(function ($item, $key) use ($operation) { return [$operation($key) => $item]; }); }); /** * Transpose (flip) a collection matrix (array of arrays). * * @see https://adamwathan.me/2016/04/06/cleaning-up-form-input-with-transpose/ */ Collection::macro('transpose', function () { if ($this->isEmpty()) { return $this; } $items = array_map(function (...$items) { return $items; }, ...$this->values()); return new static($items); }); /** * Transpose (flip) a collection matrix (array of arrays) while keeping its columns and row headers intact. * * Please note that a row missing a column another row does have can only occur for one column. It cannot * parse more than one missing column. */ Collection::macro('transposeWithKeys', function (array $rows = null) { if ($this->isEmpty()) { return $this; } $rows = $rows ?? $this->values()->reduce(function (array $rows, array $values) { return array_unique(array_merge($rows, array_keys($values))); }, []); $keys = $this->keys()->toArray(); // Transpose the matrix $items = array_map(function (...$items) use ($keys) { // The collection's keys now become column headers return array_combine($keys, $items); }, ...$this->values()); // Add the new row headers $items = array_combine($rows, $items); return new static($items); }); Collection::macro('d', function () { d($this); return $this; }); Collection::macro('ddd', function () { ddd($this); }); }
php
public function boot() { /** * Create Carbon instances from items in a collection. */ Collection::macro('carbonize', function () { return collect($this->items)->map(function ($time) { return new Carbon($time); }); }); /** * Reduce each collection item to the value found between a given start and end string. */ Collection::macro('between', function ($start, $end = null) { $end = $end ?? $start; return collect($this->items)->reduce(function ($items, $value) use ($start, $end) { if (preg_match('/^' . $start . '(.*)' . $end . '$/', $value, $matches)) { $items[] = $matches[1]; } return collect($items); }); }); /** * Perform an operation on the collection's keys. */ Collection::macro('transformKeys', function (callable $operation) { return collect($this->items)->mapWithKeys(function ($item, $key) use ($operation) { return [$operation($key) => $item]; }); }); /** * Transpose (flip) a collection matrix (array of arrays). * * @see https://adamwathan.me/2016/04/06/cleaning-up-form-input-with-transpose/ */ Collection::macro('transpose', function () { if ($this->isEmpty()) { return $this; } $items = array_map(function (...$items) { return $items; }, ...$this->values()); return new static($items); }); /** * Transpose (flip) a collection matrix (array of arrays) while keeping its columns and row headers intact. * * Please note that a row missing a column another row does have can only occur for one column. It cannot * parse more than one missing column. */ Collection::macro('transposeWithKeys', function (array $rows = null) { if ($this->isEmpty()) { return $this; } $rows = $rows ?? $this->values()->reduce(function (array $rows, array $values) { return array_unique(array_merge($rows, array_keys($values))); }, []); $keys = $this->keys()->toArray(); // Transpose the matrix $items = array_map(function (...$items) use ($keys) { // The collection's keys now become column headers return array_combine($keys, $items); }, ...$this->values()); // Add the new row headers $items = array_combine($rows, $items); return new static($items); }); Collection::macro('d', function () { d($this); return $this; }); Collection::macro('ddd', function () { ddd($this); }); }
[ "public", "function", "boot", "(", ")", "{", "/**\n * Create Carbon instances from items in a collection.\n */", "Collection", "::", "macro", "(", "'carbonize'", ",", "function", "(", ")", "{", "return", "collect", "(", "$", "this", "->", "items", ")", "->", "map", "(", "function", "(", "$", "time", ")", "{", "return", "new", "Carbon", "(", "$", "time", ")", ";", "}", ")", ";", "}", ")", ";", "/**\n * Reduce each collection item to the value found between a given start and end string.\n */", "Collection", "::", "macro", "(", "'between'", ",", "function", "(", "$", "start", ",", "$", "end", "=", "null", ")", "{", "$", "end", "=", "$", "end", "??", "$", "start", ";", "return", "collect", "(", "$", "this", "->", "items", ")", "->", "reduce", "(", "function", "(", "$", "items", ",", "$", "value", ")", "use", "(", "$", "start", ",", "$", "end", ")", "{", "if", "(", "preg_match", "(", "'/^'", ".", "$", "start", ".", "'(.*)'", ".", "$", "end", ".", "'$/'", ",", "$", "value", ",", "$", "matches", ")", ")", "{", "$", "items", "[", "]", "=", "$", "matches", "[", "1", "]", ";", "}", "return", "collect", "(", "$", "items", ")", ";", "}", ")", ";", "}", ")", ";", "/**\n * Perform an operation on the collection's keys.\n */", "Collection", "::", "macro", "(", "'transformKeys'", ",", "function", "(", "callable", "$", "operation", ")", "{", "return", "collect", "(", "$", "this", "->", "items", ")", "->", "mapWithKeys", "(", "function", "(", "$", "item", ",", "$", "key", ")", "use", "(", "$", "operation", ")", "{", "return", "[", "$", "operation", "(", "$", "key", ")", "=>", "$", "item", "]", ";", "}", ")", ";", "}", ")", ";", "/**\n * Transpose (flip) a collection matrix (array of arrays).\n *\n * @see https://adamwathan.me/2016/04/06/cleaning-up-form-input-with-transpose/\n */", "Collection", "::", "macro", "(", "'transpose'", ",", "function", "(", ")", "{", "if", "(", "$", "this", "->", "isEmpty", "(", ")", ")", "{", "return", "$", "this", ";", "}", "$", "items", "=", "array_map", "(", "function", "(", "...", "$", "items", ")", "{", "return", "$", "items", ";", "}", ",", "...", "$", "this", "->", "values", "(", ")", ")", ";", "return", "new", "static", "(", "$", "items", ")", ";", "}", ")", ";", "/**\n * Transpose (flip) a collection matrix (array of arrays) while keeping its columns and row headers intact.\n *\n * Please note that a row missing a column another row does have can only occur for one column. It cannot\n * parse more than one missing column.\n */", "Collection", "::", "macro", "(", "'transposeWithKeys'", ",", "function", "(", "array", "$", "rows", "=", "null", ")", "{", "if", "(", "$", "this", "->", "isEmpty", "(", ")", ")", "{", "return", "$", "this", ";", "}", "$", "rows", "=", "$", "rows", "??", "$", "this", "->", "values", "(", ")", "->", "reduce", "(", "function", "(", "array", "$", "rows", ",", "array", "$", "values", ")", "{", "return", "array_unique", "(", "array_merge", "(", "$", "rows", ",", "array_keys", "(", "$", "values", ")", ")", ")", ";", "}", ",", "[", "]", ")", ";", "$", "keys", "=", "$", "this", "->", "keys", "(", ")", "->", "toArray", "(", ")", ";", "// Transpose the matrix", "$", "items", "=", "array_map", "(", "function", "(", "...", "$", "items", ")", "use", "(", "$", "keys", ")", "{", "// The collection's keys now become column headers", "return", "array_combine", "(", "$", "keys", ",", "$", "items", ")", ";", "}", ",", "...", "$", "this", "->", "values", "(", ")", ")", ";", "// Add the new row headers", "$", "items", "=", "array_combine", "(", "$", "rows", ",", "$", "items", ")", ";", "return", "new", "static", "(", "$", "items", ")", ";", "}", ")", ";", "Collection", "::", "macro", "(", "'d'", ",", "function", "(", ")", "{", "d", "(", "$", "this", ")", ";", "return", "$", "this", ";", "}", ")", ";", "Collection", "::", "macro", "(", "'ddd'", ",", "function", "(", ")", "{", "ddd", "(", "$", "this", ")", ";", "}", ")", ";", "}" ]
Boot the service provider.
[ "Boot", "the", "service", "provider", "." ]
train
https://github.com/sebastiaanluca/laravel-helpers/blob/e695d71e3e13afff4b6e18a5ffb0813f49cbb883/src/Collections/CollectionMacrosServiceProvider.php#L14-L104
bearsunday/BEAR.Sunday
src/Module/Resource/ResourceModule.php
ResourceModule.configure
protected function configure() { $this->bind()->annotatedWith(AppName::class)->toInstance(self::DEFAULT_APP_NAME); $this->install(new ResourceClientModule); $this->install(new EmbedResourceModule); }
php
protected function configure() { $this->bind()->annotatedWith(AppName::class)->toInstance(self::DEFAULT_APP_NAME); $this->install(new ResourceClientModule); $this->install(new EmbedResourceModule); }
[ "protected", "function", "configure", "(", ")", "{", "$", "this", "->", "bind", "(", ")", "->", "annotatedWith", "(", "AppName", "::", "class", ")", "->", "toInstance", "(", "self", "::", "DEFAULT_APP_NAME", ")", ";", "$", "this", "->", "install", "(", "new", "ResourceClientModule", ")", ";", "$", "this", "->", "install", "(", "new", "EmbedResourceModule", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/bearsunday/BEAR.Sunday/blob/4c7e5d735ba0902bf8cceb2d6cebe192521bd80a/src/Module/Resource/ResourceModule.php#L19-L24
bearsunday/BEAR.Sunday
src/Provide/Router/RouterModule.php
RouterModule.configure
protected function configure() { $this->bind(RouterInterface::class)->to(WebRouter::class); $this->bind()->annotatedWith(DefaultSchemeHost::class)->toInstance('page://self'); }
php
protected function configure() { $this->bind(RouterInterface::class)->to(WebRouter::class); $this->bind()->annotatedWith(DefaultSchemeHost::class)->toInstance('page://self'); }
[ "protected", "function", "configure", "(", ")", "{", "$", "this", "->", "bind", "(", "RouterInterface", "::", "class", ")", "->", "to", "(", "WebRouter", "::", "class", ")", ";", "$", "this", "->", "bind", "(", ")", "->", "annotatedWith", "(", "DefaultSchemeHost", "::", "class", ")", "->", "toInstance", "(", "'page://self'", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/bearsunday/BEAR.Sunday/blob/4c7e5d735ba0902bf8cceb2d6cebe192521bd80a/src/Provide/Router/RouterModule.php#L16-L20
bearsunday/BEAR.Sunday
src/Module/SundayModule.php
SundayModule.configure
protected function configure() { $this->install(new AppModule); $this->install(new HttpCacheModule); $this->install(new DoctrineCacheModule); $this->install(new DoctrineAnnotationModule); $this->install(new ResourceModule); $this->install(new RouterModule); $this->install(new HttpResponderModule); $this->install(new ErrorModule); }
php
protected function configure() { $this->install(new AppModule); $this->install(new HttpCacheModule); $this->install(new DoctrineCacheModule); $this->install(new DoctrineAnnotationModule); $this->install(new ResourceModule); $this->install(new RouterModule); $this->install(new HttpResponderModule); $this->install(new ErrorModule); }
[ "protected", "function", "configure", "(", ")", "{", "$", "this", "->", "install", "(", "new", "AppModule", ")", ";", "$", "this", "->", "install", "(", "new", "HttpCacheModule", ")", ";", "$", "this", "->", "install", "(", "new", "DoctrineCacheModule", ")", ";", "$", "this", "->", "install", "(", "new", "DoctrineAnnotationModule", ")", ";", "$", "this", "->", "install", "(", "new", "ResourceModule", ")", ";", "$", "this", "->", "install", "(", "new", "RouterModule", ")", ";", "$", "this", "->", "install", "(", "new", "HttpResponderModule", ")", ";", "$", "this", "->", "install", "(", "new", "ErrorModule", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/bearsunday/BEAR.Sunday/blob/4c7e5d735ba0902bf8cceb2d6cebe192521bd80a/src/Module/SundayModule.php#L22-L32
bearsunday/BEAR.Sunday
src/Module/Annotation/DoctrineAnnotationModule.php
DoctrineAnnotationModule.configure
protected function configure() { $this->bind(Cache::class)->annotatedWith('annotation_cache')->to(ArrayCache::class)->in(Scope::SINGLETON); $this->bind(Reader::class)->annotatedWith('annotation_reader')->to(AnnotationReader::class)->in(Scope::SINGLETON); $this->bind(Reader::class)->toConstructor(CachedReader::class, 'reader=annotation_reader,cache=annotation_cache')->in(Scope::SINGLETON); }
php
protected function configure() { $this->bind(Cache::class)->annotatedWith('annotation_cache')->to(ArrayCache::class)->in(Scope::SINGLETON); $this->bind(Reader::class)->annotatedWith('annotation_reader')->to(AnnotationReader::class)->in(Scope::SINGLETON); $this->bind(Reader::class)->toConstructor(CachedReader::class, 'reader=annotation_reader,cache=annotation_cache')->in(Scope::SINGLETON); }
[ "protected", "function", "configure", "(", ")", "{", "$", "this", "->", "bind", "(", "Cache", "::", "class", ")", "->", "annotatedWith", "(", "'annotation_cache'", ")", "->", "to", "(", "ArrayCache", "::", "class", ")", "->", "in", "(", "Scope", "::", "SINGLETON", ")", ";", "$", "this", "->", "bind", "(", "Reader", "::", "class", ")", "->", "annotatedWith", "(", "'annotation_reader'", ")", "->", "to", "(", "AnnotationReader", "::", "class", ")", "->", "in", "(", "Scope", "::", "SINGLETON", ")", ";", "$", "this", "->", "bind", "(", "Reader", "::", "class", ")", "->", "toConstructor", "(", "CachedReader", "::", "class", ",", "'reader=annotation_reader,cache=annotation_cache'", ")", "->", "in", "(", "Scope", "::", "SINGLETON", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/bearsunday/BEAR.Sunday/blob/4c7e5d735ba0902bf8cceb2d6cebe192521bd80a/src/Module/Annotation/DoctrineAnnotationModule.php#L20-L25
bearsunday/BEAR.Sunday
src/Provide/Application/AppModule.php
AppModule.configure
protected function configure() { $this->bind(AppInterface::class)->to(App::class); $this->bind()->annotatedWith(AppName::class)->toInstance('BEAR\Sunday'); }
php
protected function configure() { $this->bind(AppInterface::class)->to(App::class); $this->bind()->annotatedWith(AppName::class)->toInstance('BEAR\Sunday'); }
[ "protected", "function", "configure", "(", ")", "{", "$", "this", "->", "bind", "(", "AppInterface", "::", "class", ")", "->", "to", "(", "App", "::", "class", ")", ";", "$", "this", "->", "bind", "(", ")", "->", "annotatedWith", "(", "AppName", "::", "class", ")", "->", "toInstance", "(", "'BEAR\\Sunday'", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/bearsunday/BEAR.Sunday/blob/4c7e5d735ba0902bf8cceb2d6cebe192521bd80a/src/Provide/Application/AppModule.php#L16-L20
bearsunday/BEAR.Sunday
src/Provide/Error/VndError.php
VndError.handle
public function handle(\Exception $e, Request $request) { if ($this->isCodeExists($e)) { $this->errorPage->code = (int) $e->getCode(); $this->errorPage->body = ['message' => (new Code)->statusText[$this->errorPage->code]]; return $this; } $this->errorPage->code = 500; $this->errorPage->body = ['message' => '500 Server Error']; error_log((string) $request); error_log((string) $e); return $this; }
php
public function handle(\Exception $e, Request $request) { if ($this->isCodeExists($e)) { $this->errorPage->code = (int) $e->getCode(); $this->errorPage->body = ['message' => (new Code)->statusText[$this->errorPage->code]]; return $this; } $this->errorPage->code = 500; $this->errorPage->body = ['message' => '500 Server Error']; error_log((string) $request); error_log((string) $e); return $this; }
[ "public", "function", "handle", "(", "\\", "Exception", "$", "e", ",", "Request", "$", "request", ")", "{", "if", "(", "$", "this", "->", "isCodeExists", "(", "$", "e", ")", ")", "{", "$", "this", "->", "errorPage", "->", "code", "=", "(", "int", ")", "$", "e", "->", "getCode", "(", ")", ";", "$", "this", "->", "errorPage", "->", "body", "=", "[", "'message'", "=>", "(", "new", "Code", ")", "->", "statusText", "[", "$", "this", "->", "errorPage", "->", "code", "]", "]", ";", "return", "$", "this", ";", "}", "$", "this", "->", "errorPage", "->", "code", "=", "500", ";", "$", "this", "->", "errorPage", "->", "body", "=", "[", "'message'", "=>", "'500 Server Error'", "]", ";", "error_log", "(", "(", "string", ")", "$", "request", ")", ";", "error_log", "(", "(", "string", ")", "$", "e", ")", ";", "return", "$", "this", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/bearsunday/BEAR.Sunday/blob/4c7e5d735ba0902bf8cceb2d6cebe192521bd80a/src/Provide/Error/VndError.php#L46-L60
bearsunday/BEAR.Sunday
src/Provide/Error/VndError.php
VndError.transfer
public function transfer() { $this->errorPage->headers['content-type'] = self::CONTENT_TYPE; $this->transfer->__invoke($this->errorPage, []); }
php
public function transfer() { $this->errorPage->headers['content-type'] = self::CONTENT_TYPE; $this->transfer->__invoke($this->errorPage, []); }
[ "public", "function", "transfer", "(", ")", "{", "$", "this", "->", "errorPage", "->", "headers", "[", "'content-type'", "]", "=", "self", "::", "CONTENT_TYPE", ";", "$", "this", "->", "transfer", "->", "__invoke", "(", "$", "this", "->", "errorPage", ",", "[", "]", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/bearsunday/BEAR.Sunday/blob/4c7e5d735ba0902bf8cceb2d6cebe192521bd80a/src/Provide/Error/VndError.php#L65-L69
ilya-dev/belt
src/Belt/Arrays.php
Arrays.first
public function first(array $elements, $amount = 1) { $elements = array_slice($elements, 0, $amount); return count($elements) == 1 ? reset($elements) : $elements; }
php
public function first(array $elements, $amount = 1) { $elements = array_slice($elements, 0, $amount); return count($elements) == 1 ? reset($elements) : $elements; }
[ "public", "function", "first", "(", "array", "$", "elements", ",", "$", "amount", "=", "1", ")", "{", "$", "elements", "=", "array_slice", "(", "$", "elements", ",", "0", ",", "$", "amount", ")", ";", "return", "count", "(", "$", "elements", ")", "==", "1", "?", "reset", "(", "$", "elements", ")", ":", "$", "elements", ";", "}" ]
Get the first n elements. @param array $elements @param integer $amount @return mixed|array
[ "Get", "the", "first", "n", "elements", "." ]
train
https://github.com/ilya-dev/belt/blob/1c1efc075c3a71de86427a1b5cbbff1a9ee4ae49/src/Belt/Arrays.php#L14-L19
ilya-dev/belt
src/Belt/Arrays.php
Arrays.last
public function last(array $elements, $amount = 1) { $elements = array_slice($elements, count($elements) - $amount); return count($elements) == 1 ? reset($elements) : $elements; }
php
public function last(array $elements, $amount = 1) { $elements = array_slice($elements, count($elements) - $amount); return count($elements) == 1 ? reset($elements) : $elements; }
[ "public", "function", "last", "(", "array", "$", "elements", ",", "$", "amount", "=", "1", ")", "{", "$", "elements", "=", "array_slice", "(", "$", "elements", ",", "count", "(", "$", "elements", ")", "-", "$", "amount", ")", ";", "return", "count", "(", "$", "elements", ")", "==", "1", "?", "reset", "(", "$", "elements", ")", ":", "$", "elements", ";", "}" ]
Get the last n elements. @param array $elements @param integer $amount @return mixed|array
[ "Get", "the", "last", "n", "elements", "." ]
train
https://github.com/ilya-dev/belt/blob/1c1efc075c3a71de86427a1b5cbbff1a9ee4ae49/src/Belt/Arrays.php#L52-L57
ilya-dev/belt
src/Belt/Arrays.php
Arrays.flatten
public function flatten(array $elements) { $level = []; foreach ($elements as $node) { if (is_array($node)) { $level = array_merge($level, $this->flatten($node)); } else { $level[] = $node; } } return $level; }
php
public function flatten(array $elements) { $level = []; foreach ($elements as $node) { if (is_array($node)) { $level = array_merge($level, $this->flatten($node)); } else { $level[] = $node; } } return $level; }
[ "public", "function", "flatten", "(", "array", "$", "elements", ")", "{", "$", "level", "=", "[", "]", ";", "foreach", "(", "$", "elements", "as", "$", "node", ")", "{", "if", "(", "is_array", "(", "$", "node", ")", ")", "{", "$", "level", "=", "array_merge", "(", "$", "level", ",", "$", "this", "->", "flatten", "(", "$", "node", ")", ")", ";", "}", "else", "{", "$", "level", "[", "]", "=", "$", "node", ";", "}", "}", "return", "$", "level", ";", "}" ]
"Flatten" an array. @param array $elements @return array
[ "Flatten", "an", "array", "." ]
train
https://github.com/ilya-dev/belt/blob/1c1efc075c3a71de86427a1b5cbbff1a9ee4ae49/src/Belt/Arrays.php#L76-L93
ilya-dev/belt
src/Belt/Arrays.php
Arrays.unique
public function unique(array $elements, Closure $iterator = null) { if ( ! is_null($iterator)) { $elements = array_filter($elements, $iterator); } else { $elements = array_unique($elements); } return array_values($elements); }
php
public function unique(array $elements, Closure $iterator = null) { if ( ! is_null($iterator)) { $elements = array_filter($elements, $iterator); } else { $elements = array_unique($elements); } return array_values($elements); }
[ "public", "function", "unique", "(", "array", "$", "elements", ",", "Closure", "$", "iterator", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "iterator", ")", ")", "{", "$", "elements", "=", "array_filter", "(", "$", "elements", ",", "$", "iterator", ")", ";", "}", "else", "{", "$", "elements", "=", "array_unique", "(", "$", "elements", ")", ";", "}", "return", "array_values", "(", "$", "elements", ")", ";", "}" ]
Remove duplicated values. @param array $elements @param Closure|null $iterator @return array
[ "Remove", "duplicated", "values", "." ]
train
https://github.com/ilya-dev/belt/blob/1c1efc075c3a71de86427a1b5cbbff1a9ee4ae49/src/Belt/Arrays.php#L127-L139
ilya-dev/belt
src/Belt/Functions.php
Functions.cache
public function cache(Closure $closure) { $hash = spl_object_hash((object) $closure); if ( ! isset ($this->cached[$hash])) { $this->cached[$hash] = $closure(); } return $this->cached[$hash]; }
php
public function cache(Closure $closure) { $hash = spl_object_hash((object) $closure); if ( ! isset ($this->cached[$hash])) { $this->cached[$hash] = $closure(); } return $this->cached[$hash]; }
[ "public", "function", "cache", "(", "Closure", "$", "closure", ")", "{", "$", "hash", "=", "spl_object_hash", "(", "(", "object", ")", "$", "closure", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "cached", "[", "$", "hash", "]", ")", ")", "{", "$", "this", "->", "cached", "[", "$", "hash", "]", "=", "$", "closure", "(", ")", ";", "}", "return", "$", "this", "->", "cached", "[", "$", "hash", "]", ";", "}" ]
Execute $closure and cache its output. @param Closure $closure @return mixed
[ "Execute", "$closure", "and", "cache", "its", "output", "." ]
train
https://github.com/ilya-dev/belt/blob/1c1efc075c3a71de86427a1b5cbbff1a9ee4ae49/src/Belt/Functions.php#L34-L44
ilya-dev/belt
src/Belt/Functions.php
Functions.compose
public function compose(array $closures, array $arguments = []) { $result = call_user_func_array(array_shift($closures), $arguments); foreach ($closures as $closure) { $result = $closure($result); } return $result; }
php
public function compose(array $closures, array $arguments = []) { $result = call_user_func_array(array_shift($closures), $arguments); foreach ($closures as $closure) { $result = $closure($result); } return $result; }
[ "public", "function", "compose", "(", "array", "$", "closures", ",", "array", "$", "arguments", "=", "[", "]", ")", "{", "$", "result", "=", "call_user_func_array", "(", "array_shift", "(", "$", "closures", ")", ",", "$", "arguments", ")", ";", "foreach", "(", "$", "closures", "as", "$", "closure", ")", "{", "$", "result", "=", "$", "closure", "(", "$", "result", ")", ";", "}", "return", "$", "result", ";", "}" ]
Compose $closures. @param array $closures @param array $arguments @return mixed
[ "Compose", "$closures", "." ]
train
https://github.com/ilya-dev/belt/blob/1c1efc075c3a71de86427a1b5cbbff1a9ee4ae49/src/Belt/Functions.php#L65-L75
ilya-dev/belt
src/Belt/Functions.php
Functions.once
public function once(Closure $closure) { $hash = spl_object_hash((object) $closure); if ( ! isset ($this->called[$hash])) { $closure(); $this->called[$hash] = true; } }
php
public function once(Closure $closure) { $hash = spl_object_hash((object) $closure); if ( ! isset ($this->called[$hash])) { $closure(); $this->called[$hash] = true; } }
[ "public", "function", "once", "(", "Closure", "$", "closure", ")", "{", "$", "hash", "=", "spl_object_hash", "(", "(", "object", ")", "$", "closure", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "called", "[", "$", "hash", "]", ")", ")", "{", "$", "closure", "(", ")", ";", "$", "this", "->", "called", "[", "$", "hash", "]", "=", "true", ";", "}", "}" ]
Execute $closure only once and ignore future calls. @param Closure $closure @return void
[ "Execute", "$closure", "only", "once", "and", "ignore", "future", "calls", "." ]
train
https://github.com/ilya-dev/belt/blob/1c1efc075c3a71de86427a1b5cbbff1a9ee4ae49/src/Belt/Functions.php#L83-L93
ilya-dev/belt
src/Belt/Functions.php
Functions.after
public function after($number, Closure $closure) { $hash = spl_object_hash((object) $closure); if (isset ($this->delayed[$hash])) { $closure = $this->delayed[$hash]; return $closure(); } $this->delayed[$hash] = function() use($number, $closure) { static $tries = 0; $tries += 1; if ($tries === $number) { return $closure(); } }; }
php
public function after($number, Closure $closure) { $hash = spl_object_hash((object) $closure); if (isset ($this->delayed[$hash])) { $closure = $this->delayed[$hash]; return $closure(); } $this->delayed[$hash] = function() use($number, $closure) { static $tries = 0; $tries += 1; if ($tries === $number) { return $closure(); } }; }
[ "public", "function", "after", "(", "$", "number", ",", "Closure", "$", "closure", ")", "{", "$", "hash", "=", "spl_object_hash", "(", "(", "object", ")", "$", "closure", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "delayed", "[", "$", "hash", "]", ")", ")", "{", "$", "closure", "=", "$", "this", "->", "delayed", "[", "$", "hash", "]", ";", "return", "$", "closure", "(", ")", ";", "}", "$", "this", "->", "delayed", "[", "$", "hash", "]", "=", "function", "(", ")", "use", "(", "$", "number", ",", "$", "closure", ")", "{", "static", "$", "tries", "=", "0", ";", "$", "tries", "+=", "1", ";", "if", "(", "$", "tries", "===", "$", "number", ")", "{", "return", "$", "closure", "(", ")", ";", "}", "}", ";", "}" ]
Only execute $closure after the exact $number of failed tries. @param integer $number @param Closure $closure @return mixed
[ "Only", "execute", "$closure", "after", "the", "exact", "$number", "of", "failed", "tries", "." ]
train
https://github.com/ilya-dev/belt/blob/1c1efc075c3a71de86427a1b5cbbff1a9ee4ae49/src/Belt/Functions.php#L102-L124
ilya-dev/belt
src/Belt/Belt.php
Belt.load
public function load($module, $instance = null) { if ( ! is_null($instance)) { if ( ! $this->hasModule($module)) { $this->addModule($module); } return ($this->instances[$module] = $instance); } if ($this->hasModule($module)) { return ($this->instances[$module] = new $module); } throw new UnexpectedValueException("Module {$module} does not exist"); }
php
public function load($module, $instance = null) { if ( ! is_null($instance)) { if ( ! $this->hasModule($module)) { $this->addModule($module); } return ($this->instances[$module] = $instance); } if ($this->hasModule($module)) { return ($this->instances[$module] = new $module); } throw new UnexpectedValueException("Module {$module} does not exist"); }
[ "public", "function", "load", "(", "$", "module", ",", "$", "instance", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "instance", ")", ")", "{", "if", "(", "!", "$", "this", "->", "hasModule", "(", "$", "module", ")", ")", "{", "$", "this", "->", "addModule", "(", "$", "module", ")", ";", "}", "return", "(", "$", "this", "->", "instances", "[", "$", "module", "]", "=", "$", "instance", ")", ";", "}", "if", "(", "$", "this", "->", "hasModule", "(", "$", "module", ")", ")", "{", "return", "(", "$", "this", "->", "instances", "[", "$", "module", "]", "=", "new", "$", "module", ")", ";", "}", "throw", "new", "UnexpectedValueException", "(", "\"Module {$module} does not exist\"", ")", ";", "}" ]
Load a module. @throws UnexpectedValueException @param string $module @param mixed|null $instance @return mixed
[ "Load", "a", "module", "." ]
train
https://github.com/ilya-dev/belt/blob/1c1efc075c3a71de86427a1b5cbbff1a9ee4ae49/src/Belt/Belt.php#L43-L61
ilya-dev/belt
src/Belt/Belt.php
Belt.getInstance
public function getInstance($module) { if ( ! $this->isLoaded($module)) { $this->load($module); } return $this->instances[$module]; }
php
public function getInstance($module) { if ( ! $this->isLoaded($module)) { $this->load($module); } return $this->instances[$module]; }
[ "public", "function", "getInstance", "(", "$", "module", ")", "{", "if", "(", "!", "$", "this", "->", "isLoaded", "(", "$", "module", ")", ")", "{", "$", "this", "->", "load", "(", "$", "module", ")", ";", "}", "return", "$", "this", "->", "instances", "[", "$", "module", "]", ";", "}" ]
Load a module (if not yet) and return its instance. @param string $module @return mixed
[ "Load", "a", "module", "(", "if", "not", "yet", ")", "and", "return", "its", "instance", "." ]
train
https://github.com/ilya-dev/belt/blob/1c1efc075c3a71de86427a1b5cbbff1a9ee4ae49/src/Belt/Belt.php#L112-L120
ilya-dev/belt
src/Belt/Belt.php
Belt.run
public function run($name, array $arguments = []) { foreach ($this->getModules() as $module) { $instance = $this->getInstance($module); if ($this->hasMethod($instance, $name)) { return call_user_func_array([$instance, $name], $arguments); } } throw new BadMethodCallException("Method {$name} does not exist"); }
php
public function run($name, array $arguments = []) { foreach ($this->getModules() as $module) { $instance = $this->getInstance($module); if ($this->hasMethod($instance, $name)) { return call_user_func_array([$instance, $name], $arguments); } } throw new BadMethodCallException("Method {$name} does not exist"); }
[ "public", "function", "run", "(", "$", "name", ",", "array", "$", "arguments", "=", "[", "]", ")", "{", "foreach", "(", "$", "this", "->", "getModules", "(", ")", "as", "$", "module", ")", "{", "$", "instance", "=", "$", "this", "->", "getInstance", "(", "$", "module", ")", ";", "if", "(", "$", "this", "->", "hasMethod", "(", "$", "instance", ",", "$", "name", ")", ")", "{", "return", "call_user_func_array", "(", "[", "$", "instance", ",", "$", "name", "]", ",", "$", "arguments", ")", ";", "}", "}", "throw", "new", "BadMethodCallException", "(", "\"Method {$name} does not exist\"", ")", ";", "}" ]
Run a method and return its output. @throws BadMethodCallException @param string $name @param array $arguments @return mixed
[ "Run", "a", "method", "and", "return", "its", "output", "." ]
train
https://github.com/ilya-dev/belt/blob/1c1efc075c3a71de86427a1b5cbbff1a9ee4ae49/src/Belt/Belt.php#L142-L155
ilya-dev/belt
src/Belt/Collections.php
Collections.each
public function each(array $collection, Closure $iterator) { foreach ($collection as $key => $node) { $iterator($key, $node); } }
php
public function each(array $collection, Closure $iterator) { foreach ($collection as $key => $node) { $iterator($key, $node); } }
[ "public", "function", "each", "(", "array", "$", "collection", ",", "Closure", "$", "iterator", ")", "{", "foreach", "(", "$", "collection", "as", "$", "key", "=>", "$", "node", ")", "{", "$", "iterator", "(", "$", "key", ",", "$", "node", ")", ";", "}", "}" ]
Iterate through $collection using $iterator. @param array $collection @param Closure $iterator @return void
[ "Iterate", "through", "$collection", "using", "$iterator", "." ]
train
https://github.com/ilya-dev/belt/blob/1c1efc075c3a71de86427a1b5cbbff1a9ee4ae49/src/Belt/Collections.php#L15-L21
ilya-dev/belt
src/Belt/Collections.php
Collections.map
public function map(array $collection, Closure $iterator) { foreach ($collection as $key => $node) { $collection[$key] = $iterator($key, $node); } return $collection; }
php
public function map(array $collection, Closure $iterator) { foreach ($collection as $key => $node) { $collection[$key] = $iterator($key, $node); } return $collection; }
[ "public", "function", "map", "(", "array", "$", "collection", ",", "Closure", "$", "iterator", ")", "{", "foreach", "(", "$", "collection", "as", "$", "key", "=>", "$", "node", ")", "{", "$", "collection", "[", "$", "key", "]", "=", "$", "iterator", "(", "$", "key", ",", "$", "node", ")", ";", "}", "return", "$", "collection", ";", "}" ]
"Map" through $collection using $iterator. @param array $collection @param Closure $iterator @return array
[ "Map", "through", "$collection", "using", "$iterator", "." ]
train
https://github.com/ilya-dev/belt/blob/1c1efc075c3a71de86427a1b5cbbff1a9ee4ae49/src/Belt/Collections.php#L30-L38
ilya-dev/belt
src/Belt/Collections.php
Collections.any
public function any(array $collection, Closure $iterator) { foreach ($collection as $node) { if ($iterator($node)) { return true; } } return false; }
php
public function any(array $collection, Closure $iterator) { foreach ($collection as $node) { if ($iterator($node)) { return true; } } return false; }
[ "public", "function", "any", "(", "array", "$", "collection", ",", "Closure", "$", "iterator", ")", "{", "foreach", "(", "$", "collection", "as", "$", "node", ")", "{", "if", "(", "$", "iterator", "(", "$", "node", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Check whether any values in $collection pass $iterator. @param array $collection @param Closure $iterator @return boolean
[ "Check", "whether", "any", "values", "in", "$collection", "pass", "$iterator", "." ]
train
https://github.com/ilya-dev/belt/blob/1c1efc075c3a71de86427a1b5cbbff1a9ee4ae49/src/Belt/Collections.php#L87-L98
ilya-dev/belt
src/Belt/Collections.php
Collections.all
public function all(array $collection, Closure $iterator) { foreach ($collection as $node) { if ( ! $iterator($node)) { return false; } } return true; }
php
public function all(array $collection, Closure $iterator) { foreach ($collection as $node) { if ( ! $iterator($node)) { return false; } } return true; }
[ "public", "function", "all", "(", "array", "$", "collection", ",", "Closure", "$", "iterator", ")", "{", "foreach", "(", "$", "collection", "as", "$", "node", ")", "{", "if", "(", "!", "$", "iterator", "(", "$", "node", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Check whether all values in $collection pass $iterator. @param array $collection @param Closure $iterator @return boolean
[ "Check", "whether", "all", "values", "in", "$collection", "pass", "$iterator", "." ]
train
https://github.com/ilya-dev/belt/blob/1c1efc075c3a71de86427a1b5cbbff1a9ee4ae49/src/Belt/Collections.php#L107-L118
ilya-dev/belt
src/Belt/Collections.php
Collections.reject
public function reject(array $collection, Closure $iterator) { foreach ($collection as $key => $node) { if ( ! $iterator($node)) { unset($collection[$key]); } } return array_values($collection); }
php
public function reject(array $collection, Closure $iterator) { foreach ($collection as $key => $node) { if ( ! $iterator($node)) { unset($collection[$key]); } } return array_values($collection); }
[ "public", "function", "reject", "(", "array", "$", "collection", ",", "Closure", "$", "iterator", ")", "{", "foreach", "(", "$", "collection", "as", "$", "key", "=>", "$", "node", ")", "{", "if", "(", "!", "$", "iterator", "(", "$", "node", ")", ")", "{", "unset", "(", "$", "collection", "[", "$", "key", "]", ")", ";", "}", "}", "return", "array_values", "(", "$", "collection", ")", ";", "}" ]
Run $iterator and remove all failing items in $collection. @param array $collection @param Closure $iterator @return array
[ "Run", "$iterator", "and", "remove", "all", "failing", "items", "in", "$collection", "." ]
train
https://github.com/ilya-dev/belt/blob/1c1efc075c3a71de86427a1b5cbbff1a9ee4ae49/src/Belt/Collections.php#L127-L138
ilya-dev/belt
src/Belt/Collections.php
Collections.pluck
public function pluck(array $collection, $key) { $values = []; foreach ($collection as $node) { if ( ! isset($node[$key])) { continue; } $values[] = $node[$key]; } return $values; }
php
public function pluck(array $collection, $key) { $values = []; foreach ($collection as $node) { if ( ! isset($node[$key])) { continue; } $values[] = $node[$key]; } return $values; }
[ "public", "function", "pluck", "(", "array", "$", "collection", ",", "$", "key", ")", "{", "$", "values", "=", "[", "]", ";", "foreach", "(", "$", "collection", "as", "$", "node", ")", "{", "if", "(", "!", "isset", "(", "$", "node", "[", "$", "key", "]", ")", ")", "{", "continue", ";", "}", "$", "values", "[", "]", "=", "$", "node", "[", "$", "key", "]", ";", "}", "return", "$", "values", ";", "}" ]
Extract an array of values associated with $key from $collection. @param array $collection @param string $key @return array
[ "Extract", "an", "array", "of", "values", "associated", "with", "$key", "from", "$collection", "." ]
train
https://github.com/ilya-dev/belt/blob/1c1efc075c3a71de86427a1b5cbbff1a9ee4ae49/src/Belt/Collections.php#L147-L162
ilya-dev/belt
src/Belt/Collections.php
Collections.sortBy
public function sortBy(array $collection, Closure $iterator) { $collection = array_map($iterator, $collection); sort($collection); return array_values($collection); }
php
public function sortBy(array $collection, Closure $iterator) { $collection = array_map($iterator, $collection); sort($collection); return array_values($collection); }
[ "public", "function", "sortBy", "(", "array", "$", "collection", ",", "Closure", "$", "iterator", ")", "{", "$", "collection", "=", "array_map", "(", "$", "iterator", ",", "$", "collection", ")", ";", "sort", "(", "$", "collection", ")", ";", "return", "array_values", "(", "$", "collection", ")", ";", "}" ]
Return $collection sorted in ascending order based on $iterator results. @param array $collection @param Closure $iterator @return array
[ "Return", "$collection", "sorted", "in", "ascending", "order", "based", "on", "$iterator", "results", "." ]
train
https://github.com/ilya-dev/belt/blob/1c1efc075c3a71de86427a1b5cbbff1a9ee4ae49/src/Belt/Collections.php#L208-L215
ilya-dev/belt
src/Belt/Collections.php
Collections.groupBy
public function groupBy(array $collection, Closure $iterator) { $groups = []; foreach ($collection as $node) { $groups[$iterator($node)][] = $node; } sort($groups); return $groups; }
php
public function groupBy(array $collection, Closure $iterator) { $groups = []; foreach ($collection as $node) { $groups[$iterator($node)][] = $node; } sort($groups); return $groups; }
[ "public", "function", "groupBy", "(", "array", "$", "collection", ",", "Closure", "$", "iterator", ")", "{", "$", "groups", "=", "[", "]", ";", "foreach", "(", "$", "collection", "as", "$", "node", ")", "{", "$", "groups", "[", "$", "iterator", "(", "$", "node", ")", "]", "[", "]", "=", "$", "node", ";", "}", "sort", "(", "$", "groups", ")", ";", "return", "$", "groups", ";", "}" ]
Group values in $collection by $iterator's return value. @param array $collection @param Closure $iterator @return array
[ "Group", "values", "in", "$collection", "by", "$iterator", "s", "return", "value", "." ]
train
https://github.com/ilya-dev/belt/blob/1c1efc075c3a71de86427a1b5cbbff1a9ee4ae49/src/Belt/Collections.php#L224-L236
ilya-dev/belt
src/Belt/Objects.php
Objects.extend
public function extend($source, $destination) { foreach($source as $key => $value) { $destination->{$key} = $value; } return $destination; }
php
public function extend($source, $destination) { foreach($source as $key => $value) { $destination->{$key} = $value; } return $destination; }
[ "public", "function", "extend", "(", "$", "source", ",", "$", "destination", ")", "{", "foreach", "(", "$", "source", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "destination", "->", "{", "$", "key", "}", "=", "$", "value", ";", "}", "return", "$", "destination", ";", "}" ]
Copy all properties from $source to $destination. @param mixed $source @param mixed $destination @return mixed
[ "Copy", "all", "properties", "from", "$source", "to", "$destination", "." ]
train
https://github.com/ilya-dev/belt/blob/1c1efc075c3a71de86427a1b5cbbff1a9ee4ae49/src/Belt/Objects.php#L65-L73
ilya-dev/belt
src/Belt/Objects.php
Objects.defaults
public function defaults($object, $defaults) { if (is_array($defaults)) { foreach ($defaults as $default) { $this->defaults($object, $default); } return $object; } foreach ($defaults as $key => $value) { if ( ! property_exists($object, $key)) { $object->{$key} = $value; } } return $object; }
php
public function defaults($object, $defaults) { if (is_array($defaults)) { foreach ($defaults as $default) { $this->defaults($object, $default); } return $object; } foreach ($defaults as $key => $value) { if ( ! property_exists($object, $key)) { $object->{$key} = $value; } } return $object; }
[ "public", "function", "defaults", "(", "$", "object", ",", "$", "defaults", ")", "{", "if", "(", "is_array", "(", "$", "defaults", ")", ")", "{", "foreach", "(", "$", "defaults", "as", "$", "default", ")", "{", "$", "this", "->", "defaults", "(", "$", "object", ",", "$", "default", ")", ";", "}", "return", "$", "object", ";", "}", "foreach", "(", "$", "defaults", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "property_exists", "(", "$", "object", ",", "$", "key", ")", ")", "{", "$", "object", "->", "{", "$", "key", "}", "=", "$", "value", ";", "}", "}", "return", "$", "object", ";", "}" ]
Fill in any missing values using $defaults. @param mixed $object @param mixed $defaults @return mixed
[ "Fill", "in", "any", "missing", "values", "using", "$defaults", "." ]
train
https://github.com/ilya-dev/belt/blob/1c1efc075c3a71de86427a1b5cbbff1a9ee4ae49/src/Belt/Objects.php#L82-L103
ilya-dev/belt
src/Belt/Objects.php
Objects.methods
public function methods($object) { $methods = (new ReflectionClass($object))->getMethods(ReflectionMethod::IS_PUBLIC); $iterator = function(ReflectionMethod $method) { return $method->getName(); }; return array_map($iterator, $methods); }
php
public function methods($object) { $methods = (new ReflectionClass($object))->getMethods(ReflectionMethod::IS_PUBLIC); $iterator = function(ReflectionMethod $method) { return $method->getName(); }; return array_map($iterator, $methods); }
[ "public", "function", "methods", "(", "$", "object", ")", "{", "$", "methods", "=", "(", "new", "ReflectionClass", "(", "$", "object", ")", ")", "->", "getMethods", "(", "ReflectionMethod", "::", "IS_PUBLIC", ")", ";", "$", "iterator", "=", "function", "(", "ReflectionMethod", "$", "method", ")", "{", "return", "$", "method", "->", "getName", "(", ")", ";", "}", ";", "return", "array_map", "(", "$", "iterator", ",", "$", "methods", ")", ";", "}" ]
Get the names of all public methods. @param mixed $object @return array
[ "Get", "the", "names", "of", "all", "public", "methods", "." ]
train
https://github.com/ilya-dev/belt/blob/1c1efc075c3a71de86427a1b5cbbff1a9ee4ae49/src/Belt/Objects.php#L122-L132
neos/neos-seo
Classes/Fusion/XmlSitemapUrlsImplementation.php
XmlSitemapUrlsImplementation.isDocumentNodeToBeIndexed
protected function isDocumentNodeToBeIndexed(NodeInterface $node): bool { return !$node->getNodeType()->isOfType('Neos.Seo:NoindexMixin') && $node->isVisible() && ($this->getRenderHiddenInIndex() || !$node->isHiddenInIndex()) && $node->isAccessible() && $node->getProperty('metaRobotsNoindex') !== true; }
php
protected function isDocumentNodeToBeIndexed(NodeInterface $node): bool { return !$node->getNodeType()->isOfType('Neos.Seo:NoindexMixin') && $node->isVisible() && ($this->getRenderHiddenInIndex() || !$node->isHiddenInIndex()) && $node->isAccessible() && $node->getProperty('metaRobotsNoindex') !== true; }
[ "protected", "function", "isDocumentNodeToBeIndexed", "(", "NodeInterface", "$", "node", ")", ":", "bool", "{", "return", "!", "$", "node", "->", "getNodeType", "(", ")", "->", "isOfType", "(", "'Neos.Seo:NoindexMixin'", ")", "&&", "$", "node", "->", "isVisible", "(", ")", "&&", "(", "$", "this", "->", "getRenderHiddenInIndex", "(", ")", "||", "!", "$", "node", "->", "isHiddenInIndex", "(", ")", ")", "&&", "$", "node", "->", "isAccessible", "(", ")", "&&", "$", "node", "->", "getProperty", "(", "'metaRobotsNoindex'", ")", "!==", "true", ";", "}" ]
Return TRUE/FALSE if the node is currently hidden; taking the "renderHiddenInIndex" configuration of the Menu Fusion object into account. @param NodeInterface $node @return bool @throws NodeException
[ "Return", "TRUE", "/", "FALSE", "if", "the", "node", "is", "currently", "hidden", ";", "taking", "the", "renderHiddenInIndex", "configuration", "of", "the", "Menu", "Fusion", "object", "into", "account", "." ]
train
https://github.com/neos/neos-seo/blob/dc494526e0c216bf19fcf7f52c73f6da496e30a1/Classes/Fusion/XmlSitemapUrlsImplementation.php#L186-L191
neos/neos-seo
Classes/Fusion/XmlSitemapUrlsImplementation.php
XmlSitemapUrlsImplementation.evaluate
public function evaluate(): array { if ($this->items === null) { $items = []; try { $this->appendItems($items, $this->getStartingPoint()); } catch (NodeException $e) { } $this->items = $items; } return $this->items; }
php
public function evaluate(): array { if ($this->items === null) { $items = []; try { $this->appendItems($items, $this->getStartingPoint()); } catch (NodeException $e) { } $this->items = $items; } return $this->items; }
[ "public", "function", "evaluate", "(", ")", ":", "array", "{", "if", "(", "$", "this", "->", "items", "===", "null", ")", "{", "$", "items", "=", "[", "]", ";", "try", "{", "$", "this", "->", "appendItems", "(", "$", "items", ",", "$", "this", "->", "getStartingPoint", "(", ")", ")", ";", "}", "catch", "(", "NodeException", "$", "e", ")", "{", "}", "$", "this", "->", "items", "=", "$", "items", ";", "}", "return", "$", "this", "->", "items", ";", "}" ]
Evaluate this Fusion object and return the result @return array
[ "Evaluate", "this", "Fusion", "object", "and", "return", "the", "result" ]
train
https://github.com/neos/neos-seo/blob/dc494526e0c216bf19fcf7f52c73f6da496e30a1/Classes/Fusion/XmlSitemapUrlsImplementation.php#L198-L211
johnbillion/extended-template-parts
src/extended-template-part.php
Extended_Template_Part.get_output
public function get_output() : string { $output = ( false !== $this->args['cache'] ) ? $this->get_cache() : ''; if ( $output ) { return $output; } ob_start(); if ( $this->has_template() ) { $this->load_template( $this->locate_template() ); } $output = ob_get_clean(); if ( false !== $this->args['cache'] ) { $this->set_cache( $output ); } return $output; }
php
public function get_output() : string { $output = ( false !== $this->args['cache'] ) ? $this->get_cache() : ''; if ( $output ) { return $output; } ob_start(); if ( $this->has_template() ) { $this->load_template( $this->locate_template() ); } $output = ob_get_clean(); if ( false !== $this->args['cache'] ) { $this->set_cache( $output ); } return $output; }
[ "public", "function", "get_output", "(", ")", ":", "string", "{", "$", "output", "=", "(", "false", "!==", "$", "this", "->", "args", "[", "'cache'", "]", ")", "?", "$", "this", "->", "get_cache", "(", ")", ":", "''", ";", "if", "(", "$", "output", ")", "{", "return", "$", "output", ";", "}", "ob_start", "(", ")", ";", "if", "(", "$", "this", "->", "has_template", "(", ")", ")", "{", "$", "this", "->", "load_template", "(", "$", "this", "->", "locate_template", "(", ")", ")", ";", "}", "$", "output", "=", "ob_get_clean", "(", ")", ";", "if", "(", "false", "!==", "$", "this", "->", "args", "[", "'cache'", "]", ")", "{", "$", "this", "->", "set_cache", "(", "$", "output", ")", ";", "}", "return", "$", "output", ";", "}" ]
Gets the output of the template part. @return string The template part output.
[ "Gets", "the", "output", "of", "the", "template", "part", "." ]
train
https://github.com/johnbillion/extended-template-parts/blob/c61293355847b1f9d18f9a6e1d047df85bae8049/src/extended-template-part.php#L75-L94
johnbillion/extended-template-parts
src/extended-template-part.php
Extended_Template_Part.locate_template
protected function locate_template() : string { if ( isset( $this->template ) ) { return $this->template; } $templates = []; if ( ! empty( $this->name ) ) { $templates[] = "{$this->args['dir']}/{$this->slug}-{$this->name}.php"; } $templates[] = "{$this->args['dir']}/{$this->slug}.php"; $this->template = locate_template( $templates ); if ( 0 !== validate_file( $this->template ) ) { $this->template = ''; } return $this->template; }
php
protected function locate_template() : string { if ( isset( $this->template ) ) { return $this->template; } $templates = []; if ( ! empty( $this->name ) ) { $templates[] = "{$this->args['dir']}/{$this->slug}-{$this->name}.php"; } $templates[] = "{$this->args['dir']}/{$this->slug}.php"; $this->template = locate_template( $templates ); if ( 0 !== validate_file( $this->template ) ) { $this->template = ''; } return $this->template; }
[ "protected", "function", "locate_template", "(", ")", ":", "string", "{", "if", "(", "isset", "(", "$", "this", "->", "template", ")", ")", "{", "return", "$", "this", "->", "template", ";", "}", "$", "templates", "=", "[", "]", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "name", ")", ")", "{", "$", "templates", "[", "]", "=", "\"{$this->args['dir']}/{$this->slug}-{$this->name}.php\"", ";", "}", "$", "templates", "[", "]", "=", "\"{$this->args['dir']}/{$this->slug}.php\"", ";", "$", "this", "->", "template", "=", "locate_template", "(", "$", "templates", ")", ";", "if", "(", "0", "!==", "validate_file", "(", "$", "this", "->", "template", ")", ")", "{", "$", "this", "->", "template", "=", "''", ";", "}", "return", "$", "this", "->", "template", ";", "}" ]
Locate the template part file according to the slug and name. @return string The template part file name. Empty string if none is found.
[ "Locate", "the", "template", "part", "file", "according", "to", "the", "slug", "and", "name", "." ]
train
https://github.com/johnbillion/extended-template-parts/blob/c61293355847b1f9d18f9a6e1d047df85bae8049/src/extended-template-part.php#L119-L140
johnbillion/extended-template-parts
src/extended-template-part.php
Extended_Template_Part.load_template
protected function load_template( string $template_file ) { global $posts, $post, $wp_did_header, $wp_query, $wp_rewrite, $wpdb, $wp_version, $wp, $id, $comment, $user_ID; if ( 0 !== validate_file( $template_file ) ) { return; } require $template_file; }
php
protected function load_template( string $template_file ) { global $posts, $post, $wp_did_header, $wp_query, $wp_rewrite, $wpdb, $wp_version, $wp, $id, $comment, $user_ID; if ( 0 !== validate_file( $template_file ) ) { return; } require $template_file; }
[ "protected", "function", "load_template", "(", "string", "$", "template_file", ")", "{", "global", "$", "posts", ",", "$", "post", ",", "$", "wp_did_header", ",", "$", "wp_query", ",", "$", "wp_rewrite", ",", "$", "wpdb", ",", "$", "wp_version", ",", "$", "wp", ",", "$", "id", ",", "$", "comment", ",", "$", "user_ID", ";", "if", "(", "0", "!==", "validate_file", "(", "$", "template_file", ")", ")", "{", "return", ";", "}", "require", "$", "template_file", ";", "}" ]
Load the template part. @param string $template_file The template part file path.
[ "Load", "the", "template", "part", "." ]
train
https://github.com/johnbillion/extended-template-parts/blob/c61293355847b1f9d18f9a6e1d047df85bae8049/src/extended-template-part.php#L147-L153
johnbillion/extended-template-parts
src/extended-template-part.php
Extended_Template_Part.set_cache
protected function set_cache( string $output ) : bool { return set_transient( $this->cache_key(), $output, $this->args['cache'] ); }
php
protected function set_cache( string $output ) : bool { return set_transient( $this->cache_key(), $output, $this->args['cache'] ); }
[ "protected", "function", "set_cache", "(", "string", "$", "output", ")", ":", "bool", "{", "return", "set_transient", "(", "$", "this", "->", "cache_key", "(", ")", ",", "$", "output", ",", "$", "this", "->", "args", "[", "'cache'", "]", ")", ";", "}" ]
Cache the template part output. @param string $output The template part output. @return bool Whether the transient data was successfully stored.
[ "Cache", "the", "template", "part", "output", "." ]
train
https://github.com/johnbillion/extended-template-parts/blob/c61293355847b1f9d18f9a6e1d047df85bae8049/src/extended-template-part.php#L170-L172
Nohac/laravel-graphiql
src/GraphiqlServiceProvider.php
GraphiqlServiceProvider.boot
public function boot() { $viewPath = __DIR__.'/../resources/views'; $this->loadViewsFrom($viewPath, 'graphiql'); // Publish a config file $configPath = __DIR__.'/../config/graphiql.php'; $this->publishes([ $configPath => config_path('graphiql.php'), ], 'config'); //Publish views $this->publishes([ __DIR__.'/../resources/views' => config('graphiql.paths.views'), ], 'views'); //Publish assets $this->publishes([ __DIR__.'/../resources/assets' => config('graphiql.paths.assets'), ], 'assets'); //Include routes \Route::group(['namespace' => 'Graphiql'], function ($router) { $router->get(config('graphiql.routes.ui'), [ 'as' => 'graphiql', 'middleware' => config('graphiql.routes.middleware', []), 'uses' => '\Graphiql\Http\Controllers\GraphiqlController@index', ]); }); }
php
public function boot() { $viewPath = __DIR__.'/../resources/views'; $this->loadViewsFrom($viewPath, 'graphiql'); // Publish a config file $configPath = __DIR__.'/../config/graphiql.php'; $this->publishes([ $configPath => config_path('graphiql.php'), ], 'config'); //Publish views $this->publishes([ __DIR__.'/../resources/views' => config('graphiql.paths.views'), ], 'views'); //Publish assets $this->publishes([ __DIR__.'/../resources/assets' => config('graphiql.paths.assets'), ], 'assets'); //Include routes \Route::group(['namespace' => 'Graphiql'], function ($router) { $router->get(config('graphiql.routes.ui'), [ 'as' => 'graphiql', 'middleware' => config('graphiql.routes.middleware', []), 'uses' => '\Graphiql\Http\Controllers\GraphiqlController@index', ]); }); }
[ "public", "function", "boot", "(", ")", "{", "$", "viewPath", "=", "__DIR__", ".", "'/../resources/views'", ";", "$", "this", "->", "loadViewsFrom", "(", "$", "viewPath", ",", "'graphiql'", ")", ";", "// Publish a config file", "$", "configPath", "=", "__DIR__", ".", "'/../config/graphiql.php'", ";", "$", "this", "->", "publishes", "(", "[", "$", "configPath", "=>", "config_path", "(", "'graphiql.php'", ")", ",", "]", ",", "'config'", ")", ";", "//Publish views", "$", "this", "->", "publishes", "(", "[", "__DIR__", ".", "'/../resources/views'", "=>", "config", "(", "'graphiql.paths.views'", ")", ",", "]", ",", "'views'", ")", ";", "//Publish assets", "$", "this", "->", "publishes", "(", "[", "__DIR__", ".", "'/../resources/assets'", "=>", "config", "(", "'graphiql.paths.assets'", ")", ",", "]", ",", "'assets'", ")", ";", "//Include routes", "\\", "Route", "::", "group", "(", "[", "'namespace'", "=>", "'Graphiql'", "]", ",", "function", "(", "$", "router", ")", "{", "$", "router", "->", "get", "(", "config", "(", "'graphiql.routes.ui'", ")", ",", "[", "'as'", "=>", "'graphiql'", ",", "'middleware'", "=>", "config", "(", "'graphiql.routes.middleware'", ",", "[", "]", ")", ",", "'uses'", "=>", "'\\Graphiql\\Http\\Controllers\\GraphiqlController@index'", ",", "]", ")", ";", "}", ")", ";", "}" ]
Bootstrap the application events. @return void
[ "Bootstrap", "the", "application", "events", "." ]
train
https://github.com/Nohac/laravel-graphiql/blob/c2a3ce1f7a577de839bc3df642d3517a90702106/src/GraphiqlServiceProvider.php#L15-L44
Nohac/laravel-graphiql
src/GraphiqlServiceProvider.php
GraphiqlServiceProvider.register
public function register() { $configPath = __DIR__.'/../config/graphiql.php'; $this->mergeConfigFrom($configPath, 'graphiql'); if ($this->app->runningInConsole()) { $this->commands([ PublishCommand::class ]); } }
php
public function register() { $configPath = __DIR__.'/../config/graphiql.php'; $this->mergeConfigFrom($configPath, 'graphiql'); if ($this->app->runningInConsole()) { $this->commands([ PublishCommand::class ]); } }
[ "public", "function", "register", "(", ")", "{", "$", "configPath", "=", "__DIR__", ".", "'/../config/graphiql.php'", ";", "$", "this", "->", "mergeConfigFrom", "(", "$", "configPath", ",", "'graphiql'", ")", ";", "if", "(", "$", "this", "->", "app", "->", "runningInConsole", "(", ")", ")", "{", "$", "this", "->", "commands", "(", "[", "PublishCommand", "::", "class", "]", ")", ";", "}", "}" ]
Register the service provider. @return void
[ "Register", "the", "service", "provider", "." ]
train
https://github.com/Nohac/laravel-graphiql/blob/c2a3ce1f7a577de839bc3df642d3517a90702106/src/GraphiqlServiceProvider.php#L51-L60
ray-di/Ray.Di
src/AbstractModule.php
AbstractModule.override
public function override(self $module) { $module->getContainer()->merge($this->container); $this->container = $module->getContainer(); }
php
public function override(self $module) { $module->getContainer()->merge($this->container); $this->container = $module->getContainer(); }
[ "public", "function", "override", "(", "self", "$", "module", ")", "{", "$", "module", "->", "getContainer", "(", ")", "->", "merge", "(", "$", "this", "->", "container", ")", ";", "$", "this", "->", "container", "=", "$", "module", "->", "getContainer", "(", ")", ";", "}" ]
Override module
[ "Override", "module" ]
train
https://github.com/ray-di/Ray.Di/blob/80f8d57949b97942365a71ce94f756816b32eb90/src/AbstractModule.php#L54-L58
ray-di/Ray.Di
src/AbstractModule.php
AbstractModule.bindInterceptor
public function bindInterceptor(AbstractMatcher $classMatcher, AbstractMatcher $methodMatcher, array $interceptors) { $pointcut = new Pointcut($classMatcher, $methodMatcher, $interceptors); $this->container->addPointcut($pointcut); foreach ($interceptors as $interceptor) { (new Bind($this->container, $interceptor))->to($interceptor)->in(Scope::SINGLETON); } }
php
public function bindInterceptor(AbstractMatcher $classMatcher, AbstractMatcher $methodMatcher, array $interceptors) { $pointcut = new Pointcut($classMatcher, $methodMatcher, $interceptors); $this->container->addPointcut($pointcut); foreach ($interceptors as $interceptor) { (new Bind($this->container, $interceptor))->to($interceptor)->in(Scope::SINGLETON); } }
[ "public", "function", "bindInterceptor", "(", "AbstractMatcher", "$", "classMatcher", ",", "AbstractMatcher", "$", "methodMatcher", ",", "array", "$", "interceptors", ")", "{", "$", "pointcut", "=", "new", "Pointcut", "(", "$", "classMatcher", ",", "$", "methodMatcher", ",", "$", "interceptors", ")", ";", "$", "this", "->", "container", "->", "addPointcut", "(", "$", "pointcut", ")", ";", "foreach", "(", "$", "interceptors", "as", "$", "interceptor", ")", "{", "(", "new", "Bind", "(", "$", "this", "->", "container", ",", "$", "interceptor", ")", ")", "->", "to", "(", "$", "interceptor", ")", "->", "in", "(", "Scope", "::", "SINGLETON", ")", ";", "}", "}" ]
Bind interceptor @param string[] $interceptors
[ "Bind", "interceptor" ]
train
https://github.com/ray-di/Ray.Di/blob/80f8d57949b97942365a71ce94f756816b32eb90/src/AbstractModule.php#L77-L84
ray-di/Ray.Di
src/AbstractModule.php
AbstractModule.bindPriorityInterceptor
public function bindPriorityInterceptor(AbstractMatcher $classMatcher, AbstractMatcher $methodMatcher, array $interceptors) { $pointcut = new PriorityPointcut($classMatcher, $methodMatcher, $interceptors); $this->container->addPointcut($pointcut); foreach ($interceptors as $interceptor) { (new Bind($this->container, $interceptor))->to($interceptor)->in(Scope::SINGLETON); } }
php
public function bindPriorityInterceptor(AbstractMatcher $classMatcher, AbstractMatcher $methodMatcher, array $interceptors) { $pointcut = new PriorityPointcut($classMatcher, $methodMatcher, $interceptors); $this->container->addPointcut($pointcut); foreach ($interceptors as $interceptor) { (new Bind($this->container, $interceptor))->to($interceptor)->in(Scope::SINGLETON); } }
[ "public", "function", "bindPriorityInterceptor", "(", "AbstractMatcher", "$", "classMatcher", ",", "AbstractMatcher", "$", "methodMatcher", ",", "array", "$", "interceptors", ")", "{", "$", "pointcut", "=", "new", "PriorityPointcut", "(", "$", "classMatcher", ",", "$", "methodMatcher", ",", "$", "interceptors", ")", ";", "$", "this", "->", "container", "->", "addPointcut", "(", "$", "pointcut", ")", ";", "foreach", "(", "$", "interceptors", "as", "$", "interceptor", ")", "{", "(", "new", "Bind", "(", "$", "this", "->", "container", ",", "$", "interceptor", ")", ")", "->", "to", "(", "$", "interceptor", ")", "->", "in", "(", "Scope", "::", "SINGLETON", ")", ";", "}", "}" ]
Bind interceptor early
[ "Bind", "interceptor", "early" ]
train
https://github.com/ray-di/Ray.Di/blob/80f8d57949b97942365a71ce94f756816b32eb90/src/AbstractModule.php#L89-L96
ray-di/Ray.Di
src/AbstractModule.php
AbstractModule.rename
public function rename(string $interface, string $newName, string $sourceName = Name::ANY, string $targetInterface = '') { $targetInterface = $targetInterface ?: $interface; if ($this->lastModule instanceof self) { $this->lastModule->getContainer()->move($interface, $sourceName, $targetInterface, $newName); } }
php
public function rename(string $interface, string $newName, string $sourceName = Name::ANY, string $targetInterface = '') { $targetInterface = $targetInterface ?: $interface; if ($this->lastModule instanceof self) { $this->lastModule->getContainer()->move($interface, $sourceName, $targetInterface, $newName); } }
[ "public", "function", "rename", "(", "string", "$", "interface", ",", "string", "$", "newName", ",", "string", "$", "sourceName", "=", "Name", "::", "ANY", ",", "string", "$", "targetInterface", "=", "''", ")", "{", "$", "targetInterface", "=", "$", "targetInterface", "?", ":", "$", "interface", ";", "if", "(", "$", "this", "->", "lastModule", "instanceof", "self", ")", "{", "$", "this", "->", "lastModule", "->", "getContainer", "(", ")", "->", "move", "(", "$", "interface", ",", "$", "sourceName", ",", "$", "targetInterface", ",", "$", "newName", ")", ";", "}", "}" ]
Rename binding name @param string $interface Interface @param string $newName New binding name @param string $sourceName Original binding name @param string $targetInterface Original interface
[ "Rename", "binding", "name" ]
train
https://github.com/ray-di/Ray.Di/blob/80f8d57949b97942365a71ce94f756816b32eb90/src/AbstractModule.php#L106-L112
ray-di/Ray.Di
src/AnnotatedClass.php
AnnotatedClass.getNewInstance
public function getNewInstance(\ReflectionClass $class) : NewInstance { $setterMethods = new SetterMethods([]); $methods = $class->getMethods(); foreach ($methods as $method) { if ($method->name === '__construct') { continue; } $setterMethods->add($this->injectionMethod->getSetterMethod($method)); } $name = $this->injectionMethod->getConstructorName($class); return new NewInstance($class, $setterMethods, $name); }
php
public function getNewInstance(\ReflectionClass $class) : NewInstance { $setterMethods = new SetterMethods([]); $methods = $class->getMethods(); foreach ($methods as $method) { if ($method->name === '__construct') { continue; } $setterMethods->add($this->injectionMethod->getSetterMethod($method)); } $name = $this->injectionMethod->getConstructorName($class); return new NewInstance($class, $setterMethods, $name); }
[ "public", "function", "getNewInstance", "(", "\\", "ReflectionClass", "$", "class", ")", ":", "NewInstance", "{", "$", "setterMethods", "=", "new", "SetterMethods", "(", "[", "]", ")", ";", "$", "methods", "=", "$", "class", "->", "getMethods", "(", ")", ";", "foreach", "(", "$", "methods", "as", "$", "method", ")", "{", "if", "(", "$", "method", "->", "name", "===", "'__construct'", ")", "{", "continue", ";", "}", "$", "setterMethods", "->", "add", "(", "$", "this", "->", "injectionMethod", "->", "getSetterMethod", "(", "$", "method", ")", ")", ";", "}", "$", "name", "=", "$", "this", "->", "injectionMethod", "->", "getConstructorName", "(", "$", "class", ")", ";", "return", "new", "NewInstance", "(", "$", "class", ",", "$", "setterMethods", ",", "$", "name", ")", ";", "}" ]
Return factory instance @param \ReflectionClass $class Target class reflection
[ "Return", "factory", "instance" ]
train
https://github.com/ray-di/Ray.Di/blob/80f8d57949b97942365a71ce94f756816b32eb90/src/AnnotatedClass.php#L33-L46
ray-di/Ray.Di
src/AnnotatedClass.php
AnnotatedClass.getPostConstruct
public function getPostConstruct(\ReflectionClass $class) { $methods = $class->getMethods(); foreach ($methods as $method) { /* @var $annotation PostConstruct|null */ $annotation = $this->reader->getMethodAnnotation($method, PostConstruct::class); if ($annotation instanceof PostConstruct) { return $method; } } }
php
public function getPostConstruct(\ReflectionClass $class) { $methods = $class->getMethods(); foreach ($methods as $method) { /* @var $annotation PostConstruct|null */ $annotation = $this->reader->getMethodAnnotation($method, PostConstruct::class); if ($annotation instanceof PostConstruct) { return $method; } } }
[ "public", "function", "getPostConstruct", "(", "\\", "ReflectionClass", "$", "class", ")", "{", "$", "methods", "=", "$", "class", "->", "getMethods", "(", ")", ";", "foreach", "(", "$", "methods", "as", "$", "method", ")", "{", "/* @var $annotation PostConstruct|null */", "$", "annotation", "=", "$", "this", "->", "reader", "->", "getMethodAnnotation", "(", "$", "method", ",", "PostConstruct", "::", "class", ")", ";", "if", "(", "$", "annotation", "instanceof", "PostConstruct", ")", "{", "return", "$", "method", ";", "}", "}", "}" ]
Return @-PostConstruct method reflection @return null|\ReflectionMethod
[ "Return", "@", "-", "PostConstruct", "method", "reflection" ]
train
https://github.com/ray-di/Ray.Di/blob/80f8d57949b97942365a71ce94f756816b32eb90/src/AnnotatedClass.php#L53-L63
ray-di/Ray.Di
src/AssistedInterceptor.php
AssistedInterceptor.invoke
public function invoke(MethodInvocation $invocation) { /** @var ReflectionMethod $method */ $method = $invocation->getMethod(); $assisted = $method->getAnnotation(Assisted::class); /* @var \Ray\Di\Di\Assisted $assisted */ $parameters = $method->getParameters(); $arguments = $invocation->getArguments()->getArrayCopy(); if ($assisted instanceof Assisted && $method instanceof ReflectionMethod) { $this->methodInvocationProvider->set($invocation); $arguments = $this->injectAssistedParameters($method, $assisted, $parameters, $arguments); } $invocation->getArguments()->exchangeArray($arguments); return $invocation->proceed(); }
php
public function invoke(MethodInvocation $invocation) { /** @var ReflectionMethod $method */ $method = $invocation->getMethod(); $assisted = $method->getAnnotation(Assisted::class); /* @var \Ray\Di\Di\Assisted $assisted */ $parameters = $method->getParameters(); $arguments = $invocation->getArguments()->getArrayCopy(); if ($assisted instanceof Assisted && $method instanceof ReflectionMethod) { $this->methodInvocationProvider->set($invocation); $arguments = $this->injectAssistedParameters($method, $assisted, $parameters, $arguments); } $invocation->getArguments()->exchangeArray($arguments); return $invocation->proceed(); }
[ "public", "function", "invoke", "(", "MethodInvocation", "$", "invocation", ")", "{", "/** @var ReflectionMethod $method */", "$", "method", "=", "$", "invocation", "->", "getMethod", "(", ")", ";", "$", "assisted", "=", "$", "method", "->", "getAnnotation", "(", "Assisted", "::", "class", ")", ";", "/* @var \\Ray\\Di\\Di\\Assisted $assisted */", "$", "parameters", "=", "$", "method", "->", "getParameters", "(", ")", ";", "$", "arguments", "=", "$", "invocation", "->", "getArguments", "(", ")", "->", "getArrayCopy", "(", ")", ";", "if", "(", "$", "assisted", "instanceof", "Assisted", "&&", "$", "method", "instanceof", "ReflectionMethod", ")", "{", "$", "this", "->", "methodInvocationProvider", "->", "set", "(", "$", "invocation", ")", ";", "$", "arguments", "=", "$", "this", "->", "injectAssistedParameters", "(", "$", "method", ",", "$", "assisted", ",", "$", "parameters", ",", "$", "arguments", ")", ";", "}", "$", "invocation", "->", "getArguments", "(", ")", "->", "exchangeArray", "(", "$", "arguments", ")", ";", "return", "$", "invocation", "->", "proceed", "(", ")", ";", "}" ]
Intercepts any method and injects instances of the missing arguments when they are type hinted @return object
[ "Intercepts", "any", "method", "and", "injects", "instances", "of", "the", "missing", "arguments", "when", "they", "are", "type", "hinted" ]
train
https://github.com/ray-di/Ray.Di/blob/80f8d57949b97942365a71ce94f756816b32eb90/src/AssistedInterceptor.php#L37-L52
ray-di/Ray.Di
src/AssistedInterceptor.php
AssistedInterceptor.getName
private function getName(ReflectionMethod $method, \ReflectionParameter $parameter) : string { $named = $method->getAnnotation(Named::class); if (! $named instanceof Named) { return Name::ANY; } parse_str($named->value, $names); $paramName = $parameter->getName(); if (isset($names[$paramName])) { return $names[$paramName]; } return Name::ANY; }
php
private function getName(ReflectionMethod $method, \ReflectionParameter $parameter) : string { $named = $method->getAnnotation(Named::class); if (! $named instanceof Named) { return Name::ANY; } parse_str($named->value, $names); $paramName = $parameter->getName(); if (isset($names[$paramName])) { return $names[$paramName]; } return Name::ANY; }
[ "private", "function", "getName", "(", "ReflectionMethod", "$", "method", ",", "\\", "ReflectionParameter", "$", "parameter", ")", ":", "string", "{", "$", "named", "=", "$", "method", "->", "getAnnotation", "(", "Named", "::", "class", ")", ";", "if", "(", "!", "$", "named", "instanceof", "Named", ")", "{", "return", "Name", "::", "ANY", ";", "}", "parse_str", "(", "$", "named", "->", "value", ",", "$", "names", ")", ";", "$", "paramName", "=", "$", "parameter", "->", "getName", "(", ")", ";", "if", "(", "isset", "(", "$", "names", "[", "$", "paramName", "]", ")", ")", "{", "return", "$", "names", "[", "$", "paramName", "]", ";", "}", "return", "Name", "::", "ANY", ";", "}" ]
Return dependency "name"
[ "Return", "dependency", "name" ]
train
https://github.com/ray-di/Ray.Di/blob/80f8d57949b97942365a71ce94f756816b32eb90/src/AssistedInterceptor.php#L77-L90
ray-di/Ray.Di
src/Dependency.php
Dependency.register
public function register(array &$container, Bind $bind) { $this->index = $index = (string) $bind; $container[$index] = $bind->getBound(); }
php
public function register(array &$container, Bind $bind) { $this->index = $index = (string) $bind; $container[$index] = $bind->getBound(); }
[ "public", "function", "register", "(", "array", "&", "$", "container", ",", "Bind", "$", "bind", ")", "{", "$", "this", "->", "index", "=", "$", "index", "=", "(", "string", ")", "$", "bind", ";", "$", "container", "[", "$", "index", "]", "=", "$", "bind", "->", "getBound", "(", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/ray-di/Ray.Di/blob/80f8d57949b97942365a71ce94f756816b32eb90/src/Dependency.php#L63-L67
ray-di/Ray.Di
src/Dependency.php
Dependency.inject
public function inject(Container $container) { // singleton ? if ($this->isSingleton === true && $this->instance) { return $this->instance; } // create dependency injected instance $this->instance = ($this->newInstance)($container); // @PostConstruct if ($this->postConstruct) { $this->instance->{$this->postConstruct}(); } return $this->instance; }
php
public function inject(Container $container) { // singleton ? if ($this->isSingleton === true && $this->instance) { return $this->instance; } // create dependency injected instance $this->instance = ($this->newInstance)($container); // @PostConstruct if ($this->postConstruct) { $this->instance->{$this->postConstruct}(); } return $this->instance; }
[ "public", "function", "inject", "(", "Container", "$", "container", ")", "{", "// singleton ?", "if", "(", "$", "this", "->", "isSingleton", "===", "true", "&&", "$", "this", "->", "instance", ")", "{", "return", "$", "this", "->", "instance", ";", "}", "// create dependency injected instance", "$", "this", "->", "instance", "=", "(", "$", "this", "->", "newInstance", ")", "(", "$", "container", ")", ";", "// @PostConstruct", "if", "(", "$", "this", "->", "postConstruct", ")", "{", "$", "this", "->", "instance", "->", "{", "$", "this", "->", "postConstruct", "}", "(", ")", ";", "}", "return", "$", "this", "->", "instance", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/ray-di/Ray.Di/blob/80f8d57949b97942365a71ce94f756816b32eb90/src/Dependency.php#L72-L88
ray-di/Ray.Di
src/BindValidator.php
BindValidator.to
public function to(string $interface, string $class) { if (! class_exists($class)) { throw new NotFound($class); } if (interface_exists($interface) && ! (new \ReflectionClass($class))->implementsInterface($interface)) { $msg = "[{$class}] is no implemented [{$interface}] interface"; throw new InvalidType($msg); } }
php
public function to(string $interface, string $class) { if (! class_exists($class)) { throw new NotFound($class); } if (interface_exists($interface) && ! (new \ReflectionClass($class))->implementsInterface($interface)) { $msg = "[{$class}] is no implemented [{$interface}] interface"; throw new InvalidType($msg); } }
[ "public", "function", "to", "(", "string", "$", "interface", ",", "string", "$", "class", ")", "{", "if", "(", "!", "class_exists", "(", "$", "class", ")", ")", "{", "throw", "new", "NotFound", "(", "$", "class", ")", ";", "}", "if", "(", "interface_exists", "(", "$", "interface", ")", "&&", "!", "(", "new", "\\", "ReflectionClass", "(", "$", "class", ")", ")", "->", "implementsInterface", "(", "$", "interface", ")", ")", "{", "$", "msg", "=", "\"[{$class}] is no implemented [{$interface}] interface\"", ";", "throw", "new", "InvalidType", "(", "$", "msg", ")", ";", "}", "}" ]
To validator
[ "To", "validator" ]
train
https://github.com/ray-di/Ray.Di/blob/80f8d57949b97942365a71ce94f756816b32eb90/src/BindValidator.php#L23-L33
ray-di/Ray.Di
src/BindValidator.php
BindValidator.toProvider
public function toProvider(string $provider) { if (! class_exists($provider)) { throw new NotFound($provider); } if (! (new \ReflectionClass($provider))->implementsInterface(ProviderInterface::class)) { throw new InvalidProvider($provider); } }
php
public function toProvider(string $provider) { if (! class_exists($provider)) { throw new NotFound($provider); } if (! (new \ReflectionClass($provider))->implementsInterface(ProviderInterface::class)) { throw new InvalidProvider($provider); } }
[ "public", "function", "toProvider", "(", "string", "$", "provider", ")", "{", "if", "(", "!", "class_exists", "(", "$", "provider", ")", ")", "{", "throw", "new", "NotFound", "(", "$", "provider", ")", ";", "}", "if", "(", "!", "(", "new", "\\", "ReflectionClass", "(", "$", "provider", ")", ")", "->", "implementsInterface", "(", "ProviderInterface", "::", "class", ")", ")", "{", "throw", "new", "InvalidProvider", "(", "$", "provider", ")", ";", "}", "}" ]
toProvider validator @throws NotFound
[ "toProvider", "validator" ]
train
https://github.com/ray-di/Ray.Di/blob/80f8d57949b97942365a71ce94f756816b32eb90/src/BindValidator.php#L40-L48
ray-di/Ray.Di
src/Container.php
Container.add
public function add(Bind $bind) { $dependency = $bind->getBound(); $dependency->register($this->container, $bind); }
php
public function add(Bind $bind) { $dependency = $bind->getBound(); $dependency->register($this->container, $bind); }
[ "public", "function", "add", "(", "Bind", "$", "bind", ")", "{", "$", "dependency", "=", "$", "bind", "->", "getBound", "(", ")", ";", "$", "dependency", "->", "register", "(", "$", "this", "->", "container", ",", "$", "bind", ")", ";", "}" ]
Add binding to container
[ "Add", "binding", "to", "container" ]
train
https://github.com/ray-di/Ray.Di/blob/80f8d57949b97942365a71ce94f756816b32eb90/src/Container.php#L33-L37
ray-di/Ray.Di
src/Container.php
Container.getDependency
public function getDependency(string $index) { if (! isset($this->container[$index])) { throw $this->unbound($index); } $dependency = $this->container[$index]; return $dependency->inject($this); }
php
public function getDependency(string $index) { if (! isset($this->container[$index])) { throw $this->unbound($index); } $dependency = $this->container[$index]; return $dependency->inject($this); }
[ "public", "function", "getDependency", "(", "string", "$", "index", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "container", "[", "$", "index", "]", ")", ")", "{", "throw", "$", "this", "->", "unbound", "(", "$", "index", ")", ";", "}", "$", "dependency", "=", "$", "this", "->", "container", "[", "$", "index", "]", ";", "return", "$", "dependency", "->", "inject", "(", "$", "this", ")", ";", "}" ]
Return dependency injected instance @throws Unbound
[ "Return", "dependency", "injected", "instance" ]
train
https://github.com/ray-di/Ray.Di/blob/80f8d57949b97942365a71ce94f756816b32eb90/src/Container.php#L60-L68
ray-di/Ray.Di
src/Container.php
Container.move
public function move(string $sourceInterface, string $sourceName, string $targetInterface, string $targetName) { $sourceIndex = $sourceInterface . '-' . $sourceName; if (! isset($this->container[$sourceIndex])) { throw $this->unbound($sourceIndex); } $targetIndex = $targetInterface . '-' . $targetName; $this->container[$targetIndex] = $this->container[$sourceIndex]; unset($this->container[$sourceIndex]); }
php
public function move(string $sourceInterface, string $sourceName, string $targetInterface, string $targetName) { $sourceIndex = $sourceInterface . '-' . $sourceName; if (! isset($this->container[$sourceIndex])) { throw $this->unbound($sourceIndex); } $targetIndex = $targetInterface . '-' . $targetName; $this->container[$targetIndex] = $this->container[$sourceIndex]; unset($this->container[$sourceIndex]); }
[ "public", "function", "move", "(", "string", "$", "sourceInterface", ",", "string", "$", "sourceName", ",", "string", "$", "targetInterface", ",", "string", "$", "targetName", ")", "{", "$", "sourceIndex", "=", "$", "sourceInterface", ".", "'-'", ".", "$", "sourceName", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "container", "[", "$", "sourceIndex", "]", ")", ")", "{", "throw", "$", "this", "->", "unbound", "(", "$", "sourceIndex", ")", ";", "}", "$", "targetIndex", "=", "$", "targetInterface", ".", "'-'", ".", "$", "targetName", ";", "$", "this", "->", "container", "[", "$", "targetIndex", "]", "=", "$", "this", "->", "container", "[", "$", "sourceIndex", "]", ";", "unset", "(", "$", "this", "->", "container", "[", "$", "sourceIndex", "]", ")", ";", "}" ]
Rename existing dependency interface + name
[ "Rename", "existing", "dependency", "interface", "+", "name" ]
train
https://github.com/ray-di/Ray.Di/blob/80f8d57949b97942365a71ce94f756816b32eb90/src/Container.php#L73-L82
ray-di/Ray.Di
src/Container.php
Container.unbound
public function unbound(string $index) { list($class, $name) = explode('-', $index); if (class_exists($class) && ! (new \ReflectionClass($class))->isAbstract()) { return new Untargeted($class); } return new Unbound("{$class}-{$name}"); }
php
public function unbound(string $index) { list($class, $name) = explode('-', $index); if (class_exists($class) && ! (new \ReflectionClass($class))->isAbstract()) { return new Untargeted($class); } return new Unbound("{$class}-{$name}"); }
[ "public", "function", "unbound", "(", "string", "$", "index", ")", "{", "list", "(", "$", "class", ",", "$", "name", ")", "=", "explode", "(", "'-'", ",", "$", "index", ")", ";", "if", "(", "class_exists", "(", "$", "class", ")", "&&", "!", "(", "new", "\\", "ReflectionClass", "(", "$", "class", ")", ")", "->", "isAbstract", "(", ")", ")", "{", "return", "new", "Untargeted", "(", "$", "class", ")", ";", "}", "return", "new", "Unbound", "(", "\"{$class}-{$name}\"", ")", ";", "}" ]
Return Unbound exception @param string $index {interface}-{bind name} @return Unbound|Untargeted
[ "Return", "Unbound", "exception" ]
train
https://github.com/ray-di/Ray.Di/blob/80f8d57949b97942365a71ce94f756816b32eb90/src/Container.php#L91-L99
ray-di/Ray.Di
src/Container.php
Container.merge
public function merge(self $container) { $this->container += $container->getContainer(); $this->pointcuts = array_merge($this->pointcuts, $container->getPointcuts()); }
php
public function merge(self $container) { $this->container += $container->getContainer(); $this->pointcuts = array_merge($this->pointcuts, $container->getPointcuts()); }
[ "public", "function", "merge", "(", "self", "$", "container", ")", "{", "$", "this", "->", "container", "+=", "$", "container", "->", "getContainer", "(", ")", ";", "$", "this", "->", "pointcuts", "=", "array_merge", "(", "$", "this", "->", "pointcuts", ",", "$", "container", "->", "getPointcuts", "(", ")", ")", ";", "}" ]
Merge container
[ "Merge", "container" ]
train
https://github.com/ray-di/Ray.Di/blob/80f8d57949b97942365a71ce94f756816b32eb90/src/Container.php#L124-L128
ray-di/Ray.Di
src/Container.php
Container.weaveAspects
public function weaveAspects(CompilerInterface $compiler) { foreach ($this->container as $dependency) { if (! $dependency instanceof Dependency) { continue; } $dependency->weaveAspects($compiler, $this->pointcuts); } }
php
public function weaveAspects(CompilerInterface $compiler) { foreach ($this->container as $dependency) { if (! $dependency instanceof Dependency) { continue; } $dependency->weaveAspects($compiler, $this->pointcuts); } }
[ "public", "function", "weaveAspects", "(", "CompilerInterface", "$", "compiler", ")", "{", "foreach", "(", "$", "this", "->", "container", "as", "$", "dependency", ")", "{", "if", "(", "!", "$", "dependency", "instanceof", "Dependency", ")", "{", "continue", ";", "}", "$", "dependency", "->", "weaveAspects", "(", "$", "compiler", ",", "$", "this", "->", "pointcuts", ")", ";", "}", "}" ]
Weave aspects to all dependency in container
[ "Weave", "aspects", "to", "all", "dependency", "in", "container" ]
train
https://github.com/ray-di/Ray.Di/blob/80f8d57949b97942365a71ce94f756816b32eb90/src/Container.php#L133-L141
ray-di/Ray.Di
src/Container.php
Container.weaveAspect
public function weaveAspect(Compiler $compiler, Dependency $dependency) : self { $dependency->weaveAspects($compiler, $this->pointcuts); return $this; }
php
public function weaveAspect(Compiler $compiler, Dependency $dependency) : self { $dependency->weaveAspects($compiler, $this->pointcuts); return $this; }
[ "public", "function", "weaveAspect", "(", "Compiler", "$", "compiler", ",", "Dependency", "$", "dependency", ")", ":", "self", "{", "$", "dependency", "->", "weaveAspects", "(", "$", "compiler", ",", "$", "this", "->", "pointcuts", ")", ";", "return", "$", "this", ";", "}" ]
Weave aspect to single dependency
[ "Weave", "aspect", "to", "single", "dependency" ]
train
https://github.com/ray-di/Ray.Di/blob/80f8d57949b97942365a71ce94f756816b32eb90/src/Container.php#L146-L151
ray-di/Ray.Di
src/Bind.php
Bind.to
public function to(string $class) : self { $this->untarget = null; $this->validate->to($this->interface, $class); $this->bound = (new DependencyFactory)->newAnnotatedDependency(new \ReflectionClass($class)); $this->container->add($this); return $this; }
php
public function to(string $class) : self { $this->untarget = null; $this->validate->to($this->interface, $class); $this->bound = (new DependencyFactory)->newAnnotatedDependency(new \ReflectionClass($class)); $this->container->add($this); return $this; }
[ "public", "function", "to", "(", "string", "$", "class", ")", ":", "self", "{", "$", "this", "->", "untarget", "=", "null", ";", "$", "this", "->", "validate", "->", "to", "(", "$", "this", "->", "interface", ",", "$", "class", ")", ";", "$", "this", "->", "bound", "=", "(", "new", "DependencyFactory", ")", "->", "newAnnotatedDependency", "(", "new", "\\", "ReflectionClass", "(", "$", "class", ")", ")", ";", "$", "this", "->", "container", "->", "add", "(", "$", "this", ")", ";", "return", "$", "this", ";", "}" ]
Bind to class
[ "Bind", "to", "class" ]
train
https://github.com/ray-di/Ray.Di/blob/80f8d57949b97942365a71ce94f756816b32eb90/src/Bind.php#L83-L91
ray-di/Ray.Di
src/Bind.php
Bind.toConstructor
public function toConstructor(string $class, $name, InjectionPoints $injectionPoints = null, string $postConstruct = null) : self { if (\is_array($name)) { $name = $this->getStringName($name); } $this->untarget = null; $postConstructRef = $postConstruct ? new \ReflectionMethod($class, $postConstruct) : null; $this->bound = (new DependencyFactory)->newToConstructor(new \ReflectionClass($class), $name, $injectionPoints, $postConstructRef); $this->container->add($this); return $this; }
php
public function toConstructor(string $class, $name, InjectionPoints $injectionPoints = null, string $postConstruct = null) : self { if (\is_array($name)) { $name = $this->getStringName($name); } $this->untarget = null; $postConstructRef = $postConstruct ? new \ReflectionMethod($class, $postConstruct) : null; $this->bound = (new DependencyFactory)->newToConstructor(new \ReflectionClass($class), $name, $injectionPoints, $postConstructRef); $this->container->add($this); return $this; }
[ "public", "function", "toConstructor", "(", "string", "$", "class", ",", "$", "name", ",", "InjectionPoints", "$", "injectionPoints", "=", "null", ",", "string", "$", "postConstruct", "=", "null", ")", ":", "self", "{", "if", "(", "\\", "is_array", "(", "$", "name", ")", ")", "{", "$", "name", "=", "$", "this", "->", "getStringName", "(", "$", "name", ")", ";", "}", "$", "this", "->", "untarget", "=", "null", ";", "$", "postConstructRef", "=", "$", "postConstruct", "?", "new", "\\", "ReflectionMethod", "(", "$", "class", ",", "$", "postConstruct", ")", ":", "null", ";", "$", "this", "->", "bound", "=", "(", "new", "DependencyFactory", ")", "->", "newToConstructor", "(", "new", "\\", "ReflectionClass", "(", "$", "class", ")", ",", "$", "name", ",", "$", "injectionPoints", ",", "$", "postConstructRef", ")", ";", "$", "this", "->", "container", "->", "add", "(", "$", "this", ")", ";", "return", "$", "this", ";", "}" ]
Bind to constructor @param string $class class name @param string | array $name "varName=bindName,..." or [[$varName => $bindName],[$varName => $bindName]...] @param InjectionPoints $injectionPoints injection points @param string $postConstruct method name of initialization after all dependencies are injected*
[ "Bind", "to", "constructor" ]
train
https://github.com/ray-di/Ray.Di/blob/80f8d57949b97942365a71ce94f756816b32eb90/src/Bind.php#L101-L112
ray-di/Ray.Di
src/Bind.php
Bind.toProvider
public function toProvider(string $provider, string $context = '') : self { $this->untarget = null; $this->validate->toProvider($provider); $this->bound = (new DependencyFactory)->newProvider(new \ReflectionClass($provider), $context); $this->container->add($this); return $this; }
php
public function toProvider(string $provider, string $context = '') : self { $this->untarget = null; $this->validate->toProvider($provider); $this->bound = (new DependencyFactory)->newProvider(new \ReflectionClass($provider), $context); $this->container->add($this); return $this; }
[ "public", "function", "toProvider", "(", "string", "$", "provider", ",", "string", "$", "context", "=", "''", ")", ":", "self", "{", "$", "this", "->", "untarget", "=", "null", ";", "$", "this", "->", "validate", "->", "toProvider", "(", "$", "provider", ")", ";", "$", "this", "->", "bound", "=", "(", "new", "DependencyFactory", ")", "->", "newProvider", "(", "new", "\\", "ReflectionClass", "(", "$", "provider", ")", ",", "$", "context", ")", ";", "$", "this", "->", "container", "->", "add", "(", "$", "this", ")", ";", "return", "$", "this", ";", "}" ]
Bind to provider
[ "Bind", "to", "provider" ]
train
https://github.com/ray-di/Ray.Di/blob/80f8d57949b97942365a71ce94f756816b32eb90/src/Bind.php#L117-L125
ray-di/Ray.Di
src/Bind.php
Bind.toInstance
public function toInstance($instance) : self { $this->untarget = null; $this->bound = new Instance($instance); $this->container->add($this); return $this; }
php
public function toInstance($instance) : self { $this->untarget = null; $this->bound = new Instance($instance); $this->container->add($this); return $this; }
[ "public", "function", "toInstance", "(", "$", "instance", ")", ":", "self", "{", "$", "this", "->", "untarget", "=", "null", ";", "$", "this", "->", "bound", "=", "new", "Instance", "(", "$", "instance", ")", ";", "$", "this", "->", "container", "->", "add", "(", "$", "this", ")", ";", "return", "$", "this", ";", "}" ]
Bind to instance
[ "Bind", "to", "instance" ]
train
https://github.com/ray-di/Ray.Di/blob/80f8d57949b97942365a71ce94f756816b32eb90/src/Bind.php#L130-L137
ray-di/Ray.Di
src/Bind.php
Bind.in
public function in(string $scope) : self { if ($this->bound instanceof Dependency || $this->bound instanceof DependencyProvider) { $this->bound->setScope($scope); } if ($this->untarget) { $this->untarget->setScope($scope); } return $this; }
php
public function in(string $scope) : self { if ($this->bound instanceof Dependency || $this->bound instanceof DependencyProvider) { $this->bound->setScope($scope); } if ($this->untarget) { $this->untarget->setScope($scope); } return $this; }
[ "public", "function", "in", "(", "string", "$", "scope", ")", ":", "self", "{", "if", "(", "$", "this", "->", "bound", "instanceof", "Dependency", "||", "$", "this", "->", "bound", "instanceof", "DependencyProvider", ")", "{", "$", "this", "->", "bound", "->", "setScope", "(", "$", "scope", ")", ";", "}", "if", "(", "$", "this", "->", "untarget", ")", "{", "$", "this", "->", "untarget", "->", "setScope", "(", "$", "scope", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set scope
[ "Set", "scope" ]
train
https://github.com/ray-di/Ray.Di/blob/80f8d57949b97942365a71ce94f756816b32eb90/src/Bind.php#L142-L152
ray-di/Ray.Di
src/Bind.php
Bind.getStringName
private function getStringName(array $name) : string { $names = array_reduce(array_keys($name), function (array $carry, $key) use ($name) : array { $carry[] .= $key . '=' . $name[(string) $key]; return $carry; }, []); return implode(',', $names); }
php
private function getStringName(array $name) : string { $names = array_reduce(array_keys($name), function (array $carry, $key) use ($name) : array { $carry[] .= $key . '=' . $name[(string) $key]; return $carry; }, []); return implode(',', $names); }
[ "private", "function", "getStringName", "(", "array", "$", "name", ")", ":", "string", "{", "$", "names", "=", "array_reduce", "(", "array_keys", "(", "$", "name", ")", ",", "function", "(", "array", "$", "carry", ",", "$", "key", ")", "use", "(", "$", "name", ")", ":", "array", "{", "$", "carry", "[", "]", ".=", "$", "key", ".", "'='", ".", "$", "name", "[", "(", "string", ")", "$", "key", "]", ";", "return", "$", "carry", ";", "}", ",", "[", "]", ")", ";", "return", "implode", "(", "','", ",", "$", "names", ")", ";", "}" ]
Return string input: [['varA' => 'nameA'], ['varB' => 'nameB']] output: "varA=nameA,varB=nameB"
[ "Return", "string" ]
train
https://github.com/ray-di/Ray.Di/blob/80f8d57949b97942365a71ce94f756816b32eb90/src/Bind.php#L175-L184
ray-di/Ray.Di
src/AspectBind.php
AspectBind.inject
public function inject(Container $container) : array { $bindings = $this->bind->getBindings(); foreach ($bindings as &$interceptors) { /* @var string[] $interceptors */ foreach ($interceptors as &$interceptor) { if (\is_string($interceptor)) { $interceptor = $container->getInstance($interceptor, Name::ANY); } } } return $bindings; }
php
public function inject(Container $container) : array { $bindings = $this->bind->getBindings(); foreach ($bindings as &$interceptors) { /* @var string[] $interceptors */ foreach ($interceptors as &$interceptor) { if (\is_string($interceptor)) { $interceptor = $container->getInstance($interceptor, Name::ANY); } } } return $bindings; }
[ "public", "function", "inject", "(", "Container", "$", "container", ")", ":", "array", "{", "$", "bindings", "=", "$", "this", "->", "bind", "->", "getBindings", "(", ")", ";", "foreach", "(", "$", "bindings", "as", "&", "$", "interceptors", ")", "{", "/* @var string[] $interceptors */", "foreach", "(", "$", "interceptors", "as", "&", "$", "interceptor", ")", "{", "if", "(", "\\", "is_string", "(", "$", "interceptor", ")", ")", "{", "$", "interceptor", "=", "$", "container", "->", "getInstance", "(", "$", "interceptor", ",", "Name", "::", "ANY", ")", ";", "}", "}", "}", "return", "$", "bindings", ";", "}" ]
Instantiate interceptors
[ "Instantiate", "interceptors" ]
train
https://github.com/ray-di/Ray.Di/blob/80f8d57949b97942365a71ce94f756816b32eb90/src/AspectBind.php#L24-L37
ray-di/Ray.Di
src/DependencyFactory.php
DependencyFactory.newAnnotatedDependency
public function newAnnotatedDependency(\ReflectionClass $class) : Dependency { $annotateClass = new AnnotatedClass(new AnnotationReader); $newInstance = $annotateClass->getNewInstance($class); $postConstruct = $annotateClass->getPostConstruct($class); return new Dependency($newInstance, $postConstruct); }
php
public function newAnnotatedDependency(\ReflectionClass $class) : Dependency { $annotateClass = new AnnotatedClass(new AnnotationReader); $newInstance = $annotateClass->getNewInstance($class); $postConstruct = $annotateClass->getPostConstruct($class); return new Dependency($newInstance, $postConstruct); }
[ "public", "function", "newAnnotatedDependency", "(", "\\", "ReflectionClass", "$", "class", ")", ":", "Dependency", "{", "$", "annotateClass", "=", "new", "AnnotatedClass", "(", "new", "AnnotationReader", ")", ";", "$", "newInstance", "=", "$", "annotateClass", "->", "getNewInstance", "(", "$", "class", ")", ";", "$", "postConstruct", "=", "$", "annotateClass", "->", "getPostConstruct", "(", "$", "class", ")", ";", "return", "new", "Dependency", "(", "$", "newInstance", ",", "$", "postConstruct", ")", ";", "}" ]
Create dependency object
[ "Create", "dependency", "object" ]
train
https://github.com/ray-di/Ray.Di/blob/80f8d57949b97942365a71ce94f756816b32eb90/src/DependencyFactory.php#L14-L21
ray-di/Ray.Di
src/DependencyFactory.php
DependencyFactory.newProvider
public function newProvider(\ReflectionClass $provider, string $context) : DependencyProvider { $dependency = $this->newAnnotatedDependency($provider); return new DependencyProvider($dependency, $context); }
php
public function newProvider(\ReflectionClass $provider, string $context) : DependencyProvider { $dependency = $this->newAnnotatedDependency($provider); return new DependencyProvider($dependency, $context); }
[ "public", "function", "newProvider", "(", "\\", "ReflectionClass", "$", "provider", ",", "string", "$", "context", ")", ":", "DependencyProvider", "{", "$", "dependency", "=", "$", "this", "->", "newAnnotatedDependency", "(", "$", "provider", ")", ";", "return", "new", "DependencyProvider", "(", "$", "dependency", ",", "$", "context", ")", ";", "}" ]
Create Provider binding
[ "Create", "Provider", "binding" ]
train
https://github.com/ray-di/Ray.Di/blob/80f8d57949b97942365a71ce94f756816b32eb90/src/DependencyFactory.php#L26-L31
ray-di/Ray.Di
src/DependencyFactory.php
DependencyFactory.newToConstructor
public function newToConstructor( \ReflectionClass $class, string $name, InjectionPoints $injectionPoints = null, \ReflectionMethod $postConstruct = null ) : Dependency { $setterMethods = $injectionPoints ? $injectionPoints($class->name) : new SetterMethods([]); $newInstance = new NewInstance($class, $setterMethods, new Name($name)); return new Dependency($newInstance, $postConstruct); }
php
public function newToConstructor( \ReflectionClass $class, string $name, InjectionPoints $injectionPoints = null, \ReflectionMethod $postConstruct = null ) : Dependency { $setterMethods = $injectionPoints ? $injectionPoints($class->name) : new SetterMethods([]); $newInstance = new NewInstance($class, $setterMethods, new Name($name)); return new Dependency($newInstance, $postConstruct); }
[ "public", "function", "newToConstructor", "(", "\\", "ReflectionClass", "$", "class", ",", "string", "$", "name", ",", "InjectionPoints", "$", "injectionPoints", "=", "null", ",", "\\", "ReflectionMethod", "$", "postConstruct", "=", "null", ")", ":", "Dependency", "{", "$", "setterMethods", "=", "$", "injectionPoints", "?", "$", "injectionPoints", "(", "$", "class", "->", "name", ")", ":", "new", "SetterMethods", "(", "[", "]", ")", ";", "$", "newInstance", "=", "new", "NewInstance", "(", "$", "class", ",", "$", "setterMethods", ",", "new", "Name", "(", "$", "name", ")", ")", ";", "return", "new", "Dependency", "(", "$", "newInstance", ",", "$", "postConstruct", ")", ";", "}" ]
Create ToConstructor binding
[ "Create", "ToConstructor", "binding" ]
train
https://github.com/ray-di/Ray.Di/blob/80f8d57949b97942365a71ce94f756816b32eb90/src/DependencyFactory.php#L36-L46
ray-di/Ray.Di
src/DependencyProvider.php
DependencyProvider.inject
public function inject(Container $container) { if ($this->isSingleton && $this->instance) { return $this->instance; } $provider = $this->dependency->inject($container); if ($provider instanceof SetContextInterface) { $this->setContext($provider); } $this->instance = $provider->get(); return $this->instance; }
php
public function inject(Container $container) { if ($this->isSingleton && $this->instance) { return $this->instance; } $provider = $this->dependency->inject($container); if ($provider instanceof SetContextInterface) { $this->setContext($provider); } $this->instance = $provider->get(); return $this->instance; }
[ "public", "function", "inject", "(", "Container", "$", "container", ")", "{", "if", "(", "$", "this", "->", "isSingleton", "&&", "$", "this", "->", "instance", ")", "{", "return", "$", "this", "->", "instance", ";", "}", "$", "provider", "=", "$", "this", "->", "dependency", "->", "inject", "(", "$", "container", ")", ";", "if", "(", "$", "provider", "instanceof", "SetContextInterface", ")", "{", "$", "this", "->", "setContext", "(", "$", "provider", ")", ";", "}", "$", "this", "->", "instance", "=", "$", "provider", "->", "get", "(", ")", ";", "return", "$", "this", "->", "instance", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/ray-di/Ray.Di/blob/80f8d57949b97942365a71ce94f756816b32eb90/src/DependencyProvider.php#L61-L73
ray-di/Ray.Di
src/SpyCompiler.php
SpyCompiler.compile
public function compile(string $class, BindInterface $bind) : string { if ($this->hasNoBinding($class, $bind)) { return $class; } return $class . $this->getInterceptors($bind); }
php
public function compile(string $class, BindInterface $bind) : string { if ($this->hasNoBinding($class, $bind)) { return $class; } return $class . $this->getInterceptors($bind); }
[ "public", "function", "compile", "(", "string", "$", "class", ",", "BindInterface", "$", "bind", ")", ":", "string", "{", "if", "(", "$", "this", "->", "hasNoBinding", "(", "$", "class", ",", "$", "bind", ")", ")", "{", "return", "$", "class", ";", "}", "return", "$", "class", ".", "$", "this", "->", "getInterceptors", "(", "$", "bind", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/ray-di/Ray.Di/blob/80f8d57949b97942365a71ce94f756816b32eb90/src/SpyCompiler.php#L22-L29
ray-di/Ray.Di
src/InjectionPoint.php
InjectionPoint.getMethod
public function getMethod() : \ReflectionMethod { $class = $this->parameter->getDeclaringClass(); if (! $class instanceof \ReflectionClass) { throw new \LogicException($this->parameter->getName()); } $method = $this->parameter->getDeclaringFunction()->getShortName(); return new \ReflectionMethod($class->name, $method); }
php
public function getMethod() : \ReflectionMethod { $class = $this->parameter->getDeclaringClass(); if (! $class instanceof \ReflectionClass) { throw new \LogicException($this->parameter->getName()); } $method = $this->parameter->getDeclaringFunction()->getShortName(); return new \ReflectionMethod($class->name, $method); }
[ "public", "function", "getMethod", "(", ")", ":", "\\", "ReflectionMethod", "{", "$", "class", "=", "$", "this", "->", "parameter", "->", "getDeclaringClass", "(", ")", ";", "if", "(", "!", "$", "class", "instanceof", "\\", "ReflectionClass", ")", "{", "throw", "new", "\\", "LogicException", "(", "$", "this", "->", "parameter", "->", "getName", "(", ")", ")", ";", "}", "$", "method", "=", "$", "this", "->", "parameter", "->", "getDeclaringFunction", "(", ")", "->", "getShortName", "(", ")", ";", "return", "new", "\\", "ReflectionMethod", "(", "$", "class", "->", "name", ",", "$", "method", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/ray-di/Ray.Di/blob/80f8d57949b97942365a71ce94f756816b32eb90/src/InjectionPoint.php#L39-L48
ray-di/Ray.Di
src/InjectionPoint.php
InjectionPoint.getClass
public function getClass() : \ReflectionClass { $class = $this->parameter->getDeclaringClass(); if ($class instanceof \ReflectionClass) { return $class; } throw new \LogicException($this->parameter->getName()); }
php
public function getClass() : \ReflectionClass { $class = $this->parameter->getDeclaringClass(); if ($class instanceof \ReflectionClass) { return $class; } throw new \LogicException($this->parameter->getName()); }
[ "public", "function", "getClass", "(", ")", ":", "\\", "ReflectionClass", "{", "$", "class", "=", "$", "this", "->", "parameter", "->", "getDeclaringClass", "(", ")", ";", "if", "(", "$", "class", "instanceof", "\\", "ReflectionClass", ")", "{", "return", "$", "class", ";", "}", "throw", "new", "\\", "LogicException", "(", "$", "this", "->", "parameter", "->", "getName", "(", ")", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/ray-di/Ray.Di/blob/80f8d57949b97942365a71ce94f756816b32eb90/src/InjectionPoint.php#L53-L61
ray-di/Ray.Di
src/InjectionPoint.php
InjectionPoint.getQualifiers
public function getQualifiers() : array { $qualifiers = []; $annotations = $this->reader->getMethodAnnotations($this->getMethod()); foreach ($annotations as $annotation) { $qualifier = $this->reader->getClassAnnotation( new \ReflectionClass($annotation), Qualifier::class ); if ($qualifier instanceof Qualifier) { $qualifiers[] = $annotation; } } return $qualifiers; }
php
public function getQualifiers() : array { $qualifiers = []; $annotations = $this->reader->getMethodAnnotations($this->getMethod()); foreach ($annotations as $annotation) { $qualifier = $this->reader->getClassAnnotation( new \ReflectionClass($annotation), Qualifier::class ); if ($qualifier instanceof Qualifier) { $qualifiers[] = $annotation; } } return $qualifiers; }
[ "public", "function", "getQualifiers", "(", ")", ":", "array", "{", "$", "qualifiers", "=", "[", "]", ";", "$", "annotations", "=", "$", "this", "->", "reader", "->", "getMethodAnnotations", "(", "$", "this", "->", "getMethod", "(", ")", ")", ";", "foreach", "(", "$", "annotations", "as", "$", "annotation", ")", "{", "$", "qualifier", "=", "$", "this", "->", "reader", "->", "getClassAnnotation", "(", "new", "\\", "ReflectionClass", "(", "$", "annotation", ")", ",", "Qualifier", "::", "class", ")", ";", "if", "(", "$", "qualifier", "instanceof", "Qualifier", ")", "{", "$", "qualifiers", "[", "]", "=", "$", "annotation", ";", "}", "}", "return", "$", "qualifiers", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/ray-di/Ray.Di/blob/80f8d57949b97942365a71ce94f756816b32eb90/src/InjectionPoint.php#L66-L81
ray-di/Ray.Di
src/Arguments.php
Arguments.inject
public function inject(Container $container) : array { $parameters = $this->arguments; foreach ($parameters as &$parameter) { $parameter = $this->getParameter($container, $parameter); } return $parameters; }
php
public function inject(Container $container) : array { $parameters = $this->arguments; foreach ($parameters as &$parameter) { $parameter = $this->getParameter($container, $parameter); } return $parameters; }
[ "public", "function", "inject", "(", "Container", "$", "container", ")", ":", "array", "{", "$", "parameters", "=", "$", "this", "->", "arguments", ";", "foreach", "(", "$", "parameters", "as", "&", "$", "parameter", ")", "{", "$", "parameter", "=", "$", "this", "->", "getParameter", "(", "$", "container", ",", "$", "parameter", ")", ";", "}", "return", "$", "parameters", ";", "}" ]
Return arguments @throws Exception\Unbound @return Argument[]
[ "Return", "arguments" ]
train
https://github.com/ray-di/Ray.Di/blob/80f8d57949b97942365a71ce94f756816b32eb90/src/Arguments.php#L32-L40
creof/wkb-parser
lib/CrEOF/Geo/WKB/Parser.php
Parser.parse
public function parse($input = null) { if (null !== $input) { $this->reader->load($input); } return $this->readGeometry(); }
php
public function parse($input = null) { if (null !== $input) { $this->reader->load($input); } return $this->readGeometry(); }
[ "public", "function", "parse", "(", "$", "input", "=", "null", ")", "{", "if", "(", "null", "!==", "$", "input", ")", "{", "$", "this", "->", "reader", "->", "load", "(", "$", "input", ")", ";", "}", "return", "$", "this", "->", "readGeometry", "(", ")", ";", "}" ]
Parse input data @param string $input @return array @throws UnexpectedValueException
[ "Parse", "input", "data" ]
train
https://github.com/creof/wkb-parser/blob/1ddb69da8cc90607dd528fd9992ef1fc10cc8839/lib/CrEOF/Geo/WKB/Parser.php#L129-L136
creof/wkb-parser
lib/CrEOF/Geo/WKB/Parser.php
Parser.readGeometry
private function readGeometry() { $this->srid = null; try { $this->byteOrder = $this->readByteOrder(); $this->type = $this->readType(); if ($this->hasFlag($this->type, self::WKB_FLAG_SRID)) { $this->srid = $this->readSrid(); } $this->dimensions = $this->getDimensions($this->type); $this->pointSize = 2 + strlen($this->getDimensionType($this->dimensions)); $typeName = $this->getTypeName($this->type); return array( 'type' => $typeName, 'srid' => $this->srid, 'value' => $this->$typeName(), 'dimension' => $this->getDimensionType($this->dimensions) ); } catch (ExceptionInterface $e) { throw new $e($e->getMessage() . ' at byte ' . $this->reader->getLastPosition(), $e->getCode(), $e->getPrevious()); } }
php
private function readGeometry() { $this->srid = null; try { $this->byteOrder = $this->readByteOrder(); $this->type = $this->readType(); if ($this->hasFlag($this->type, self::WKB_FLAG_SRID)) { $this->srid = $this->readSrid(); } $this->dimensions = $this->getDimensions($this->type); $this->pointSize = 2 + strlen($this->getDimensionType($this->dimensions)); $typeName = $this->getTypeName($this->type); return array( 'type' => $typeName, 'srid' => $this->srid, 'value' => $this->$typeName(), 'dimension' => $this->getDimensionType($this->dimensions) ); } catch (ExceptionInterface $e) { throw new $e($e->getMessage() . ' at byte ' . $this->reader->getLastPosition(), $e->getCode(), $e->getPrevious()); } }
[ "private", "function", "readGeometry", "(", ")", "{", "$", "this", "->", "srid", "=", "null", ";", "try", "{", "$", "this", "->", "byteOrder", "=", "$", "this", "->", "readByteOrder", "(", ")", ";", "$", "this", "->", "type", "=", "$", "this", "->", "readType", "(", ")", ";", "if", "(", "$", "this", "->", "hasFlag", "(", "$", "this", "->", "type", ",", "self", "::", "WKB_FLAG_SRID", ")", ")", "{", "$", "this", "->", "srid", "=", "$", "this", "->", "readSrid", "(", ")", ";", "}", "$", "this", "->", "dimensions", "=", "$", "this", "->", "getDimensions", "(", "$", "this", "->", "type", ")", ";", "$", "this", "->", "pointSize", "=", "2", "+", "strlen", "(", "$", "this", "->", "getDimensionType", "(", "$", "this", "->", "dimensions", ")", ")", ";", "$", "typeName", "=", "$", "this", "->", "getTypeName", "(", "$", "this", "->", "type", ")", ";", "return", "array", "(", "'type'", "=>", "$", "typeName", ",", "'srid'", "=>", "$", "this", "->", "srid", ",", "'value'", "=>", "$", "this", "->", "$", "typeName", "(", ")", ",", "'dimension'", "=>", "$", "this", "->", "getDimensionType", "(", "$", "this", "->", "dimensions", ")", ")", ";", "}", "catch", "(", "ExceptionInterface", "$", "e", ")", "{", "throw", "new", "$", "e", "(", "$", "e", "->", "getMessage", "(", ")", ".", "' at byte '", ".", "$", "this", "->", "reader", "->", "getLastPosition", "(", ")", ",", "$", "e", "->", "getCode", "(", ")", ",", "$", "e", "->", "getPrevious", "(", ")", ")", ";", "}", "}" ]
Parse geometry data @return array @throws UnexpectedValueException
[ "Parse", "geometry", "data" ]
train
https://github.com/creof/wkb-parser/blob/1ddb69da8cc90607dd528fd9992ef1fc10cc8839/lib/CrEOF/Geo/WKB/Parser.php#L144-L170
creof/wkb-parser
lib/CrEOF/Geo/WKB/Parser.php
Parser.getDimensions
private function getDimensions($type) { if ($this->is2D($type)) { return null; } if ($type & (self::WKB_FLAG_SRID | self::WKB_FLAG_M | self::WKB_FLAG_Z)) { return $type & (self::WKB_FLAG_M | self::WKB_FLAG_Z); } return $type - ($type % 1000); }
php
private function getDimensions($type) { if ($this->is2D($type)) { return null; } if ($type & (self::WKB_FLAG_SRID | self::WKB_FLAG_M | self::WKB_FLAG_Z)) { return $type & (self::WKB_FLAG_M | self::WKB_FLAG_Z); } return $type - ($type % 1000); }
[ "private", "function", "getDimensions", "(", "$", "type", ")", "{", "if", "(", "$", "this", "->", "is2D", "(", "$", "type", ")", ")", "{", "return", "null", ";", "}", "if", "(", "$", "type", "&", "(", "self", "::", "WKB_FLAG_SRID", "|", "self", "::", "WKB_FLAG_M", "|", "self", "::", "WKB_FLAG_Z", ")", ")", "{", "return", "$", "type", "&", "(", "self", "::", "WKB_FLAG_M", "|", "self", "::", "WKB_FLAG_Z", ")", ";", "}", "return", "$", "type", "-", "(", "$", "type", "%", "1000", ")", ";", "}" ]
@param int $type @return int|null
[ "@param", "int", "$type" ]
train
https://github.com/creof/wkb-parser/blob/1ddb69da8cc90607dd528fd9992ef1fc10cc8839/lib/CrEOF/Geo/WKB/Parser.php#L200-L211
creof/wkb-parser
lib/CrEOF/Geo/WKB/Parser.php
Parser.getDimensionType
private function getDimensionType($dimensions) { if ($this->is2D($dimensions)) { return null; } switch ($dimensions) { case (1000): //no break case (self::WKB_FLAG_Z): return 'Z'; case (2000): //no break case (self::WKB_FLAG_M): return 'M'; case (3000): //no break case (self::WKB_FLAG_M | self::WKB_FLAG_Z): return 'ZM'; } throw new UnexpectedValueException(sprintf('%s with unsupported dimensions 0x%2$X (%2$d)', $this->getTypeName($this->type), $dimensions)); }
php
private function getDimensionType($dimensions) { if ($this->is2D($dimensions)) { return null; } switch ($dimensions) { case (1000): //no break case (self::WKB_FLAG_Z): return 'Z'; case (2000): //no break case (self::WKB_FLAG_M): return 'M'; case (3000): //no break case (self::WKB_FLAG_M | self::WKB_FLAG_Z): return 'ZM'; } throw new UnexpectedValueException(sprintf('%s with unsupported dimensions 0x%2$X (%2$d)', $this->getTypeName($this->type), $dimensions)); }
[ "private", "function", "getDimensionType", "(", "$", "dimensions", ")", "{", "if", "(", "$", "this", "->", "is2D", "(", "$", "dimensions", ")", ")", "{", "return", "null", ";", "}", "switch", "(", "$", "dimensions", ")", "{", "case", "(", "1000", ")", ":", "//no break", "case", "(", "self", "::", "WKB_FLAG_Z", ")", ":", "return", "'Z'", ";", "case", "(", "2000", ")", ":", "//no break", "case", "(", "self", "::", "WKB_FLAG_M", ")", ":", "return", "'M'", ";", "case", "(", "3000", ")", ":", "//no break", "case", "(", "self", "::", "WKB_FLAG_M", "|", "self", "::", "WKB_FLAG_Z", ")", ":", "return", "'ZM'", ";", "}", "throw", "new", "UnexpectedValueException", "(", "sprintf", "(", "'%s with unsupported dimensions 0x%2$X (%2$d)'", ",", "$", "this", "->", "getTypeName", "(", "$", "this", "->", "type", ")", ",", "$", "dimensions", ")", ")", ";", "}" ]
@param int $dimensions @return string @throws UnexpectedValueException
[ "@param", "int", "$dimensions" ]
train
https://github.com/creof/wkb-parser/blob/1ddb69da8cc90607dd528fd9992ef1fc10cc8839/lib/CrEOF/Geo/WKB/Parser.php#L219-L241
creof/wkb-parser
lib/CrEOF/Geo/WKB/Parser.php
Parser.getDimensionedPrimitive
private function getDimensionedPrimitive($type) { if (null === $this->dimensions) { return $type; } if ($this->dimensions & (self::WKB_FLAG_Z | self::WKB_FLAG_M)) { return $type | $this->dimensions; } return $type + $this->dimensions; }
php
private function getDimensionedPrimitive($type) { if (null === $this->dimensions) { return $type; } if ($this->dimensions & (self::WKB_FLAG_Z | self::WKB_FLAG_M)) { return $type | $this->dimensions; } return $type + $this->dimensions; }
[ "private", "function", "getDimensionedPrimitive", "(", "$", "type", ")", "{", "if", "(", "null", "===", "$", "this", "->", "dimensions", ")", "{", "return", "$", "type", ";", "}", "if", "(", "$", "this", "->", "dimensions", "&", "(", "self", "::", "WKB_FLAG_Z", "|", "self", "::", "WKB_FLAG_M", ")", ")", "{", "return", "$", "type", "|", "$", "this", "->", "dimensions", ";", "}", "return", "$", "type", "+", "$", "this", "->", "dimensions", ";", "}" ]
@param int $type @return int
[ "@param", "int", "$type" ]
train
https://github.com/creof/wkb-parser/blob/1ddb69da8cc90607dd528fd9992ef1fc10cc8839/lib/CrEOF/Geo/WKB/Parser.php#L248-L259
creof/wkb-parser
lib/CrEOF/Geo/WKB/Parser.php
Parser.getTypeName
private function getTypeName($type) { switch ($this->getTypePrimitive($type)) { case (self::WKB_TYPE_POINT): $typeName = self::TYPE_POINT; break; case (self::WKB_TYPE_LINESTRING): $typeName = self::TYPE_LINESTRING; break; case (self::WKB_TYPE_POLYGON): $typeName = self::TYPE_POLYGON; break; case (self::WKB_TYPE_MULTIPOINT): $typeName = self::TYPE_MULTIPOINT; break; case (self::WKB_TYPE_MULTILINESTRING): $typeName = self::TYPE_MULTILINESTRING; break; case (self::WKB_TYPE_MULTIPOLYGON): $typeName = self::TYPE_MULTIPOLYGON; break; case (self::WKB_TYPE_GEOMETRYCOLLECTION): $typeName = self::TYPE_GEOMETRYCOLLECTION; break; case (self::WKB_TYPE_CIRCULARSTRING): $typeName = self::TYPE_CIRCULARSTRING; break; case (self::WKB_TYPE_COMPOUNDCURVE): $typeName = self::TYPE_COMPOUNDCURVE; break; case (self::WKB_TYPE_CURVEPOLYGON): $typeName = self::TYPE_CURVEPOLYGON; break; case (self::WKB_TYPE_MULTICURVE): $typeName = self::TYPE_MULTICURVE; break; case (self::WKB_TYPE_MULTISURFACE): $typeName = self::TYPE_MULTISURFACE; break; case (self::WKB_TYPE_POLYHEDRALSURFACE): $typeName = self::TYPE_POLYHEDRALSURFACE; break; default: throw new UnexpectedValueException('Unsupported WKB type "' . $this->type . '"'); } return strtoupper($typeName); }
php
private function getTypeName($type) { switch ($this->getTypePrimitive($type)) { case (self::WKB_TYPE_POINT): $typeName = self::TYPE_POINT; break; case (self::WKB_TYPE_LINESTRING): $typeName = self::TYPE_LINESTRING; break; case (self::WKB_TYPE_POLYGON): $typeName = self::TYPE_POLYGON; break; case (self::WKB_TYPE_MULTIPOINT): $typeName = self::TYPE_MULTIPOINT; break; case (self::WKB_TYPE_MULTILINESTRING): $typeName = self::TYPE_MULTILINESTRING; break; case (self::WKB_TYPE_MULTIPOLYGON): $typeName = self::TYPE_MULTIPOLYGON; break; case (self::WKB_TYPE_GEOMETRYCOLLECTION): $typeName = self::TYPE_GEOMETRYCOLLECTION; break; case (self::WKB_TYPE_CIRCULARSTRING): $typeName = self::TYPE_CIRCULARSTRING; break; case (self::WKB_TYPE_COMPOUNDCURVE): $typeName = self::TYPE_COMPOUNDCURVE; break; case (self::WKB_TYPE_CURVEPOLYGON): $typeName = self::TYPE_CURVEPOLYGON; break; case (self::WKB_TYPE_MULTICURVE): $typeName = self::TYPE_MULTICURVE; break; case (self::WKB_TYPE_MULTISURFACE): $typeName = self::TYPE_MULTISURFACE; break; case (self::WKB_TYPE_POLYHEDRALSURFACE): $typeName = self::TYPE_POLYHEDRALSURFACE; break; default: throw new UnexpectedValueException('Unsupported WKB type "' . $this->type . '"'); } return strtoupper($typeName); }
[ "private", "function", "getTypeName", "(", "$", "type", ")", "{", "switch", "(", "$", "this", "->", "getTypePrimitive", "(", "$", "type", ")", ")", "{", "case", "(", "self", "::", "WKB_TYPE_POINT", ")", ":", "$", "typeName", "=", "self", "::", "TYPE_POINT", ";", "break", ";", "case", "(", "self", "::", "WKB_TYPE_LINESTRING", ")", ":", "$", "typeName", "=", "self", "::", "TYPE_LINESTRING", ";", "break", ";", "case", "(", "self", "::", "WKB_TYPE_POLYGON", ")", ":", "$", "typeName", "=", "self", "::", "TYPE_POLYGON", ";", "break", ";", "case", "(", "self", "::", "WKB_TYPE_MULTIPOINT", ")", ":", "$", "typeName", "=", "self", "::", "TYPE_MULTIPOINT", ";", "break", ";", "case", "(", "self", "::", "WKB_TYPE_MULTILINESTRING", ")", ":", "$", "typeName", "=", "self", "::", "TYPE_MULTILINESTRING", ";", "break", ";", "case", "(", "self", "::", "WKB_TYPE_MULTIPOLYGON", ")", ":", "$", "typeName", "=", "self", "::", "TYPE_MULTIPOLYGON", ";", "break", ";", "case", "(", "self", "::", "WKB_TYPE_GEOMETRYCOLLECTION", ")", ":", "$", "typeName", "=", "self", "::", "TYPE_GEOMETRYCOLLECTION", ";", "break", ";", "case", "(", "self", "::", "WKB_TYPE_CIRCULARSTRING", ")", ":", "$", "typeName", "=", "self", "::", "TYPE_CIRCULARSTRING", ";", "break", ";", "case", "(", "self", "::", "WKB_TYPE_COMPOUNDCURVE", ")", ":", "$", "typeName", "=", "self", "::", "TYPE_COMPOUNDCURVE", ";", "break", ";", "case", "(", "self", "::", "WKB_TYPE_CURVEPOLYGON", ")", ":", "$", "typeName", "=", "self", "::", "TYPE_CURVEPOLYGON", ";", "break", ";", "case", "(", "self", "::", "WKB_TYPE_MULTICURVE", ")", ":", "$", "typeName", "=", "self", "::", "TYPE_MULTICURVE", ";", "break", ";", "case", "(", "self", "::", "WKB_TYPE_MULTISURFACE", ")", ":", "$", "typeName", "=", "self", "::", "TYPE_MULTISURFACE", ";", "break", ";", "case", "(", "self", "::", "WKB_TYPE_POLYHEDRALSURFACE", ")", ":", "$", "typeName", "=", "self", "::", "TYPE_POLYHEDRALSURFACE", ";", "break", ";", "default", ":", "throw", "new", "UnexpectedValueException", "(", "'Unsupported WKB type \"'", ".", "$", "this", "->", "type", ".", "'\"'", ")", ";", "}", "return", "strtoupper", "(", "$", "typeName", ")", ";", "}" ]
Get name of data type @param int $type @return string @throws UnexpectedValueException
[ "Get", "name", "of", "data", "type" ]
train
https://github.com/creof/wkb-parser/blob/1ddb69da8cc90607dd528fd9992ef1fc10cc8839/lib/CrEOF/Geo/WKB/Parser.php#L287-L334
creof/wkb-parser
lib/CrEOF/Geo/WKB/Parser.php
Parser.readPoints
private function readPoints($count) { $points = array(); for ($i = 0; $i < $count; $i++) { $points[] = $this->point(); } return $points; }
php
private function readPoints($count) { $points = array(); for ($i = 0; $i < $count; $i++) { $points[] = $this->point(); } return $points; }
[ "private", "function", "readPoints", "(", "$", "count", ")", "{", "$", "points", "=", "array", "(", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "count", ";", "$", "i", "++", ")", "{", "$", "points", "[", "]", "=", "$", "this", "->", "point", "(", ")", ";", "}", "return", "$", "points", ";", "}" ]
@param int $count @return array @throws UnexpectedValueException
[ "@param", "int", "$count" ]
train
https://github.com/creof/wkb-parser/blob/1ddb69da8cc90607dd528fd9992ef1fc10cc8839/lib/CrEOF/Geo/WKB/Parser.php#L381-L390