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
CSharpRU/vault-php
src/Client.php
Client.checkResponse
protected function checkResponse(ResponseInterface $response) { if ($response->getStatusCode() >= 400) { $message = sprintf( "Something went wrong when calling Vault (%s - %s)\n%s.", $response->getStatusCode(), $response->getReasonPhrase(), $response->getBody()->getContents() ); if ($response->getStatusCode() >= 500) { throw new ServerException($message, $response->getStatusCode(), $response); } throw new ClientException($message, $response->getStatusCode(), $response); } }
php
protected function checkResponse(ResponseInterface $response) { if ($response->getStatusCode() >= 400) { $message = sprintf( "Something went wrong when calling Vault (%s - %s)\n%s.", $response->getStatusCode(), $response->getReasonPhrase(), $response->getBody()->getContents() ); if ($response->getStatusCode() >= 500) { throw new ServerException($message, $response->getStatusCode(), $response); } throw new ClientException($message, $response->getStatusCode(), $response); } }
[ "protected", "function", "checkResponse", "(", "ResponseInterface", "$", "response", ")", "{", "if", "(", "$", "response", "->", "getStatusCode", "(", ")", ">=", "400", ")", "{", "$", "message", "=", "sprintf", "(", "\"Something went wrong when calling Vault (%s - %s)\\n%s.\"", ",", "$", "response", "->", "getStatusCode", "(", ")", ",", "$", "response", "->", "getReasonPhrase", "(", ")", ",", "$", "response", "->", "getBody", "(", ")", "->", "getContents", "(", ")", ")", ";", "if", "(", "$", "response", "->", "getStatusCode", "(", ")", ">=", "500", ")", "{", "throw", "new", "ServerException", "(", "$", "message", ",", "$", "response", "->", "getStatusCode", "(", ")", ",", "$", "response", ")", ";", "}", "throw", "new", "ClientException", "(", "$", "message", ",", "$", "response", "->", "getStatusCode", "(", ")", ",", "$", "response", ")", ";", "}", "}" ]
Returns true whenever request should be retried. @param ResponseInterface $response @throws \Vault\Exceptions\ClientException @throws \Vault\Exceptions\ServerException
[ "Returns", "true", "whenever", "request", "should", "be", "retried", "." ]
train
https://github.com/CSharpRU/vault-php/blob/c6f959e118b4f29e4802d017f952d774379df70c/src/Client.php#L320-L336
CSharpRU/vault-php
src/AuthenticationStrategies/AppRoleAuthenticationStrategy.php
AppRoleAuthenticationStrategy.authenticate
public function authenticate() { $response = $this->client->write( '/auth/approle/login', [ 'role_id' => $this->roleId, 'secret_id' => $this->secretId, ] ); return $response->getAuth(); }
php
public function authenticate() { $response = $this->client->write( '/auth/approle/login', [ 'role_id' => $this->roleId, 'secret_id' => $this->secretId, ] ); return $response->getAuth(); }
[ "public", "function", "authenticate", "(", ")", "{", "$", "response", "=", "$", "this", "->", "client", "->", "write", "(", "'/auth/approle/login'", ",", "[", "'role_id'", "=>", "$", "this", "->", "roleId", ",", "'secret_id'", "=>", "$", "this", "->", "secretId", ",", "]", ")", ";", "return", "$", "response", "->", "getAuth", "(", ")", ";", "}" ]
Returns auth for further interactions with Vault. @return Auth @throws \Vault\Exceptions\TransportException @throws \Vault\Exceptions\ServerException @throws \Vault\Exceptions\ClientException @throws \RuntimeException @throws \InvalidArgumentException
[ "Returns", "auth", "for", "further", "interactions", "with", "Vault", "." ]
train
https://github.com/CSharpRU/vault-php/blob/c6f959e118b4f29e4802d017f952d774379df70c/src/AuthenticationStrategies/AppRoleAuthenticationStrategy.php#L47-L58
CSharpRU/vault-php
src/Helpers/ArrayHelper.php
ArrayHelper.toArray
public static function toArray($object, $recursive = true) { $array = []; if ($object instanceof BaseObject) { return $object->toArray($recursive); } foreach ($object as $key => $value) { if ($value instanceof BaseObject) { $newValue = $value->toArray($recursive); } else { $newValue = (is_array($value) || is_object($value)) && $recursive ? self::toArray($value) : $value; } $array[$key] = $newValue; } return $array; }
php
public static function toArray($object, $recursive = true) { $array = []; if ($object instanceof BaseObject) { return $object->toArray($recursive); } foreach ($object as $key => $value) { if ($value instanceof BaseObject) { $newValue = $value->toArray($recursive); } else { $newValue = (is_array($value) || is_object($value)) && $recursive ? self::toArray($value) : $value; } $array[$key] = $newValue; } return $array; }
[ "public", "static", "function", "toArray", "(", "$", "object", ",", "$", "recursive", "=", "true", ")", "{", "$", "array", "=", "[", "]", ";", "if", "(", "$", "object", "instanceof", "BaseObject", ")", "{", "return", "$", "object", "->", "toArray", "(", "$", "recursive", ")", ";", "}", "foreach", "(", "$", "object", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "value", "instanceof", "BaseObject", ")", "{", "$", "newValue", "=", "$", "value", "->", "toArray", "(", "$", "recursive", ")", ";", "}", "else", "{", "$", "newValue", "=", "(", "is_array", "(", "$", "value", ")", "||", "is_object", "(", "$", "value", ")", ")", "&&", "$", "recursive", "?", "self", "::", "toArray", "(", "$", "value", ")", ":", "$", "value", ";", "}", "$", "array", "[", "$", "key", "]", "=", "$", "newValue", ";", "}", "return", "$", "array", ";", "}" ]
@param object|array $object @param bool|true $recursive @return array
[ "@param", "object|array", "$object", "@param", "bool|true", "$recursive" ]
train
https://github.com/CSharpRU/vault-php/blob/c6f959e118b4f29e4802d017f952d774379df70c/src/Helpers/ArrayHelper.php#L20-L39
TimeToogo/Pinq
Source/Expressions/ArrayItemExpression.php
ArrayItemExpression.update
public function update(Expression $key = null, Expression $value, $isReference) { if ($this->key === $key && $this->value === $value && $this->isReference === $isReference ) { return $this; } return new self($key, $value, $isReference); }
php
public function update(Expression $key = null, Expression $value, $isReference) { if ($this->key === $key && $this->value === $value && $this->isReference === $isReference ) { return $this; } return new self($key, $value, $isReference); }
[ "public", "function", "update", "(", "Expression", "$", "key", "=", "null", ",", "Expression", "$", "value", ",", "$", "isReference", ")", "{", "if", "(", "$", "this", "->", "key", "===", "$", "key", "&&", "$", "this", "->", "value", "===", "$", "value", "&&", "$", "this", "->", "isReference", "===", "$", "isReference", ")", "{", "return", "$", "this", ";", "}", "return", "new", "self", "(", "$", "key", ",", "$", "value", ",", "$", "isReference", ")", ";", "}" ]
@param Expression $key @param Expression $value @param boolean $isReference @return self
[ "@param", "Expression", "$key", "@param", "Expression", "$value", "@param", "boolean", "$isReference" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Expressions/ArrayItemExpression.php#L89-L99
TimeToogo/Pinq
Source/Expressions/AssignmentExpression.php
AssignmentExpression.toBinaryOperationEquivalent
public function toBinaryOperationEquivalent() { $binaryOperator = Assignment::toBinaryOperator($this->operator); if($binaryOperator === null) { return $this; } return $this->update( $this->assignTo, Assignment::EQUAL, Expression::binaryOperation( $this->assignTo, $binaryOperator, $this->assignmentValue ) ); }
php
public function toBinaryOperationEquivalent() { $binaryOperator = Assignment::toBinaryOperator($this->operator); if($binaryOperator === null) { return $this; } return $this->update( $this->assignTo, Assignment::EQUAL, Expression::binaryOperation( $this->assignTo, $binaryOperator, $this->assignmentValue ) ); }
[ "public", "function", "toBinaryOperationEquivalent", "(", ")", "{", "$", "binaryOperator", "=", "Assignment", "::", "toBinaryOperator", "(", "$", "this", "->", "operator", ")", ";", "if", "(", "$", "binaryOperator", "===", "null", ")", "{", "return", "$", "this", ";", "}", "return", "$", "this", "->", "update", "(", "$", "this", "->", "assignTo", ",", "Assignment", "::", "EQUAL", ",", "Expression", "::", "binaryOperation", "(", "$", "this", "->", "assignTo", ",", "$", "binaryOperator", ",", "$", "this", "->", "assignmentValue", ")", ")", ";", "}" ]
Converts the assignment expression with compound assignment operators to the equivalent assignment and binary operator combination <code> $variable += 5 </code> becomes <code> $variable = $variable + 5 </code> @return AssignmentExpression
[ "Converts", "the", "assignment", "expression", "with", "compound", "assignment", "operators", "to", "the", "equivalent", "assignment", "and", "binary", "operator", "combination" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Expressions/AssignmentExpression.php#L75-L92
TimeToogo/Pinq
Source/Expressions/AssignmentExpression.php
AssignmentExpression.update
public function update(Expression $assignTo, $operator, Expression $assignmentValue) { if ($this->assignTo === $assignTo && $this->operator === $operator && $this->assignmentValue === $assignmentValue ) { return $this; } return new self($assignTo, $operator, $assignmentValue); }
php
public function update(Expression $assignTo, $operator, Expression $assignmentValue) { if ($this->assignTo === $assignTo && $this->operator === $operator && $this->assignmentValue === $assignmentValue ) { return $this; } return new self($assignTo, $operator, $assignmentValue); }
[ "public", "function", "update", "(", "Expression", "$", "assignTo", ",", "$", "operator", ",", "Expression", "$", "assignmentValue", ")", "{", "if", "(", "$", "this", "->", "assignTo", "===", "$", "assignTo", "&&", "$", "this", "->", "operator", "===", "$", "operator", "&&", "$", "this", "->", "assignmentValue", "===", "$", "assignmentValue", ")", "{", "return", "$", "this", ";", "}", "return", "new", "self", "(", "$", "assignTo", ",", "$", "operator", ",", "$", "assignmentValue", ")", ";", "}" ]
@param Expression $assignTo @param string $operator @param Expression $assignmentValue @return self
[ "@param", "Expression", "$assignTo", "@param", "string", "$operator", "@param", "Expression", "$assignmentValue" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Expressions/AssignmentExpression.php#L106-L116
TimeToogo/Pinq
Source/Queries/Segments/Join.php
Join.update
public function update( Common\Join\Options $options, Functions\ConnectorProjection $joiningFunction ) { if ($this->options === $options && $joiningFunction === $this->joiningFunction) { return $this; } return new self($options, $joiningFunction); }
php
public function update( Common\Join\Options $options, Functions\ConnectorProjection $joiningFunction ) { if ($this->options === $options && $joiningFunction === $this->joiningFunction) { return $this; } return new self($options, $joiningFunction); }
[ "public", "function", "update", "(", "Common", "\\", "Join", "\\", "Options", "$", "options", ",", "Functions", "\\", "ConnectorProjection", "$", "joiningFunction", ")", "{", "if", "(", "$", "this", "->", "options", "===", "$", "options", "&&", "$", "joiningFunction", "===", "$", "this", "->", "joiningFunction", ")", "{", "return", "$", "this", ";", "}", "return", "new", "self", "(", "$", "options", ",", "$", "joiningFunction", ")", ";", "}" ]
@param Common\Join\Options $options @param Functions\ConnectorProjection $joiningFunction @return Join
[ "@param", "Common", "\\", "Join", "\\", "Options", "$options", "@param", "Functions", "\\", "ConnectorProjection", "$joiningFunction" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Queries/Segments/Join.php#L75-L84
TimeToogo/Pinq
Source/Iterators/Common/Functions.php
Functions.allowExcessiveArguments
public static function allowExcessiveArguments(callable $function) { $reflection = Reflection::fromCallable($function); if ($reflection->isUserDefined()) { return $function; } if (Reflection::isVariadic($reflection)) { return $function; } $numberOfArguments = $reflection->getNumberOfParameters(); $argumentLimiter = function () use ($function, $numberOfArguments) { return call_user_func_array($function, array_slice(func_get_args(), 0, $numberOfArguments)); }; /* * If there are default values, just use the default closure to * ensure correct default values are used for unsupplied arguments. */ if ($numberOfArguments !== $reflection->getNumberOfRequiredParameters()) { return $argumentLimiter; } /* * Micro-optimization: provide simple wrappers for internal functions * with simple signatures rather than the more costly argument array slicing. */ switch ($numberOfArguments) { case 0: return function () use ($function) { return $function(); }; case 1: return function ($a) use ($function) { return $function($a); }; case 2: return function ($a, $b) use ($function) { return $function($a, $b); }; case 3: return function ($a, $b, $c) use ($function) { return $function($a, $b, $c); }; case 4: return function ($a, $b, $c, $d) use ($function) { return $function($a, $b, $c, $d); }; default: return $argumentLimiter; } }
php
public static function allowExcessiveArguments(callable $function) { $reflection = Reflection::fromCallable($function); if ($reflection->isUserDefined()) { return $function; } if (Reflection::isVariadic($reflection)) { return $function; } $numberOfArguments = $reflection->getNumberOfParameters(); $argumentLimiter = function () use ($function, $numberOfArguments) { return call_user_func_array($function, array_slice(func_get_args(), 0, $numberOfArguments)); }; /* * If there are default values, just use the default closure to * ensure correct default values are used for unsupplied arguments. */ if ($numberOfArguments !== $reflection->getNumberOfRequiredParameters()) { return $argumentLimiter; } /* * Micro-optimization: provide simple wrappers for internal functions * with simple signatures rather than the more costly argument array slicing. */ switch ($numberOfArguments) { case 0: return function () use ($function) { return $function(); }; case 1: return function ($a) use ($function) { return $function($a); }; case 2: return function ($a, $b) use ($function) { return $function($a, $b); }; case 3: return function ($a, $b, $c) use ($function) { return $function($a, $b, $c); }; case 4: return function ($a, $b, $c, $d) use ($function) { return $function($a, $b, $c, $d); }; default: return $argumentLimiter; } }
[ "public", "static", "function", "allowExcessiveArguments", "(", "callable", "$", "function", ")", "{", "$", "reflection", "=", "Reflection", "::", "fromCallable", "(", "$", "function", ")", ";", "if", "(", "$", "reflection", "->", "isUserDefined", "(", ")", ")", "{", "return", "$", "function", ";", "}", "if", "(", "Reflection", "::", "isVariadic", "(", "$", "reflection", ")", ")", "{", "return", "$", "function", ";", "}", "$", "numberOfArguments", "=", "$", "reflection", "->", "getNumberOfParameters", "(", ")", ";", "$", "argumentLimiter", "=", "function", "(", ")", "use", "(", "$", "function", ",", "$", "numberOfArguments", ")", "{", "return", "call_user_func_array", "(", "$", "function", ",", "array_slice", "(", "func_get_args", "(", ")", ",", "0", ",", "$", "numberOfArguments", ")", ")", ";", "}", ";", "/*\n * If there are default values, just use the default closure to\n * ensure correct default values are used for unsupplied arguments.\n */", "if", "(", "$", "numberOfArguments", "!==", "$", "reflection", "->", "getNumberOfRequiredParameters", "(", ")", ")", "{", "return", "$", "argumentLimiter", ";", "}", "/*\n * Micro-optimization: provide simple wrappers for internal functions\n * with simple signatures rather than the more costly argument array slicing.\n */", "switch", "(", "$", "numberOfArguments", ")", "{", "case", "0", ":", "return", "function", "(", ")", "use", "(", "$", "function", ")", "{", "return", "$", "function", "(", ")", ";", "}", ";", "case", "1", ":", "return", "function", "(", "$", "a", ")", "use", "(", "$", "function", ")", "{", "return", "$", "function", "(", "$", "a", ")", ";", "}", ";", "case", "2", ":", "return", "function", "(", "$", "a", ",", "$", "b", ")", "use", "(", "$", "function", ")", "{", "return", "$", "function", "(", "$", "a", ",", "$", "b", ")", ";", "}", ";", "case", "3", ":", "return", "function", "(", "$", "a", ",", "$", "b", ",", "$", "c", ")", "use", "(", "$", "function", ")", "{", "return", "$", "function", "(", "$", "a", ",", "$", "b", ",", "$", "c", ")", ";", "}", ";", "case", "4", ":", "return", "function", "(", "$", "a", ",", "$", "b", ",", "$", "c", ",", "$", "d", ")", "use", "(", "$", "function", ")", "{", "return", "$", "function", "(", "$", "a", ",", "$", "b", ",", "$", "c", ",", "$", "d", ")", ";", "}", ";", "default", ":", "return", "$", "argumentLimiter", ";", "}", "}" ]
Returns a wrapper function that will allow the function to be called with excessive number of arguments, this is useful for internal function support. Note that references will not be maintained. @param callable $function @return callable
[ "Returns", "a", "wrapper", "function", "that", "will", "allow", "the", "function", "to", "be", "called", "with", "excessive", "number", "of", "arguments", "this", "is", "useful", "for", "internal", "function", "support", ".", "Note", "that", "references", "will", "not", "be", "maintained", "." ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Iterators/Common/Functions.php#L28-L86
TimeToogo/Pinq
Source/Parsing/PhpParser/Parser.php
Parser.getMatchingFunctionNode
private function getMatchingFunctionNode(array $locatedFunctionNodes, IFunctionReflection $reflection) { $locationHash = $reflection->getLocation()->getHash(); if (empty($locatedFunctionNodes[$locationHash])) { throw InvalidFunctionException::invalidFunctionMessage( 'Cannot parse function, the function could not be located', $reflection->getInnerReflection() ); } // If multiple functions defined on a single line we // perform all possible resolution to resolve the conflict. // Magic constants / scopes are resolved in parameter expressions // to allow matching of functions with these special constants in // default values. /** @var $matchedFunctionsByLocation LocatedFunctionNode[] */ $matchedFunctionsByLocation = $locatedFunctionNodes[$locationHash]; $functionSignature = $reflection->getSignature(); $fullyMatchedFunctions = []; foreach ($matchedFunctionsByLocation as $matchedFunction) { $magicData = $reflection->resolveMagic($matchedFunction->getDeclaration()); $resolvedMatchedFunctionSignature = $matchedFunction->getSignature()->resolveMagic($magicData); if ($functionSignature->getHash() === $resolvedMatchedFunctionSignature->getHash()) { $fullyMatchedFunctions[] = $matchedFunction; } } if (empty($fullyMatchedFunctions)) { throw InvalidFunctionException::invalidFunctionMessage( 'Cannot parse function, the function\'s signature could not be matched', $reflection->getInnerReflection() ); } elseif (count($fullyMatchedFunctions) > 1) { throw InvalidFunctionException::invalidFunctionMessage( 'Cannot parse function, %d ambiguous functions are defined on the same line ' . 'with identical signatures', $reflection->getInnerReflection(), count($locatedFunctionNodes[$locationHash]) ); } return $fullyMatchedFunctions[0]; }
php
private function getMatchingFunctionNode(array $locatedFunctionNodes, IFunctionReflection $reflection) { $locationHash = $reflection->getLocation()->getHash(); if (empty($locatedFunctionNodes[$locationHash])) { throw InvalidFunctionException::invalidFunctionMessage( 'Cannot parse function, the function could not be located', $reflection->getInnerReflection() ); } // If multiple functions defined on a single line we // perform all possible resolution to resolve the conflict. // Magic constants / scopes are resolved in parameter expressions // to allow matching of functions with these special constants in // default values. /** @var $matchedFunctionsByLocation LocatedFunctionNode[] */ $matchedFunctionsByLocation = $locatedFunctionNodes[$locationHash]; $functionSignature = $reflection->getSignature(); $fullyMatchedFunctions = []; foreach ($matchedFunctionsByLocation as $matchedFunction) { $magicData = $reflection->resolveMagic($matchedFunction->getDeclaration()); $resolvedMatchedFunctionSignature = $matchedFunction->getSignature()->resolveMagic($magicData); if ($functionSignature->getHash() === $resolvedMatchedFunctionSignature->getHash()) { $fullyMatchedFunctions[] = $matchedFunction; } } if (empty($fullyMatchedFunctions)) { throw InvalidFunctionException::invalidFunctionMessage( 'Cannot parse function, the function\'s signature could not be matched', $reflection->getInnerReflection() ); } elseif (count($fullyMatchedFunctions) > 1) { throw InvalidFunctionException::invalidFunctionMessage( 'Cannot parse function, %d ambiguous functions are defined on the same line ' . 'with identical signatures', $reflection->getInnerReflection(), count($locatedFunctionNodes[$locationHash]) ); } return $fullyMatchedFunctions[0]; }
[ "private", "function", "getMatchingFunctionNode", "(", "array", "$", "locatedFunctionNodes", ",", "IFunctionReflection", "$", "reflection", ")", "{", "$", "locationHash", "=", "$", "reflection", "->", "getLocation", "(", ")", "->", "getHash", "(", ")", ";", "if", "(", "empty", "(", "$", "locatedFunctionNodes", "[", "$", "locationHash", "]", ")", ")", "{", "throw", "InvalidFunctionException", "::", "invalidFunctionMessage", "(", "'Cannot parse function, the function could not be located'", ",", "$", "reflection", "->", "getInnerReflection", "(", ")", ")", ";", "}", "// If multiple functions defined on a single line we", "// perform all possible resolution to resolve the conflict.", "// Magic constants / scopes are resolved in parameter expressions", "// to allow matching of functions with these special constants in", "// default values.", "/** @var $matchedFunctionsByLocation LocatedFunctionNode[] */", "$", "matchedFunctionsByLocation", "=", "$", "locatedFunctionNodes", "[", "$", "locationHash", "]", ";", "$", "functionSignature", "=", "$", "reflection", "->", "getSignature", "(", ")", ";", "$", "fullyMatchedFunctions", "=", "[", "]", ";", "foreach", "(", "$", "matchedFunctionsByLocation", "as", "$", "matchedFunction", ")", "{", "$", "magicData", "=", "$", "reflection", "->", "resolveMagic", "(", "$", "matchedFunction", "->", "getDeclaration", "(", ")", ")", ";", "$", "resolvedMatchedFunctionSignature", "=", "$", "matchedFunction", "->", "getSignature", "(", ")", "->", "resolveMagic", "(", "$", "magicData", ")", ";", "if", "(", "$", "functionSignature", "->", "getHash", "(", ")", "===", "$", "resolvedMatchedFunctionSignature", "->", "getHash", "(", ")", ")", "{", "$", "fullyMatchedFunctions", "[", "]", "=", "$", "matchedFunction", ";", "}", "}", "if", "(", "empty", "(", "$", "fullyMatchedFunctions", ")", ")", "{", "throw", "InvalidFunctionException", "::", "invalidFunctionMessage", "(", "'Cannot parse function, the function\\'s signature could not be matched'", ",", "$", "reflection", "->", "getInnerReflection", "(", ")", ")", ";", "}", "elseif", "(", "count", "(", "$", "fullyMatchedFunctions", ")", ">", "1", ")", "{", "throw", "InvalidFunctionException", "::", "invalidFunctionMessage", "(", "'Cannot parse function, %d ambiguous functions are defined on the same line '", ".", "'with identical signatures'", ",", "$", "reflection", "->", "getInnerReflection", "(", ")", ",", "count", "(", "$", "locatedFunctionNodes", "[", "$", "locationHash", "]", ")", ")", ";", "}", "return", "$", "fullyMatchedFunctions", "[", "0", "]", ";", "}" ]
@param array <array<LocatedFunctionNode>> $locatedFunctionNodes @param IFunctionReflection $reflection @throws InvalidFunctionException @return LocatedFunctionNode
[ "@param", "array", "<array<LocatedFunctionNode", ">>", "$locatedFunctionNodes", "@param", "IFunctionReflection", "$reflection" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Parsing/PhpParser/Parser.php#L89-L134
TimeToogo/Pinq
Source/Iterators/Common/Identity.php
Identity.hash
public static function hash($value) { $typeIdentifier = gettype($value)[0]; switch ($typeIdentifier) { case 's': //string return 's' . (strlen($value) > 32 ? md5($value) : $value); case 'i': //integer case 'b': //boolean case 'd': //double case 'r': //resource case 'u': //unknown type return $typeIdentifier . $value; case 'N': //NULL return 'N'; case 'o': //object return 'o' . spl_object_hash($value); case 'a': //array return self::arrayHash($value); } }
php
public static function hash($value) { $typeIdentifier = gettype($value)[0]; switch ($typeIdentifier) { case 's': //string return 's' . (strlen($value) > 32 ? md5($value) : $value); case 'i': //integer case 'b': //boolean case 'd': //double case 'r': //resource case 'u': //unknown type return $typeIdentifier . $value; case 'N': //NULL return 'N'; case 'o': //object return 'o' . spl_object_hash($value); case 'a': //array return self::arrayHash($value); } }
[ "public", "static", "function", "hash", "(", "$", "value", ")", "{", "$", "typeIdentifier", "=", "gettype", "(", "$", "value", ")", "[", "0", "]", ";", "switch", "(", "$", "typeIdentifier", ")", "{", "case", "'s'", ":", "//string", "return", "'s'", ".", "(", "strlen", "(", "$", "value", ")", ">", "32", "?", "md5", "(", "$", "value", ")", ":", "$", "value", ")", ";", "case", "'i'", ":", "//integer", "case", "'b'", ":", "//boolean", "case", "'d'", ":", "//double", "case", "'r'", ":", "//resource", "case", "'u'", ":", "//unknown type", "return", "$", "typeIdentifier", ".", "$", "value", ";", "case", "'N'", ":", "//NULL", "return", "'N'", ";", "case", "'o'", ":", "//object", "return", "'o'", ".", "spl_object_hash", "(", "$", "value", ")", ";", "case", "'a'", ":", "//array", "return", "self", "::", "arrayHash", "(", "$", "value", ")", ";", "}", "}" ]
Returns a string representing the supplied value's identity. @param mixed $value @return string
[ "Returns", "a", "string", "representing", "the", "supplied", "value", "s", "identity", "." ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Iterators/Common/Identity.php#L24-L54
TimeToogo/Pinq
Source/Providers/DSL/Compilation/Processors/Expression/ExpressionProcessor.php
ExpressionProcessor.processFunction
public function processFunction(IFunction $function) { return $function->update( $function->getScopeType(), $function->getNamespace(), $function->getParameterScopedVariableMap(), $this->walkAll($function->getParameters()->getAll()), $this->walkAll($function->getBodyExpressions()) ); }
php
public function processFunction(IFunction $function) { return $function->update( $function->getScopeType(), $function->getNamespace(), $function->getParameterScopedVariableMap(), $this->walkAll($function->getParameters()->getAll()), $this->walkAll($function->getBodyExpressions()) ); }
[ "public", "function", "processFunction", "(", "IFunction", "$", "function", ")", "{", "return", "$", "function", "->", "update", "(", "$", "function", "->", "getScopeType", "(", ")", ",", "$", "function", "->", "getNamespace", "(", ")", ",", "$", "function", "->", "getParameterScopedVariableMap", "(", ")", ",", "$", "this", "->", "walkAll", "(", "$", "function", "->", "getParameters", "(", ")", "->", "getAll", "(", ")", ")", ",", "$", "this", "->", "walkAll", "(", "$", "function", "->", "getBodyExpressions", "(", ")", ")", ")", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Providers/DSL/Compilation/Processors/Expression/ExpressionProcessor.php#L19-L28
TimeToogo/Pinq
Source/Expressions/Operators/Assignment.php
Assignment.toBinaryOperator
public static function toBinaryOperator($assignment) { return isset(self::$toBinaryOperatorMap[$assignment]) ? self::$toBinaryOperatorMap[$assignment] : null; }
php
public static function toBinaryOperator($assignment) { return isset(self::$toBinaryOperatorMap[$assignment]) ? self::$toBinaryOperatorMap[$assignment] : null; }
[ "public", "static", "function", "toBinaryOperator", "(", "$", "assignment", ")", "{", "return", "isset", "(", "self", "::", "$", "toBinaryOperatorMap", "[", "$", "assignment", "]", ")", "?", "self", "::", "$", "toBinaryOperatorMap", "[", "$", "assignment", "]", ":", "null", ";", "}" ]
Returns the equivalent binary operator of the supplied assignment operator or null if there is no equivalent. @param string $assignment @return string|null
[ "Returns", "the", "equivalent", "binary", "operator", "of", "the", "supplied", "assignment", "operator", "or", "null", "if", "there", "is", "no", "equivalent", "." ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Expressions/Operators/Assignment.php#L57-L60
TimeToogo/Pinq
Source/Expressions/Operators/Assignment.php
Assignment.doAssignment
public static function doAssignment(&$left, $operator, $right) { if (self::$assignments === null) { self::$assignments = [ self::EQUAL => function (&$l, $r) { return $l = $r; }, self::CONCATENATE => function (&$l, $r) { return $l .= $r; }, self::BITWISE_AND => function (&$l, $r) { return $l &= $r; }, self::BITWISE_OR => function (&$l, $r) { return $l |= $r; }, self::BITWISE_XOR => function (&$l, $r) { return $l ^= $r; }, self::SHIFT_LEFT => function (&$l, $r) { return $l <<= $r; }, self::SHIFT_RIGHT => function (&$l, $r) { return $l >>= $r; }, self::ADDITION => function (&$l, $r) { return $l += $r; }, self::SUBTRACTION => function (&$l, $r) { return $l -= $r; }, self::MULTIPLICATION => function (&$l, $r) { return $l *= $r; }, self::DIVISION => function (&$l, $r) { return $l /= $r; }, self::MODULUS => function (&$l, $r) { return $l %= $r; }, //Compatible with < PHP 5.6 self::POWER => function (&$l, $r) { return $l = pow($l, $r); }, ]; } if (!isset(self::$assignments[$operator])) { throw new PinqException('Assignment operator \'%s\' is not supported', $operator); } $assignment = self::$assignments[$operator]; return $assignment($left, $right); }
php
public static function doAssignment(&$left, $operator, $right) { if (self::$assignments === null) { self::$assignments = [ self::EQUAL => function (&$l, $r) { return $l = $r; }, self::CONCATENATE => function (&$l, $r) { return $l .= $r; }, self::BITWISE_AND => function (&$l, $r) { return $l &= $r; }, self::BITWISE_OR => function (&$l, $r) { return $l |= $r; }, self::BITWISE_XOR => function (&$l, $r) { return $l ^= $r; }, self::SHIFT_LEFT => function (&$l, $r) { return $l <<= $r; }, self::SHIFT_RIGHT => function (&$l, $r) { return $l >>= $r; }, self::ADDITION => function (&$l, $r) { return $l += $r; }, self::SUBTRACTION => function (&$l, $r) { return $l -= $r; }, self::MULTIPLICATION => function (&$l, $r) { return $l *= $r; }, self::DIVISION => function (&$l, $r) { return $l /= $r; }, self::MODULUS => function (&$l, $r) { return $l %= $r; }, //Compatible with < PHP 5.6 self::POWER => function (&$l, $r) { return $l = pow($l, $r); }, ]; } if (!isset(self::$assignments[$operator])) { throw new PinqException('Assignment operator \'%s\' is not supported', $operator); } $assignment = self::$assignments[$operator]; return $assignment($left, $right); }
[ "public", "static", "function", "doAssignment", "(", "&", "$", "left", ",", "$", "operator", ",", "$", "right", ")", "{", "if", "(", "self", "::", "$", "assignments", "===", "null", ")", "{", "self", "::", "$", "assignments", "=", "[", "self", "::", "EQUAL", "=>", "function", "(", "&", "$", "l", ",", "$", "r", ")", "{", "return", "$", "l", "=", "$", "r", ";", "}", ",", "self", "::", "CONCATENATE", "=>", "function", "(", "&", "$", "l", ",", "$", "r", ")", "{", "return", "$", "l", ".=", "$", "r", ";", "}", ",", "self", "::", "BITWISE_AND", "=>", "function", "(", "&", "$", "l", ",", "$", "r", ")", "{", "return", "$", "l", "&=", "$", "r", ";", "}", ",", "self", "::", "BITWISE_OR", "=>", "function", "(", "&", "$", "l", ",", "$", "r", ")", "{", "return", "$", "l", "|=", "$", "r", ";", "}", ",", "self", "::", "BITWISE_XOR", "=>", "function", "(", "&", "$", "l", ",", "$", "r", ")", "{", "return", "$", "l", "^=", "$", "r", ";", "}", ",", "self", "::", "SHIFT_LEFT", "=>", "function", "(", "&", "$", "l", ",", "$", "r", ")", "{", "return", "$", "l", "<<=", "$", "r", ";", "}", ",", "self", "::", "SHIFT_RIGHT", "=>", "function", "(", "&", "$", "l", ",", "$", "r", ")", "{", "return", "$", "l", ">>=", "$", "r", ";", "}", ",", "self", "::", "ADDITION", "=>", "function", "(", "&", "$", "l", ",", "$", "r", ")", "{", "return", "$", "l", "+=", "$", "r", ";", "}", ",", "self", "::", "SUBTRACTION", "=>", "function", "(", "&", "$", "l", ",", "$", "r", ")", "{", "return", "$", "l", "-=", "$", "r", ";", "}", ",", "self", "::", "MULTIPLICATION", "=>", "function", "(", "&", "$", "l", ",", "$", "r", ")", "{", "return", "$", "l", "*=", "$", "r", ";", "}", ",", "self", "::", "DIVISION", "=>", "function", "(", "&", "$", "l", ",", "$", "r", ")", "{", "return", "$", "l", "/=", "$", "r", ";", "}", ",", "self", "::", "MODULUS", "=>", "function", "(", "&", "$", "l", ",", "$", "r", ")", "{", "return", "$", "l", "%=", "$", "r", ";", "}", ",", "//Compatible with < PHP 5.6", "self", "::", "POWER", "=>", "function", "(", "&", "$", "l", ",", "$", "r", ")", "{", "return", "$", "l", "=", "pow", "(", "$", "l", ",", "$", "r", ")", ";", "}", ",", "]", ";", "}", "if", "(", "!", "isset", "(", "self", "::", "$", "assignments", "[", "$", "operator", "]", ")", ")", "{", "throw", "new", "PinqException", "(", "'Assignment operator \\'%s\\' is not supported'", ",", "$", "operator", ")", ";", "}", "$", "assignment", "=", "self", "::", "$", "assignments", "[", "$", "operator", "]", ";", "return", "$", "assignment", "(", "$", "left", ",", "$", "right", ")", ";", "}" ]
Performs the assignment operation on the supplied values. @param mixed $left @param string $operator @param mixed $right @return mixed @throws PinqException
[ "Performs", "the", "assignment", "operation", "on", "the", "supplied", "values", "." ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Expressions/Operators/Assignment.php#L74-L102
TimeToogo/Pinq
Source/Queries/Requests/ProjectionRequestBase.php
ProjectionRequestBase.updateProjection
public function updateProjection(Functions\ElementProjection $projectionFunction = null) { if ($this->projectionFunction === $projectionFunction) { return $this; } return $this->withProjectionFunction($projectionFunction); }
php
public function updateProjection(Functions\ElementProjection $projectionFunction = null) { if ($this->projectionFunction === $projectionFunction) { return $this; } return $this->withProjectionFunction($projectionFunction); }
[ "public", "function", "updateProjection", "(", "Functions", "\\", "ElementProjection", "$", "projectionFunction", "=", "null", ")", "{", "if", "(", "$", "this", "->", "projectionFunction", "===", "$", "projectionFunction", ")", "{", "return", "$", "this", ";", "}", "return", "$", "this", "->", "withProjectionFunction", "(", "$", "projectionFunction", ")", ";", "}" ]
@param Functions\ElementProjection $projectionFunction @return static
[ "@param", "Functions", "\\", "ElementProjection", "$projectionFunction" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Queries/Requests/ProjectionRequestBase.php#L51-L58
TimeToogo/Pinq
Source/Iterators/Common/Set.php
Set.contains
public function contains($value) { return $value === null ? array_key_exists(Identity::hash(null), $this->values) : isset($this->values[Identity::hash($value)]); }
php
public function contains($value) { return $value === null ? array_key_exists(Identity::hash(null), $this->values) : isset($this->values[Identity::hash($value)]); }
[ "public", "function", "contains", "(", "$", "value", ")", "{", "return", "$", "value", "===", "null", "?", "array_key_exists", "(", "Identity", "::", "hash", "(", "null", ")", ",", "$", "this", "->", "values", ")", ":", "isset", "(", "$", "this", "->", "values", "[", "Identity", "::", "hash", "(", "$", "value", ")", "]", ")", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Iterators/Common/Set.php#L43-L46
TimeToogo/Pinq
Source/Iterators/Common/Set.php
Set.addRef
public function addRef(&$value) { $identityHash = Identity::hash($value); if (isset($this->values[$identityHash]) || array_key_exists($identityHash, $this->values)) { return false; } $this->values[$identityHash] =& $value; $this->length++; return true; }
php
public function addRef(&$value) { $identityHash = Identity::hash($value); if (isset($this->values[$identityHash]) || array_key_exists($identityHash, $this->values)) { return false; } $this->values[$identityHash] =& $value; $this->length++; return true; }
[ "public", "function", "addRef", "(", "&", "$", "value", ")", "{", "$", "identityHash", "=", "Identity", "::", "hash", "(", "$", "value", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "values", "[", "$", "identityHash", "]", ")", "||", "array_key_exists", "(", "$", "identityHash", ",", "$", "this", "->", "values", ")", ")", "{", "return", "false", ";", "}", "$", "this", "->", "values", "[", "$", "identityHash", "]", "=", "&", "$", "value", ";", "$", "this", "->", "length", "++", ";", "return", "true", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Iterators/Common/Set.php#L59-L71
TimeToogo/Pinq
Source/Parsing/FunctionSignature.php
FunctionSignature.fromReflection
public static function fromReflection(\ReflectionFunctionAbstract $reflection) { $returnsReference = $reflection->returnsReference(); $name = $reflection->getShortName(); $parameterExpressions = self::getParameterExpressionsFromReflection($reflection); if ($reflection->isClosure()) { return self::closure( $returnsReference, $parameterExpressions, array_keys($reflection->getStaticVariables()) ); } elseif ($reflection instanceof \ReflectionMethod) { if ($reflection->isPublic()) { $accessModifier = self::ACCESS_PUBLIC; } elseif ($reflection->isProtected()) { $accessModifier = self::ACCESS_PROTECTED; } else { $accessModifier = self::ACCESS_PRIVATE; } if ($reflection->isAbstract()) { $polymorphModifier = self::POLYMORPH_ABSTRACT; } elseif ($reflection->isFinal()) { $polymorphModifier = self::POLYMORPH_FINAL; } else { $polymorphModifier = null; } return self::method( $returnsReference, $accessModifier, $polymorphModifier, $reflection->isStatic(), $name, $parameterExpressions ); } else { return self::func( $returnsReference, $name, $parameterExpressions ); } }
php
public static function fromReflection(\ReflectionFunctionAbstract $reflection) { $returnsReference = $reflection->returnsReference(); $name = $reflection->getShortName(); $parameterExpressions = self::getParameterExpressionsFromReflection($reflection); if ($reflection->isClosure()) { return self::closure( $returnsReference, $parameterExpressions, array_keys($reflection->getStaticVariables()) ); } elseif ($reflection instanceof \ReflectionMethod) { if ($reflection->isPublic()) { $accessModifier = self::ACCESS_PUBLIC; } elseif ($reflection->isProtected()) { $accessModifier = self::ACCESS_PROTECTED; } else { $accessModifier = self::ACCESS_PRIVATE; } if ($reflection->isAbstract()) { $polymorphModifier = self::POLYMORPH_ABSTRACT; } elseif ($reflection->isFinal()) { $polymorphModifier = self::POLYMORPH_FINAL; } else { $polymorphModifier = null; } return self::method( $returnsReference, $accessModifier, $polymorphModifier, $reflection->isStatic(), $name, $parameterExpressions ); } else { return self::func( $returnsReference, $name, $parameterExpressions ); } }
[ "public", "static", "function", "fromReflection", "(", "\\", "ReflectionFunctionAbstract", "$", "reflection", ")", "{", "$", "returnsReference", "=", "$", "reflection", "->", "returnsReference", "(", ")", ";", "$", "name", "=", "$", "reflection", "->", "getShortName", "(", ")", ";", "$", "parameterExpressions", "=", "self", "::", "getParameterExpressionsFromReflection", "(", "$", "reflection", ")", ";", "if", "(", "$", "reflection", "->", "isClosure", "(", ")", ")", "{", "return", "self", "::", "closure", "(", "$", "returnsReference", ",", "$", "parameterExpressions", ",", "array_keys", "(", "$", "reflection", "->", "getStaticVariables", "(", ")", ")", ")", ";", "}", "elseif", "(", "$", "reflection", "instanceof", "\\", "ReflectionMethod", ")", "{", "if", "(", "$", "reflection", "->", "isPublic", "(", ")", ")", "{", "$", "accessModifier", "=", "self", "::", "ACCESS_PUBLIC", ";", "}", "elseif", "(", "$", "reflection", "->", "isProtected", "(", ")", ")", "{", "$", "accessModifier", "=", "self", "::", "ACCESS_PROTECTED", ";", "}", "else", "{", "$", "accessModifier", "=", "self", "::", "ACCESS_PRIVATE", ";", "}", "if", "(", "$", "reflection", "->", "isAbstract", "(", ")", ")", "{", "$", "polymorphModifier", "=", "self", "::", "POLYMORPH_ABSTRACT", ";", "}", "elseif", "(", "$", "reflection", "->", "isFinal", "(", ")", ")", "{", "$", "polymorphModifier", "=", "self", "::", "POLYMORPH_FINAL", ";", "}", "else", "{", "$", "polymorphModifier", "=", "null", ";", "}", "return", "self", "::", "method", "(", "$", "returnsReference", ",", "$", "accessModifier", ",", "$", "polymorphModifier", ",", "$", "reflection", "->", "isStatic", "(", ")", ",", "$", "name", ",", "$", "parameterExpressions", ")", ";", "}", "else", "{", "return", "self", "::", "func", "(", "$", "returnsReference", ",", "$", "name", ",", "$", "parameterExpressions", ")", ";", "}", "}" ]
Creates a function signature instance from the supplied reflection. @param \ReflectionFunctionAbstract $reflection @return self
[ "Creates", "a", "function", "signature", "instance", "from", "the", "supplied", "reflection", "." ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Parsing/FunctionSignature.php#L115-L159
TimeToogo/Pinq
Source/Parsing/FunctionSignature.php
FunctionSignature.func
public static function func( $returnsReference, $name, array $parameterExpressions ) { return new self( self::TYPE_FUNCTION, $returnsReference, null, null, null, $name, $parameterExpressions, null); }
php
public static function func( $returnsReference, $name, array $parameterExpressions ) { return new self( self::TYPE_FUNCTION, $returnsReference, null, null, null, $name, $parameterExpressions, null); }
[ "public", "static", "function", "func", "(", "$", "returnsReference", ",", "$", "name", ",", "array", "$", "parameterExpressions", ")", "{", "return", "new", "self", "(", "self", "::", "TYPE_FUNCTION", ",", "$", "returnsReference", ",", "null", ",", "null", ",", "null", ",", "$", "name", ",", "$", "parameterExpressions", ",", "null", ")", ";", "}" ]
Creates a function signature with the supplied parameters. @param boolean $returnsReference @param string $name @param O\ParameterExpression[] $parameterExpressions @return self
[ "Creates", "a", "function", "signature", "with", "the", "supplied", "parameters", "." ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Parsing/FunctionSignature.php#L170-L184
TimeToogo/Pinq
Source/Parsing/FunctionSignature.php
FunctionSignature.closure
public static function closure( $returnsReference, array $parameterExpressions, array $scopedVariableNames ) { return new self( self::TYPE_CLOSURE, $returnsReference, null, null, null, null, $parameterExpressions, $scopedVariableNames); }
php
public static function closure( $returnsReference, array $parameterExpressions, array $scopedVariableNames ) { return new self( self::TYPE_CLOSURE, $returnsReference, null, null, null, null, $parameterExpressions, $scopedVariableNames); }
[ "public", "static", "function", "closure", "(", "$", "returnsReference", ",", "array", "$", "parameterExpressions", ",", "array", "$", "scopedVariableNames", ")", "{", "return", "new", "self", "(", "self", "::", "TYPE_CLOSURE", ",", "$", "returnsReference", ",", "null", ",", "null", ",", "null", ",", "null", ",", "$", "parameterExpressions", ",", "$", "scopedVariableNames", ")", ";", "}" ]
Creates a closure signature with the supplied parameters. @param boolean $returnsReference @param O\ParameterExpression[] $parameterExpressions @param string[] $scopedVariableNames @return self
[ "Creates", "a", "closure", "signature", "with", "the", "supplied", "parameters", "." ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Parsing/FunctionSignature.php#L195-L209
TimeToogo/Pinq
Source/Parsing/FunctionSignature.php
FunctionSignature.method
public static function method( $returnsReference, $accessModifier, $polymorphModifier, $isStatic, $name, array $parameterExpressions ) { return new self( self::TYPE_METHOD, $returnsReference, $accessModifier, $polymorphModifier, $isStatic, $name, $parameterExpressions, null); }
php
public static function method( $returnsReference, $accessModifier, $polymorphModifier, $isStatic, $name, array $parameterExpressions ) { return new self( self::TYPE_METHOD, $returnsReference, $accessModifier, $polymorphModifier, $isStatic, $name, $parameterExpressions, null); }
[ "public", "static", "function", "method", "(", "$", "returnsReference", ",", "$", "accessModifier", ",", "$", "polymorphModifier", ",", "$", "isStatic", ",", "$", "name", ",", "array", "$", "parameterExpressions", ")", "{", "return", "new", "self", "(", "self", "::", "TYPE_METHOD", ",", "$", "returnsReference", ",", "$", "accessModifier", ",", "$", "polymorphModifier", ",", "$", "isStatic", ",", "$", "name", ",", "$", "parameterExpressions", ",", "null", ")", ";", "}" ]
Creates a method signature with the supplied parameters. @param boolean $returnsReference @param int|null $accessModifier @param int|null $polymorphModifier @param boolean $isStatic @param string $name @param O\ParameterExpression[] $parameterExpressions @return self
[ "Creates", "a", "method", "signature", "with", "the", "supplied", "parameters", "." ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Parsing/FunctionSignature.php#L223-L240
TimeToogo/Pinq
Source/Expressions/Expression.php
Expression.simplifyAll
final public static function simplifyAll( array $expressions, IEvaluationContext $context = null ) { $simplifiedExpressions = []; foreach ($expressions as $expression) { $simplifiedExpressions[] = $expression->simplify($context); } return $simplifiedExpressions; }
php
final public static function simplifyAll( array $expressions, IEvaluationContext $context = null ) { $simplifiedExpressions = []; foreach ($expressions as $expression) { $simplifiedExpressions[] = $expression->simplify($context); } return $simplifiedExpressions; }
[ "final", "public", "static", "function", "simplifyAll", "(", "array", "$", "expressions", ",", "IEvaluationContext", "$", "context", "=", "null", ")", "{", "$", "simplifiedExpressions", "=", "[", "]", ";", "foreach", "(", "$", "expressions", "as", "$", "expression", ")", "{", "$", "simplifiedExpressions", "[", "]", "=", "$", "expression", "->", "simplify", "(", "$", "context", ")", ";", "}", "return", "$", "simplifiedExpressions", ";", "}" ]
@param Expression[] $expressions @param IEvaluationContext $context @return Expression[]
[ "@param", "Expression", "[]", "$expressions", "@param", "IEvaluationContext", "$context" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Expressions/Expression.php#L46-L56
TimeToogo/Pinq
Source/Expressions/Expression.php
Expression.verifyAll
final protected static function verifyAll(array $expressions, $type = __CLASS__) { foreach ($expressions as $key => $expression) { if (!($expression instanceof $type)) { throw new PinqException( 'Invalid array of expressions: invalid expression of type %s at index %s, expecting %s', Utilities::getTypeOrClass($expression), $key, $type); } } return $expressions; }
php
final protected static function verifyAll(array $expressions, $type = __CLASS__) { foreach ($expressions as $key => $expression) { if (!($expression instanceof $type)) { throw new PinqException( 'Invalid array of expressions: invalid expression of type %s at index %s, expecting %s', Utilities::getTypeOrClass($expression), $key, $type); } } return $expressions; }
[ "final", "protected", "static", "function", "verifyAll", "(", "array", "$", "expressions", ",", "$", "type", "=", "__CLASS__", ")", "{", "foreach", "(", "$", "expressions", "as", "$", "key", "=>", "$", "expression", ")", "{", "if", "(", "!", "(", "$", "expression", "instanceof", "$", "type", ")", ")", "{", "throw", "new", "PinqException", "(", "'Invalid array of expressions: invalid expression of type %s at index %s, expecting %s'", ",", "Utilities", "::", "getTypeOrClass", "(", "$", "expression", ")", ",", "$", "key", ",", "$", "type", ")", ";", "}", "}", "return", "$", "expressions", ";", "}" ]
Verifies the supplied array only contains expressions of the supplied type. @param mixed[] $expressions @param string $type @return Expression[] @throws PinqException If the array contains invalid expressions.
[ "Verifies", "the", "supplied", "array", "only", "contains", "expressions", "of", "the", "supplied", "type", "." ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Expressions/Expression.php#L84-L97
TimeToogo/Pinq
Source/Expressions/Expression.php
Expression.asEvaluator
public function asEvaluator(IEvaluationContext $context = null) { return CompiledEvaluator::fromExpressions([Expression::returnExpression($this)], $context); }
php
public function asEvaluator(IEvaluationContext $context = null) { return CompiledEvaluator::fromExpressions([Expression::returnExpression($this)], $context); }
[ "public", "function", "asEvaluator", "(", "IEvaluationContext", "$", "context", "=", "null", ")", "{", "return", "CompiledEvaluator", "::", "fromExpressions", "(", "[", "Expression", "::", "returnExpression", "(", "$", "this", ")", "]", ",", "$", "context", ")", ";", "}" ]
Creates an expression evaluator for the expression with the supplied context. @param IEvaluationContext|null $context @return IEvaluator
[ "Creates", "an", "expression", "evaluator", "for", "the", "expression", "with", "the", "supplied", "context", "." ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Expressions/Expression.php#L114-L117
TimeToogo/Pinq
Source/Expressions/Expression.php
Expression.compileDebug
final public function compileDebug() { return (new DynamicExpressionWalker([ ValueExpression::getType() => function (ValueExpression $expression) { $value = $expression->getValue(); return !is_scalar($value) && $value !== null ? Expression::constant( '{' . Utilities::getTypeOrClass($expression->getValue()) . '}' ) : $expression; } ])) ->walk($this) ->compile(); }
php
final public function compileDebug() { return (new DynamicExpressionWalker([ ValueExpression::getType() => function (ValueExpression $expression) { $value = $expression->getValue(); return !is_scalar($value) && $value !== null ? Expression::constant( '{' . Utilities::getTypeOrClass($expression->getValue()) . '}' ) : $expression; } ])) ->walk($this) ->compile(); }
[ "final", "public", "function", "compileDebug", "(", ")", "{", "return", "(", "new", "DynamicExpressionWalker", "(", "[", "ValueExpression", "::", "getType", "(", ")", "=>", "function", "(", "ValueExpression", "$", "expression", ")", "{", "$", "value", "=", "$", "expression", "->", "getValue", "(", ")", ";", "return", "!", "is_scalar", "(", "$", "value", ")", "&&", "$", "value", "!==", "null", "?", "Expression", "::", "constant", "(", "'{'", ".", "Utilities", "::", "getTypeOrClass", "(", "$", "expression", "->", "getValue", "(", ")", ")", ".", "'}'", ")", ":", "$", "expression", ";", "}", "]", ")", ")", "->", "walk", "(", "$", "this", ")", "->", "compile", "(", ")", ";", "}" ]
Compiles the expression tree into debug code. @return string
[ "Compiles", "the", "expression", "tree", "into", "debug", "code", "." ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Expressions/Expression.php#L235-L250
TimeToogo/Pinq
Source/Expressions/Expression.php
Expression.allOfType
final public static function allOfType(array $expressions, $type, $allowNull = false) { foreach ($expressions as $expression) { if ($expression instanceof $type || $expression === null && $allowNull) { continue; } return false; } return true; }
php
final public static function allOfType(array $expressions, $type, $allowNull = false) { foreach ($expressions as $expression) { if ($expression instanceof $type || $expression === null && $allowNull) { continue; } return false; } return true; }
[ "final", "public", "static", "function", "allOfType", "(", "array", "$", "expressions", ",", "$", "type", ",", "$", "allowNull", "=", "false", ")", "{", "foreach", "(", "$", "expressions", "as", "$", "expression", ")", "{", "if", "(", "$", "expression", "instanceof", "$", "type", "||", "$", "expression", "===", "null", "&&", "$", "allowNull", ")", "{", "continue", ";", "}", "return", "false", ";", "}", "return", "true", ";", "}" ]
Returns whether the expressions are all of the supplied type. @param Expression[] $expressions @param string $type @param boolean $allowNull @return boolean
[ "Returns", "whether", "the", "expressions", "are", "all", "of", "the", "supplied", "type", "." ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Expressions/Expression.php#L263-L274
TimeToogo/Pinq
Source/Expressions/Expression.php
Expression.cloneAll
final public static function cloneAll(array $expressions) { return array_map( function (Expression $expression = null) { return $expression === null ? null : clone $expression; }, $expressions ); }
php
final public static function cloneAll(array $expressions) { return array_map( function (Expression $expression = null) { return $expression === null ? null : clone $expression; }, $expressions ); }
[ "final", "public", "static", "function", "cloneAll", "(", "array", "$", "expressions", ")", "{", "return", "array_map", "(", "function", "(", "Expression", "$", "expression", "=", "null", ")", "{", "return", "$", "expression", "===", "null", "?", "null", ":", "clone", "$", "expression", ";", "}", ",", "$", "expressions", ")", ";", "}" ]
@param Expression|null[] $expressions @return Expression|null[]
[ "@param", "Expression|null", "[]", "$expressions" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Expressions/Expression.php#L281-L289
TimeToogo/Pinq
Source/Expressions/Expression.php
Expression.assign
final public static function assign(Expression $assignToValue, $assignmentOperator, Expression $assignmentValue) { return new AssignmentExpression( $assignToValue, $assignmentOperator, $assignmentValue); }
php
final public static function assign(Expression $assignToValue, $assignmentOperator, Expression $assignmentValue) { return new AssignmentExpression( $assignToValue, $assignmentOperator, $assignmentValue); }
[ "final", "public", "static", "function", "assign", "(", "Expression", "$", "assignToValue", ",", "$", "assignmentOperator", ",", "Expression", "$", "assignmentValue", ")", "{", "return", "new", "AssignmentExpression", "(", "$", "assignToValue", ",", "$", "assignmentOperator", ",", "$", "assignmentValue", ")", ";", "}" ]
@param Expression $assignToValue @param string $assignmentOperator @param Expression $assignmentValue @return AssignmentExpression
[ "@param", "Expression", "$assignToValue", "@param", "string", "$assignmentOperator", "@param", "Expression", "$assignmentValue" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Expressions/Expression.php#L298-L304
TimeToogo/Pinq
Source/Expressions/Expression.php
Expression.binaryOperation
final public static function binaryOperation(Expression $leftOperand, $operator, Expression $rightOperand) { return new BinaryOperationExpression( $leftOperand, $operator, $rightOperand); }
php
final public static function binaryOperation(Expression $leftOperand, $operator, Expression $rightOperand) { return new BinaryOperationExpression( $leftOperand, $operator, $rightOperand); }
[ "final", "public", "static", "function", "binaryOperation", "(", "Expression", "$", "leftOperand", ",", "$", "operator", ",", "Expression", "$", "rightOperand", ")", "{", "return", "new", "BinaryOperationExpression", "(", "$", "leftOperand", ",", "$", "operator", ",", "$", "rightOperand", ")", ";", "}" ]
@param Expression $leftOperand @param string $operator @param Expression $rightOperand @return BinaryOperationExpression
[ "@param", "Expression", "$leftOperand", "@param", "string", "$operator", "@param", "Expression", "$rightOperand" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Expressions/Expression.php#L313-L319
TimeToogo/Pinq
Source/Expressions/Expression.php
Expression.methodCall
final public static function methodCall(Expression $value, Expression $name, array $arguments = []) { return new MethodCallExpression( $value, $name, $arguments); }
php
final public static function methodCall(Expression $value, Expression $name, array $arguments = []) { return new MethodCallExpression( $value, $name, $arguments); }
[ "final", "public", "static", "function", "methodCall", "(", "Expression", "$", "value", ",", "Expression", "$", "name", ",", "array", "$", "arguments", "=", "[", "]", ")", "{", "return", "new", "MethodCallExpression", "(", "$", "value", ",", "$", "name", ",", "$", "arguments", ")", ";", "}" ]
@param Expression $value @param Expression $name @param ArgumentExpression[] $arguments @return MethodCallExpression
[ "@param", "Expression", "$value", "@param", "Expression", "$name", "@param", "ArgumentExpression", "[]", "$arguments" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Expressions/Expression.php#L350-L356
TimeToogo/Pinq
Source/Expressions/Expression.php
Expression.ternary
final public static function ternary(Expression $condition, Expression $ifTrue = null, Expression $ifFalse) { return new TernaryExpression( $condition, $ifTrue, $ifFalse); }
php
final public static function ternary(Expression $condition, Expression $ifTrue = null, Expression $ifFalse) { return new TernaryExpression( $condition, $ifTrue, $ifFalse); }
[ "final", "public", "static", "function", "ternary", "(", "Expression", "$", "condition", ",", "Expression", "$", "ifTrue", "=", "null", ",", "Expression", "$", "ifFalse", ")", "{", "return", "new", "TernaryExpression", "(", "$", "condition", ",", "$", "ifTrue", ",", "$", "ifFalse", ")", ";", "}" ]
@param Expression $condition @param Expression $ifTrue @param Expression $ifFalse @return TernaryExpression
[ "@param", "Expression", "$condition", "@param", "Expression", "$ifTrue", "@param", "Expression", "$ifFalse" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Expressions/Expression.php#L480-L486
TimeToogo/Pinq
Source/Expressions/Expression.php
Expression.parameter
final public static function parameter( $name, $typeHint = null, Expression $defaultValue = null, $isPassedByReference = false, $isVariadic = false ) { return new ParameterExpression( $name, $typeHint, $defaultValue, $isPassedByReference, $isVariadic); }
php
final public static function parameter( $name, $typeHint = null, Expression $defaultValue = null, $isPassedByReference = false, $isVariadic = false ) { return new ParameterExpression( $name, $typeHint, $defaultValue, $isPassedByReference, $isVariadic); }
[ "final", "public", "static", "function", "parameter", "(", "$", "name", ",", "$", "typeHint", "=", "null", ",", "Expression", "$", "defaultValue", "=", "null", ",", "$", "isPassedByReference", "=", "false", ",", "$", "isVariadic", "=", "false", ")", "{", "return", "new", "ParameterExpression", "(", "$", "name", ",", "$", "typeHint", ",", "$", "defaultValue", ",", "$", "isPassedByReference", ",", "$", "isVariadic", ")", ";", "}" ]
@param string $name @param string|null $typeHint @param Expression $defaultValue @param boolean $isPassedByReference @param boolean $isVariadic @return ParameterExpression
[ "@param", "string", "$name", "@param", "string|null", "$typeHint", "@param", "Expression", "$defaultValue", "@param", "boolean", "$isPassedByReference", "@param", "boolean", "$isVariadic" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Expressions/Expression.php#L517-L530
TimeToogo/Pinq
Source/Expressions/Expression.php
Expression.arrayItem
final public static function arrayItem(Expression $key = null, Expression $value, $isReference = false) { return new ArrayItemExpression($key, $value, $isReference); }
php
final public static function arrayItem(Expression $key = null, Expression $value, $isReference = false) { return new ArrayItemExpression($key, $value, $isReference); }
[ "final", "public", "static", "function", "arrayItem", "(", "Expression", "$", "key", "=", "null", ",", "Expression", "$", "value", ",", "$", "isReference", "=", "false", ")", "{", "return", "new", "ArrayItemExpression", "(", "$", "key", ",", "$", "value", ",", "$", "isReference", ")", ";", "}" ]
@param Expression $key @param Expression $value @param boolean $isReference @return ArrayItemExpression
[ "@param", "Expression", "$key", "@param", "Expression", "$value", "@param", "boolean", "$isReference" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Expressions/Expression.php#L603-L606
TimeToogo/Pinq
Source/Expressions/Expression.php
Expression.closure
final public static function closure( $returnsReference, $isStatic, array $parameterExpressions, array $usedVariables, array $bodyExpressions ) { return new ClosureExpression( $returnsReference, $isStatic, $parameterExpressions, $usedVariables, $bodyExpressions); }
php
final public static function closure( $returnsReference, $isStatic, array $parameterExpressions, array $usedVariables, array $bodyExpressions ) { return new ClosureExpression( $returnsReference, $isStatic, $parameterExpressions, $usedVariables, $bodyExpressions); }
[ "final", "public", "static", "function", "closure", "(", "$", "returnsReference", ",", "$", "isStatic", ",", "array", "$", "parameterExpressions", ",", "array", "$", "usedVariables", ",", "array", "$", "bodyExpressions", ")", "{", "return", "new", "ClosureExpression", "(", "$", "returnsReference", ",", "$", "isStatic", ",", "$", "parameterExpressions", ",", "$", "usedVariables", ",", "$", "bodyExpressions", ")", ";", "}" ]
@param boolean $returnsReference @param boolean $isStatic @param ParameterExpression[] $parameterExpressions @param ClosureUsedVariableExpression[] $usedVariables @param Expression[] $bodyExpressions @return ClosureExpression
[ "@param", "boolean", "$returnsReference", "@param", "boolean", "$isStatic", "@param", "ParameterExpression", "[]", "$parameterExpressions", "@param", "ClosureUsedVariableExpression", "[]", "$usedVariables", "@param", "Expression", "[]", "$bodyExpressions" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Expressions/Expression.php#L617-L630
TimeToogo/Pinq
Source/Providers/DSL/Compilation/Processors/Visitors/ScopeProcessor.php
ScopeProcessor.processSegments
protected function processSegments(array $segments) { $this->segments = []; foreach ($segments as $segment) { $this->segments[] = $segment->traverse($this); } return $this->segments; }
php
protected function processSegments(array $segments) { $this->segments = []; foreach ($segments as $segment) { $this->segments[] = $segment->traverse($this); } return $this->segments; }
[ "protected", "function", "processSegments", "(", "array", "$", "segments", ")", "{", "$", "this", "->", "segments", "=", "[", "]", ";", "foreach", "(", "$", "segments", "as", "$", "segment", ")", "{", "$", "this", "->", "segments", "[", "]", "=", "$", "segment", "->", "traverse", "(", "$", "this", ")", ";", "}", "return", "$", "this", "->", "segments", ";", "}" ]
@param Queries\ISegment[] $segments @return Queries\ISegment[]
[ "@param", "Queries", "\\", "ISegment", "[]", "$segments" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Providers/DSL/Compilation/Processors/Visitors/ScopeProcessor.php#L26-L35
TimeToogo/Pinq
Source/Caching/CacheProvider.php
CacheProvider.setDirectoryCache
public static function setDirectoryCache($directory, $fileExtension = DirectoryCache::DEFAULT_EXTENSION) { self::$cacheImplementation = new DirectoryCache($directory, $fileExtension); self::$hasBeenCleared = false; }
php
public static function setDirectoryCache($directory, $fileExtension = DirectoryCache::DEFAULT_EXTENSION) { self::$cacheImplementation = new DirectoryCache($directory, $fileExtension); self::$hasBeenCleared = false; }
[ "public", "static", "function", "setDirectoryCache", "(", "$", "directory", ",", "$", "fileExtension", "=", "DirectoryCache", "::", "DEFAULT_EXTENSION", ")", "{", "self", "::", "$", "cacheImplementation", "=", "new", "DirectoryCache", "(", "$", "directory", ",", "$", "fileExtension", ")", ";", "self", "::", "$", "hasBeenCleared", "=", "false", ";", "}" ]
Uses the supplied directory to store the parsed queries. @param string $directory The directory to cache the data @param string $fileExtension The file extension for every cache file @return void
[ "Uses", "the", "supplied", "directory", "to", "store", "the", "parsed", "queries", "." ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Caching/CacheProvider.php#L102-L106
TimeToogo/Pinq
Source/Caching/CacheProvider.php
CacheProvider.setDoctrineCache
public static function setDoctrineCache(DoctrineCacheProvider $cache) { self::$cacheImplementation = new DoctrineCache($cache); self::$hasBeenCleared = false; }
php
public static function setDoctrineCache(DoctrineCacheProvider $cache) { self::$cacheImplementation = new DoctrineCache($cache); self::$hasBeenCleared = false; }
[ "public", "static", "function", "setDoctrineCache", "(", "DoctrineCacheProvider", "$", "cache", ")", "{", "self", "::", "$", "cacheImplementation", "=", "new", "DoctrineCache", "(", "$", "cache", ")", ";", "self", "::", "$", "hasBeenCleared", "=", "false", ";", "}" ]
Uses the supplied doctrine cache to store the parsed queries. @param DoctrineCacheProvider $cache The doctrine cache @return void
[ "Uses", "the", "supplied", "doctrine", "cache", "to", "store", "the", "parsed", "queries", "." ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Caching/CacheProvider.php#L115-L119
TimeToogo/Pinq
Source/Caching/CacheProvider.php
CacheProvider.setArrayAccessCache
public static function setArrayAccessCache(\ArrayAccess $cache) { self::$cacheImplementation = new ArrayAccessCacheAdapter($cache); self::$hasBeenCleared = false; }
php
public static function setArrayAccessCache(\ArrayAccess $cache) { self::$cacheImplementation = new ArrayAccessCacheAdapter($cache); self::$hasBeenCleared = false; }
[ "public", "static", "function", "setArrayAccessCache", "(", "\\", "ArrayAccess", "$", "cache", ")", "{", "self", "::", "$", "cacheImplementation", "=", "new", "ArrayAccessCacheAdapter", "(", "$", "cache", ")", ";", "self", "::", "$", "hasBeenCleared", "=", "false", ";", "}" ]
Uses the supplied array access cache to store the parsed queries. @param \ArrayAccess $cache The array access cache @return void
[ "Uses", "the", "supplied", "array", "access", "cache", "to", "store", "the", "parsed", "queries", "." ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Caching/CacheProvider.php#L128-L132
TimeToogo/Pinq
Source/Iterators/Common/OrderedIterator.php
OrderedIterator.thenOrderBy
final public function thenOrderBy(callable $orderByFunction, $isAscending) { $newOrderedIterator = new self($this->getSourceIterator(), function () { }, true); $newOrderedIterator->orderByFunctions = $this->orderByFunctions; $newOrderedIterator->isAscendingArray = $this->isAscendingArray; $newOrderedIterator->orderByFunctions[] = Functions::allowExcessiveArguments($orderByFunction); $newOrderedIterator->isAscendingArray[] = $isAscending; return $newOrderedIterator; }
php
final public function thenOrderBy(callable $orderByFunction, $isAscending) { $newOrderedIterator = new self($this->getSourceIterator(), function () { }, true); $newOrderedIterator->orderByFunctions = $this->orderByFunctions; $newOrderedIterator->isAscendingArray = $this->isAscendingArray; $newOrderedIterator->orderByFunctions[] = Functions::allowExcessiveArguments($orderByFunction); $newOrderedIterator->isAscendingArray[] = $isAscending; return $newOrderedIterator; }
[ "final", "public", "function", "thenOrderBy", "(", "callable", "$", "orderByFunction", ",", "$", "isAscending", ")", "{", "$", "newOrderedIterator", "=", "new", "self", "(", "$", "this", "->", "getSourceIterator", "(", ")", ",", "function", "(", ")", "{", "}", ",", "true", ")", ";", "$", "newOrderedIterator", "->", "orderByFunctions", "=", "$", "this", "->", "orderByFunctions", ";", "$", "newOrderedIterator", "->", "isAscendingArray", "=", "$", "this", "->", "isAscendingArray", ";", "$", "newOrderedIterator", "->", "orderByFunctions", "[", "]", "=", "Functions", "::", "allowExcessiveArguments", "(", "$", "orderByFunction", ")", ";", "$", "newOrderedIterator", "->", "isAscendingArray", "[", "]", "=", "$", "isAscending", ";", "return", "$", "newOrderedIterator", ";", "}" ]
@param callable $orderByFunction @param boolean $isAscending @return IOrderedIterator
[ "@param", "callable", "$orderByFunction", "@param", "boolean", "$isAscending" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Iterators/Common/OrderedIterator.php#L38-L49
TimeToogo/Pinq
Source/Expressions/TraversalExpression.php
TraversalExpression.updateValue
final public function updateValue(Expression $value) { if ($this->value === $value) { return $this; } return $this->updateValueExpression($value); }
php
final public function updateValue(Expression $value) { if ($this->value === $value) { return $this; } return $this->updateValueExpression($value); }
[ "final", "public", "function", "updateValue", "(", "Expression", "$", "value", ")", "{", "if", "(", "$", "this", "->", "value", "===", "$", "value", ")", "{", "return", "$", "this", ";", "}", "return", "$", "this", "->", "updateValueExpression", "(", "$", "value", ")", ";", "}" ]
@param Expression $value @return static
[ "@param", "Expression", "$value" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Expressions/TraversalExpression.php#L35-L42
TimeToogo/Pinq
Source/Queries/Functions/FunctionEvaluationContextFactory.php
FunctionEvaluationContextFactory.getEvaluationContext
public function getEvaluationContext(IResolvedParameterRegistry $parameters = null) { $thisObject = null; $variableTable = array_fill_keys($this->parameterScopedVariableMap, null); unset($variableTable['this']); if ($parameters !== null) { foreach ($this->parameterScopedVariableMap as $parameter => $variableName) { if ($variableName === 'this') { $thisObject = $parameters[$parameter]; } else { $variableTable[$variableName] = $parameters[$parameter]; } } } foreach ($this->unusedParameterDefaultMap as $name => $evaluator) { $variableTable[$name] = $evaluator->evaluate(); } return new O\EvaluationContext($this->namespace, $this->scopeType, $thisObject, $variableTable); }
php
public function getEvaluationContext(IResolvedParameterRegistry $parameters = null) { $thisObject = null; $variableTable = array_fill_keys($this->parameterScopedVariableMap, null); unset($variableTable['this']); if ($parameters !== null) { foreach ($this->parameterScopedVariableMap as $parameter => $variableName) { if ($variableName === 'this') { $thisObject = $parameters[$parameter]; } else { $variableTable[$variableName] = $parameters[$parameter]; } } } foreach ($this->unusedParameterDefaultMap as $name => $evaluator) { $variableTable[$name] = $evaluator->evaluate(); } return new O\EvaluationContext($this->namespace, $this->scopeType, $thisObject, $variableTable); }
[ "public", "function", "getEvaluationContext", "(", "IResolvedParameterRegistry", "$", "parameters", "=", "null", ")", "{", "$", "thisObject", "=", "null", ";", "$", "variableTable", "=", "array_fill_keys", "(", "$", "this", "->", "parameterScopedVariableMap", ",", "null", ")", ";", "unset", "(", "$", "variableTable", "[", "'this'", "]", ")", ";", "if", "(", "$", "parameters", "!==", "null", ")", "{", "foreach", "(", "$", "this", "->", "parameterScopedVariableMap", "as", "$", "parameter", "=>", "$", "variableName", ")", "{", "if", "(", "$", "variableName", "===", "'this'", ")", "{", "$", "thisObject", "=", "$", "parameters", "[", "$", "parameter", "]", ";", "}", "else", "{", "$", "variableTable", "[", "$", "variableName", "]", "=", "$", "parameters", "[", "$", "parameter", "]", ";", "}", "}", "}", "foreach", "(", "$", "this", "->", "unusedParameterDefaultMap", "as", "$", "name", "=>", "$", "evaluator", ")", "{", "$", "variableTable", "[", "$", "name", "]", "=", "$", "evaluator", "->", "evaluate", "(", ")", ";", "}", "return", "new", "O", "\\", "EvaluationContext", "(", "$", "this", "->", "namespace", ",", "$", "this", "->", "scopeType", ",", "$", "thisObject", ",", "$", "variableTable", ")", ";", "}" ]
Gets an evaluation context for function with the resolved parameters. @param IResolvedParameterRegistry|null $parameters @return O\IEvaluationContext
[ "Gets", "an", "evaluation", "context", "for", "function", "with", "the", "resolved", "parameters", "." ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Queries/Functions/FunctionEvaluationContextFactory.php#L123-L144
TimeToogo/Pinq
Source/Providers/DSL/RepositoryCompilerConfiguration.php
RepositoryCompilerConfiguration.buildCompiledOperationQuery
protected function buildCompiledOperationQuery(Queries\IOperationQuery $query) { $compiler = $this->getOperationQueryCompiler($query); $compiler->compile(); return $compiler->getCompilation()->asCompiled(); }
php
protected function buildCompiledOperationQuery(Queries\IOperationQuery $query) { $compiler = $this->getOperationQueryCompiler($query); $compiler->compile(); return $compiler->getCompilation()->asCompiled(); }
[ "protected", "function", "buildCompiledOperationQuery", "(", "Queries", "\\", "IOperationQuery", "$", "query", ")", "{", "$", "compiler", "=", "$", "this", "->", "getOperationQueryCompiler", "(", "$", "query", ")", ";", "$", "compiler", "->", "compile", "(", ")", ";", "return", "$", "compiler", "->", "getCompilation", "(", ")", "->", "asCompiled", "(", ")", ";", "}" ]
@param Queries\IOperationQuery $query @return Compilation\ICompiledOperation
[ "@param", "Queries", "\\", "IOperationQuery", "$query" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Providers/DSL/RepositoryCompilerConfiguration.php#L109-L115
TimeToogo/Pinq
Source/Expressions/MethodCallExpression.php
MethodCallExpression.update
public function update( Expression $value, Expression $name, array $arguments ) { if ($this->value === $value && $this->name === $name && $this->arguments === $arguments ) { return $this; } return new self( $value, $name, $arguments); }
php
public function update( Expression $value, Expression $name, array $arguments ) { if ($this->value === $value && $this->name === $name && $this->arguments === $arguments ) { return $this; } return new self( $value, $name, $arguments); }
[ "public", "function", "update", "(", "Expression", "$", "value", ",", "Expression", "$", "name", ",", "array", "$", "arguments", ")", "{", "if", "(", "$", "this", "->", "value", "===", "$", "value", "&&", "$", "this", "->", "name", "===", "$", "name", "&&", "$", "this", "->", "arguments", "===", "$", "arguments", ")", "{", "return", "$", "this", ";", "}", "return", "new", "self", "(", "$", "value", ",", "$", "name", ",", "$", "arguments", ")", ";", "}" ]
@param Expression $value @param Expression $name @param ArgumentExpression[] $arguments @return MethodCallExpression
[ "@param", "Expression", "$value", "@param", "Expression", "$name", "@param", "ArgumentExpression", "[]", "$arguments" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Expressions/MethodCallExpression.php#L59-L75
TimeToogo/Pinq
Source/Collection.php
Collection.from
public static function from($elements, Iterators\IIteratorScheme $scheme = null, Traversable $source = null) { if ($source !== null && !($source instanceof Collection)) { throw new PinqException( 'Cannot construct %s: expecting source to be type %s or null, %s given', __CLASS__, __CLASS__, Utilities::getTypeOrClass($source)); } return new static($elements, $scheme, $source); }
php
public static function from($elements, Iterators\IIteratorScheme $scheme = null, Traversable $source = null) { if ($source !== null && !($source instanceof Collection)) { throw new PinqException( 'Cannot construct %s: expecting source to be type %s or null, %s given', __CLASS__, __CLASS__, Utilities::getTypeOrClass($source)); } return new static($elements, $scheme, $source); }
[ "public", "static", "function", "from", "(", "$", "elements", ",", "Iterators", "\\", "IIteratorScheme", "$", "scheme", "=", "null", ",", "Traversable", "$", "source", "=", "null", ")", "{", "if", "(", "$", "source", "!==", "null", "&&", "!", "(", "$", "source", "instanceof", "Collection", ")", ")", "{", "throw", "new", "PinqException", "(", "'Cannot construct %s: expecting source to be type %s or null, %s given'", ",", "__CLASS__", ",", "__CLASS__", ",", "Utilities", "::", "getTypeOrClass", "(", "$", "source", ")", ")", ";", "}", "return", "new", "static", "(", "$", "elements", ",", "$", "scheme", ",", "$", "source", ")", ";", "}" ]
{@inheritDoc} @param Collection|null $source
[ "{" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Collection.php#L39-L50
TimeToogo/Pinq
Source/Queries/Operations/RemoveWhere.php
RemoveWhere.update
public function update(Functions\ElementProjection $predicateFunction) { if ($this->predicateFunction === $predicateFunction) { return $this; } return new self($predicateFunction); }
php
public function update(Functions\ElementProjection $predicateFunction) { if ($this->predicateFunction === $predicateFunction) { return $this; } return new self($predicateFunction); }
[ "public", "function", "update", "(", "Functions", "\\", "ElementProjection", "$", "predicateFunction", ")", "{", "if", "(", "$", "this", "->", "predicateFunction", "===", "$", "predicateFunction", ")", "{", "return", "$", "this", ";", "}", "return", "new", "self", "(", "$", "predicateFunction", ")", ";", "}" ]
@param Functions\ElementProjection $predicateFunction @return RemoveWhere
[ "@param", "Functions", "\\", "ElementProjection", "$predicateFunction" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Queries/Operations/RemoveWhere.php#L52-L59
TimeToogo/Pinq
Source/Queries/Common/Join/Filter/Equality.php
Equality.update
public function update( Functions\ElementProjection $outerKeyFunction, Functions\ElementProjection $innerKeyFunction ) { if ($this->outerKeyFunction === $outerKeyFunction && $this->innerKeyFunction === $innerKeyFunction ) { return $this; } return new self($outerKeyFunction, $innerKeyFunction); }
php
public function update( Functions\ElementProjection $outerKeyFunction, Functions\ElementProjection $innerKeyFunction ) { if ($this->outerKeyFunction === $outerKeyFunction && $this->innerKeyFunction === $innerKeyFunction ) { return $this; } return new self($outerKeyFunction, $innerKeyFunction); }
[ "public", "function", "update", "(", "Functions", "\\", "ElementProjection", "$", "outerKeyFunction", ",", "Functions", "\\", "ElementProjection", "$", "innerKeyFunction", ")", "{", "if", "(", "$", "this", "->", "outerKeyFunction", "===", "$", "outerKeyFunction", "&&", "$", "this", "->", "innerKeyFunction", "===", "$", "innerKeyFunction", ")", "{", "return", "$", "this", ";", "}", "return", "new", "self", "(", "$", "outerKeyFunction", ",", "$", "innerKeyFunction", ")", ";", "}" ]
@param Functions\ElementProjection $outerKeyFunction @param Functions\ElementProjection $innerKeyFunction @return Equality
[ "@param", "Functions", "\\", "ElementProjection", "$outerKeyFunction", "@param", "Functions", "\\", "ElementProjection", "$innerKeyFunction" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Queries/Common/Join/Filter/Equality.php#L75-L86
TimeToogo/Pinq
Source/Parsing/Reflection.php
Reflection.fromCallable
final public static function fromCallable(callable $function) { // If is array it could be an instance or static method: // ['class', 'method'] or [$instance, 'method']; if (is_array($function)) { return new \ReflectionMethod($function[0], $function[1]); } // If it is a closure it could be an actual closure or // possibly a closure of another function from // \ReflectionFunction::getClosure or \ReflectionMethod::getClosure elseif ($function instanceof \Closure) { $reflection = new \ReflectionFunction($function); // If the name is {closure} it as an actual closure if ($reflection->getShortName() === '{closure}') { return $reflection; } // Bail out, no (sane) way of determining the actual function // represented by the closure throw InvalidFunctionException::invalidFunctionMessage( 'The function has been wrapped in closure ' . '(most likely via ReflectionFunction::getClosure or \ReflectionMethod::getClosure) ' . 'and this is not supported', $reflection); } // If an object but not a closure it must be an object defining // the __invoke magic method. elseif (is_object($function)) { return new \ReflectionMethod($function, '__invoke'); } // Fallback to function else { $name = null; is_callable($function, false, $name); return new \ReflectionFunction($name); } }
php
final public static function fromCallable(callable $function) { // If is array it could be an instance or static method: // ['class', 'method'] or [$instance, 'method']; if (is_array($function)) { return new \ReflectionMethod($function[0], $function[1]); } // If it is a closure it could be an actual closure or // possibly a closure of another function from // \ReflectionFunction::getClosure or \ReflectionMethod::getClosure elseif ($function instanceof \Closure) { $reflection = new \ReflectionFunction($function); // If the name is {closure} it as an actual closure if ($reflection->getShortName() === '{closure}') { return $reflection; } // Bail out, no (sane) way of determining the actual function // represented by the closure throw InvalidFunctionException::invalidFunctionMessage( 'The function has been wrapped in closure ' . '(most likely via ReflectionFunction::getClosure or \ReflectionMethod::getClosure) ' . 'and this is not supported', $reflection); } // If an object but not a closure it must be an object defining // the __invoke magic method. elseif (is_object($function)) { return new \ReflectionMethod($function, '__invoke'); } // Fallback to function else { $name = null; is_callable($function, false, $name); return new \ReflectionFunction($name); } }
[ "final", "public", "static", "function", "fromCallable", "(", "callable", "$", "function", ")", "{", "// If is array it could be an instance or static method:", "// ['class', 'method'] or [$instance, 'method'];", "if", "(", "is_array", "(", "$", "function", ")", ")", "{", "return", "new", "\\", "ReflectionMethod", "(", "$", "function", "[", "0", "]", ",", "$", "function", "[", "1", "]", ")", ";", "}", "// If it is a closure it could be an actual closure or", "// possibly a closure of another function from", "// \\ReflectionFunction::getClosure or \\ReflectionMethod::getClosure", "elseif", "(", "$", "function", "instanceof", "\\", "Closure", ")", "{", "$", "reflection", "=", "new", "\\", "ReflectionFunction", "(", "$", "function", ")", ";", "// If the name is {closure} it as an actual closure", "if", "(", "$", "reflection", "->", "getShortName", "(", ")", "===", "'{closure}'", ")", "{", "return", "$", "reflection", ";", "}", "// Bail out, no (sane) way of determining the actual function", "// represented by the closure", "throw", "InvalidFunctionException", "::", "invalidFunctionMessage", "(", "'The function has been wrapped in closure '", ".", "'(most likely via ReflectionFunction::getClosure or \\ReflectionMethod::getClosure) '", ".", "'and this is not supported'", ",", "$", "reflection", ")", ";", "}", "// If an object but not a closure it must be an object defining", "// the __invoke magic method.", "elseif", "(", "is_object", "(", "$", "function", ")", ")", "{", "return", "new", "\\", "ReflectionMethod", "(", "$", "function", ",", "'__invoke'", ")", ";", "}", "// Fallback to function", "else", "{", "$", "name", "=", "null", ";", "is_callable", "(", "$", "function", ",", "false", ",", "$", "name", ")", ";", "return", "new", "\\", "ReflectionFunction", "(", "$", "name", ")", ";", "}", "}" ]
@param callable $function @return \ReflectionFunctionAbstract @throws InvalidFunctionException
[ "@param", "callable", "$function" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Parsing/Reflection.php#L24-L61
TimeToogo/Pinq
Source/Parsing/Reflection.php
Reflection.isVariadic
public static function isVariadic(\ReflectionFunctionAbstract $function) { if (self::$supportsVariadicParameters === null) { self::$supportsVariadicParameters = method_exists('\ReflectionParameter', 'isVariadic'); } foreach ($function->getParameters() as $parameter) { if ($parameter->getName() === '...' || (self::$supportsVariadicParameters && $parameter->isVariadic()) ) { return true; } } return false; }
php
public static function isVariadic(\ReflectionFunctionAbstract $function) { if (self::$supportsVariadicParameters === null) { self::$supportsVariadicParameters = method_exists('\ReflectionParameter', 'isVariadic'); } foreach ($function->getParameters() as $parameter) { if ($parameter->getName() === '...' || (self::$supportsVariadicParameters && $parameter->isVariadic()) ) { return true; } } return false; }
[ "public", "static", "function", "isVariadic", "(", "\\", "ReflectionFunctionAbstract", "$", "function", ")", "{", "if", "(", "self", "::", "$", "supportsVariadicParameters", "===", "null", ")", "{", "self", "::", "$", "supportsVariadicParameters", "=", "method_exists", "(", "'\\ReflectionParameter'", ",", "'isVariadic'", ")", ";", "}", "foreach", "(", "$", "function", "->", "getParameters", "(", ")", "as", "$", "parameter", ")", "{", "if", "(", "$", "parameter", "->", "getName", "(", ")", "===", "'...'", "||", "(", "self", "::", "$", "supportsVariadicParameters", "&&", "$", "parameter", "->", "isVariadic", "(", ")", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
@param \ReflectionFunctionAbstract $function @return boolean
[ "@param", "\\", "ReflectionFunctionAbstract", "$function" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Parsing/Reflection.php#L70-L85
TimeToogo/Pinq
Source/Providers/Traversable/ScopeEvaluator.php
ScopeEvaluator.evaluateJoinOptions
public static function evaluateJoinOptions( ITraversable $traversable, Common\Join\Options $join, Queries\IResolvedParameterRegistry $resolvedParameters ) { $values = self::evaluateSource($join->getSource(), $resolvedParameters); $joiningTraversable = $join->isGroupJoin() ? $traversable->groupJoin($values) : $traversable->join($values); if ($join->hasFilter()) { $filter = $join->getFilter(); if ($filter instanceof Common\Join\Filter\Custom) { $joiningTraversable = $joiningTraversable->on( $resolvedParameters[$filter->getOnFunction()->getCallableId()] ); } elseif ($filter instanceof Common\Join\Filter\Equality) { $joiningTraversable = $joiningTraversable->onEquality( $resolvedParameters[$filter->getOuterKeyFunction()->getCallableId()], $resolvedParameters[$filter->getInnerKeyFunction()->getCallableId()] ); } } if ($join->hasDefault()) { $joiningTraversable = $joiningTraversable->withDefault( $resolvedParameters[$join->getDefaultValueId()], $resolvedParameters[$join->getDefaultKeyId()] ); } return $joiningTraversable; }
php
public static function evaluateJoinOptions( ITraversable $traversable, Common\Join\Options $join, Queries\IResolvedParameterRegistry $resolvedParameters ) { $values = self::evaluateSource($join->getSource(), $resolvedParameters); $joiningTraversable = $join->isGroupJoin() ? $traversable->groupJoin($values) : $traversable->join($values); if ($join->hasFilter()) { $filter = $join->getFilter(); if ($filter instanceof Common\Join\Filter\Custom) { $joiningTraversable = $joiningTraversable->on( $resolvedParameters[$filter->getOnFunction()->getCallableId()] ); } elseif ($filter instanceof Common\Join\Filter\Equality) { $joiningTraversable = $joiningTraversable->onEquality( $resolvedParameters[$filter->getOuterKeyFunction()->getCallableId()], $resolvedParameters[$filter->getInnerKeyFunction()->getCallableId()] ); } } if ($join->hasDefault()) { $joiningTraversable = $joiningTraversable->withDefault( $resolvedParameters[$join->getDefaultValueId()], $resolvedParameters[$join->getDefaultKeyId()] ); } return $joiningTraversable; }
[ "public", "static", "function", "evaluateJoinOptions", "(", "ITraversable", "$", "traversable", ",", "Common", "\\", "Join", "\\", "Options", "$", "join", ",", "Queries", "\\", "IResolvedParameterRegistry", "$", "resolvedParameters", ")", "{", "$", "values", "=", "self", "::", "evaluateSource", "(", "$", "join", "->", "getSource", "(", ")", ",", "$", "resolvedParameters", ")", ";", "$", "joiningTraversable", "=", "$", "join", "->", "isGroupJoin", "(", ")", "?", "$", "traversable", "->", "groupJoin", "(", "$", "values", ")", ":", "$", "traversable", "->", "join", "(", "$", "values", ")", ";", "if", "(", "$", "join", "->", "hasFilter", "(", ")", ")", "{", "$", "filter", "=", "$", "join", "->", "getFilter", "(", ")", ";", "if", "(", "$", "filter", "instanceof", "Common", "\\", "Join", "\\", "Filter", "\\", "Custom", ")", "{", "$", "joiningTraversable", "=", "$", "joiningTraversable", "->", "on", "(", "$", "resolvedParameters", "[", "$", "filter", "->", "getOnFunction", "(", ")", "->", "getCallableId", "(", ")", "]", ")", ";", "}", "elseif", "(", "$", "filter", "instanceof", "Common", "\\", "Join", "\\", "Filter", "\\", "Equality", ")", "{", "$", "joiningTraversable", "=", "$", "joiningTraversable", "->", "onEquality", "(", "$", "resolvedParameters", "[", "$", "filter", "->", "getOuterKeyFunction", "(", ")", "->", "getCallableId", "(", ")", "]", ",", "$", "resolvedParameters", "[", "$", "filter", "->", "getInnerKeyFunction", "(", ")", "->", "getCallableId", "(", ")", "]", ")", ";", "}", "}", "if", "(", "$", "join", "->", "hasDefault", "(", ")", ")", "{", "$", "joiningTraversable", "=", "$", "joiningTraversable", "->", "withDefault", "(", "$", "resolvedParameters", "[", "$", "join", "->", "getDefaultValueId", "(", ")", "]", ",", "$", "resolvedParameters", "[", "$", "join", "->", "getDefaultKeyId", "(", ")", "]", ")", ";", "}", "return", "$", "joiningTraversable", ";", "}" ]
Evaluates the join segment values and filter upon the supplied traversable. @param ITraversable $traversable @param Common\Join\Options $join @param Queries\IResolvedParameterRegistry $resolvedParameters @return \Pinq\Interfaces\IJoiningToTraversable
[ "Evaluates", "the", "join", "segment", "values", "and", "filter", "upon", "the", "supplied", "traversable", "." ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Providers/Traversable/ScopeEvaluator.php#L121-L152
TimeToogo/Pinq
Source/Providers/DSL/Compilation/Processors/Expression/ProcessorFactory.php
ProcessorFactory.from
public static function from(Queries\IQuery $query, IExpressionProcessor $expressionProcessor) { if ($query instanceof Queries\IRequestQuery) { return new RequestQueryProcessor($expressionProcessor, $query); } elseif ($query instanceof Queries\IOperationQuery) { return new OperationQueryProcessor($expressionProcessor, $query); } }
php
public static function from(Queries\IQuery $query, IExpressionProcessor $expressionProcessor) { if ($query instanceof Queries\IRequestQuery) { return new RequestQueryProcessor($expressionProcessor, $query); } elseif ($query instanceof Queries\IOperationQuery) { return new OperationQueryProcessor($expressionProcessor, $query); } }
[ "public", "static", "function", "from", "(", "Queries", "\\", "IQuery", "$", "query", ",", "IExpressionProcessor", "$", "expressionProcessor", ")", "{", "if", "(", "$", "query", "instanceof", "Queries", "\\", "IRequestQuery", ")", "{", "return", "new", "RequestQueryProcessor", "(", "$", "expressionProcessor", ",", "$", "query", ")", ";", "}", "elseif", "(", "$", "query", "instanceof", "Queries", "\\", "IOperationQuery", ")", "{", "return", "new", "OperationQueryProcessor", "(", "$", "expressionProcessor", ",", "$", "query", ")", ";", "}", "}" ]
Builds a query processor from the supplied query. @param Queries\IQuery $query @param IExpressionProcessor $expressionProcessor @return OperationQueryProcessor|RequestQueryProcessor
[ "Builds", "a", "query", "processor", "from", "the", "supplied", "query", "." ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Providers/DSL/Compilation/Processors/Expression/ProcessorFactory.php#L22-L29
TimeToogo/Pinq
Source/Parsing/InvalidFunctionException.php
InvalidFunctionException.invalidFunctionMessage
public static function invalidFunctionMessage($messageFormat, \ReflectionFunctionAbstract $reflection) { return self::construct( array_merge( [ 'Invalid function %s defined in %s lines %d-%d: ' . $messageFormat, $reflection->getName(), $reflection->getFileName(), $reflection->getStartLine(), $reflection->getEndLine() ], array_slice(func_get_args(), 2) ) ); }
php
public static function invalidFunctionMessage($messageFormat, \ReflectionFunctionAbstract $reflection) { return self::construct( array_merge( [ 'Invalid function %s defined in %s lines %d-%d: ' . $messageFormat, $reflection->getName(), $reflection->getFileName(), $reflection->getStartLine(), $reflection->getEndLine() ], array_slice(func_get_args(), 2) ) ); }
[ "public", "static", "function", "invalidFunctionMessage", "(", "$", "messageFormat", ",", "\\", "ReflectionFunctionAbstract", "$", "reflection", ")", "{", "return", "self", "::", "construct", "(", "array_merge", "(", "[", "'Invalid function %s defined in %s lines %d-%d: '", ".", "$", "messageFormat", ",", "$", "reflection", "->", "getName", "(", ")", ",", "$", "reflection", "->", "getFileName", "(", ")", ",", "$", "reflection", "->", "getStartLine", "(", ")", ",", "$", "reflection", "->", "getEndLine", "(", ")", "]", ",", "array_slice", "(", "func_get_args", "(", ")", ",", "2", ")", ")", ")", ";", "}" ]
@param string $messageFormat @param \ReflectionFunctionAbstract $reflection @return self
[ "@param", "string", "$messageFormat", "@param", "\\", "ReflectionFunctionAbstract", "$reflection" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Parsing/InvalidFunctionException.php#L21-L35
TimeToogo/Pinq
Source/Expressions/Operators/Cast.php
Cast.doCast
public static function doCast($castTypeOperator, $value) { if (!isset(self::$castTypeMap[$castTypeOperator])) { throw new PinqException('Cast operator \'%s\' is not supported', $castTypeOperator); } settype($value, self::$castTypeMap[$castTypeOperator]); return $value; }
php
public static function doCast($castTypeOperator, $value) { if (!isset(self::$castTypeMap[$castTypeOperator])) { throw new PinqException('Cast operator \'%s\' is not supported', $castTypeOperator); } settype($value, self::$castTypeMap[$castTypeOperator]); return $value; }
[ "public", "static", "function", "doCast", "(", "$", "castTypeOperator", ",", "$", "value", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "castTypeMap", "[", "$", "castTypeOperator", "]", ")", ")", "{", "throw", "new", "PinqException", "(", "'Cast operator \\'%s\\' is not supported'", ",", "$", "castTypeOperator", ")", ";", "}", "settype", "(", "$", "value", ",", "self", "::", "$", "castTypeMap", "[", "$", "castTypeOperator", "]", ")", ";", "return", "$", "value", ";", "}" ]
Performs the cast operation on the supplied value. @param string $castTypeOperator @param mixed $value @return mixed @throws PinqException
[ "Performs", "the", "cast", "operation", "on", "the", "supplied", "value", "." ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Expressions/Operators/Cast.php#L39-L48
TimeToogo/Pinq
Source/Parsing/FunctionLocation.php
FunctionLocation.fromReflection
public static function fromReflection(\ReflectionFunctionAbstract $reflection) { if ($reflection instanceof \ReflectionFunction) { $namespace = $reflection->getNamespaceName(); } elseif ($reflection instanceof \ReflectionMethod) { $namespace = $reflection->getDeclaringClass()->getNamespaceName(); } else { $namespace = null; } return new self( $reflection->getFileName(), $namespace, $reflection->getStartLine(), $reflection->getEndLine()); }
php
public static function fromReflection(\ReflectionFunctionAbstract $reflection) { if ($reflection instanceof \ReflectionFunction) { $namespace = $reflection->getNamespaceName(); } elseif ($reflection instanceof \ReflectionMethod) { $namespace = $reflection->getDeclaringClass()->getNamespaceName(); } else { $namespace = null; } return new self( $reflection->getFileName(), $namespace, $reflection->getStartLine(), $reflection->getEndLine()); }
[ "public", "static", "function", "fromReflection", "(", "\\", "ReflectionFunctionAbstract", "$", "reflection", ")", "{", "if", "(", "$", "reflection", "instanceof", "\\", "ReflectionFunction", ")", "{", "$", "namespace", "=", "$", "reflection", "->", "getNamespaceName", "(", ")", ";", "}", "elseif", "(", "$", "reflection", "instanceof", "\\", "ReflectionMethod", ")", "{", "$", "namespace", "=", "$", "reflection", "->", "getDeclaringClass", "(", ")", "->", "getNamespaceName", "(", ")", ";", "}", "else", "{", "$", "namespace", "=", "null", ";", "}", "return", "new", "self", "(", "$", "reflection", "->", "getFileName", "(", ")", ",", "$", "namespace", ",", "$", "reflection", "->", "getStartLine", "(", ")", ",", "$", "reflection", "->", "getEndLine", "(", ")", ")", ";", "}" ]
Creates a function location instance from the supplied reflection. @param \ReflectionFunctionAbstract $reflection @return self
[ "Creates", "a", "function", "location", "instance", "from", "the", "supplied", "reflection", "." ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Parsing/FunctionLocation.php#L66-L81
TimeToogo/Pinq
Source/Analysis/TypeSystem.php
TypeSystem.flattenComposedTypes
protected function flattenComposedTypes(array $types) { $composedTypes = []; foreach ($types as $type) { if ($type instanceof ICompositeType) { $composedTypes += $this->flattenComposedTypes($type->getComposedTypes()); } else { $composedTypes[$type->getIdentifier()] = $type; } } return $composedTypes; }
php
protected function flattenComposedTypes(array $types) { $composedTypes = []; foreach ($types as $type) { if ($type instanceof ICompositeType) { $composedTypes += $this->flattenComposedTypes($type->getComposedTypes()); } else { $composedTypes[$type->getIdentifier()] = $type; } } return $composedTypes; }
[ "protected", "function", "flattenComposedTypes", "(", "array", "$", "types", ")", "{", "$", "composedTypes", "=", "[", "]", ";", "foreach", "(", "$", "types", "as", "$", "type", ")", "{", "if", "(", "$", "type", "instanceof", "ICompositeType", ")", "{", "$", "composedTypes", "+=", "$", "this", "->", "flattenComposedTypes", "(", "$", "type", "->", "getComposedTypes", "(", ")", ")", ";", "}", "else", "{", "$", "composedTypes", "[", "$", "type", "->", "getIdentifier", "(", ")", "]", "=", "$", "type", ";", "}", "}", "return", "$", "composedTypes", ";", "}" ]
Flattens all the composed types. @param IType[] $types @return IType[]
[ "Flattens", "all", "the", "composed", "types", "." ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Analysis/TypeSystem.php#L207-L219
TimeToogo/Pinq
Source/Expressions/ReturnExpression.php
ReturnExpression.update
public function update(Expression $value = null) { if ($this->value === $value) { return $this; } return new self($value); }
php
public function update(Expression $value = null) { if ($this->value === $value) { return $this; } return new self($value); }
[ "public", "function", "update", "(", "Expression", "$", "value", "=", "null", ")", "{", "if", "(", "$", "this", "->", "value", "===", "$", "value", ")", "{", "return", "$", "this", ";", "}", "return", "new", "self", "(", "$", "value", ")", ";", "}" ]
@param Expression $value @return self
[ "@param", "Expression", "$value" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Expressions/ReturnExpression.php#L60-L67
TimeToogo/Pinq
Source/Queries/Builders/OperationQueryBuilder.php
OperationQueryBuilder.buildOperationQuery
protected function buildOperationQuery( Queries\IScope $scope, Queries\IOperation $operation ) { return new Queries\OperationQuery($scope, $operation); }
php
protected function buildOperationQuery( Queries\IScope $scope, Queries\IOperation $operation ) { return new Queries\OperationQuery($scope, $operation); }
[ "protected", "function", "buildOperationQuery", "(", "Queries", "\\", "IScope", "$", "scope", ",", "Queries", "\\", "IOperation", "$", "operation", ")", "{", "return", "new", "Queries", "\\", "OperationQuery", "(", "$", "scope", ",", "$", "operation", ")", ";", "}" ]
@param Queries\IScope $scope @param Queries\IOperation $operation @return Queries\IOperationQuery
[ "@param", "Queries", "\\", "IScope", "$scope", "@param", "Queries", "\\", "IOperation", "$operation" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Queries/Builders/OperationQueryBuilder.php#L41-L46
TimeToogo/Pinq
Source/Queries/Builders/OperationQueryBuilder.php
OperationQueryBuilder.buildOperationQueryInterpreter
protected function buildOperationQueryInterpreter( Interpretations\IOperationInterpretation $operationInterpretation, IScopeInterpreter $scopeInterpreter, O\IEvaluationContext $evaluationContext = null ) { return new OperationQueryInterpreter($operationInterpretation, $scopeInterpreter, $evaluationContext); }
php
protected function buildOperationQueryInterpreter( Interpretations\IOperationInterpretation $operationInterpretation, IScopeInterpreter $scopeInterpreter, O\IEvaluationContext $evaluationContext = null ) { return new OperationQueryInterpreter($operationInterpretation, $scopeInterpreter, $evaluationContext); }
[ "protected", "function", "buildOperationQueryInterpreter", "(", "Interpretations", "\\", "IOperationInterpretation", "$", "operationInterpretation", ",", "IScopeInterpreter", "$", "scopeInterpreter", ",", "O", "\\", "IEvaluationContext", "$", "evaluationContext", "=", "null", ")", "{", "return", "new", "OperationQueryInterpreter", "(", "$", "operationInterpretation", ",", "$", "scopeInterpreter", ",", "$", "evaluationContext", ")", ";", "}" ]
@param Interpretations\IOperationInterpretation $operationInterpretation @param IScopeInterpreter $scopeInterpreter @param O\IEvaluationContext $evaluationContext @return IOperationQueryInterpreter
[ "@param", "Interpretations", "\\", "IOperationInterpretation", "$operationInterpretation", "@param", "IScopeInterpreter", "$scopeInterpreter", "@param", "O", "\\", "IEvaluationContext", "$evaluationContext" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Queries/Builders/OperationQueryBuilder.php#L86-L92
TimeToogo/Pinq
Source/Providers/DSL/Compilation/Parameters/ParameterCollection.php
ParameterCollection.addExpression
public function addExpression( O\Expression $expression, IParameterHasher $hasher, IFunction $context = null, $data = null ) { $this->parameters[] = new ExpressionParameter($expression, $hasher, $context, $data); }
php
public function addExpression( O\Expression $expression, IParameterHasher $hasher, IFunction $context = null, $data = null ) { $this->parameters[] = new ExpressionParameter($expression, $hasher, $context, $data); }
[ "public", "function", "addExpression", "(", "O", "\\", "Expression", "$", "expression", ",", "IParameterHasher", "$", "hasher", ",", "IFunction", "$", "context", "=", "null", ",", "$", "data", "=", "null", ")", "{", "$", "this", "->", "parameters", "[", "]", "=", "new", "ExpressionParameter", "(", "$", "expression", ",", "$", "hasher", ",", "$", "context", ",", "$", "data", ")", ";", "}" ]
Adds an expression parameter to the collection. @param O\Expression $expression @param IParameterHasher $hasher @param IFunction|null $context @param mixed $data @return void
[ "Adds", "an", "expression", "parameter", "to", "the", "collection", "." ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Providers/DSL/Compilation/Parameters/ParameterCollection.php#L30-L37
TimeToogo/Pinq
Source/Providers/DSL/Compilation/Parameters/ParameterCollection.php
ParameterCollection.addId
public function addId($parameterId, IParameterHasher $hasher, $data = null) { $this->parameters[] = new StandardParameter($parameterId, $hasher, $data); }
php
public function addId($parameterId, IParameterHasher $hasher, $data = null) { $this->parameters[] = new StandardParameter($parameterId, $hasher, $data); }
[ "public", "function", "addId", "(", "$", "parameterId", ",", "IParameterHasher", "$", "hasher", ",", "$", "data", "=", "null", ")", "{", "$", "this", "->", "parameters", "[", "]", "=", "new", "StandardParameter", "(", "$", "parameterId", ",", "$", "hasher", ",", "$", "data", ")", ";", "}" ]
Adds a standard parameter id to the collection. @param $parameterId @param IParameterHasher $hasher @param mixed $data @return void
[ "Adds", "a", "standard", "parameter", "id", "to", "the", "collection", "." ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Providers/DSL/Compilation/Parameters/ParameterCollection.php#L48-L51
TimeToogo/Pinq
Source/Providers/DSL/Compilation/Parameters/ParameterCollection.php
ParameterCollection.remove
public function remove(IQueryParameter $parameter) { foreach($this->parameters as $key => $someParameter) { if($someParameter === $parameter) { unset($this->parameters[$key]); } } }
php
public function remove(IQueryParameter $parameter) { foreach($this->parameters as $key => $someParameter) { if($someParameter === $parameter) { unset($this->parameters[$key]); } } }
[ "public", "function", "remove", "(", "IQueryParameter", "$", "parameter", ")", "{", "foreach", "(", "$", "this", "->", "parameters", "as", "$", "key", "=>", "$", "someParameter", ")", "{", "if", "(", "$", "someParameter", "===", "$", "parameter", ")", "{", "unset", "(", "$", "this", "->", "parameters", "[", "$", "key", "]", ")", ";", "}", "}", "}" ]
Removes a query parameter from the collection. @param IQueryParameter $parameter @return void
[ "Removes", "a", "query", "parameter", "from", "the", "collection", "." ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Providers/DSL/Compilation/Parameters/ParameterCollection.php#L72-L79
TimeToogo/Pinq
Source/Queries/Common/Join/Options.php
Options.update
public function update( Common\ISource $source, $isGroupJoin, IFilter $filter = null, $hasDefault = false ) { if ($this->source === $source && $this->isGroupJoin === $isGroupJoin && $this->filter === $filter && $this->hasDefault === $hasDefault ) { return $this; } return new self($source, $isGroupJoin, $filter, $hasDefault, $this->defaultValueId, $this->defaultKeyId); }
php
public function update( Common\ISource $source, $isGroupJoin, IFilter $filter = null, $hasDefault = false ) { if ($this->source === $source && $this->isGroupJoin === $isGroupJoin && $this->filter === $filter && $this->hasDefault === $hasDefault ) { return $this; } return new self($source, $isGroupJoin, $filter, $hasDefault, $this->defaultValueId, $this->defaultKeyId); }
[ "public", "function", "update", "(", "Common", "\\", "ISource", "$", "source", ",", "$", "isGroupJoin", ",", "IFilter", "$", "filter", "=", "null", ",", "$", "hasDefault", "=", "false", ")", "{", "if", "(", "$", "this", "->", "source", "===", "$", "source", "&&", "$", "this", "->", "isGroupJoin", "===", "$", "isGroupJoin", "&&", "$", "this", "->", "filter", "===", "$", "filter", "&&", "$", "this", "->", "hasDefault", "===", "$", "hasDefault", ")", "{", "return", "$", "this", ";", "}", "return", "new", "self", "(", "$", "source", ",", "$", "isGroupJoin", ",", "$", "filter", ",", "$", "hasDefault", ",", "$", "this", "->", "defaultValueId", ",", "$", "this", "->", "defaultKeyId", ")", ";", "}" ]
@param Common\ISource $source @param boolean $isGroupJoin @param IFilter|null $filter @param boolean $hasDefault @return Options
[ "@param", "Common", "\\", "ISource", "$source", "@param", "boolean", "$isGroupJoin", "@param", "IFilter|null", "$filter", "@param", "boolean", "$hasDefault" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Queries/Common/Join/Options.php#L137-L152
TimeToogo/Pinq
Source/Queries/Common/Join/Options.php
Options.updateSource
public function updateSource(Common\ISource $source) { return $this->update($source, $this->isGroupJoin, $this->filter, $this->hasDefault); }
php
public function updateSource(Common\ISource $source) { return $this->update($source, $this->isGroupJoin, $this->filter, $this->hasDefault); }
[ "public", "function", "updateSource", "(", "Common", "\\", "ISource", "$", "source", ")", "{", "return", "$", "this", "->", "update", "(", "$", "source", ",", "$", "this", "->", "isGroupJoin", ",", "$", "this", "->", "filter", ",", "$", "this", "->", "hasDefault", ")", ";", "}" ]
@param Common\ISource $source @return Options
[ "@param", "Common", "\\", "ISource", "$source" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Queries/Common/Join/Options.php#L159-L162
TimeToogo/Pinq
Source/Queries/Operations/JoinApply.php
JoinApply.update
public function update( Common\Join\Options $options, Functions\ConnectorMutator $mutatorFunction ) { if ($this->options === $options && $this->mutatorFunction === $mutatorFunction) { return $this; } return new self($options, $mutatorFunction); }
php
public function update( Common\Join\Options $options, Functions\ConnectorMutator $mutatorFunction ) { if ($this->options === $options && $this->mutatorFunction === $mutatorFunction) { return $this; } return new self($options, $mutatorFunction); }
[ "public", "function", "update", "(", "Common", "\\", "Join", "\\", "Options", "$", "options", ",", "Functions", "\\", "ConnectorMutator", "$", "mutatorFunction", ")", "{", "if", "(", "$", "this", "->", "options", "===", "$", "options", "&&", "$", "this", "->", "mutatorFunction", "===", "$", "mutatorFunction", ")", "{", "return", "$", "this", ";", "}", "return", "new", "self", "(", "$", "options", ",", "$", "mutatorFunction", ")", ";", "}" ]
@param Common\Join\Options $options @param Functions\ConnectorMutator $mutatorFunction @return JoinApply
[ "@param", "Common", "\\", "Join", "\\", "Options", "$options", "@param", "Functions", "\\", "ConnectorMutator", "$mutatorFunction" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Queries/Operations/JoinApply.php#L76-L85
TimeToogo/Pinq
Source/Queries/Builders/RequestQueryBuilder.php
RequestQueryBuilder.buildRequestQuery
protected function buildRequestQuery( Queries\IScope $scope, Queries\IRequest $request ) { return new Queries\RequestQuery($scope, $request); }
php
protected function buildRequestQuery( Queries\IScope $scope, Queries\IRequest $request ) { return new Queries\RequestQuery($scope, $request); }
[ "protected", "function", "buildRequestQuery", "(", "Queries", "\\", "IScope", "$", "scope", ",", "Queries", "\\", "IRequest", "$", "request", ")", "{", "return", "new", "Queries", "\\", "RequestQuery", "(", "$", "scope", ",", "$", "request", ")", ";", "}" ]
@param Queries\IScope $scope @param Queries\IRequest $request @return Queries\IRequestQuery
[ "@param", "Queries", "\\", "IScope", "$scope", "@param", "Queries", "\\", "IRequest", "$request" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Queries/Builders/RequestQueryBuilder.php#L36-L41
TimeToogo/Pinq
Source/Queries/Builders/RequestQueryBuilder.php
RequestQueryBuilder.buildRequestQueryInterpreter
protected function buildRequestQueryInterpreter( Interpretations\IRequestInterpretation $requestInterpretation, IScopeInterpreter $scopeInterpreter, O\IEvaluationContext $evaluationContext = null ) { return new RequestQueryInterpreter($requestInterpretation, $scopeInterpreter, $evaluationContext); }
php
protected function buildRequestQueryInterpreter( Interpretations\IRequestInterpretation $requestInterpretation, IScopeInterpreter $scopeInterpreter, O\IEvaluationContext $evaluationContext = null ) { return new RequestQueryInterpreter($requestInterpretation, $scopeInterpreter, $evaluationContext); }
[ "protected", "function", "buildRequestQueryInterpreter", "(", "Interpretations", "\\", "IRequestInterpretation", "$", "requestInterpretation", ",", "IScopeInterpreter", "$", "scopeInterpreter", ",", "O", "\\", "IEvaluationContext", "$", "evaluationContext", "=", "null", ")", "{", "return", "new", "RequestQueryInterpreter", "(", "$", "requestInterpretation", ",", "$", "scopeInterpreter", ",", "$", "evaluationContext", ")", ";", "}" ]
@param Interpretations\IRequestInterpretation $requestInterpretation @param IScopeInterpreter $scopeInterpreter @param O\IEvaluationContext $evaluationContext @return IRequestQueryInterpreter
[ "@param", "Interpretations", "\\", "IRequestInterpretation", "$requestInterpretation", "@param", "IScopeInterpreter", "$scopeInterpreter", "@param", "O", "\\", "IEvaluationContext", "$evaluationContext" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Queries/Builders/RequestQueryBuilder.php#L81-L87
TimeToogo/Pinq
Source/Expressions/IndexExpression.php
IndexExpression.update
public function update(Expression $value, Expression $index = null) { if ($this->value === $value && $this->index === $index) { return $this; } return new self($value, $index); }
php
public function update(Expression $value, Expression $index = null) { if ($this->value === $value && $this->index === $index) { return $this; } return new self($value, $index); }
[ "public", "function", "update", "(", "Expression", "$", "value", ",", "Expression", "$", "index", "=", "null", ")", "{", "if", "(", "$", "this", "->", "value", "===", "$", "value", "&&", "$", "this", "->", "index", "===", "$", "index", ")", "{", "return", "$", "this", ";", "}", "return", "new", "self", "(", "$", "value", ",", "$", "index", ")", ";", "}" ]
@param Expression $value @param Expression|null $index @return self
[ "@param", "Expression", "$value", "@param", "Expression|null", "$index" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Expressions/IndexExpression.php#L51-L58
TimeToogo/Pinq
Source/Queries/Functions/FunctionBase.php
FunctionBase.factory
public static function factory() { $static = get_called_class(); return function ( $callableParameter, $scopeType, $namespace, array $parameterScopedVariableMap, array $parameterExpressions, array $bodyExpressions = null ) use ($static) { return new $static( $callableParameter, $scopeType, $namespace, $parameterScopedVariableMap, $parameterExpressions, $bodyExpressions); }; }
php
public static function factory() { $static = get_called_class(); return function ( $callableParameter, $scopeType, $namespace, array $parameterScopedVariableMap, array $parameterExpressions, array $bodyExpressions = null ) use ($static) { return new $static( $callableParameter, $scopeType, $namespace, $parameterScopedVariableMap, $parameterExpressions, $bodyExpressions); }; }
[ "public", "static", "function", "factory", "(", ")", "{", "$", "static", "=", "get_called_class", "(", ")", ";", "return", "function", "(", "$", "callableParameter", ",", "$", "scopeType", ",", "$", "namespace", ",", "array", "$", "parameterScopedVariableMap", ",", "array", "$", "parameterExpressions", ",", "array", "$", "bodyExpressions", "=", "null", ")", "use", "(", "$", "static", ")", "{", "return", "new", "$", "static", "(", "$", "callableParameter", ",", "$", "scopeType", ",", "$", "namespace", ",", "$", "parameterScopedVariableMap", ",", "$", "parameterExpressions", ",", "$", "bodyExpressions", ")", ";", "}", ";", "}" ]
Gets a callable factory for the function structure. @return callable
[ "Gets", "a", "callable", "factory", "for", "the", "function", "structure", "." ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Queries/Functions/FunctionBase.php#L72-L92
TimeToogo/Pinq
Source/Expressions/ParameterExpression.php
ParameterExpression.update
public function update($name, $typeHint, Expression $defaultValue = null, $isPassedByReference, $isVariadic) { if ($this->name === $name && $this->typeHint === $typeHint && $this->defaultValue === $defaultValue && $this->isPassedByReference === $isPassedByReference && $this->isVariadic === $isVariadic ) { return $this; } return new self( $name, $typeHint, $defaultValue, $isPassedByReference, $isVariadic); }
php
public function update($name, $typeHint, Expression $defaultValue = null, $isPassedByReference, $isVariadic) { if ($this->name === $name && $this->typeHint === $typeHint && $this->defaultValue === $defaultValue && $this->isPassedByReference === $isPassedByReference && $this->isVariadic === $isVariadic ) { return $this; } return new self( $name, $typeHint, $defaultValue, $isPassedByReference, $isVariadic); }
[ "public", "function", "update", "(", "$", "name", ",", "$", "typeHint", ",", "Expression", "$", "defaultValue", "=", "null", ",", "$", "isPassedByReference", ",", "$", "isVariadic", ")", "{", "if", "(", "$", "this", "->", "name", "===", "$", "name", "&&", "$", "this", "->", "typeHint", "===", "$", "typeHint", "&&", "$", "this", "->", "defaultValue", "===", "$", "defaultValue", "&&", "$", "this", "->", "isPassedByReference", "===", "$", "isPassedByReference", "&&", "$", "this", "->", "isVariadic", "===", "$", "isVariadic", ")", "{", "return", "$", "this", ";", "}", "return", "new", "self", "(", "$", "name", ",", "$", "typeHint", ",", "$", "defaultValue", ",", "$", "isPassedByReference", ",", "$", "isVariadic", ")", ";", "}" ]
@param string $name @param string|null $typeHint @param Expression|null $defaultValue @param boolean $isPassedByReference @param boolean $isVariadic @return self
[ "@param", "string", "$name", "@param", "string|null", "$typeHint", "@param", "Expression|null", "$defaultValue", "@param", "boolean", "$isPassedByReference", "@param", "boolean", "$isVariadic" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Expressions/ParameterExpression.php#L122-L139
TimeToogo/Pinq
Source/Providers/DSL/Compilation/Processors/Structure/StructuralExpressionLocator.php
StructuralExpressionLocator.processQuery
public static function processQuery(ParameterCollection $parameters, Queries\IQuery $query, IStructuralExpressionProcessor $processor) { $processor = Expression\ProcessorFactory::from( $query, new self($parameters, $processor) ); $processor->buildQuery(); }
php
public static function processQuery(ParameterCollection $parameters, Queries\IQuery $query, IStructuralExpressionProcessor $processor) { $processor = Expression\ProcessorFactory::from( $query, new self($parameters, $processor) ); $processor->buildQuery(); }
[ "public", "static", "function", "processQuery", "(", "ParameterCollection", "$", "parameters", ",", "Queries", "\\", "IQuery", "$", "query", ",", "IStructuralExpressionProcessor", "$", "processor", ")", "{", "$", "processor", "=", "Expression", "\\", "ProcessorFactory", "::", "from", "(", "$", "query", ",", "new", "self", "(", "$", "parameters", ",", "$", "processor", ")", ")", ";", "$", "processor", "->", "buildQuery", "(", ")", ";", "}" ]
@param ParameterCollection $parameters @param Queries\IQuery $query @param IStructuralExpressionProcessor $processor @return void
[ "@param", "ParameterCollection", "$parameters", "@param", "Queries", "\\", "IQuery", "$query", "@param", "IStructuralExpressionProcessor", "$processor" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Providers/DSL/Compilation/Processors/Structure/StructuralExpressionLocator.php#L37-L44
TimeToogo/Pinq
Source/Expressions/ClosureExpression.php
ClosureExpression.update
public function update( $returnsReference, $isStatic, array $parameterExpressions, array $usedVariables, array $bodyExpressions ) { if ($this->returnsReference === $returnsReference && $this->isStatic === $isStatic && $this->parameters === $parameterExpressions && $this->usedVariables === $usedVariables && $this->bodyExpressions === $bodyExpressions ) { return $this; } return new self( $returnsReference, $isStatic, $parameterExpressions, $usedVariables, $bodyExpressions); }
php
public function update( $returnsReference, $isStatic, array $parameterExpressions, array $usedVariables, array $bodyExpressions ) { if ($this->returnsReference === $returnsReference && $this->isStatic === $isStatic && $this->parameters === $parameterExpressions && $this->usedVariables === $usedVariables && $this->bodyExpressions === $bodyExpressions ) { return $this; } return new self( $returnsReference, $isStatic, $parameterExpressions, $usedVariables, $bodyExpressions); }
[ "public", "function", "update", "(", "$", "returnsReference", ",", "$", "isStatic", ",", "array", "$", "parameterExpressions", ",", "array", "$", "usedVariables", ",", "array", "$", "bodyExpressions", ")", "{", "if", "(", "$", "this", "->", "returnsReference", "===", "$", "returnsReference", "&&", "$", "this", "->", "isStatic", "===", "$", "isStatic", "&&", "$", "this", "->", "parameters", "===", "$", "parameterExpressions", "&&", "$", "this", "->", "usedVariables", "===", "$", "usedVariables", "&&", "$", "this", "->", "bodyExpressions", "===", "$", "bodyExpressions", ")", "{", "return", "$", "this", ";", "}", "return", "new", "self", "(", "$", "returnsReference", ",", "$", "isStatic", ",", "$", "parameterExpressions", ",", "$", "usedVariables", ",", "$", "bodyExpressions", ")", ";", "}" ]
@param boolean $returnsReference @param boolean $isStatic @param ParameterExpression[] $parameterExpressions @param ClosureUsedVariableExpression[] $usedVariables @param Expression[] $bodyExpressions @return self
[ "@param", "boolean", "$returnsReference", "@param", "boolean", "$isStatic", "@param", "ParameterExpression", "[]", "$parameterExpressions", "@param", "ClosureUsedVariableExpression", "[]", "$usedVariables", "@param", "Expression", "[]", "$bodyExpressions" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Expressions/ClosureExpression.php#L124-L146
TimeToogo/Pinq
Source/Providers/DSL/QueryCompilerConfiguration.php
QueryCompilerConfiguration.buildCompiledRequestQuery
protected function buildCompiledRequestQuery(Queries\IRequestQuery $query) { $compiler = $this->getRequestQueryCompiler($query); $compiler->compile(); return $compiler->getCompilation()->asCompiled(); }
php
protected function buildCompiledRequestQuery(Queries\IRequestQuery $query) { $compiler = $this->getRequestQueryCompiler($query); $compiler->compile(); return $compiler->getCompilation()->asCompiled(); }
[ "protected", "function", "buildCompiledRequestQuery", "(", "Queries", "\\", "IRequestQuery", "$", "query", ")", "{", "$", "compiler", "=", "$", "this", "->", "getRequestQueryCompiler", "(", "$", "query", ")", ";", "$", "compiler", "->", "compile", "(", ")", ";", "return", "$", "compiler", "->", "getCompilation", "(", ")", "->", "asCompiled", "(", ")", ";", "}" ]
@param Queries\IRequestQuery $query @return Compilation\ICompiledRequest
[ "@param", "Queries", "\\", "IRequestQuery", "$query" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Providers/DSL/QueryCompilerConfiguration.php#L229-L235
TimeToogo/Pinq
Source/Queries/Common/Source/QueryScope.php
QueryScope.update
public function update(Queries\IScope $scope) { if ($this->scope === $scope) { return $this; } return new self($scope); }
php
public function update(Queries\IScope $scope) { if ($this->scope === $scope) { return $this; } return new self($scope); }
[ "public", "function", "update", "(", "Queries", "\\", "IScope", "$", "scope", ")", "{", "if", "(", "$", "this", "->", "scope", "===", "$", "scope", ")", "{", "return", "$", "this", ";", "}", "return", "new", "self", "(", "$", "scope", ")", ";", "}" ]
@param Queries\IScope $scope @return QueryScope
[ "@param", "Queries", "\\", "IScope", "$scope" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Queries/Common/Source/QueryScope.php#L54-L61
TimeToogo/Pinq
Source/Analysis/TypeData/PinqAPI.php
PinqAPI.generatePinqTypeData
protected function generatePinqTypeData( $traversableType, $orderedTraversableType, $joiningOnTraversableType, $joiningToTraversableType, $mutable = false ) { $pinqTypes = []; $traversableTypeId = TypeId::getObject($traversableType); $orderedTraversableTypeId = TypeId::getObject($orderedTraversableType); $joiningOnTraversableTypeId = TypeId::getObject($joiningOnTraversableType); $joiningToTraversableTypeId = TypeId::getObject($joiningToTraversableType); $commonMethods = [ 'asArray' => INativeType::TYPE_ARRAY, 'asTraversable' => TypeId::getObject(Pinq\ITraversable::ITRAVERSABLE_TYPE), 'asCollection' => TypeId::getObject(Pinq\ICollection::ICOLLECTION_TYPE), 'isSource' => INativeType::TYPE_BOOL, 'getSource' => $traversableTypeId, 'iterate' => INativeType::TYPE_NULL, 'getIterator' => TypeId::getObject('Traversable'), 'getTrueIterator' => TypeId::getObject('Traversable'), 'getIteratorScheme' => TypeId::getObject(IIteratorScheme::IITERATOR_SCHEME_TYPE), 'first' => INativeType::TYPE_MIXED, 'last' => INativeType::TYPE_MIXED, 'count' => INativeType::TYPE_INT, 'isEmpty' => INativeType::TYPE_BOOL, 'aggregate' => INativeType::TYPE_MIXED, 'maximum' => INativeType::TYPE_MIXED, 'minimum' => INativeType::TYPE_MIXED, 'sum' => INativeType::TYPE_MIXED, 'average' => INativeType::TYPE_MIXED, 'all' => INativeType::TYPE_BOOL, 'any' => INativeType::TYPE_BOOL, 'implode' => INativeType::TYPE_STRING, 'contains' => INativeType::TYPE_BOOL, 'where' => $traversableTypeId, 'orderBy' => $orderedTraversableTypeId, 'orderByAscending' => $orderedTraversableTypeId, 'orderByDescending' => $orderedTraversableTypeId, 'skip' => $traversableTypeId, 'take' => $traversableTypeId, 'slice' => $traversableTypeId, 'indexBy' => $traversableTypeId, 'keys' => $traversableTypeId, 'reindex' => $traversableTypeId, 'groupBy' => $traversableTypeId, 'join' => $joiningOnTraversableTypeId, 'groupJoin' => $joiningOnTraversableTypeId, 'select' => $traversableTypeId, 'selectMany' => $traversableTypeId, 'unique' => $traversableTypeId, 'append' => $traversableTypeId, 'whereIn' => $traversableTypeId, 'except' => $traversableTypeId, 'union' => $traversableTypeId, 'intersect' => $traversableTypeId, 'difference' => $traversableTypeId, ]; if ($mutable) { $commonMethods += [ 'apply' => INativeType::TYPE_NULL, 'addRange' => INativeType::TYPE_NULL, 'remove' => INativeType::TYPE_NULL, 'removeRange' => INativeType::TYPE_NULL, 'removeWhere' => INativeType::TYPE_NULL, 'clear' => INativeType::TYPE_NULL, ]; } $pinqTypes[$traversableType] = [ 'methods' => $commonMethods ]; $pinqTypes[$orderedTraversableType] = [ 'methods' => [ 'thenBy' => $orderedTraversableTypeId, 'thenByAscending' => $orderedTraversableTypeId, 'thenByDescending' => $orderedTraversableTypeId, ] + $commonMethods ]; $joiningMethods = [ 'withDefault' => $joiningToTraversableTypeId, 'to' => $traversableTypeId, ]; if ($mutable) { $joiningMethods += [ 'apply' => INativeType::TYPE_NULL, ]; } $pinqTypes[$joiningToTraversableType] = [ 'methods' => $joiningMethods ]; $pinqTypes[$joiningOnTraversableType] = [ 'methods' => [ 'on' => $joiningToTraversableTypeId, 'onEquality' => $joiningToTraversableTypeId, ] + $joiningMethods ]; return $pinqTypes; }
php
protected function generatePinqTypeData( $traversableType, $orderedTraversableType, $joiningOnTraversableType, $joiningToTraversableType, $mutable = false ) { $pinqTypes = []; $traversableTypeId = TypeId::getObject($traversableType); $orderedTraversableTypeId = TypeId::getObject($orderedTraversableType); $joiningOnTraversableTypeId = TypeId::getObject($joiningOnTraversableType); $joiningToTraversableTypeId = TypeId::getObject($joiningToTraversableType); $commonMethods = [ 'asArray' => INativeType::TYPE_ARRAY, 'asTraversable' => TypeId::getObject(Pinq\ITraversable::ITRAVERSABLE_TYPE), 'asCollection' => TypeId::getObject(Pinq\ICollection::ICOLLECTION_TYPE), 'isSource' => INativeType::TYPE_BOOL, 'getSource' => $traversableTypeId, 'iterate' => INativeType::TYPE_NULL, 'getIterator' => TypeId::getObject('Traversable'), 'getTrueIterator' => TypeId::getObject('Traversable'), 'getIteratorScheme' => TypeId::getObject(IIteratorScheme::IITERATOR_SCHEME_TYPE), 'first' => INativeType::TYPE_MIXED, 'last' => INativeType::TYPE_MIXED, 'count' => INativeType::TYPE_INT, 'isEmpty' => INativeType::TYPE_BOOL, 'aggregate' => INativeType::TYPE_MIXED, 'maximum' => INativeType::TYPE_MIXED, 'minimum' => INativeType::TYPE_MIXED, 'sum' => INativeType::TYPE_MIXED, 'average' => INativeType::TYPE_MIXED, 'all' => INativeType::TYPE_BOOL, 'any' => INativeType::TYPE_BOOL, 'implode' => INativeType::TYPE_STRING, 'contains' => INativeType::TYPE_BOOL, 'where' => $traversableTypeId, 'orderBy' => $orderedTraversableTypeId, 'orderByAscending' => $orderedTraversableTypeId, 'orderByDescending' => $orderedTraversableTypeId, 'skip' => $traversableTypeId, 'take' => $traversableTypeId, 'slice' => $traversableTypeId, 'indexBy' => $traversableTypeId, 'keys' => $traversableTypeId, 'reindex' => $traversableTypeId, 'groupBy' => $traversableTypeId, 'join' => $joiningOnTraversableTypeId, 'groupJoin' => $joiningOnTraversableTypeId, 'select' => $traversableTypeId, 'selectMany' => $traversableTypeId, 'unique' => $traversableTypeId, 'append' => $traversableTypeId, 'whereIn' => $traversableTypeId, 'except' => $traversableTypeId, 'union' => $traversableTypeId, 'intersect' => $traversableTypeId, 'difference' => $traversableTypeId, ]; if ($mutable) { $commonMethods += [ 'apply' => INativeType::TYPE_NULL, 'addRange' => INativeType::TYPE_NULL, 'remove' => INativeType::TYPE_NULL, 'removeRange' => INativeType::TYPE_NULL, 'removeWhere' => INativeType::TYPE_NULL, 'clear' => INativeType::TYPE_NULL, ]; } $pinqTypes[$traversableType] = [ 'methods' => $commonMethods ]; $pinqTypes[$orderedTraversableType] = [ 'methods' => [ 'thenBy' => $orderedTraversableTypeId, 'thenByAscending' => $orderedTraversableTypeId, 'thenByDescending' => $orderedTraversableTypeId, ] + $commonMethods ]; $joiningMethods = [ 'withDefault' => $joiningToTraversableTypeId, 'to' => $traversableTypeId, ]; if ($mutable) { $joiningMethods += [ 'apply' => INativeType::TYPE_NULL, ]; } $pinqTypes[$joiningToTraversableType] = [ 'methods' => $joiningMethods ]; $pinqTypes[$joiningOnTraversableType] = [ 'methods' => [ 'on' => $joiningToTraversableTypeId, 'onEquality' => $joiningToTraversableTypeId, ] + $joiningMethods ]; return $pinqTypes; }
[ "protected", "function", "generatePinqTypeData", "(", "$", "traversableType", ",", "$", "orderedTraversableType", ",", "$", "joiningOnTraversableType", ",", "$", "joiningToTraversableType", ",", "$", "mutable", "=", "false", ")", "{", "$", "pinqTypes", "=", "[", "]", ";", "$", "traversableTypeId", "=", "TypeId", "::", "getObject", "(", "$", "traversableType", ")", ";", "$", "orderedTraversableTypeId", "=", "TypeId", "::", "getObject", "(", "$", "orderedTraversableType", ")", ";", "$", "joiningOnTraversableTypeId", "=", "TypeId", "::", "getObject", "(", "$", "joiningOnTraversableType", ")", ";", "$", "joiningToTraversableTypeId", "=", "TypeId", "::", "getObject", "(", "$", "joiningToTraversableType", ")", ";", "$", "commonMethods", "=", "[", "'asArray'", "=>", "INativeType", "::", "TYPE_ARRAY", ",", "'asTraversable'", "=>", "TypeId", "::", "getObject", "(", "Pinq", "\\", "ITraversable", "::", "ITRAVERSABLE_TYPE", ")", ",", "'asCollection'", "=>", "TypeId", "::", "getObject", "(", "Pinq", "\\", "ICollection", "::", "ICOLLECTION_TYPE", ")", ",", "'isSource'", "=>", "INativeType", "::", "TYPE_BOOL", ",", "'getSource'", "=>", "$", "traversableTypeId", ",", "'iterate'", "=>", "INativeType", "::", "TYPE_NULL", ",", "'getIterator'", "=>", "TypeId", "::", "getObject", "(", "'Traversable'", ")", ",", "'getTrueIterator'", "=>", "TypeId", "::", "getObject", "(", "'Traversable'", ")", ",", "'getIteratorScheme'", "=>", "TypeId", "::", "getObject", "(", "IIteratorScheme", "::", "IITERATOR_SCHEME_TYPE", ")", ",", "'first'", "=>", "INativeType", "::", "TYPE_MIXED", ",", "'last'", "=>", "INativeType", "::", "TYPE_MIXED", ",", "'count'", "=>", "INativeType", "::", "TYPE_INT", ",", "'isEmpty'", "=>", "INativeType", "::", "TYPE_BOOL", ",", "'aggregate'", "=>", "INativeType", "::", "TYPE_MIXED", ",", "'maximum'", "=>", "INativeType", "::", "TYPE_MIXED", ",", "'minimum'", "=>", "INativeType", "::", "TYPE_MIXED", ",", "'sum'", "=>", "INativeType", "::", "TYPE_MIXED", ",", "'average'", "=>", "INativeType", "::", "TYPE_MIXED", ",", "'all'", "=>", "INativeType", "::", "TYPE_BOOL", ",", "'any'", "=>", "INativeType", "::", "TYPE_BOOL", ",", "'implode'", "=>", "INativeType", "::", "TYPE_STRING", ",", "'contains'", "=>", "INativeType", "::", "TYPE_BOOL", ",", "'where'", "=>", "$", "traversableTypeId", ",", "'orderBy'", "=>", "$", "orderedTraversableTypeId", ",", "'orderByAscending'", "=>", "$", "orderedTraversableTypeId", ",", "'orderByDescending'", "=>", "$", "orderedTraversableTypeId", ",", "'skip'", "=>", "$", "traversableTypeId", ",", "'take'", "=>", "$", "traversableTypeId", ",", "'slice'", "=>", "$", "traversableTypeId", ",", "'indexBy'", "=>", "$", "traversableTypeId", ",", "'keys'", "=>", "$", "traversableTypeId", ",", "'reindex'", "=>", "$", "traversableTypeId", ",", "'groupBy'", "=>", "$", "traversableTypeId", ",", "'join'", "=>", "$", "joiningOnTraversableTypeId", ",", "'groupJoin'", "=>", "$", "joiningOnTraversableTypeId", ",", "'select'", "=>", "$", "traversableTypeId", ",", "'selectMany'", "=>", "$", "traversableTypeId", ",", "'unique'", "=>", "$", "traversableTypeId", ",", "'append'", "=>", "$", "traversableTypeId", ",", "'whereIn'", "=>", "$", "traversableTypeId", ",", "'except'", "=>", "$", "traversableTypeId", ",", "'union'", "=>", "$", "traversableTypeId", ",", "'intersect'", "=>", "$", "traversableTypeId", ",", "'difference'", "=>", "$", "traversableTypeId", ",", "]", ";", "if", "(", "$", "mutable", ")", "{", "$", "commonMethods", "+=", "[", "'apply'", "=>", "INativeType", "::", "TYPE_NULL", ",", "'addRange'", "=>", "INativeType", "::", "TYPE_NULL", ",", "'remove'", "=>", "INativeType", "::", "TYPE_NULL", ",", "'removeRange'", "=>", "INativeType", "::", "TYPE_NULL", ",", "'removeWhere'", "=>", "INativeType", "::", "TYPE_NULL", ",", "'clear'", "=>", "INativeType", "::", "TYPE_NULL", ",", "]", ";", "}", "$", "pinqTypes", "[", "$", "traversableType", "]", "=", "[", "'methods'", "=>", "$", "commonMethods", "]", ";", "$", "pinqTypes", "[", "$", "orderedTraversableType", "]", "=", "[", "'methods'", "=>", "[", "'thenBy'", "=>", "$", "orderedTraversableTypeId", ",", "'thenByAscending'", "=>", "$", "orderedTraversableTypeId", ",", "'thenByDescending'", "=>", "$", "orderedTraversableTypeId", ",", "]", "+", "$", "commonMethods", "]", ";", "$", "joiningMethods", "=", "[", "'withDefault'", "=>", "$", "joiningToTraversableTypeId", ",", "'to'", "=>", "$", "traversableTypeId", ",", "]", ";", "if", "(", "$", "mutable", ")", "{", "$", "joiningMethods", "+=", "[", "'apply'", "=>", "INativeType", "::", "TYPE_NULL", ",", "]", ";", "}", "$", "pinqTypes", "[", "$", "joiningToTraversableType", "]", "=", "[", "'methods'", "=>", "$", "joiningMethods", "]", ";", "$", "pinqTypes", "[", "$", "joiningOnTraversableType", "]", "=", "[", "'methods'", "=>", "[", "'on'", "=>", "$", "joiningToTraversableTypeId", ",", "'onEquality'", "=>", "$", "joiningToTraversableTypeId", ",", "]", "+", "$", "joiningMethods", "]", ";", "return", "$", "pinqTypes", ";", "}" ]
@param string $traversableType @param string $orderedTraversableType @param string $joiningOnTraversableType @param string $joiningToTraversableType @param bool $mutable @return array
[ "@param", "string", "$traversableType", "@param", "string", "$orderedTraversableType", "@param", "string", "$joiningOnTraversableType", "@param", "string", "$joiningToTraversableType", "@param", "bool", "$mutable" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Analysis/TypeData/PinqAPI.php#L68-L174
TimeToogo/Pinq
Source/Expressions/CompiledEvaluator.php
CompiledEvaluator.fromExpressions
public static function fromExpressions(array $expressions, IEvaluationContext $context = null) { $evaluator = new self($context); $namespace = $evaluator->context->getNamespace(); $contextParameterName = self::CONTEXT_PARAMETER_NAME; $variableTable = $evaluator->context->getVariableTable(); //Replace any non value types with references in the variable table. $expressions = (new DynamicExpressionWalker([ ValueExpression::getType() => function (ValueExpression $expression) use ($evaluator, $variableTable, &$name) { $value = $expression->getValue(); if (!ValueExpression::isValueType($value)) { $name = $name !== null ? $name : 0; do { $name++; } while (isset($variableTable['o' . $name])); $name = 'o' . $name; $evaluator->extraVariables[$name] = $value; return Expression::variable(Expression::value($name)); } return $expression; } ]))->walkAll($expressions); $bodyCode = ''; foreach ($evaluator->extraVariables + $variableTable as $variable => $value) { $variableName = Expression::value($variable); $variableCode = Expression::variable($variableName)->compile(); $bodyCode .= "$variableCode =& $$contextParameterName" . '[' . $variableName->compile() . '];'; } $bodyCode .= "unset($$contextParameterName);"; $bodyCode .= implode(';', Expression::compileAll($expressions)) . ';'; $evaluator->code = <<<PHP namespace {$namespace} { return function ($$contextParameterName) { $bodyCode }; } PHP; $evaluator->initializeEvaluator(); return $evaluator; }
php
public static function fromExpressions(array $expressions, IEvaluationContext $context = null) { $evaluator = new self($context); $namespace = $evaluator->context->getNamespace(); $contextParameterName = self::CONTEXT_PARAMETER_NAME; $variableTable = $evaluator->context->getVariableTable(); //Replace any non value types with references in the variable table. $expressions = (new DynamicExpressionWalker([ ValueExpression::getType() => function (ValueExpression $expression) use ($evaluator, $variableTable, &$name) { $value = $expression->getValue(); if (!ValueExpression::isValueType($value)) { $name = $name !== null ? $name : 0; do { $name++; } while (isset($variableTable['o' . $name])); $name = 'o' . $name; $evaluator->extraVariables[$name] = $value; return Expression::variable(Expression::value($name)); } return $expression; } ]))->walkAll($expressions); $bodyCode = ''; foreach ($evaluator->extraVariables + $variableTable as $variable => $value) { $variableName = Expression::value($variable); $variableCode = Expression::variable($variableName)->compile(); $bodyCode .= "$variableCode =& $$contextParameterName" . '[' . $variableName->compile() . '];'; } $bodyCode .= "unset($$contextParameterName);"; $bodyCode .= implode(';', Expression::compileAll($expressions)) . ';'; $evaluator->code = <<<PHP namespace {$namespace} { return function ($$contextParameterName) { $bodyCode }; } PHP; $evaluator->initializeEvaluator(); return $evaluator; }
[ "public", "static", "function", "fromExpressions", "(", "array", "$", "expressions", ",", "IEvaluationContext", "$", "context", "=", "null", ")", "{", "$", "evaluator", "=", "new", "self", "(", "$", "context", ")", ";", "$", "namespace", "=", "$", "evaluator", "->", "context", "->", "getNamespace", "(", ")", ";", "$", "contextParameterName", "=", "self", "::", "CONTEXT_PARAMETER_NAME", ";", "$", "variableTable", "=", "$", "evaluator", "->", "context", "->", "getVariableTable", "(", ")", ";", "//Replace any non value types with references in the variable table.", "$", "expressions", "=", "(", "new", "DynamicExpressionWalker", "(", "[", "ValueExpression", "::", "getType", "(", ")", "=>", "function", "(", "ValueExpression", "$", "expression", ")", "use", "(", "$", "evaluator", ",", "$", "variableTable", ",", "&", "$", "name", ")", "{", "$", "value", "=", "$", "expression", "->", "getValue", "(", ")", ";", "if", "(", "!", "ValueExpression", "::", "isValueType", "(", "$", "value", ")", ")", "{", "$", "name", "=", "$", "name", "!==", "null", "?", "$", "name", ":", "0", ";", "do", "{", "$", "name", "++", ";", "}", "while", "(", "isset", "(", "$", "variableTable", "[", "'o'", ".", "$", "name", "]", ")", ")", ";", "$", "name", "=", "'o'", ".", "$", "name", ";", "$", "evaluator", "->", "extraVariables", "[", "$", "name", "]", "=", "$", "value", ";", "return", "Expression", "::", "variable", "(", "Expression", "::", "value", "(", "$", "name", ")", ")", ";", "}", "return", "$", "expression", ";", "}", "]", ")", ")", "->", "walkAll", "(", "$", "expressions", ")", ";", "$", "bodyCode", "=", "''", ";", "foreach", "(", "$", "evaluator", "->", "extraVariables", "+", "$", "variableTable", "as", "$", "variable", "=>", "$", "value", ")", "{", "$", "variableName", "=", "Expression", "::", "value", "(", "$", "variable", ")", ";", "$", "variableCode", "=", "Expression", "::", "variable", "(", "$", "variableName", ")", "->", "compile", "(", ")", ";", "$", "bodyCode", ".=", "\"$variableCode =& $$contextParameterName\"", ".", "'['", ".", "$", "variableName", "->", "compile", "(", ")", ".", "'];'", ";", "}", "$", "bodyCode", ".=", "\"unset($$contextParameterName);\"", ";", "$", "bodyCode", ".=", "implode", "(", "';'", ",", "Expression", "::", "compileAll", "(", "$", "expressions", ")", ")", ".", "';'", ";", "$", "evaluator", "->", "code", "=", " <<<PHP\nnamespace {$namespace} {\n return function ($$contextParameterName) {\n $bodyCode\n };\n}\nPHP", ";", "$", "evaluator", "->", "initializeEvaluator", "(", ")", ";", "return", "$", "evaluator", ";", "}" ]
Creates a new compiled evaluator from the supplied expressions. @param Expression[] $expressions @param IEvaluationContext $context @return CompiledEvaluator
[ "Creates", "a", "new", "compiled", "evaluator", "from", "the", "supplied", "expressions", "." ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Expressions/CompiledEvaluator.php#L42-L90
TimeToogo/Pinq
Source/Parsing/PhpParser/AST.php
AST.parseNode
protected function parseNode(Node $node) { switch (true) { case $node instanceof Node\Stmt: return $this->parseStatementNode($node); case $node instanceof Node\Expr: return $this->parseExpressionNode($node); case $node instanceof Node\Param: return $this->parseParameterNode($node); case $node instanceof Node\Arg: return $this->parseArgumentNode($node); default: throw new ASTException('Unsupported node type: %s', get_class($node)); } }
php
protected function parseNode(Node $node) { switch (true) { case $node instanceof Node\Stmt: return $this->parseStatementNode($node); case $node instanceof Node\Expr: return $this->parseExpressionNode($node); case $node instanceof Node\Param: return $this->parseParameterNode($node); case $node instanceof Node\Arg: return $this->parseArgumentNode($node); default: throw new ASTException('Unsupported node type: %s', get_class($node)); } }
[ "protected", "function", "parseNode", "(", "Node", "$", "node", ")", "{", "switch", "(", "true", ")", "{", "case", "$", "node", "instanceof", "Node", "\\", "Stmt", ":", "return", "$", "this", "->", "parseStatementNode", "(", "$", "node", ")", ";", "case", "$", "node", "instanceof", "Node", "\\", "Expr", ":", "return", "$", "this", "->", "parseExpressionNode", "(", "$", "node", ")", ";", "case", "$", "node", "instanceof", "Node", "\\", "Param", ":", "return", "$", "this", "->", "parseParameterNode", "(", "$", "node", ")", ";", "case", "$", "node", "instanceof", "Node", "\\", "Arg", ":", "return", "$", "this", "->", "parseArgumentNode", "(", "$", "node", ")", ";", "default", ":", "throw", "new", "ASTException", "(", "'Unsupported node type: %s'", ",", "get_class", "(", "$", "node", ")", ")", ";", "}", "}" ]
@param Node $node @throws \Pinq\Parsing\ASTException @return Expression
[ "@param", "Node", "$node" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Parsing/PhpParser/AST.php#L72-L90
TimeToogo/Pinq
Source/Parsing/PhpParser/AST.php
AST.parseNameNode
final public function parseNameNode($node) { if ($node instanceof Node\Name) { return Expression::value($this->parseAbsoluteName($node)); } elseif (is_string($node)) { return Expression::value($node); } return $this->parseNode($node); }
php
final public function parseNameNode($node) { if ($node instanceof Node\Name) { return Expression::value($this->parseAbsoluteName($node)); } elseif (is_string($node)) { return Expression::value($node); } return $this->parseNode($node); }
[ "final", "public", "function", "parseNameNode", "(", "$", "node", ")", "{", "if", "(", "$", "node", "instanceof", "Node", "\\", "Name", ")", "{", "return", "Expression", "::", "value", "(", "$", "this", "->", "parseAbsoluteName", "(", "$", "node", ")", ")", ";", "}", "elseif", "(", "is_string", "(", "$", "node", ")", ")", "{", "return", "Expression", "::", "value", "(", "$", "node", ")", ";", "}", "return", "$", "this", "->", "parseNode", "(", "$", "node", ")", ";", "}" ]
@param $node @return Expression
[ "@param", "$node" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Parsing/PhpParser/AST.php#L97-L106
TimeToogo/Pinq
Source/Parsing/PhpParser/AST.php
AST.parseExpressionNode
public function parseExpressionNode(Node\Expr $node) { switch (true) { case $mappedNode = $this->parseOperatorNode($node): return $mappedNode; case $node instanceof Node\Scalar && $mappedNode = $this->parseScalarNode($node): return $mappedNode; case $node instanceof Node\Expr\Variable: return Expression::variable($this->parseNameNode($node->name)); case $node instanceof Node\Expr\Array_: return $this->parseArrayNode($node); case $node instanceof Node\Expr\FuncCall: return $this->parseFunctionCallNode($node); case $node instanceof Node\Expr\New_: return Expression::newExpression( $this->parseNameNode($node->class), $this->parseNodes($node->args) ); case $node instanceof Node\Expr\MethodCall: return Expression::methodCall( $this->parseNode($node->var), $this->parseNameNode($node->name), $this->parseNodes($node->args) ); case $node instanceof Node\Expr\PropertyFetch: return Expression::field( $this->parseNode($node->var), $this->parseNameNode($node->name) ); case $node instanceof Node\Expr\ArrayDimFetch: return Expression::index( $this->parseNode($node->var), $node->dim === null ? null : $this->parseNode($node->dim) ); case $node instanceof Node\Expr\ConstFetch: return Expression::constant($this->parseAbsoluteName($node->name)); case $node instanceof Node\Expr\ClassConstFetch: return Expression::classConstant( $this->parseNameNode($node->class), $node->name ); case $node instanceof Node\Expr\StaticCall: return Expression::staticMethodCall( $this->parseNameNode($node->class), $this->parseNameNode($node->name), $this->parseNodes($node->args) ); case $node instanceof Node\Expr\StaticPropertyFetch: return Expression::staticField( $this->parseNameNode($node->class), $this->parseNameNode($node->name) ); case $node instanceof Node\Expr\Ternary: return $this->parseTernaryNode($node); case $node instanceof Node\Expr\Closure: return $this->parseClosureNode($node); case $node instanceof Node\Expr\Empty_: return Expression::emptyExpression($this->parseNode($node->expr)); case $node instanceof Node\Expr\Isset_: return Expression::issetExpression($this->parseNodes($node->vars)); default: throw new ASTException( 'Cannot parse AST with unknown expression node: %s', get_class($node)); } }
php
public function parseExpressionNode(Node\Expr $node) { switch (true) { case $mappedNode = $this->parseOperatorNode($node): return $mappedNode; case $node instanceof Node\Scalar && $mappedNode = $this->parseScalarNode($node): return $mappedNode; case $node instanceof Node\Expr\Variable: return Expression::variable($this->parseNameNode($node->name)); case $node instanceof Node\Expr\Array_: return $this->parseArrayNode($node); case $node instanceof Node\Expr\FuncCall: return $this->parseFunctionCallNode($node); case $node instanceof Node\Expr\New_: return Expression::newExpression( $this->parseNameNode($node->class), $this->parseNodes($node->args) ); case $node instanceof Node\Expr\MethodCall: return Expression::methodCall( $this->parseNode($node->var), $this->parseNameNode($node->name), $this->parseNodes($node->args) ); case $node instanceof Node\Expr\PropertyFetch: return Expression::field( $this->parseNode($node->var), $this->parseNameNode($node->name) ); case $node instanceof Node\Expr\ArrayDimFetch: return Expression::index( $this->parseNode($node->var), $node->dim === null ? null : $this->parseNode($node->dim) ); case $node instanceof Node\Expr\ConstFetch: return Expression::constant($this->parseAbsoluteName($node->name)); case $node instanceof Node\Expr\ClassConstFetch: return Expression::classConstant( $this->parseNameNode($node->class), $node->name ); case $node instanceof Node\Expr\StaticCall: return Expression::staticMethodCall( $this->parseNameNode($node->class), $this->parseNameNode($node->name), $this->parseNodes($node->args) ); case $node instanceof Node\Expr\StaticPropertyFetch: return Expression::staticField( $this->parseNameNode($node->class), $this->parseNameNode($node->name) ); case $node instanceof Node\Expr\Ternary: return $this->parseTernaryNode($node); case $node instanceof Node\Expr\Closure: return $this->parseClosureNode($node); case $node instanceof Node\Expr\Empty_: return Expression::emptyExpression($this->parseNode($node->expr)); case $node instanceof Node\Expr\Isset_: return Expression::issetExpression($this->parseNodes($node->vars)); default: throw new ASTException( 'Cannot parse AST with unknown expression node: %s', get_class($node)); } }
[ "public", "function", "parseExpressionNode", "(", "Node", "\\", "Expr", "$", "node", ")", "{", "switch", "(", "true", ")", "{", "case", "$", "mappedNode", "=", "$", "this", "->", "parseOperatorNode", "(", "$", "node", ")", ":", "return", "$", "mappedNode", ";", "case", "$", "node", "instanceof", "Node", "\\", "Scalar", "&&", "$", "mappedNode", "=", "$", "this", "->", "parseScalarNode", "(", "$", "node", ")", ":", "return", "$", "mappedNode", ";", "case", "$", "node", "instanceof", "Node", "\\", "Expr", "\\", "Variable", ":", "return", "Expression", "::", "variable", "(", "$", "this", "->", "parseNameNode", "(", "$", "node", "->", "name", ")", ")", ";", "case", "$", "node", "instanceof", "Node", "\\", "Expr", "\\", "Array_", ":", "return", "$", "this", "->", "parseArrayNode", "(", "$", "node", ")", ";", "case", "$", "node", "instanceof", "Node", "\\", "Expr", "\\", "FuncCall", ":", "return", "$", "this", "->", "parseFunctionCallNode", "(", "$", "node", ")", ";", "case", "$", "node", "instanceof", "Node", "\\", "Expr", "\\", "New_", ":", "return", "Expression", "::", "newExpression", "(", "$", "this", "->", "parseNameNode", "(", "$", "node", "->", "class", ")", ",", "$", "this", "->", "parseNodes", "(", "$", "node", "->", "args", ")", ")", ";", "case", "$", "node", "instanceof", "Node", "\\", "Expr", "\\", "MethodCall", ":", "return", "Expression", "::", "methodCall", "(", "$", "this", "->", "parseNode", "(", "$", "node", "->", "var", ")", ",", "$", "this", "->", "parseNameNode", "(", "$", "node", "->", "name", ")", ",", "$", "this", "->", "parseNodes", "(", "$", "node", "->", "args", ")", ")", ";", "case", "$", "node", "instanceof", "Node", "\\", "Expr", "\\", "PropertyFetch", ":", "return", "Expression", "::", "field", "(", "$", "this", "->", "parseNode", "(", "$", "node", "->", "var", ")", ",", "$", "this", "->", "parseNameNode", "(", "$", "node", "->", "name", ")", ")", ";", "case", "$", "node", "instanceof", "Node", "\\", "Expr", "\\", "ArrayDimFetch", ":", "return", "Expression", "::", "index", "(", "$", "this", "->", "parseNode", "(", "$", "node", "->", "var", ")", ",", "$", "node", "->", "dim", "===", "null", "?", "null", ":", "$", "this", "->", "parseNode", "(", "$", "node", "->", "dim", ")", ")", ";", "case", "$", "node", "instanceof", "Node", "\\", "Expr", "\\", "ConstFetch", ":", "return", "Expression", "::", "constant", "(", "$", "this", "->", "parseAbsoluteName", "(", "$", "node", "->", "name", ")", ")", ";", "case", "$", "node", "instanceof", "Node", "\\", "Expr", "\\", "ClassConstFetch", ":", "return", "Expression", "::", "classConstant", "(", "$", "this", "->", "parseNameNode", "(", "$", "node", "->", "class", ")", ",", "$", "node", "->", "name", ")", ";", "case", "$", "node", "instanceof", "Node", "\\", "Expr", "\\", "StaticCall", ":", "return", "Expression", "::", "staticMethodCall", "(", "$", "this", "->", "parseNameNode", "(", "$", "node", "->", "class", ")", ",", "$", "this", "->", "parseNameNode", "(", "$", "node", "->", "name", ")", ",", "$", "this", "->", "parseNodes", "(", "$", "node", "->", "args", ")", ")", ";", "case", "$", "node", "instanceof", "Node", "\\", "Expr", "\\", "StaticPropertyFetch", ":", "return", "Expression", "::", "staticField", "(", "$", "this", "->", "parseNameNode", "(", "$", "node", "->", "class", ")", ",", "$", "this", "->", "parseNameNode", "(", "$", "node", "->", "name", ")", ")", ";", "case", "$", "node", "instanceof", "Node", "\\", "Expr", "\\", "Ternary", ":", "return", "$", "this", "->", "parseTernaryNode", "(", "$", "node", ")", ";", "case", "$", "node", "instanceof", "Node", "\\", "Expr", "\\", "Closure", ":", "return", "$", "this", "->", "parseClosureNode", "(", "$", "node", ")", ";", "case", "$", "node", "instanceof", "Node", "\\", "Expr", "\\", "Empty_", ":", "return", "Expression", "::", "emptyExpression", "(", "$", "this", "->", "parseNode", "(", "$", "node", "->", "expr", ")", ")", ";", "case", "$", "node", "instanceof", "Node", "\\", "Expr", "\\", "Isset_", ":", "return", "Expression", "::", "issetExpression", "(", "$", "this", "->", "parseNodes", "(", "$", "node", "->", "vars", ")", ")", ";", "default", ":", "throw", "new", "ASTException", "(", "'Cannot parse AST with unknown expression node: %s'", ",", "get_class", "(", "$", "node", ")", ")", ";", "}", "}" ]
<editor-fold defaultstate="collapsed" desc="Expression node parsers">
[ "<editor", "-", "fold", "defaultstate", "=", "collapsed", "desc", "=", "Expression", "node", "parsers", ">" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Parsing/PhpParser/AST.php#L143-L226
TimeToogo/Pinq
Source/Parsing/PhpParser/AST.php
AST.parseStatementNode
private function parseStatementNode(Node\Stmt $node) { switch (true) { case $node instanceof Node\Stmt\Return_: return Expression::returnExpression($node->expr !== null ? $this->parseNode($node->expr) : null); case $node instanceof Node\Stmt\Throw_: return Expression::throwExpression($this->parseNode($node->expr)); case $node instanceof Node\Stmt\Unset_: return Expression::unsetExpression($this->parseNodes($node->vars)); default: $this->verifyNotControlStructure($node); throw new ASTException( 'Cannot parse AST with unknown statement node: %s', get_class($node)); } }
php
private function parseStatementNode(Node\Stmt $node) { switch (true) { case $node instanceof Node\Stmt\Return_: return Expression::returnExpression($node->expr !== null ? $this->parseNode($node->expr) : null); case $node instanceof Node\Stmt\Throw_: return Expression::throwExpression($this->parseNode($node->expr)); case $node instanceof Node\Stmt\Unset_: return Expression::unsetExpression($this->parseNodes($node->vars)); default: $this->verifyNotControlStructure($node); throw new ASTException( 'Cannot parse AST with unknown statement node: %s', get_class($node)); } }
[ "private", "function", "parseStatementNode", "(", "Node", "\\", "Stmt", "$", "node", ")", "{", "switch", "(", "true", ")", "{", "case", "$", "node", "instanceof", "Node", "\\", "Stmt", "\\", "Return_", ":", "return", "Expression", "::", "returnExpression", "(", "$", "node", "->", "expr", "!==", "null", "?", "$", "this", "->", "parseNode", "(", "$", "node", "->", "expr", ")", ":", "null", ")", ";", "case", "$", "node", "instanceof", "Node", "\\", "Stmt", "\\", "Throw_", ":", "return", "Expression", "::", "throwExpression", "(", "$", "this", "->", "parseNode", "(", "$", "node", "->", "expr", ")", ")", ";", "case", "$", "node", "instanceof", "Node", "\\", "Stmt", "\\", "Unset_", ":", "return", "Expression", "::", "unsetExpression", "(", "$", "this", "->", "parseNodes", "(", "$", "node", "->", "vars", ")", ")", ";", "default", ":", "$", "this", "->", "verifyNotControlStructure", "(", "$", "node", ")", ";", "throw", "new", "ASTException", "(", "'Cannot parse AST with unknown statement node: %s'", ",", "get_class", "(", "$", "node", ")", ")", ";", "}", "}" ]
<editor-fold defaultstate="collapsed" desc="Statement node parsers">
[ "<editor", "-", "fold", "defaultstate", "=", "collapsed", "desc", "=", "Statement", "node", "parsers", ">" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Parsing/PhpParser/AST.php#L316-L335
TimeToogo/Pinq
Source/Parsing/PhpParser/AST.php
AST.parseOperatorNode
private function parseOperatorNode(Node\Expr $node) { $nodeType = str_replace('Expr_', '', $node->getType()); switch (true) { case isset(self::$assignOperatorsMap[$nodeType]): return Expression::assign( $this->parseNode($node->var), self::$assignOperatorsMap[$nodeType], $this->parseNode($node->expr) ); case $node instanceof Node\Expr\Instanceof_: return Expression::binaryOperation( $this->parseNode($node->expr), Operators\Binary::IS_INSTANCE_OF, $this->parseNameNode($node->class) ); case isset(self::$binaryOperatorsMap[$nodeType]): return Expression::binaryOperation( $this->parseNode($node->left), self::$binaryOperatorsMap[$nodeType], $this->parseNode($node->right) ); case isset(self::$unaryOperatorsMap[$nodeType]): return Expression::unaryOperation( self::$unaryOperatorsMap[$nodeType], $this->parseNode(isset($node->expr) ? $node->expr : $node->var) ); case isset(self::$castOperatorMap[$nodeType]): return Expression::cast( self::$castOperatorMap[$nodeType], $this->parseNode($node->expr) ); default: return null; } }
php
private function parseOperatorNode(Node\Expr $node) { $nodeType = str_replace('Expr_', '', $node->getType()); switch (true) { case isset(self::$assignOperatorsMap[$nodeType]): return Expression::assign( $this->parseNode($node->var), self::$assignOperatorsMap[$nodeType], $this->parseNode($node->expr) ); case $node instanceof Node\Expr\Instanceof_: return Expression::binaryOperation( $this->parseNode($node->expr), Operators\Binary::IS_INSTANCE_OF, $this->parseNameNode($node->class) ); case isset(self::$binaryOperatorsMap[$nodeType]): return Expression::binaryOperation( $this->parseNode($node->left), self::$binaryOperatorsMap[$nodeType], $this->parseNode($node->right) ); case isset(self::$unaryOperatorsMap[$nodeType]): return Expression::unaryOperation( self::$unaryOperatorsMap[$nodeType], $this->parseNode(isset($node->expr) ? $node->expr : $node->var) ); case isset(self::$castOperatorMap[$nodeType]): return Expression::cast( self::$castOperatorMap[$nodeType], $this->parseNode($node->expr) ); default: return null; } }
[ "private", "function", "parseOperatorNode", "(", "Node", "\\", "Expr", "$", "node", ")", "{", "$", "nodeType", "=", "str_replace", "(", "'Expr_'", ",", "''", ",", "$", "node", "->", "getType", "(", ")", ")", ";", "switch", "(", "true", ")", "{", "case", "isset", "(", "self", "::", "$", "assignOperatorsMap", "[", "$", "nodeType", "]", ")", ":", "return", "Expression", "::", "assign", "(", "$", "this", "->", "parseNode", "(", "$", "node", "->", "var", ")", ",", "self", "::", "$", "assignOperatorsMap", "[", "$", "nodeType", "]", ",", "$", "this", "->", "parseNode", "(", "$", "node", "->", "expr", ")", ")", ";", "case", "$", "node", "instanceof", "Node", "\\", "Expr", "\\", "Instanceof_", ":", "return", "Expression", "::", "binaryOperation", "(", "$", "this", "->", "parseNode", "(", "$", "node", "->", "expr", ")", ",", "Operators", "\\", "Binary", "::", "IS_INSTANCE_OF", ",", "$", "this", "->", "parseNameNode", "(", "$", "node", "->", "class", ")", ")", ";", "case", "isset", "(", "self", "::", "$", "binaryOperatorsMap", "[", "$", "nodeType", "]", ")", ":", "return", "Expression", "::", "binaryOperation", "(", "$", "this", "->", "parseNode", "(", "$", "node", "->", "left", ")", ",", "self", "::", "$", "binaryOperatorsMap", "[", "$", "nodeType", "]", ",", "$", "this", "->", "parseNode", "(", "$", "node", "->", "right", ")", ")", ";", "case", "isset", "(", "self", "::", "$", "unaryOperatorsMap", "[", "$", "nodeType", "]", ")", ":", "return", "Expression", "::", "unaryOperation", "(", "self", "::", "$", "unaryOperatorsMap", "[", "$", "nodeType", "]", ",", "$", "this", "->", "parseNode", "(", "isset", "(", "$", "node", "->", "expr", ")", "?", "$", "node", "->", "expr", ":", "$", "node", "->", "var", ")", ")", ";", "case", "isset", "(", "self", "::", "$", "castOperatorMap", "[", "$", "nodeType", "]", ")", ":", "return", "Expression", "::", "cast", "(", "self", "::", "$", "castOperatorMap", "[", "$", "nodeType", "]", ",", "$", "this", "->", "parseNode", "(", "$", "node", "->", "expr", ")", ")", ";", "default", ":", "return", "null", ";", "}", "}" ]
<editor-fold defaultstate="collapsed" desc="Operator node maps">
[ "<editor", "-", "fold", "defaultstate", "=", "collapsed", "desc", "=", "Operator", "node", "maps", ">" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Parsing/PhpParser/AST.php#L364-L405
TimeToogo/Pinq
Source/Expressions/Operators/Binary.php
Binary.doBinaryOperation
public static function doBinaryOperation($left, $operator, $right) { if (self::$binaryOperations === null) { self::$binaryOperations = [ self::BITWISE_AND => function ($l, $r) { return $l & $r; }, self::BITWISE_OR => function ($l, $r) { return $l | $r; }, self::BITWISE_XOR => function ($l, $r) { return $l ^ $r; }, self::SHIFT_LEFT => function ($l, $r) { return $l << $r; }, self::SHIFT_RIGHT => function ($l, $r) { return $l >> $r; }, self::LOGICAL_AND => function ($l, $r) { return $l && $r; }, self::LOGICAL_OR => function ($l, $r) { return $l || $r; }, self::ADDITION => function ($l, $r) { return $l + $r; }, self::SUBTRACTION => function ($l, $r) { return $l - $r; }, self::MULTIPLICATION => function ($l, $r) { return $l * $r; }, self::DIVISION => function ($l, $r) { return $l / $r; }, self::MODULUS => function ($l, $r) { return $l % $r; }, //Compatible with < PHP 5.6 self::POWER => function ($l, $r) { return pow($l, $r); }, self::CONCATENATION => function ($l, $r) { return $l . $r; }, self::IS_INSTANCE_OF => function ($l, $r) { return $l instanceof $r; }, self::EQUALITY => function ($l, $r) { return $l == $r; }, self::IDENTITY => function ($l, $r) { return $l === $r; }, self::INEQUALITY => function ($l, $r) { return $l != $r; }, self::NOT_IDENTICAL => function ($l, $r) { return $l !== $r; }, self::LESS_THAN => function ($l, $r) { return $l < $r; }, self::LESS_THAN_OR_EQUAL_TO => function ($l, $r) { return $l <= $r; }, self::GREATER_THAN => function ($l, $r) { return $l > $r; }, self::GREATER_THAN_OR_EQUAL_TO => function ($l, $r) { return $l >= $r; }, ]; } if (!isset(self::$binaryOperations[$operator])) { throw new PinqException('Binary operator \'%s\' is not supported', $operator); } $operation = self::$binaryOperations[$operator]; return $operation($left, $right); }
php
public static function doBinaryOperation($left, $operator, $right) { if (self::$binaryOperations === null) { self::$binaryOperations = [ self::BITWISE_AND => function ($l, $r) { return $l & $r; }, self::BITWISE_OR => function ($l, $r) { return $l | $r; }, self::BITWISE_XOR => function ($l, $r) { return $l ^ $r; }, self::SHIFT_LEFT => function ($l, $r) { return $l << $r; }, self::SHIFT_RIGHT => function ($l, $r) { return $l >> $r; }, self::LOGICAL_AND => function ($l, $r) { return $l && $r; }, self::LOGICAL_OR => function ($l, $r) { return $l || $r; }, self::ADDITION => function ($l, $r) { return $l + $r; }, self::SUBTRACTION => function ($l, $r) { return $l - $r; }, self::MULTIPLICATION => function ($l, $r) { return $l * $r; }, self::DIVISION => function ($l, $r) { return $l / $r; }, self::MODULUS => function ($l, $r) { return $l % $r; }, //Compatible with < PHP 5.6 self::POWER => function ($l, $r) { return pow($l, $r); }, self::CONCATENATION => function ($l, $r) { return $l . $r; }, self::IS_INSTANCE_OF => function ($l, $r) { return $l instanceof $r; }, self::EQUALITY => function ($l, $r) { return $l == $r; }, self::IDENTITY => function ($l, $r) { return $l === $r; }, self::INEQUALITY => function ($l, $r) { return $l != $r; }, self::NOT_IDENTICAL => function ($l, $r) { return $l !== $r; }, self::LESS_THAN => function ($l, $r) { return $l < $r; }, self::LESS_THAN_OR_EQUAL_TO => function ($l, $r) { return $l <= $r; }, self::GREATER_THAN => function ($l, $r) { return $l > $r; }, self::GREATER_THAN_OR_EQUAL_TO => function ($l, $r) { return $l >= $r; }, ]; } if (!isset(self::$binaryOperations[$operator])) { throw new PinqException('Binary operator \'%s\' is not supported', $operator); } $operation = self::$binaryOperations[$operator]; return $operation($left, $right); }
[ "public", "static", "function", "doBinaryOperation", "(", "$", "left", ",", "$", "operator", ",", "$", "right", ")", "{", "if", "(", "self", "::", "$", "binaryOperations", "===", "null", ")", "{", "self", "::", "$", "binaryOperations", "=", "[", "self", "::", "BITWISE_AND", "=>", "function", "(", "$", "l", ",", "$", "r", ")", "{", "return", "$", "l", "&", "$", "r", ";", "}", ",", "self", "::", "BITWISE_OR", "=>", "function", "(", "$", "l", ",", "$", "r", ")", "{", "return", "$", "l", "|", "$", "r", ";", "}", ",", "self", "::", "BITWISE_XOR", "=>", "function", "(", "$", "l", ",", "$", "r", ")", "{", "return", "$", "l", "^", "$", "r", ";", "}", ",", "self", "::", "SHIFT_LEFT", "=>", "function", "(", "$", "l", ",", "$", "r", ")", "{", "return", "$", "l", "<<", "$", "r", ";", "}", ",", "self", "::", "SHIFT_RIGHT", "=>", "function", "(", "$", "l", ",", "$", "r", ")", "{", "return", "$", "l", ">>", "$", "r", ";", "}", ",", "self", "::", "LOGICAL_AND", "=>", "function", "(", "$", "l", ",", "$", "r", ")", "{", "return", "$", "l", "&&", "$", "r", ";", "}", ",", "self", "::", "LOGICAL_OR", "=>", "function", "(", "$", "l", ",", "$", "r", ")", "{", "return", "$", "l", "||", "$", "r", ";", "}", ",", "self", "::", "ADDITION", "=>", "function", "(", "$", "l", ",", "$", "r", ")", "{", "return", "$", "l", "+", "$", "r", ";", "}", ",", "self", "::", "SUBTRACTION", "=>", "function", "(", "$", "l", ",", "$", "r", ")", "{", "return", "$", "l", "-", "$", "r", ";", "}", ",", "self", "::", "MULTIPLICATION", "=>", "function", "(", "$", "l", ",", "$", "r", ")", "{", "return", "$", "l", "*", "$", "r", ";", "}", ",", "self", "::", "DIVISION", "=>", "function", "(", "$", "l", ",", "$", "r", ")", "{", "return", "$", "l", "/", "$", "r", ";", "}", ",", "self", "::", "MODULUS", "=>", "function", "(", "$", "l", ",", "$", "r", ")", "{", "return", "$", "l", "%", "$", "r", ";", "}", ",", "//Compatible with < PHP 5.6", "self", "::", "POWER", "=>", "function", "(", "$", "l", ",", "$", "r", ")", "{", "return", "pow", "(", "$", "l", ",", "$", "r", ")", ";", "}", ",", "self", "::", "CONCATENATION", "=>", "function", "(", "$", "l", ",", "$", "r", ")", "{", "return", "$", "l", ".", "$", "r", ";", "}", ",", "self", "::", "IS_INSTANCE_OF", "=>", "function", "(", "$", "l", ",", "$", "r", ")", "{", "return", "$", "l", "instanceof", "$", "r", ";", "}", ",", "self", "::", "EQUALITY", "=>", "function", "(", "$", "l", ",", "$", "r", ")", "{", "return", "$", "l", "==", "$", "r", ";", "}", ",", "self", "::", "IDENTITY", "=>", "function", "(", "$", "l", ",", "$", "r", ")", "{", "return", "$", "l", "===", "$", "r", ";", "}", ",", "self", "::", "INEQUALITY", "=>", "function", "(", "$", "l", ",", "$", "r", ")", "{", "return", "$", "l", "!=", "$", "r", ";", "}", ",", "self", "::", "NOT_IDENTICAL", "=>", "function", "(", "$", "l", ",", "$", "r", ")", "{", "return", "$", "l", "!==", "$", "r", ";", "}", ",", "self", "::", "LESS_THAN", "=>", "function", "(", "$", "l", ",", "$", "r", ")", "{", "return", "$", "l", "<", "$", "r", ";", "}", ",", "self", "::", "LESS_THAN_OR_EQUAL_TO", "=>", "function", "(", "$", "l", ",", "$", "r", ")", "{", "return", "$", "l", "<=", "$", "r", ";", "}", ",", "self", "::", "GREATER_THAN", "=>", "function", "(", "$", "l", ",", "$", "r", ")", "{", "return", "$", "l", ">", "$", "r", ";", "}", ",", "self", "::", "GREATER_THAN_OR_EQUAL_TO", "=>", "function", "(", "$", "l", ",", "$", "r", ")", "{", "return", "$", "l", ">=", "$", "r", ";", "}", ",", "]", ";", "}", "if", "(", "!", "isset", "(", "self", "::", "$", "binaryOperations", "[", "$", "operator", "]", ")", ")", "{", "throw", "new", "PinqException", "(", "'Binary operator \\'%s\\' is not supported'", ",", "$", "operator", ")", ";", "}", "$", "operation", "=", "self", "::", "$", "binaryOperations", "[", "$", "operator", "]", ";", "return", "$", "operation", "(", "$", "left", ",", "$", "right", ")", ";", "}" ]
Performs the binary operation on the supplied values. @param mixed $left @param string $operator @param mixed $right @return mixed @throws PinqException
[ "Performs", "the", "binary", "operation", "on", "the", "supplied", "values", "." ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Expressions/Operators/Binary.php#L55-L93
TimeToogo/Pinq
Source/Expressions/ExpressionWalker.php
ExpressionWalker.walk
final public function walk(Expression $expression = null) { if ($expression === null) { return null; } return $this->doWalk($expression); }
php
final public function walk(Expression $expression = null) { if ($expression === null) { return null; } return $this->doWalk($expression); }
[ "final", "public", "function", "walk", "(", "Expression", "$", "expression", "=", "null", ")", "{", "if", "(", "$", "expression", "===", "null", ")", "{", "return", "null", ";", "}", "return", "$", "this", "->", "doWalk", "(", "$", "expression", ")", ";", "}" ]
Walks the expression tree and returns the updated expression tree. @param Expression $expression @return Expression|null
[ "Walks", "the", "expression", "tree", "and", "returns", "the", "updated", "expression", "tree", "." ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Expressions/ExpressionWalker.php#L19-L26
TimeToogo/Pinq
Source/Expressions/ExpressionWalker.php
ExpressionWalker.doWalkAll
protected function doWalkAll(array $expressions) { foreach ($expressions as $key => $expression) { $expressions[$key] = $this->walk($expression); } return $expressions; }
php
protected function doWalkAll(array $expressions) { foreach ($expressions as $key => $expression) { $expressions[$key] = $this->walk($expression); } return $expressions; }
[ "protected", "function", "doWalkAll", "(", "array", "$", "expressions", ")", "{", "foreach", "(", "$", "expressions", "as", "$", "key", "=>", "$", "expression", ")", "{", "$", "expressions", "[", "$", "key", "]", "=", "$", "this", "->", "walk", "(", "$", "expression", ")", ";", "}", "return", "$", "expressions", ";", "}" ]
@param Expression|null[] $expressions @return Expression[]
[ "@param", "Expression|null", "[]", "$expressions" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Expressions/ExpressionWalker.php#L53-L60
TimeToogo/Pinq
Source/Queries/Common/Join/Filter/Custom.php
Custom.update
public function update(Functions\ConnectorProjection $onFunction) { if ($this->onFunction === $onFunction) { return $this; } return new self($onFunction); }
php
public function update(Functions\ConnectorProjection $onFunction) { if ($this->onFunction === $onFunction) { return $this; } return new self($onFunction); }
[ "public", "function", "update", "(", "Functions", "\\", "ConnectorProjection", "$", "onFunction", ")", "{", "if", "(", "$", "this", "->", "onFunction", "===", "$", "onFunction", ")", "{", "return", "$", "this", ";", "}", "return", "new", "self", "(", "$", "onFunction", ")", ";", "}" ]
@param Functions\ConnectorProjection $onFunction @return Custom
[ "@param", "Functions", "\\", "ConnectorProjection", "$onFunction" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Queries/Common/Join/Filter/Custom.php#L51-L58
TimeToogo/Pinq
Source/Queries/Requests/Aggregate.php
Aggregate.update
public function update(Functions\Aggregator $aggregatorFunction) { if ($this->aggregatorFunction === $aggregatorFunction) { return $this; } return new self($aggregatorFunction); }
php
public function update(Functions\Aggregator $aggregatorFunction) { if ($this->aggregatorFunction === $aggregatorFunction) { return $this; } return new self($aggregatorFunction); }
[ "public", "function", "update", "(", "Functions", "\\", "Aggregator", "$", "aggregatorFunction", ")", "{", "if", "(", "$", "this", "->", "aggregatorFunction", "===", "$", "aggregatorFunction", ")", "{", "return", "$", "this", ";", "}", "return", "new", "self", "(", "$", "aggregatorFunction", ")", ";", "}" ]
@param Functions\Aggregator $aggregatorFunction @return Aggregate
[ "@param", "Functions", "\\", "Aggregator", "$aggregatorFunction" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Queries/Requests/Aggregate.php#L52-L59
TimeToogo/Pinq
Source/Expressions/UnaryOperationExpression.php
UnaryOperationExpression.update
public function update($operator, Expression $operand) { if ($this->operator === $operator && $this->operand === $operand) { return $this; } return new self($operator, $operand); }
php
public function update($operator, Expression $operand) { if ($this->operator === $operator && $this->operand === $operand) { return $this; } return new self($operator, $operand); }
[ "public", "function", "update", "(", "$", "operator", ",", "Expression", "$", "operand", ")", "{", "if", "(", "$", "this", "->", "operator", "===", "$", "operator", "&&", "$", "this", "->", "operand", "===", "$", "operand", ")", "{", "return", "$", "this", ";", "}", "return", "new", "self", "(", "$", "operator", ",", "$", "operand", ")", ";", "}" ]
@param int $operator @param Expression $operand @return self
[ "@param", "int", "$operator", "@param", "Expression", "$operand" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Expressions/UnaryOperationExpression.php#L57-L64
TimeToogo/Pinq
Source/Expressions/ArgumentExpression.php
ArgumentExpression.update
public function update(Expression $value, $isUnpacked) { if ($this->value === $value && $this->isUnpacked === $isUnpacked ) { return $this; } return new self($value, $isUnpacked); }
php
public function update(Expression $value, $isUnpacked) { if ($this->value === $value && $this->isUnpacked === $isUnpacked ) { return $this; } return new self($value, $isUnpacked); }
[ "public", "function", "update", "(", "Expression", "$", "value", ",", "$", "isUnpacked", ")", "{", "if", "(", "$", "this", "->", "value", "===", "$", "value", "&&", "$", "this", "->", "isUnpacked", "===", "$", "isUnpacked", ")", "{", "return", "$", "this", ";", "}", "return", "new", "self", "(", "$", "value", ",", "$", "isUnpacked", ")", ";", "}" ]
@param Expression $value @param boolean $isUnpacked @return self
[ "@param", "Expression", "$value", "@param", "boolean", "$isUnpacked" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Expressions/ArgumentExpression.php#L69-L78
TimeToogo/Pinq
Source/Repository.php
Repository.newMethodSegment
protected function newMethodSegment($name, array $arguments = []) { return $this->repositoryProvider->createRepository($this->newMethod($name, $arguments)); }
php
protected function newMethodSegment($name, array $arguments = []) { return $this->repositoryProvider->createRepository($this->newMethod($name, $arguments)); }
[ "protected", "function", "newMethodSegment", "(", "$", "name", ",", "array", "$", "arguments", "=", "[", "]", ")", "{", "return", "$", "this", "->", "repositoryProvider", "->", "createRepository", "(", "$", "this", "->", "newMethod", "(", "$", "name", ",", "$", "arguments", ")", ")", ";", "}" ]
{@inheritDoc} @return IRepository
[ "{" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Repository.php#L49-L52
TimeToogo/Pinq
Source/Traversable.php
Traversable.from
public static function from($elements, IIteratorScheme $scheme = null, Traversable $source = null) { return new static($elements, $scheme, $source); }
php
public static function from($elements, IIteratorScheme $scheme = null, Traversable $source = null) { return new static($elements, $scheme, $source); }
[ "public", "static", "function", "from", "(", "$", "elements", ",", "IIteratorScheme", "$", "scheme", "=", "null", ",", "Traversable", "$", "source", "=", "null", ")", "{", "return", "new", "static", "(", "$", "elements", ",", "$", "scheme", ",", "$", "source", ")", ";", "}" ]
Constructs a new traversable object from the supplied elements. @param array|\Traversable $elements @param IIteratorScheme|null $scheme @param Traversable|null $source @return ITraversable
[ "Constructs", "a", "new", "traversable", "object", "from", "the", "supplied", "elements", "." ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Traversable.php#L52-L55
TimeToogo/Pinq
Source/Traversable.php
Traversable.factory
public static function factory(IIteratorScheme $scheme = null, Traversable $source = null) { //static:: doesn't work in closures? $static = get_called_class(); return function ($elements) use ($static, $scheme, $source) { return $static::from($elements, $scheme, $source); }; }
php
public static function factory(IIteratorScheme $scheme = null, Traversable $source = null) { //static:: doesn't work in closures? $static = get_called_class(); return function ($elements) use ($static, $scheme, $source) { return $static::from($elements, $scheme, $source); }; }
[ "public", "static", "function", "factory", "(", "IIteratorScheme", "$", "scheme", "=", "null", ",", "Traversable", "$", "source", "=", "null", ")", "{", "//static:: doesn't work in closures?", "$", "static", "=", "get_called_class", "(", ")", ";", "return", "function", "(", "$", "elements", ")", "use", "(", "$", "static", ",", "$", "scheme", ",", "$", "source", ")", "{", "return", "$", "static", "::", "from", "(", "$", "elements", ",", "$", "scheme", ",", "$", "source", ")", ";", "}", ";", "}" ]
Returns a callable for the traversable constructor. @param IIteratorScheme|null $scheme @param Traversable|null $source @return callable
[ "Returns", "a", "callable", "for", "the", "traversable", "constructor", "." ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Traversable.php#L65-L73
TimeToogo/Pinq
Source/Traversable.php
Traversable.validateIsOrdered
private function validateIsOrdered($method) { $innerIterator = $this->elements; if (!($innerIterator instanceof Iterators\IOrderedIterator)) { throw new PinqException( 'Invalid call to %s: %s::%s must be called first.', $method, __CLASS__, 'orderBy'); } return $innerIterator; }
php
private function validateIsOrdered($method) { $innerIterator = $this->elements; if (!($innerIterator instanceof Iterators\IOrderedIterator)) { throw new PinqException( 'Invalid call to %s: %s::%s must be called first.', $method, __CLASS__, 'orderBy'); } return $innerIterator; }
[ "private", "function", "validateIsOrdered", "(", "$", "method", ")", "{", "$", "innerIterator", "=", "$", "this", "->", "elements", ";", "if", "(", "!", "(", "$", "innerIterator", "instanceof", "Iterators", "\\", "IOrderedIterator", ")", ")", "{", "throw", "new", "PinqException", "(", "'Invalid call to %s: %s::%s must be called first.'", ",", "$", "method", ",", "__CLASS__", ",", "'orderBy'", ")", ";", "}", "return", "$", "innerIterator", ";", "}" ]
Verifies that the traversable is ordered. @param string $method The called method name @return Iterators\IOrderedIterator @throws PinqException
[ "Verifies", "that", "the", "traversable", "is", "ordered", "." ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Traversable.php#L223-L235
TimeToogo/Pinq
Source/Traversable.php
Traversable.union
public function union($values) { return $this->constructScopedSelf( $this->scheme->unionIterator( $this->elements, $this->scheme->toIterator($values) ) ); }
php
public function union($values) { return $this->constructScopedSelf( $this->scheme->unionIterator( $this->elements, $this->scheme->toIterator($values) ) ); }
[ "public", "function", "union", "(", "$", "values", ")", "{", "return", "$", "this", "->", "constructScopedSelf", "(", "$", "this", "->", "scheme", "->", "unionIterator", "(", "$", "this", "->", "elements", ",", "$", "this", "->", "scheme", "->", "toIterator", "(", "$", "values", ")", ")", ")", ";", "}" ]
<editor-fold defaultstate="collapsed" desc="Set Operations">
[ "<editor", "-", "fold", "defaultstate", "=", "collapsed", "desc", "=", "Set", "Operations", ">" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Traversable.php#L397-L405
TimeToogo/Pinq
Source/Traversable.php
Traversable.append
public function append($values) { return $this->constructScopedSelf( $this->scheme->appendIterator( $this->elements, $this->scheme->toIterator($values) ) ); }
php
public function append($values) { return $this->constructScopedSelf( $this->scheme->appendIterator( $this->elements, $this->scheme->toIterator($values) ) ); }
[ "public", "function", "append", "(", "$", "values", ")", "{", "return", "$", "this", "->", "constructScopedSelf", "(", "$", "this", "->", "scheme", "->", "appendIterator", "(", "$", "this", "->", "elements", ",", "$", "this", "->", "scheme", "->", "toIterator", "(", "$", "values", ")", ")", ")", ";", "}" ]
<editor-fold defaultstate="collapsed" desc="Multiset Operations">
[ "<editor", "-", "fold", "defaultstate", "=", "collapsed", "desc", "=", "Multiset", "Operations", ">" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Traversable.php#L431-L439
TimeToogo/Pinq
Source/Traversable.php
Traversable.offsetExists
public function offsetExists($index) { foreach ($this->keys() as $key) { if ($key === $index) { return true; } } return false; }
php
public function offsetExists($index) { foreach ($this->keys() as $key) { if ($key === $index) { return true; } } return false; }
[ "public", "function", "offsetExists", "(", "$", "index", ")", "{", "foreach", "(", "$", "this", "->", "keys", "(", ")", "as", "$", "key", ")", "{", "if", "(", "$", "key", "===", "$", "index", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
<editor-fold defaultstate="collapsed" desc="Array Access">
[ "<editor", "-", "fold", "defaultstate", "=", "collapsed", "desc", "=", "Array", "Access", ">" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Traversable.php#L465-L474
TimeToogo/Pinq
Source/Traversable.php
Traversable.count
public function count() { if($this->elements instanceof \Countable) { return $this->elements->count(); } $count = 0; foreach($this->elements as $value) { $count++; } return $count; }
php
public function count() { if($this->elements instanceof \Countable) { return $this->elements->count(); } $count = 0; foreach($this->elements as $value) { $count++; } return $count; }
[ "public", "function", "count", "(", ")", "{", "if", "(", "$", "this", "->", "elements", "instanceof", "\\", "Countable", ")", "{", "return", "$", "this", "->", "elements", "->", "count", "(", ")", ";", "}", "$", "count", "=", "0", ";", "foreach", "(", "$", "this", "->", "elements", "as", "$", "value", ")", "{", "$", "count", "++", ";", "}", "return", "$", "count", ";", "}" ]
<editor-fold defaultstate="collapsed" desc="Aggregates">
[ "<editor", "-", "fold", "defaultstate", "=", "collapsed", "desc", "=", "Aggregates", ">" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Traversable.php#L501-L514
TimeToogo/Pinq
Source/Iterators/Standard/IGeneratorAdapter.php
IGeneratorAdapter.buildGeneratorWrapper
protected function buildGeneratorWrapper() { foreach ($this->generator as $key => &$value) { yield null; $this->currentKey = $key; $this->currentValue =& $value; } }
php
protected function buildGeneratorWrapper() { foreach ($this->generator as $key => &$value) { yield null; $this->currentKey = $key; $this->currentValue =& $value; } }
[ "protected", "function", "buildGeneratorWrapper", "(", ")", "{", "foreach", "(", "$", "this", "->", "generator", "as", "$", "key", "=>", "&", "$", "value", ")", "{", "yield", "null", ";", "$", "this", "->", "currentKey", "=", "$", "key", ";", "$", "this", "->", "currentValue", "=", "&", "$", "value", ";", "}", "}" ]
hence we should be able to utilise generator in this iterator
[ "hence", "we", "should", "be", "able", "to", "utilise", "generator", "in", "this", "iterator" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Iterators/Standard/IGeneratorAdapter.php#L50-L57
TimeToogo/Pinq
Source/Parsing/FunctionScope.php
FunctionScope.fromReflection
public static function fromReflection(\ReflectionFunctionAbstract $reflection, callable $callable) { if (is_array($callable)) { /** @var $reflection \ReflectionMethod */ $thisObject = is_object($callable[0]) ? $callable[0] : null; $scopeType = $reflection->getDeclaringClass()->getName(); } elseif (is_object($callable) && !($callable instanceof \Closure)) { /** @var $reflection \ReflectionMethod */ $thisObject = $callable; $scopeType = $reflection->getDeclaringClass()->getName(); } elseif ($reflection->isClosure()) { $thisObject = $reflection->getClosureThis(); $scopeClass = $reflection->getClosureScopeClass(); $scopeType = $scopeClass === null ? null : $scopeClass->getName(); } else { $thisObject = null; $scopeType = null; } $variableTable = $reflection->getStaticVariables(); return new self($thisObject, $scopeType, $variableTable); }
php
public static function fromReflection(\ReflectionFunctionAbstract $reflection, callable $callable) { if (is_array($callable)) { /** @var $reflection \ReflectionMethod */ $thisObject = is_object($callable[0]) ? $callable[0] : null; $scopeType = $reflection->getDeclaringClass()->getName(); } elseif (is_object($callable) && !($callable instanceof \Closure)) { /** @var $reflection \ReflectionMethod */ $thisObject = $callable; $scopeType = $reflection->getDeclaringClass()->getName(); } elseif ($reflection->isClosure()) { $thisObject = $reflection->getClosureThis(); $scopeClass = $reflection->getClosureScopeClass(); $scopeType = $scopeClass === null ? null : $scopeClass->getName(); } else { $thisObject = null; $scopeType = null; } $variableTable = $reflection->getStaticVariables(); return new self($thisObject, $scopeType, $variableTable); }
[ "public", "static", "function", "fromReflection", "(", "\\", "ReflectionFunctionAbstract", "$", "reflection", ",", "callable", "$", "callable", ")", "{", "if", "(", "is_array", "(", "$", "callable", ")", ")", "{", "/** @var $reflection \\ReflectionMethod */", "$", "thisObject", "=", "is_object", "(", "$", "callable", "[", "0", "]", ")", "?", "$", "callable", "[", "0", "]", ":", "null", ";", "$", "scopeType", "=", "$", "reflection", "->", "getDeclaringClass", "(", ")", "->", "getName", "(", ")", ";", "}", "elseif", "(", "is_object", "(", "$", "callable", ")", "&&", "!", "(", "$", "callable", "instanceof", "\\", "Closure", ")", ")", "{", "/** @var $reflection \\ReflectionMethod */", "$", "thisObject", "=", "$", "callable", ";", "$", "scopeType", "=", "$", "reflection", "->", "getDeclaringClass", "(", ")", "->", "getName", "(", ")", ";", "}", "elseif", "(", "$", "reflection", "->", "isClosure", "(", ")", ")", "{", "$", "thisObject", "=", "$", "reflection", "->", "getClosureThis", "(", ")", ";", "$", "scopeClass", "=", "$", "reflection", "->", "getClosureScopeClass", "(", ")", ";", "$", "scopeType", "=", "$", "scopeClass", "===", "null", "?", "null", ":", "$", "scopeClass", "->", "getName", "(", ")", ";", "}", "else", "{", "$", "thisObject", "=", "null", ";", "$", "scopeType", "=", "null", ";", "}", "$", "variableTable", "=", "$", "reflection", "->", "getStaticVariables", "(", ")", ";", "return", "new", "self", "(", "$", "thisObject", ",", "$", "scopeType", ",", "$", "variableTable", ")", ";", "}" ]
Creates a function scope instance from the supplied reflection and callable. @param \ReflectionFunctionAbstract $reflection @param callable $callable @return self
[ "Creates", "a", "function", "scope", "instance", "from", "the", "supplied", "reflection", "and", "callable", "." ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Parsing/FunctionScope.php#L53-L74
TimeToogo/Pinq
Source/Queries/Segments/Operation.php
Operation.update
public function update($operationType, Common\ISource $source) { if ($this->operationType === $operationType && $this->source === $source) { return $this; } return new self($operationType, $source); }
php
public function update($operationType, Common\ISource $source) { if ($this->operationType === $operationType && $this->source === $source) { return $this; } return new self($operationType, $source); }
[ "public", "function", "update", "(", "$", "operationType", ",", "Common", "\\", "ISource", "$", "source", ")", "{", "if", "(", "$", "this", "->", "operationType", "===", "$", "operationType", "&&", "$", "this", "->", "source", "===", "$", "source", ")", "{", "return", "$", "this", ";", "}", "return", "new", "self", "(", "$", "operationType", ",", "$", "source", ")", ";", "}" ]
@param int $operationType @param Common\ISource $source @return Operation
[ "@param", "int", "$operationType", "@param", "Common", "\\", "ISource", "$source" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Queries/Segments/Operation.php#L96-L103
TimeToogo/Pinq
Source/Expressions/Operators/Unary.php
Unary.doUnaryOperation
public static function doUnaryOperation($operator, &$value) { if (self::$unaryOperations === null) { self::$unaryOperations = [ self::BITWISE_NOT => function (&$i) { return ~$i; }, self::NOT => function (&$i) { return !$i; }, self::INCREMENT => function (&$i) { return $i++; }, self::DECREMENT => function (&$i) { return $i--; }, self::PRE_INCREMENT => function (&$i) { return ++$i; }, self::PRE_DECREMENT => function (&$i) { return --$i; }, self::NEGATION => function (&$i) { return -$i; }, self::PLUS => function (&$i) { return +$i; }, ]; } if (!isset(self::$unaryOperations[$operator])) { throw new PinqException('Unary operator \'%s\' is not supported', $operator); } $operation = self::$unaryOperations[$operator]; return $operation($value); }
php
public static function doUnaryOperation($operator, &$value) { if (self::$unaryOperations === null) { self::$unaryOperations = [ self::BITWISE_NOT => function (&$i) { return ~$i; }, self::NOT => function (&$i) { return !$i; }, self::INCREMENT => function (&$i) { return $i++; }, self::DECREMENT => function (&$i) { return $i--; }, self::PRE_INCREMENT => function (&$i) { return ++$i; }, self::PRE_DECREMENT => function (&$i) { return --$i; }, self::NEGATION => function (&$i) { return -$i; }, self::PLUS => function (&$i) { return +$i; }, ]; } if (!isset(self::$unaryOperations[$operator])) { throw new PinqException('Unary operator \'%s\' is not supported', $operator); } $operation = self::$unaryOperations[$operator]; return $operation($value); }
[ "public", "static", "function", "doUnaryOperation", "(", "$", "operator", ",", "&", "$", "value", ")", "{", "if", "(", "self", "::", "$", "unaryOperations", "===", "null", ")", "{", "self", "::", "$", "unaryOperations", "=", "[", "self", "::", "BITWISE_NOT", "=>", "function", "(", "&", "$", "i", ")", "{", "return", "~", "$", "i", ";", "}", ",", "self", "::", "NOT", "=>", "function", "(", "&", "$", "i", ")", "{", "return", "!", "$", "i", ";", "}", ",", "self", "::", "INCREMENT", "=>", "function", "(", "&", "$", "i", ")", "{", "return", "$", "i", "++", ";", "}", ",", "self", "::", "DECREMENT", "=>", "function", "(", "&", "$", "i", ")", "{", "return", "$", "i", "--", ";", "}", ",", "self", "::", "PRE_INCREMENT", "=>", "function", "(", "&", "$", "i", ")", "{", "return", "++", "$", "i", ";", "}", ",", "self", "::", "PRE_DECREMENT", "=>", "function", "(", "&", "$", "i", ")", "{", "return", "--", "$", "i", ";", "}", ",", "self", "::", "NEGATION", "=>", "function", "(", "&", "$", "i", ")", "{", "return", "-", "$", "i", ";", "}", ",", "self", "::", "PLUS", "=>", "function", "(", "&", "$", "i", ")", "{", "return", "+", "$", "i", ";", "}", ",", "]", ";", "}", "if", "(", "!", "isset", "(", "self", "::", "$", "unaryOperations", "[", "$", "operator", "]", ")", ")", "{", "throw", "new", "PinqException", "(", "'Unary operator \\'%s\\' is not supported'", ",", "$", "operator", ")", ";", "}", "$", "operation", "=", "self", "::", "$", "unaryOperations", "[", "$", "operator", "]", ";", "return", "$", "operation", "(", "$", "value", ")", ";", "}" ]
Performs the unary operation on the supplied value. @param string $operator @param mixed $value @return mixed @throws PinqException
[ "Performs", "the", "unary", "operation", "on", "the", "supplied", "value", "." ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Expressions/Operators/Unary.php#L37-L59
TimeToogo/Pinq
Source/Queries/Builders/ExpressionInterpreter.php
ExpressionInterpreter.getSourceMethodCall
final protected function getSourceMethodCall(O\MethodCallExpression $methodExpression) { $sourceExpression = $methodExpression->getValue(); if (!($sourceExpression instanceof O\MethodCallExpression)) { throw new PinqException( 'Cannot get source method call expression: source is not a method call, %s given', get_class($methodExpression)); } return $sourceExpression; }
php
final protected function getSourceMethodCall(O\MethodCallExpression $methodExpression) { $sourceExpression = $methodExpression->getValue(); if (!($sourceExpression instanceof O\MethodCallExpression)) { throw new PinqException( 'Cannot get source method call expression: source is not a method call, %s given', get_class($methodExpression)); } return $sourceExpression; }
[ "final", "protected", "function", "getSourceMethodCall", "(", "O", "\\", "MethodCallExpression", "$", "methodExpression", ")", "{", "$", "sourceExpression", "=", "$", "methodExpression", "->", "getValue", "(", ")", ";", "if", "(", "!", "(", "$", "sourceExpression", "instanceof", "O", "\\", "MethodCallExpression", ")", ")", "{", "throw", "new", "PinqException", "(", "'Cannot get source method call expression: source is not a method call, %s given'", ",", "get_class", "(", "$", "methodExpression", ")", ")", ";", "}", "return", "$", "sourceExpression", ";", "}" ]
@param O\MethodCallExpression $methodExpression @return O\MethodCallExpression @throws PinqException
[ "@param", "O", "\\", "MethodCallExpression", "$methodExpression" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Queries/Builders/ExpressionInterpreter.php#L140-L151
TimeToogo/Pinq
Source/Iterators/Standard/IteratorScheme.php
IteratorScheme.adapter
public static function adapter(\Traversable $iterator) { if ($iterator instanceof IIterator) { return $iterator; } elseif ($iterator instanceof IGenerator) { return new IGeneratorAdapter($iterator); } elseif ($iterator instanceof \ArrayIterator) { return new ArrayIteratorAdapter($iterator); } elseif ($iterator instanceof \IteratorAggregate) { return static::adapter($iterator->getIterator()); } else { return new IteratorAdapter($iterator); } }
php
public static function adapter(\Traversable $iterator) { if ($iterator instanceof IIterator) { return $iterator; } elseif ($iterator instanceof IGenerator) { return new IGeneratorAdapter($iterator); } elseif ($iterator instanceof \ArrayIterator) { return new ArrayIteratorAdapter($iterator); } elseif ($iterator instanceof \IteratorAggregate) { return static::adapter($iterator->getIterator()); } else { return new IteratorAdapter($iterator); } }
[ "public", "static", "function", "adapter", "(", "\\", "Traversable", "$", "iterator", ")", "{", "if", "(", "$", "iterator", "instanceof", "IIterator", ")", "{", "return", "$", "iterator", ";", "}", "elseif", "(", "$", "iterator", "instanceof", "IGenerator", ")", "{", "return", "new", "IGeneratorAdapter", "(", "$", "iterator", ")", ";", "}", "elseif", "(", "$", "iterator", "instanceof", "\\", "ArrayIterator", ")", "{", "return", "new", "ArrayIteratorAdapter", "(", "$", "iterator", ")", ";", "}", "elseif", "(", "$", "iterator", "instanceof", "\\", "IteratorAggregate", ")", "{", "return", "static", "::", "adapter", "(", "$", "iterator", "->", "getIterator", "(", ")", ")", ";", "}", "else", "{", "return", "new", "IteratorAdapter", "(", "$", "iterator", ")", ";", "}", "}" ]
@param \Traversable $iterator @return IIterator
[ "@param", "\\", "Traversable", "$iterator" ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Iterators/Standard/IteratorScheme.php#L60-L73
TimeToogo/Pinq
Source/Analysis/PhpTypeSystem.php
PhpTypeSystem.registerTypeDataModule
public function registerTypeDataModule(ITypeDataModule $module) { $this->typeDataModules[] = $module; foreach ($module->functions() as $name => $returnType) { $normalizedFunctionName = $this->normalizeFunctionName($name); $this->functionTypeMap[$normalizedFunctionName] = $returnType; unset($this->functions[$normalizedFunctionName]); } foreach ($module->types() as $name => $typeData) { $normalizedClassName = $this->normalizeClassName($name); $this->classTypeMap[$normalizedClassName] = $typeData; unset($this->objectTypes[$normalizedClassName]); } }
php
public function registerTypeDataModule(ITypeDataModule $module) { $this->typeDataModules[] = $module; foreach ($module->functions() as $name => $returnType) { $normalizedFunctionName = $this->normalizeFunctionName($name); $this->functionTypeMap[$normalizedFunctionName] = $returnType; unset($this->functions[$normalizedFunctionName]); } foreach ($module->types() as $name => $typeData) { $normalizedClassName = $this->normalizeClassName($name); $this->classTypeMap[$normalizedClassName] = $typeData; unset($this->objectTypes[$normalizedClassName]); } }
[ "public", "function", "registerTypeDataModule", "(", "ITypeDataModule", "$", "module", ")", "{", "$", "this", "->", "typeDataModules", "[", "]", "=", "$", "module", ";", "foreach", "(", "$", "module", "->", "functions", "(", ")", "as", "$", "name", "=>", "$", "returnType", ")", "{", "$", "normalizedFunctionName", "=", "$", "this", "->", "normalizeFunctionName", "(", "$", "name", ")", ";", "$", "this", "->", "functionTypeMap", "[", "$", "normalizedFunctionName", "]", "=", "$", "returnType", ";", "unset", "(", "$", "this", "->", "functions", "[", "$", "normalizedFunctionName", "]", ")", ";", "}", "foreach", "(", "$", "module", "->", "types", "(", ")", "as", "$", "name", "=>", "$", "typeData", ")", "{", "$", "normalizedClassName", "=", "$", "this", "->", "normalizeClassName", "(", "$", "name", ")", ";", "$", "this", "->", "classTypeMap", "[", "$", "normalizedClassName", "]", "=", "$", "typeData", ";", "unset", "(", "$", "this", "->", "objectTypes", "[", "$", "normalizedClassName", "]", ")", ";", "}", "}" ]
Adds the type data module to the type system. @param ITypeDataModule $module @return void
[ "Adds", "the", "type", "data", "module", "to", "the", "type", "system", "." ]
train
https://github.com/TimeToogo/Pinq/blob/fa55da968d063c5aca384b5298665348da248c08/Source/Analysis/PhpTypeSystem.php#L87-L101