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
opulencephp/Opulence
src/Opulence/Environments/Environment.php
Environment.setVar
public static function setVar(string $name, $value) { // Do not overwrite the variable if it already exists if (self::getVar($name) === null) { putenv("$name=$value"); $_ENV[$name] = $value; $_SERVER[$name] = $value; } }
php
public static function setVar(string $name, $value) { // Do not overwrite the variable if it already exists if (self::getVar($name) === null) { putenv("$name=$value"); $_ENV[$name] = $value; $_SERVER[$name] = $value; } }
[ "public", "static", "function", "setVar", "(", "string", "$", "name", ",", "$", "value", ")", "{", "// Do not overwrite the variable if it already exists", "if", "(", "self", "::", "getVar", "(", "$", "name", ")", "===", "null", ")", "{", "putenv", "(", "\"$...
Sets an environment variable, but does not overwrite existing variables @param string $name The name of the environment variable to set @param mixed $value The value
[ "Sets", "an", "environment", "variable", "but", "does", "not", "overwrite", "existing", "variables" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Environments/Environment.php#L67-L75
opulencephp/Opulence
src/Opulence/Framework/Authentication/Bootstrappers/AuthenticationBootstrapper.php
AuthenticationBootstrapper.getAuthenticator
protected function getAuthenticator(IContainer $container) : IAuthenticator { $authenticatorRegistry = new AuthenticatorRegistry(); $authenticator = new Authenticator($authenticatorRegistry); $container->bindInstance(IAuthenticatorRegistry::class, $authenticatorRegistry); return $authenticator; }
php
protected function getAuthenticator(IContainer $container) : IAuthenticator { $authenticatorRegistry = new AuthenticatorRegistry(); $authenticator = new Authenticator($authenticatorRegistry); $container->bindInstance(IAuthenticatorRegistry::class, $authenticatorRegistry); return $authenticator; }
[ "protected", "function", "getAuthenticator", "(", "IContainer", "$", "container", ")", ":", "IAuthenticator", "{", "$", "authenticatorRegistry", "=", "new", "AuthenticatorRegistry", "(", ")", ";", "$", "authenticator", "=", "new", "Authenticator", "(", "$", "authe...
Gets the authenticator @param IContainer $container The IoC container @return IAuthenticator The authenticator
[ "Gets", "the", "authenticator" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Framework/Authentication/Bootstrappers/AuthenticationBootstrapper.php#L83-L90
opulencephp/Opulence
src/Opulence/Authentication/Tokens/Signatures/Algorithms.php
Algorithms.getAll
public static function getAll() : array { return [ self::RSA_SHA256, self::RSA_SHA384, self::RSA_SHA512, self::SHA256, self::SHA384, self::SHA512 ]; }
php
public static function getAll() : array { return [ self::RSA_SHA256, self::RSA_SHA384, self::RSA_SHA512, self::SHA256, self::SHA384, self::SHA512 ]; }
[ "public", "static", "function", "getAll", "(", ")", ":", "array", "{", "return", "[", "self", "::", "RSA_SHA256", ",", "self", "::", "RSA_SHA384", ",", "self", "::", "RSA_SHA512", ",", "self", "::", "SHA256", ",", "self", "::", "SHA384", ",", "self", "...
Gets all the supported algorithms @return array All the supported algorithms
[ "Gets", "all", "the", "supported", "algorithms" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Authentication/Tokens/Signatures/Algorithms.php#L38-L48
opulencephp/Opulence
src/Opulence/Authentication/Tokens/Signatures/Algorithms.php
Algorithms.isSymmetric
public static function isSymmetric($algorithm) : bool { if (!self::has($algorithm)) { throw new InvalidArgumentException("Algorithm \"$algorithm\" is not valid"); } return in_array($algorithm, [Algorithms::SHA256, Algorithms::SHA384, Algorithms::SHA512]); }
php
public static function isSymmetric($algorithm) : bool { if (!self::has($algorithm)) { throw new InvalidArgumentException("Algorithm \"$algorithm\" is not valid"); } return in_array($algorithm, [Algorithms::SHA256, Algorithms::SHA384, Algorithms::SHA512]); }
[ "public", "static", "function", "isSymmetric", "(", "$", "algorithm", ")", ":", "bool", "{", "if", "(", "!", "self", "::", "has", "(", "$", "algorithm", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Algorithm \\\"$algorithm\\\" is not valid\...
Checks if an algorithm is symmetric @param mixed $algorithm The algorithm to check @return bool True if the algorithm is symmetric, otherwise false @throws InvalidArgumentException Thrown if the algorithm is not valid
[ "Checks", "if", "an", "algorithm", "is", "symmetric" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Authentication/Tokens/Signatures/Algorithms.php#L68-L75
opulencephp/Opulence
src/Opulence/Framework/Http/CsrfTokenChecker.php
CsrfTokenChecker.tokenIsValid
public function tokenIsValid(Request $request, ISession $session) : bool { if (!$session->has(self::TOKEN_INPUT_NAME)) { $session->set(self::TOKEN_INPUT_NAME, \bin2hex(\random_bytes(16))); } if ($this->tokenShouldNotBeChecked($request)) { return true; } // Try an input $token = $request->getInput(self::TOKEN_INPUT_NAME); // Try the X-CSRF header if ($token === null) { $token = $request->getHeaders()->get('X-CSRF-TOKEN'); } // Try the X-XSRF header if ($token === null) { $token = $request->getHeaders()->get('X-XSRF-TOKEN'); } if ($token === null) { return false; } return \hash_equals($session->get(self::TOKEN_INPUT_NAME), $token); }
php
public function tokenIsValid(Request $request, ISession $session) : bool { if (!$session->has(self::TOKEN_INPUT_NAME)) { $session->set(self::TOKEN_INPUT_NAME, \bin2hex(\random_bytes(16))); } if ($this->tokenShouldNotBeChecked($request)) { return true; } // Try an input $token = $request->getInput(self::TOKEN_INPUT_NAME); // Try the X-CSRF header if ($token === null) { $token = $request->getHeaders()->get('X-CSRF-TOKEN'); } // Try the X-XSRF header if ($token === null) { $token = $request->getHeaders()->get('X-XSRF-TOKEN'); } if ($token === null) { return false; } return \hash_equals($session->get(self::TOKEN_INPUT_NAME), $token); }
[ "public", "function", "tokenIsValid", "(", "Request", "$", "request", ",", "ISession", "$", "session", ")", ":", "bool", "{", "if", "(", "!", "$", "session", "->", "has", "(", "self", "::", "TOKEN_INPUT_NAME", ")", ")", "{", "$", "session", "->", "set"...
Checks if the token is valid @param Request $request The current request @param ISession $session The current session @return bool True if the token is valid, otherwise false
[ "Checks", "if", "the", "token", "is", "valid" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Framework/Http/CsrfTokenChecker.php#L32-L60
opulencephp/Opulence
src/Opulence/Framework/Http/CsrfTokenChecker.php
CsrfTokenChecker.tokenShouldNotBeChecked
private function tokenShouldNotBeChecked(Request $request) : bool { return in_array($request->getMethod(), [RequestMethods::GET, RequestMethods::HEAD, RequestMethods::OPTIONS]); }
php
private function tokenShouldNotBeChecked(Request $request) : bool { return in_array($request->getMethod(), [RequestMethods::GET, RequestMethods::HEAD, RequestMethods::OPTIONS]); }
[ "private", "function", "tokenShouldNotBeChecked", "(", "Request", "$", "request", ")", ":", "bool", "{", "return", "in_array", "(", "$", "request", "->", "getMethod", "(", ")", ",", "[", "RequestMethods", "::", "GET", ",", "RequestMethods", "::", "HEAD", ","...
Gets whether or not the token should even be checked @param Request $request The current request @return bool True if the token should be checked, otherwise false
[ "Gets", "whether", "or", "not", "the", "token", "should", "even", "be", "checked" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Framework/Http/CsrfTokenChecker.php#L68-L71
opulencephp/Opulence
src/Opulence/Orm/DataMappers/SqlDataMapper.php
SqlDataMapper.read
protected function read(string $sql, array $sqlParameters, int $valueType, bool $expectSingleResult = false) { try { $statement = $this->readConnection->prepare($sql); $statement->bindValues($sqlParameters); $statement->execute(); if ($expectSingleResult && $statement->rowCount() != 1) { throw new OrmException('Failed to find entity'); } $entities = []; $rows = $statement->fetchAll(PDO::FETCH_ASSOC); foreach ($rows as $row) { $entities[] = $this->loadEntity($row); } if ($valueType == self::VALUE_TYPE_ENTITY) { if (count($entities) == 0) { return null; } return $entities[0]; } else { return $entities; } } catch (PDOException $ex) { throw new OrmException('Unable to query entities', 0, $ex); } }
php
protected function read(string $sql, array $sqlParameters, int $valueType, bool $expectSingleResult = false) { try { $statement = $this->readConnection->prepare($sql); $statement->bindValues($sqlParameters); $statement->execute(); if ($expectSingleResult && $statement->rowCount() != 1) { throw new OrmException('Failed to find entity'); } $entities = []; $rows = $statement->fetchAll(PDO::FETCH_ASSOC); foreach ($rows as $row) { $entities[] = $this->loadEntity($row); } if ($valueType == self::VALUE_TYPE_ENTITY) { if (count($entities) == 0) { return null; } return $entities[0]; } else { return $entities; } } catch (PDOException $ex) { throw new OrmException('Unable to query entities', 0, $ex); } }
[ "protected", "function", "read", "(", "string", "$", "sql", ",", "array", "$", "sqlParameters", ",", "int", "$", "valueType", ",", "bool", "$", "expectSingleResult", "=", "false", ")", "{", "try", "{", "$", "statement", "=", "$", "this", "->", "readConne...
Performs the read query for entity(ies) and returns any results @param string $sql The SQL query to run @param array $sqlParameters The list of SQL parameters @param int $valueType The value type constant designating what kind of data we're expecting to return @param bool $expectSingleResult True if we're expecting a single result, otherwise false @return array|mixed|null The list of entities or an individual entity if successful, otherwise null @throws OrmException Thrown if there was an error querying the entities
[ "Performs", "the", "read", "query", "for", "entity", "(", "ies", ")", "and", "returns", "any", "results" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Orm/DataMappers/SqlDataMapper.php#L61-L91
opulencephp/Opulence
src/Opulence/Databases/Adapters/Pdo/Connection.php
Connection.connect
private function connect() { if (!$this->isConnected) { parent::__construct( $this->dsn, $this->server->getUsername(), $this->server->getPassword(), $this->driverOptions ); parent::setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); parent::setAttribute( PDO::ATTR_STATEMENT_CLASS, [__NAMESPACE__ . '\\' . self::PDO_STATEMENT_CLASS, [$this]] ); $this->isConnected = true; } }
php
private function connect() { if (!$this->isConnected) { parent::__construct( $this->dsn, $this->server->getUsername(), $this->server->getPassword(), $this->driverOptions ); parent::setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); parent::setAttribute( PDO::ATTR_STATEMENT_CLASS, [__NAMESPACE__ . '\\' . self::PDO_STATEMENT_CLASS, [$this]] ); $this->isConnected = true; } }
[ "private", "function", "connect", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isConnected", ")", "{", "parent", "::", "__construct", "(", "$", "this", "->", "dsn", ",", "$", "this", "->", "server", "->", "getUsername", "(", ")", ",", "$", "t...
Attempts to connect to the server, which is done via lazy-connecting @throws PDOException Thrown if there was an error connecting to the database
[ "Attempts", "to", "connect", "to", "the", "server", "which", "is", "done", "via", "lazy", "-", "connecting" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Databases/Adapters/Pdo/Connection.php#L235-L252
opulencephp/Opulence
src/Opulence/IO/Streams/MultiStream.php
MultiStream.addStream
public function addStream(IStream $stream) : void { if (!$stream->isReadable()) { throw new InvalidArgumentException('Stream must be readable'); } $this->isSeekable = $this->isSeekable && $stream->isSeekable(); $this->streams[] = $stream; }
php
public function addStream(IStream $stream) : void { if (!$stream->isReadable()) { throw new InvalidArgumentException('Stream must be readable'); } $this->isSeekable = $this->isSeekable && $stream->isSeekable(); $this->streams[] = $stream; }
[ "public", "function", "addStream", "(", "IStream", "$", "stream", ")", ":", "void", "{", "if", "(", "!", "$", "stream", "->", "isReadable", "(", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Stream must be readable'", ")", ";", "}", "$"...
Adds a stream to the multi-stream @param IStream $stream The stream to add @throws InvalidArgumentException Thrown if the stream is not readable
[ "Adds", "a", "stream", "to", "the", "multi", "-", "stream" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/IO/Streams/MultiStream.php#L68-L76
opulencephp/Opulence
src/Opulence/Authentication/Credentials/Authenticators/UsernamePasswordAuthenticator.php
UsernamePasswordAuthenticator.getSubjectFromUser
protected function getSubjectFromUser(IUser $user, ICredential $credential) : ISubject { $userId = $user->getId(); $roles = $this->roleRepository->getRoleNamesForSubject($userId); return new Subject([new Principal(PrincipalTypes::PRIMARY, $userId, $roles)], [$credential]); }
php
protected function getSubjectFromUser(IUser $user, ICredential $credential) : ISubject { $userId = $user->getId(); $roles = $this->roleRepository->getRoleNamesForSubject($userId); return new Subject([new Principal(PrincipalTypes::PRIMARY, $userId, $roles)], [$credential]); }
[ "protected", "function", "getSubjectFromUser", "(", "IUser", "$", "user", ",", "ICredential", "$", "credential", ")", ":", "ISubject", "{", "$", "userId", "=", "$", "user", "->", "getId", "(", ")", ";", "$", "roles", "=", "$", "this", "->", "roleReposito...
Gets a subject from a user @param IUser $user The user @param ICredential $credential The credential @return ISubject The subject
[ "Gets", "a", "subject", "from", "a", "user" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Authentication/Credentials/Authenticators/UsernamePasswordAuthenticator.php#L86-L92
opulencephp/Opulence
src/Opulence/QueryBuilders/InsertQuery.php
InsertQuery.addColumnValues
public function addColumnValues(array $columnNamesToValues) : self { $this->addUnnamedPlaceholderValues(array_values($columnNamesToValues)); // The augmenting query doesn't care about the data type, so get rid of it $columnNamesToValuesWithoutDataTypes = []; foreach ($columnNamesToValues as $name => $value) { if (is_array($value)) { $columnNamesToValuesWithoutDataTypes[$name] = $value[0]; } else { $columnNamesToValuesWithoutDataTypes[$name] = $value; } } $this->augmentingQueryBuilder->addColumnValues($columnNamesToValuesWithoutDataTypes); return $this; }
php
public function addColumnValues(array $columnNamesToValues) : self { $this->addUnnamedPlaceholderValues(array_values($columnNamesToValues)); // The augmenting query doesn't care about the data type, so get rid of it $columnNamesToValuesWithoutDataTypes = []; foreach ($columnNamesToValues as $name => $value) { if (is_array($value)) { $columnNamesToValuesWithoutDataTypes[$name] = $value[0]; } else { $columnNamesToValuesWithoutDataTypes[$name] = $value; } } $this->augmentingQueryBuilder->addColumnValues($columnNamesToValuesWithoutDataTypes); return $this; }
[ "public", "function", "addColumnValues", "(", "array", "$", "columnNamesToValues", ")", ":", "self", "{", "$", "this", "->", "addUnnamedPlaceholderValues", "(", "array_values", "(", "$", "columnNamesToValues", ")", ")", ";", "// The augmenting query doesn't care about t...
Adds column values to the query @param array $columnNamesToValues The mapping of column names to their respective values Optionally, the values can be contained in an array whose first item is the value and whose second value is the PDO constant indicating the type of data the value represents @return self For method chaining @throws InvalidQueryException Thrown if the query is invalid
[ "Adds", "column", "values", "to", "the", "query" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/QueryBuilders/InsertQuery.php#L42-L60
opulencephp/Opulence
src/Opulence/Authentication/Tokens/JsonWebTokens/JwtHeader.php
JwtHeader.add
public function add(string $name, $value) { switch ($name) { case 'alg': $this->setAlgorithm($value); break; default: $this->headers[$name] = $value; break; } }
php
public function add(string $name, $value) { switch ($name) { case 'alg': $this->setAlgorithm($value); break; default: $this->headers[$name] = $value; break; } }
[ "public", "function", "add", "(", "string", "$", "name", ",", "$", "value", ")", "{", "switch", "(", "$", "name", ")", "{", "case", "'alg'", ":", "$", "this", "->", "setAlgorithm", "(", "$", "value", ")", ";", "break", ";", "default", ":", "$", "...
Adds a header @param string $name The name of the header to add @param mixed $value The value to add
[ "Adds", "a", "header" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Authentication/Tokens/JsonWebTokens/JwtHeader.php#L67-L77
opulencephp/Opulence
src/Opulence/Authentication/Tokens/JsonWebTokens/JwtHeader.php
JwtHeader.get
public function get(string $name) { if (!array_key_exists($name, $this->headers)) { return null; } return $this->headers[$name]; }
php
public function get(string $name) { if (!array_key_exists($name, $this->headers)) { return null; } return $this->headers[$name]; }
[ "public", "function", "get", "(", "string", "$", "name", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "headers", ")", ")", "{", "return", "null", ";", "}", "return", "$", "this", "->", "headers", "[", "$",...
Gets the value for a header @param string $name The name of the header to get @return mixed|null The value of the header if it exists, otherwise null
[ "Gets", "the", "value", "for", "a", "header" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Authentication/Tokens/JsonWebTokens/JwtHeader.php#L95-L102
opulencephp/Opulence
src/Opulence/Orm/ChangeTracking/ChangeTracker.php
ChangeTracker.hasChangedUsingComparisonFunction
protected function hasChangedUsingComparisonFunction($entity) : bool { $objectHashId = spl_object_hash($entity); $originalData = $this->objectHashIdsToOriginalData[$objectHashId]; return !$this->comparators[get_class($entity)]($originalData, $entity); }
php
protected function hasChangedUsingComparisonFunction($entity) : bool { $objectHashId = spl_object_hash($entity); $originalData = $this->objectHashIdsToOriginalData[$objectHashId]; return !$this->comparators[get_class($entity)]($originalData, $entity); }
[ "protected", "function", "hasChangedUsingComparisonFunction", "(", "$", "entity", ")", ":", "bool", "{", "$", "objectHashId", "=", "spl_object_hash", "(", "$", "entity", ")", ";", "$", "originalData", "=", "$", "this", "->", "objectHashIdsToOriginalData", "[", "...
Checks to see if an entity has changed using a comparison function @param object $entity The entity to check for changes @return bool True if the entity has changed, otherwise false
[ "Checks", "to", "see", "if", "an", "entity", "has", "changed", "using", "a", "comparison", "function" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Orm/ChangeTracking/ChangeTracker.php#L91-L97
opulencephp/Opulence
src/Opulence/Framework/Events/Bootstrappers/EventDispatcherBootstrapper.php
EventDispatcherBootstrapper.getEventDispatcher
protected function getEventDispatcher(IContainer $container) : IEventDispatcher { $eventRegistry = new EventRegistry(); foreach ($this->getEventListenerConfig() as $eventName => $listeners) { foreach ((array)$listeners as $listener) { $eventRegistry->registerListener($eventName, $this->getEventListenerCallback($listener, $container)); } } return new SynchronousEventDispatcher($eventRegistry); }
php
protected function getEventDispatcher(IContainer $container) : IEventDispatcher { $eventRegistry = new EventRegistry(); foreach ($this->getEventListenerConfig() as $eventName => $listeners) { foreach ((array)$listeners as $listener) { $eventRegistry->registerListener($eventName, $this->getEventListenerCallback($listener, $container)); } } return new SynchronousEventDispatcher($eventRegistry); }
[ "protected", "function", "getEventDispatcher", "(", "IContainer", "$", "container", ")", ":", "IEventDispatcher", "{", "$", "eventRegistry", "=", "new", "EventRegistry", "(", ")", ";", "foreach", "(", "$", "this", "->", "getEventListenerConfig", "(", ")", "as", ...
Gets the event dispatcher @param IContainer $container The IoC container @return IEventDispatcher The event dispatcher
[ "Gets", "the", "event", "dispatcher" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Framework/Events/Bootstrappers/EventDispatcherBootstrapper.php#L46-L57
opulencephp/Opulence
src/Opulence/Framework/Events/Bootstrappers/EventDispatcherBootstrapper.php
EventDispatcherBootstrapper.getEventListenerCallback
protected function getEventListenerCallback($listenerConfig, IContainer $container) : callable { if (is_callable($listenerConfig)) { return $listenerConfig; } if (is_string($listenerConfig)) { if (strpos($listenerConfig, '@') === false) { throw new InvalidArgumentException("Listener data \"$listenerConfig\" is incorrectly formatted"); } list($listenerClass, $listenerMethod) = explode('@', $listenerConfig); return function ($event, $eventName, IEventDispatcher $dispatcher) use ( $container, $listenerClass, $listenerMethod ) { $listenerObject = $container->resolve($listenerClass); $listenerObject->$listenerMethod($event, $eventName, $dispatcher); }; } throw new InvalidArgumentException( 'Listener config must be either callable or string formatted like "className@methodName"' ); }
php
protected function getEventListenerCallback($listenerConfig, IContainer $container) : callable { if (is_callable($listenerConfig)) { return $listenerConfig; } if (is_string($listenerConfig)) { if (strpos($listenerConfig, '@') === false) { throw new InvalidArgumentException("Listener data \"$listenerConfig\" is incorrectly formatted"); } list($listenerClass, $listenerMethod) = explode('@', $listenerConfig); return function ($event, $eventName, IEventDispatcher $dispatcher) use ( $container, $listenerClass, $listenerMethod ) { $listenerObject = $container->resolve($listenerClass); $listenerObject->$listenerMethod($event, $eventName, $dispatcher); }; } throw new InvalidArgumentException( 'Listener config must be either callable or string formatted like "className@methodName"' ); }
[ "protected", "function", "getEventListenerCallback", "(", "$", "listenerConfig", ",", "IContainer", "$", "container", ")", ":", "callable", "{", "if", "(", "is_callable", "(", "$", "listenerConfig", ")", ")", "{", "return", "$", "listenerConfig", ";", "}", "if...
Gets a callback for an event listener from a config @param callable|string $listenerConfig The callable or "className@method" string @param IContainer $container The IoC container @return callable The event listener callable @throws InvalidArgumentException Thrown if the listener config was not set up correctly
[ "Gets", "a", "callback", "for", "an", "event", "listener", "from", "a", "config" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Framework/Events/Bootstrappers/EventDispatcherBootstrapper.php#L67-L93
opulencephp/Opulence
src/Opulence/Authentication/Tokens/JsonWebTokens/SignedJwt.php
SignedJwt.createFromString
public static function createFromString(string $token) : SignedJwt { $segments = explode('.', $token); if (count($segments) !== 3) { throw new InvalidArgumentException('Token did not contain 3 segments'); } list($encodedHeader, $encodedPayload, $encodedSignature) = $segments; $decodedHeader = \json_decode(self::base64UrlDecode($encodedHeader), true, 512, JSON_BIGINT_AS_STRING); $decodedPayload = \json_decode(self::base64UrlDecode($encodedPayload), true, 512, JSON_BIGINT_AS_STRING); $signature = self::base64UrlDecode($encodedSignature); if ($decodedHeader === null) { throw new InvalidArgumentException('Invalid header'); } if ($decodedPayload === null) { throw new InvalidArgumentException('Invalid payload'); } if (!isset($decodedHeader['alg'])) { throw new InvalidArgumentException('No algorithm set in header'); } $header = new JwtHeader($decodedHeader['alg'], $decodedHeader); $payload = new JwtPayload(); if (is_array($decodedPayload)) { foreach ($decodedPayload as $name => $value) { $payload->add($name, $value); } } return new self($header, $payload, $signature); }
php
public static function createFromString(string $token) : SignedJwt { $segments = explode('.', $token); if (count($segments) !== 3) { throw new InvalidArgumentException('Token did not contain 3 segments'); } list($encodedHeader, $encodedPayload, $encodedSignature) = $segments; $decodedHeader = \json_decode(self::base64UrlDecode($encodedHeader), true, 512, JSON_BIGINT_AS_STRING); $decodedPayload = \json_decode(self::base64UrlDecode($encodedPayload), true, 512, JSON_BIGINT_AS_STRING); $signature = self::base64UrlDecode($encodedSignature); if ($decodedHeader === null) { throw new InvalidArgumentException('Invalid header'); } if ($decodedPayload === null) { throw new InvalidArgumentException('Invalid payload'); } if (!isset($decodedHeader['alg'])) { throw new InvalidArgumentException('No algorithm set in header'); } $header = new JwtHeader($decodedHeader['alg'], $decodedHeader); $payload = new JwtPayload(); if (is_array($decodedPayload)) { foreach ($decodedPayload as $name => $value) { $payload->add($name, $value); } } return new self($header, $payload, $signature); }
[ "public", "static", "function", "createFromString", "(", "string", "$", "token", ")", ":", "SignedJwt", "{", "$", "segments", "=", "explode", "(", "'.'", ",", "$", "token", ")", ";", "if", "(", "count", "(", "$", "segments", ")", "!==", "3", ")", "{"...
Creates a signed JWT from a raw string @param string $token The token to create from @return SignedJwt The signed JSON web token @throws InvalidArgumentException Thrown if the token was not correctly formatted
[ "Creates", "a", "signed", "JWT", "from", "a", "raw", "string" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Authentication/Tokens/JsonWebTokens/SignedJwt.php#L42-L77
opulencephp/Opulence
src/Opulence/Authentication/Tokens/JsonWebTokens/SignedJwt.php
SignedJwt.createFromUnsignedJwt
public static function createFromUnsignedJwt(UnsignedJwt $unsignedJwt, string $signature) : SignedJwt { return new self($unsignedJwt->getHeader(), $unsignedJwt->getPayload(), $signature); }
php
public static function createFromUnsignedJwt(UnsignedJwt $unsignedJwt, string $signature) : SignedJwt { return new self($unsignedJwt->getHeader(), $unsignedJwt->getPayload(), $signature); }
[ "public", "static", "function", "createFromUnsignedJwt", "(", "UnsignedJwt", "$", "unsignedJwt", ",", "string", "$", "signature", ")", ":", "SignedJwt", "{", "return", "new", "self", "(", "$", "unsignedJwt", "->", "getHeader", "(", ")", ",", "$", "unsignedJwt"...
Creates a signed JWT from an unsigned JWT and signature @param UnsignedJwt $unsignedJwt The unsigned token to create the signed token from @param string $signature The signature @return SignedJwt The signed JSON web token
[ "Creates", "a", "signed", "JWT", "from", "an", "unsigned", "JWT", "and", "signature" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Authentication/Tokens/JsonWebTokens/SignedJwt.php#L86-L89
opulencephp/Opulence
src/Opulence/Authentication/Tokens/JsonWebTokens/SignedJwt.php
SignedJwt.encode
public function encode() : string { $segments = [ $this->header->encode(), $this->payload->encode(), self::base64UrlEncode($this->signature) ]; return implode('.', $segments); }
php
public function encode() : string { $segments = [ $this->header->encode(), $this->payload->encode(), self::base64UrlEncode($this->signature) ]; return implode('.', $segments); }
[ "public", "function", "encode", "(", ")", ":", "string", "{", "$", "segments", "=", "[", "$", "this", "->", "header", "->", "encode", "(", ")", ",", "$", "this", "->", "payload", "->", "encode", "(", ")", ",", "self", "::", "base64UrlEncode", "(", ...
Encodes this token as a string @return string The encoded string
[ "Encodes", "this", "token", "as", "a", "string" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Authentication/Tokens/JsonWebTokens/SignedJwt.php#L120-L129
opulencephp/Opulence
src/Opulence/QueryBuilders/ConditionalQueryBuilder.php
ConditionalQueryBuilder.addConditionToClause
public function addConditionToClause(array $clauseConditions, string $operation, string ...$conditions) : array { foreach ($conditions as $condition) { $clauseConditions[] = ['operation' => $operation, 'condition' => $condition]; } return $clauseConditions; }
php
public function addConditionToClause(array $clauseConditions, string $operation, string ...$conditions) : array { foreach ($conditions as $condition) { $clauseConditions[] = ['operation' => $operation, 'condition' => $condition]; } return $clauseConditions; }
[ "public", "function", "addConditionToClause", "(", "array", "$", "clauseConditions", ",", "string", "$", "operation", ",", "string", "...", "$", "conditions", ")", ":", "array", "{", "foreach", "(", "$", "conditions", "as", "$", "condition", ")", "{", "$", ...
Adds a condition to a clause @param array $clauseConditions The list of conditions that already belong to the clause @param string $operation Either "AND" or "OR", indicating how this condition is being added to the list of conditions @param string[] $conditions,... A variable list of conditions to be met @return array The input array with the condition added
[ "Adds", "a", "condition", "to", "a", "clause" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/QueryBuilders/ConditionalQueryBuilder.php#L29-L36
opulencephp/Opulence
src/Opulence/QueryBuilders/ConditionalQueryBuilder.php
ConditionalQueryBuilder.andWhere
public function andWhere(string ...$condition) : self { $this->whereConditions = $this->addConditionToClause( $this->whereConditions, 'AND', ...$condition); return $this; }
php
public function andWhere(string ...$condition) : self { $this->whereConditions = $this->addConditionToClause( $this->whereConditions, 'AND', ...$condition); return $this; }
[ "public", "function", "andWhere", "(", "string", "...", "$", "condition", ")", ":", "self", "{", "$", "this", "->", "whereConditions", "=", "$", "this", "->", "addConditionToClause", "(", "$", "this", "->", "whereConditions", ",", "'AND'", ",", "...", "$",...
Adds to a "WHERE" condition that will be "AND"ed with other conditions @param string[] $condition,... A variable list of conditions to be met @return self For method chaining
[ "Adds", "to", "a", "WHERE", "condition", "that", "will", "be", "AND", "ed", "with", "other", "conditions" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/QueryBuilders/ConditionalQueryBuilder.php#L44-L50
opulencephp/Opulence
src/Opulence/QueryBuilders/ConditionalQueryBuilder.php
ConditionalQueryBuilder.getClauseConditionSql
public function getClauseConditionSql(string $conditionType, array $clauseConditions) : string { if (count($clauseConditions) === 0) { return ''; } $sql = ' ' . strtoupper($conditionType); // This will help us keep track of whether or not we've added at least one clause $haveAddedAClause = false; foreach ($clauseConditions as $conditionData) { $sql .= ($haveAddedAClause ? ' ' . strtoupper($conditionData['operation']) : '') . " ({$conditionData['condition']})"; $haveAddedAClause = true; } return $sql; }
php
public function getClauseConditionSql(string $conditionType, array $clauseConditions) : string { if (count($clauseConditions) === 0) { return ''; } $sql = ' ' . strtoupper($conditionType); // This will help us keep track of whether or not we've added at least one clause $haveAddedAClause = false; foreach ($clauseConditions as $conditionData) { $sql .= ($haveAddedAClause ? ' ' . strtoupper($conditionData['operation']) : '') . " ({$conditionData['condition']})"; $haveAddedAClause = true; } return $sql; }
[ "public", "function", "getClauseConditionSql", "(", "string", "$", "conditionType", ",", "array", "$", "clauseConditions", ")", ":", "string", "{", "if", "(", "count", "(", "$", "clauseConditions", ")", "===", "0", ")", "{", "return", "''", ";", "}", "$", ...
Gets the SQL that makes up a clause that permits boolean operations ie "AND" and "OR" @param string $conditionType The name of the condition type ie "WHERE" @param array $clauseConditions The array of condition data whose SQL we want @return string The SQL that makes up the input clause(s)
[ "Gets", "the", "SQL", "that", "makes", "up", "a", "clause", "that", "permits", "boolean", "operations", "ie", "AND", "and", "OR" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/QueryBuilders/ConditionalQueryBuilder.php#L59-L76
opulencephp/Opulence
src/Opulence/QueryBuilders/ConditionalQueryBuilder.php
ConditionalQueryBuilder.orWhere
public function orWhere(string ...$condition) : self { $this->whereConditions = $this->addConditionToClause( $this->whereConditions, 'OR', ...$condition); return $this; }
php
public function orWhere(string ...$condition) : self { $this->whereConditions = $this->addConditionToClause( $this->whereConditions, 'OR', ...$condition); return $this; }
[ "public", "function", "orWhere", "(", "string", "...", "$", "condition", ")", ":", "self", "{", "$", "this", "->", "whereConditions", "=", "$", "this", "->", "addConditionToClause", "(", "$", "this", "->", "whereConditions", ",", "'OR'", ",", "...", "$", ...
Adds to a "WHERE" condition that will be "OR"ed with other conditions @param string[] $condition,... A variable list of conditions to be met @return self For method chaining
[ "Adds", "to", "a", "WHERE", "condition", "that", "will", "be", "OR", "ed", "with", "other", "conditions" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/QueryBuilders/ConditionalQueryBuilder.php#L92-L98
opulencephp/Opulence
src/Opulence/QueryBuilders/ConditionalQueryBuilder.php
ConditionalQueryBuilder.where
public function where(string ...$condition) : self { // We want to wipe out anything already in the condition list $this->whereConditions = []; $this->whereConditions = $this->addConditionToClause( $this->whereConditions, 'AND', ...$condition); return $this; }
php
public function where(string ...$condition) : self { // We want to wipe out anything already in the condition list $this->whereConditions = []; $this->whereConditions = $this->addConditionToClause( $this->whereConditions, 'AND', ...$condition); return $this; }
[ "public", "function", "where", "(", "string", "...", "$", "condition", ")", ":", "self", "{", "// We want to wipe out anything already in the condition list", "$", "this", "->", "whereConditions", "=", "[", "]", ";", "$", "this", "->", "whereConditions", "=", "$",...
Starts a "WHERE" condition Only call this method once per query because it will overwrite any previously-set "WHERE" expressions @param string[] $condition,... A variable list of conditions to be met @return self For method chaining
[ "Starts", "a", "WHERE", "condition", "Only", "call", "this", "method", "once", "per", "query", "because", "it", "will", "overwrite", "any", "previously", "-", "set", "WHERE", "expressions" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/QueryBuilders/ConditionalQueryBuilder.php#L107-L115
opulencephp/Opulence
src/Opulence/Collections/KeyHasher.php
KeyHasher.getHashKey
public function getHashKey($value) : string { if (is_string($value)) { return "__opulence:s:$value"; } if (is_int($value)) { return "__opulence:i:$value"; } if (is_float($value)) { return "__opulence:f:$value"; } if (is_object($value)) { if (method_exists($value, '__toString')) { return "__opulence:so:$value"; } return '__opulence:o:' . spl_object_hash($value); } if (is_array($value)) { return '__opulence:a:' . md5(serialize($value)); } if (is_resource($value)) { return '__opulence:r:' . "$value"; } // As a last-ditch effort, try to convert the value to a string try { return '__opulence:u' . (string)$value; } catch (Throwable $ex) { throw new RuntimeException('Value could not be converted to a key', 0, $ex); } }
php
public function getHashKey($value) : string { if (is_string($value)) { return "__opulence:s:$value"; } if (is_int($value)) { return "__opulence:i:$value"; } if (is_float($value)) { return "__opulence:f:$value"; } if (is_object($value)) { if (method_exists($value, '__toString')) { return "__opulence:so:$value"; } return '__opulence:o:' . spl_object_hash($value); } if (is_array($value)) { return '__opulence:a:' . md5(serialize($value)); } if (is_resource($value)) { return '__opulence:r:' . "$value"; } // As a last-ditch effort, try to convert the value to a string try { return '__opulence:u' . (string)$value; } catch (Throwable $ex) { throw new RuntimeException('Value could not be converted to a key', 0, $ex); } }
[ "public", "function", "getHashKey", "(", "$", "value", ")", ":", "string", "{", "if", "(", "is_string", "(", "$", "value", ")", ")", "{", "return", "\"__opulence:s:$value\"", ";", "}", "if", "(", "is_int", "(", "$", "value", ")", ")", "{", "return", ...
Gets the hash key for a value @param string|float|int|object|array|resource $value The value whose hash key we want @return string The value's hash key @throws RuntimeException Thrown if the value's hash key could not be calculated
[ "Gets", "the", "hash", "key", "for", "a", "value" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Collections/KeyHasher.php#L29-L65
opulencephp/Opulence
src/Opulence/Validation/Rules/Rules.php
Rules.between
public function between($min, $max, bool $isInclusive = true) : self { $this->createRule(BetweenRule::class, [$min, $max, $isInclusive]); return $this; }
php
public function between($min, $max, bool $isInclusive = true) : self { $this->createRule(BetweenRule::class, [$min, $max, $isInclusive]); return $this; }
[ "public", "function", "between", "(", "$", "min", ",", "$", "max", ",", "bool", "$", "isInclusive", "=", "true", ")", ":", "self", "{", "$", "this", "->", "createRule", "(", "BetweenRule", "::", "class", ",", "[", "$", "min", ",", "$", "max", ",", ...
Marks a field as having to be between values @param int|float $min The minimum value to compare against @param int|float $max The maximum value to compare against @param bool $isInclusive Whether or not the extremes are inclusive @return self For method chaining
[ "Marks", "a", "field", "as", "having", "to", "be", "between", "values" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Validation/Rules/Rules.php#L113-L118
opulencephp/Opulence
src/Opulence/Validation/Rules/Rules.php
Rules.condition
public function condition($callback) : self { if ($this->inCondition) { throw new LogicException('Cannot nest rule conditions'); } // Order is important here $this->createRule(ConditionalRule::class, [$callback]); $this->inCondition = true; return $this; }
php
public function condition($callback) : self { if ($this->inCondition) { throw new LogicException('Cannot nest rule conditions'); } // Order is important here $this->createRule(ConditionalRule::class, [$callback]); $this->inCondition = true; return $this; }
[ "public", "function", "condition", "(", "$", "callback", ")", ":", "self", "{", "if", "(", "$", "this", "->", "inCondition", ")", "{", "throw", "new", "LogicException", "(", "'Cannot nest rule conditions'", ")", ";", "}", "// Order is important here", "$", "th...
Specifies conditions that must be met for certain rules to be set @param callable $callback The callback to evaluate The variable list of rules It must accept an array of all values @return self For method chaining @throws LogicException Thrown if we were already in a condition
[ "Specifies", "conditions", "that", "must", "be", "met", "for", "certain", "rules", "to", "be", "set" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Validation/Rules/Rules.php#L128-L139
opulencephp/Opulence
src/Opulence/Validation/Rules/Rules.php
Rules.getErrors
public function getErrors(string $field) : array { $compiledErrors = []; foreach ($this->errorSlugsAndPlaceholders as $errorData) { $compiledErrors[] = $this->errorTemplateCompiler->compile( $field, $this->errorTemplateRegistry->getErrorTemplate($field, $errorData['slug']), $errorData['placeholders'] ); } return $compiledErrors; }
php
public function getErrors(string $field) : array { $compiledErrors = []; foreach ($this->errorSlugsAndPlaceholders as $errorData) { $compiledErrors[] = $this->errorTemplateCompiler->compile( $field, $this->errorTemplateRegistry->getErrorTemplate($field, $errorData['slug']), $errorData['placeholders'] ); } return $compiledErrors; }
[ "public", "function", "getErrors", "(", "string", "$", "field", ")", ":", "array", "{", "$", "compiledErrors", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "errorSlugsAndPlaceholders", "as", "$", "errorData", ")", "{", "$", "compiledErrors", "[",...
Gets the error messages @param string $field The name of the field whose errors we're getting @return array The list of errors
[ "Gets", "the", "error", "messages" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Validation/Rules/Rules.php#L210-L223
opulencephp/Opulence
src/Opulence/Validation/Rules/Rules.php
Rules.max
public function max($max, bool $isInclusive = true) : self { $this->createRule(MaxRule::class, [$max, $isInclusive]); return $this; }
php
public function max($max, bool $isInclusive = true) : self { $this->createRule(MaxRule::class, [$max, $isInclusive]); return $this; }
[ "public", "function", "max", "(", "$", "max", ",", "bool", "$", "isInclusive", "=", "true", ")", ":", "self", "{", "$", "this", "->", "createRule", "(", "MaxRule", "::", "class", ",", "[", "$", "max", ",", "$", "isInclusive", "]", ")", ";", "return...
Marks a field as having a maximum acceptable value @param int|float $max The maximum value to compare against @param bool $isInclusive Whether or not the maximum is inclusive @return self For method chaining
[ "Marks", "a", "field", "as", "having", "a", "maximum", "acceptable", "value" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Validation/Rules/Rules.php#L269-L274
opulencephp/Opulence
src/Opulence/Validation/Rules/Rules.php
Rules.min
public function min($min, bool $isInclusive = true) : self { $this->createRule(MinRule::class, [$min, $isInclusive]); return $this; }
php
public function min($min, bool $isInclusive = true) : self { $this->createRule(MinRule::class, [$min, $isInclusive]); return $this; }
[ "public", "function", "min", "(", "$", "min", ",", "bool", "$", "isInclusive", "=", "true", ")", ":", "self", "{", "$", "this", "->", "createRule", "(", "MinRule", "::", "class", ",", "[", "$", "min", ",", "$", "isInclusive", "]", ")", ";", "return...
Marks a field as having a minimum acceptable value @param int|float $min The minimum value to compare against @param bool $isInclusive Whether or not the minimum is inclusive @return self For method chaining
[ "Marks", "a", "field", "as", "having", "a", "minimum", "acceptable", "value" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Validation/Rules/Rules.php#L283-L288
opulencephp/Opulence
src/Opulence/Validation/Rules/Rules.php
Rules.pass
public function pass($value, array $allValues = [], bool $haltFieldValidationOnFailure = false) : bool { $this->errorSlugsAndPlaceholders = []; $passes = true; foreach ($this->rules as $rule) { // Non-required fields do not need to evaluate all rules when empty if (!$this->isRequired) { if ( $value === null || (is_string($value) && $value === '') || ((is_array($value) || $value instanceof Countable) && count($value) === 0) ) { continue; } } $thisRulePasses = $rule->passes($value, $allValues); if (!$thisRulePasses) { $this->addError($rule); } if ($haltFieldValidationOnFailure) { if (!$thisRulePasses) { return false; } } else { $passes = $thisRulePasses && $passes; } } return $passes; }
php
public function pass($value, array $allValues = [], bool $haltFieldValidationOnFailure = false) : bool { $this->errorSlugsAndPlaceholders = []; $passes = true; foreach ($this->rules as $rule) { // Non-required fields do not need to evaluate all rules when empty if (!$this->isRequired) { if ( $value === null || (is_string($value) && $value === '') || ((is_array($value) || $value instanceof Countable) && count($value) === 0) ) { continue; } } $thisRulePasses = $rule->passes($value, $allValues); if (!$thisRulePasses) { $this->addError($rule); } if ($haltFieldValidationOnFailure) { if (!$thisRulePasses) { return false; } } else { $passes = $thisRulePasses && $passes; } } return $passes; }
[ "public", "function", "pass", "(", "$", "value", ",", "array", "$", "allValues", "=", "[", "]", ",", "bool", "$", "haltFieldValidationOnFailure", "=", "false", ")", ":", "bool", "{", "$", "this", "->", "errorSlugsAndPlaceholders", "=", "[", "]", ";", "$"...
Gets whether or not all the rules pass @param mixed $value The value to validate @param array $allValues The list of all values @param bool $haltFieldValidationOnFailure True if we want to not check any other rules for a field once one fails, otherwise false @return bool True if all the rules pass, otherwise false
[ "Gets", "whether", "or", "not", "all", "the", "rules", "pass" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Validation/Rules/Rules.php#L324-L357
opulencephp/Opulence
src/Opulence/Validation/Rules/Rules.php
Rules.addError
protected function addError(IRule $rule) { if ($rule instanceof ConditionalRule) { $rules = $rule->getRules(); } else { $rules = [$rule]; } foreach ($rules as $singleRule) { $this->errorSlugsAndPlaceholders[] = [ 'slug' => $singleRule->getSlug(), 'placeholders' => $singleRule instanceof IRuleWithErrorPlaceholders ? $singleRule->getErrorPlaceholders() : [] ]; } }
php
protected function addError(IRule $rule) { if ($rule instanceof ConditionalRule) { $rules = $rule->getRules(); } else { $rules = [$rule]; } foreach ($rules as $singleRule) { $this->errorSlugsAndPlaceholders[] = [ 'slug' => $singleRule->getSlug(), 'placeholders' => $singleRule instanceof IRuleWithErrorPlaceholders ? $singleRule->getErrorPlaceholders() : [] ]; } }
[ "protected", "function", "addError", "(", "IRule", "$", "rule", ")", "{", "if", "(", "$", "rule", "instanceof", "ConditionalRule", ")", "{", "$", "rules", "=", "$", "rule", "->", "getRules", "(", ")", ";", "}", "else", "{", "$", "rules", "=", "[", ...
Adds an error @param IRule $rule The rule that failed
[ "Adds", "an", "error" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Validation/Rules/Rules.php#L390-L404
opulencephp/Opulence
src/Opulence/Validation/Rules/Rules.php
Rules.addRule
protected function addRule(IRule $rule) { if ($this->inCondition) { /** @var ConditionalRule $lastRule */ $lastRule = $this->rules[count($this->rules) - 1]; $lastRule->addRule($rule); } else { $this->rules[] = $rule; } }
php
protected function addRule(IRule $rule) { if ($this->inCondition) { /** @var ConditionalRule $lastRule */ $lastRule = $this->rules[count($this->rules) - 1]; $lastRule->addRule($rule); } else { $this->rules[] = $rule; } }
[ "protected", "function", "addRule", "(", "IRule", "$", "rule", ")", "{", "if", "(", "$", "this", "->", "inCondition", ")", "{", "/** @var ConditionalRule $lastRule */", "$", "lastRule", "=", "$", "this", "->", "rules", "[", "count", "(", "$", "this", "->",...
Adds a rule to the list @param IRule $rule The rule to add
[ "Adds", "a", "rule", "to", "the", "list" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Validation/Rules/Rules.php#L411-L420
opulencephp/Opulence
src/Opulence/Validation/Rules/Rules.php
Rules.createRule
protected function createRule(string $className, array $args = []) { if (!class_exists($className)) { throw new InvalidArgumentException("Class \"$className\" does not exist"); } /** @var IRule|IRuleWithArgs $rule */ $rule = new $className; if ($rule instanceof IRuleWithArgs) { $rule->setArgs($args); } $this->addRule($rule); }
php
protected function createRule(string $className, array $args = []) { if (!class_exists($className)) { throw new InvalidArgumentException("Class \"$className\" does not exist"); } /** @var IRule|IRuleWithArgs $rule */ $rule = new $className; if ($rule instanceof IRuleWithArgs) { $rule->setArgs($args); } $this->addRule($rule); }
[ "protected", "function", "createRule", "(", "string", "$", "className", ",", "array", "$", "args", "=", "[", "]", ")", "{", "if", "(", "!", "class_exists", "(", "$", "className", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Class \\\"...
Adds a rule with the input name and arguments @param string $className The fully name of the rule class, eg "Opulence\...\RequiredRule" @param array $args The extra arguments @throws InvalidArgumentException Thrown if no rule exists with the input name
[ "Adds", "a", "rule", "with", "the", "input", "name", "and", "arguments" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Validation/Rules/Rules.php#L429-L443
opulencephp/Opulence
src/Opulence/Debug/Exceptions/Handlers/Http/ExceptionRenderer.php
ExceptionRenderer.getDefaultResponseContent
protected function getDefaultResponseContent(Exception $ex, int $statusCode) : string { if ($this->inDevelopmentEnvironment) { $content = $this->getDevelopmentEnvironmentContent($ex, $statusCode); } else { $content = $this->getProductionEnvironmentContent($ex, $statusCode); } return $content; }
php
protected function getDefaultResponseContent(Exception $ex, int $statusCode) : string { if ($this->inDevelopmentEnvironment) { $content = $this->getDevelopmentEnvironmentContent($ex, $statusCode); } else { $content = $this->getProductionEnvironmentContent($ex, $statusCode); } return $content; }
[ "protected", "function", "getDefaultResponseContent", "(", "Exception", "$", "ex", ",", "int", "$", "statusCode", ")", ":", "string", "{", "if", "(", "$", "this", "->", "inDevelopmentEnvironment", ")", "{", "$", "content", "=", "$", "this", "->", "getDevelop...
Gets the default response content @param Exception $ex The exception @param int $statusCode The HTTP status code @return string The content of the response
[ "Gets", "the", "default", "response", "content" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Debug/Exceptions/Handlers/Http/ExceptionRenderer.php#L84-L93
opulencephp/Opulence
src/Opulence/Debug/Exceptions/Handlers/Http/ExceptionRenderer.php
ExceptionRenderer.getDevelopmentEnvironmentContent
protected function getDevelopmentEnvironmentContent(Exception $ex, int $statusCode) : string { ob_start(); if ($statusCode === 503) { require __DIR__ . "/templates/{$this->getRequestFormat()}/MaintenanceMode.php"; } else { require __DIR__ . "/templates/{$this->getRequestFormat()}/DevelopmentException.php"; } return ob_get_clean(); }
php
protected function getDevelopmentEnvironmentContent(Exception $ex, int $statusCode) : string { ob_start(); if ($statusCode === 503) { require __DIR__ . "/templates/{$this->getRequestFormat()}/MaintenanceMode.php"; } else { require __DIR__ . "/templates/{$this->getRequestFormat()}/DevelopmentException.php"; } return ob_get_clean(); }
[ "protected", "function", "getDevelopmentEnvironmentContent", "(", "Exception", "$", "ex", ",", "int", "$", "statusCode", ")", ":", "string", "{", "ob_start", "(", ")", ";", "if", "(", "$", "statusCode", "===", "503", ")", "{", "require", "__DIR__", ".", "\...
Gets the page contents for the default production exception page @param Exception $ex The exception @param int $statusCode The HTTP status code @return string The contents of the page
[ "Gets", "the", "page", "contents", "for", "the", "default", "production", "exception", "page" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Debug/Exceptions/Handlers/Http/ExceptionRenderer.php#L102-L113
opulencephp/Opulence
src/Opulence/Debug/Exceptions/Handlers/Http/ExceptionRenderer.php
ExceptionRenderer.getResponseContent
protected function getResponseContent($ex, int $statusCode, array $headers) : string { return $this->getDefaultResponseContent($ex, $statusCode); }
php
protected function getResponseContent($ex, int $statusCode, array $headers) : string { return $this->getDefaultResponseContent($ex, $statusCode); }
[ "protected", "function", "getResponseContent", "(", "$", "ex", ",", "int", "$", "statusCode", ",", "array", "$", "headers", ")", ":", "string", "{", "return", "$", "this", "->", "getDefaultResponseContent", "(", "$", "ex", ",", "$", "statusCode", ")", ";",...
Gets the content for the response @param Throwable|Exception $ex The exception @param int $statusCode The HTTP status code @param array $headers The HTTP headers @return string The response content
[ "Gets", "the", "content", "for", "the", "response" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Debug/Exceptions/Handlers/Http/ExceptionRenderer.php#L157-L160
opulencephp/Opulence
src/Opulence/Applications/Application.php
Application.shutDown
public function shutDown(callable $shutdownTask = null) { $taskReturnValue = null; // Don't shut down a shutdown application if ($this->isRunning) { try { $this->taskDispatcher->dispatch(TaskTypes::PRE_SHUTDOWN); $this->isRunning = false; if ($shutdownTask !== null) { $taskReturnValue = $shutdownTask(); } $this->taskDispatcher->dispatch(TaskTypes::POST_SHUTDOWN); } catch (Exception $ex) { $this->isRunning = false; throw $ex; } } return $taskReturnValue; }
php
public function shutDown(callable $shutdownTask = null) { $taskReturnValue = null; // Don't shut down a shutdown application if ($this->isRunning) { try { $this->taskDispatcher->dispatch(TaskTypes::PRE_SHUTDOWN); $this->isRunning = false; if ($shutdownTask !== null) { $taskReturnValue = $shutdownTask(); } $this->taskDispatcher->dispatch(TaskTypes::POST_SHUTDOWN); } catch (Exception $ex) { $this->isRunning = false; throw $ex; } } return $taskReturnValue; }
[ "public", "function", "shutDown", "(", "callable", "$", "shutdownTask", "=", "null", ")", "{", "$", "taskReturnValue", "=", "null", ";", "// Don't shut down a shutdown application", "if", "(", "$", "this", "->", "isRunning", ")", "{", "try", "{", "$", "this", ...
Shuts down this application @param callable $shutdownTask The task to perform on shutdown @return mixed|null The return value of the task if there was one, otherwise null @throws Exception Thrown if there was an error shutting down the application @deprecated 1.1.0 This method will be removed
[ "Shuts", "down", "this", "application" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Applications/Application.php#L69-L92
opulencephp/Opulence
src/Opulence/Applications/Application.php
Application.start
public function start(callable $startTask = null) { $taskReturnValue = null; // Don't start a running application if (!$this->isRunning) { try { $this->taskDispatcher->dispatch(TaskTypes::PRE_START); $this->isRunning = true; if ($startTask !== null) { $taskReturnValue = $startTask(); } $this->taskDispatcher->dispatch(TaskTypes::POST_START); } catch (Exception $ex) { $this->shutDown(); throw $ex; } } return $taskReturnValue; }
php
public function start(callable $startTask = null) { $taskReturnValue = null; // Don't start a running application if (!$this->isRunning) { try { $this->taskDispatcher->dispatch(TaskTypes::PRE_START); $this->isRunning = true; if ($startTask !== null) { $taskReturnValue = $startTask(); } $this->taskDispatcher->dispatch(TaskTypes::POST_START); } catch (Exception $ex) { $this->shutDown(); throw $ex; } } return $taskReturnValue; }
[ "public", "function", "start", "(", "callable", "$", "startTask", "=", "null", ")", "{", "$", "taskReturnValue", "=", "null", ";", "// Don't start a running application", "if", "(", "!", "$", "this", "->", "isRunning", ")", "{", "try", "{", "$", "this", "-...
Starts this application @param callable $startTask The task to perform on startup @return mixed|null The return value of the task if there was one, otherwise null @throws Exception Thrown if there was a problem starting the application @deprecated 1.1.0 This method will be removed
[ "Starts", "this", "application" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Applications/Application.php#L102-L125
opulencephp/Opulence
src/Opulence/QueryBuilders/DeleteQuery.php
DeleteQuery.addUsing
public function addUsing(string ...$expression) : self { $this->usingExpressions = array_merge($this->usingExpressions, $expression); return $this; }
php
public function addUsing(string ...$expression) : self { $this->usingExpressions = array_merge($this->usingExpressions, $expression); return $this; }
[ "public", "function", "addUsing", "(", "string", "...", "$", "expression", ")", ":", "self", "{", "$", "this", "->", "usingExpressions", "=", "array_merge", "(", "$", "this", "->", "usingExpressions", ",", "$", "expression", ")", ";", "return", "$", "this"...
Adds to a "USING" expression @param string[] $expression,... A variable list of other tables' names to use in the WHERE condition @return self For method chaining
[ "Adds", "to", "a", "USING", "expression" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/QueryBuilders/DeleteQuery.php#L43-L48
opulencephp/Opulence
src/Opulence/QueryBuilders/DeleteQuery.php
DeleteQuery.andWhere
public function andWhere(...$conditions) : self { $this->conditionalQueryBuilder->andWhere( ...$this->createConditionExpressions($conditions) ); return $this; }
php
public function andWhere(...$conditions) : self { $this->conditionalQueryBuilder->andWhere( ...$this->createConditionExpressions($conditions) ); return $this; }
[ "public", "function", "andWhere", "(", "...", "$", "conditions", ")", ":", "self", "{", "$", "this", "->", "conditionalQueryBuilder", "->", "andWhere", "(", "...", "$", "this", "->", "createConditionExpressions", "(", "$", "conditions", ")", ")", ";", "retur...
Adds to a "WHERE" condition that will be "AND"ed with other conditions @param array $conditions,... A variable list of conditions to be met @return self For method chaining
[ "Adds", "to", "a", "WHERE", "condition", "that", "will", "be", "AND", "ed", "with", "other", "conditions" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/QueryBuilders/DeleteQuery.php#L56-L63
opulencephp/Opulence
src/Opulence/QueryBuilders/DeleteQuery.php
DeleteQuery.orWhere
public function orWhere(...$conditions) : self { $this->conditionalQueryBuilder->orWhere( ...$this->createConditionExpressions($conditions) ); return $this; }
php
public function orWhere(...$conditions) : self { $this->conditionalQueryBuilder->orWhere( ...$this->createConditionExpressions($conditions) ); return $this; }
[ "public", "function", "orWhere", "(", "...", "$", "conditions", ")", ":", "self", "{", "$", "this", "->", "conditionalQueryBuilder", "->", "orWhere", "(", "...", "$", "this", "->", "createConditionExpressions", "(", "$", "conditions", ")", ")", ";", "return"...
Adds to a "WHERE" condition that will be "OR"ed with other conditions @param array $conditions,... A variable list of conditions to be met @return self For method chaining
[ "Adds", "to", "a", "WHERE", "condition", "that", "will", "be", "OR", "ed", "with", "other", "conditions" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/QueryBuilders/DeleteQuery.php#L89-L96
opulencephp/Opulence
src/Opulence/QueryBuilders/DeleteQuery.php
DeleteQuery.where
public function where(...$conditions) : self { $this->conditionalQueryBuilder->where( ...$this->createConditionExpressions($conditions) ); return $this; }
php
public function where(...$conditions) : self { $this->conditionalQueryBuilder->where( ...$this->createConditionExpressions($conditions) ); return $this; }
[ "public", "function", "where", "(", "...", "$", "conditions", ")", ":", "self", "{", "$", "this", "->", "conditionalQueryBuilder", "->", "where", "(", "...", "$", "this", "->", "createConditionExpressions", "(", "$", "conditions", ")", ")", ";", "return", ...
Starts a "WHERE" condition Only call this method once per query because it will overwrite any previously-set "WHERE" expressions @param array $conditions,... A variable list of conditions to be met @return self For method chaining
[ "Starts", "a", "WHERE", "condition", "Only", "call", "this", "method", "once", "per", "query", "because", "it", "will", "overwrite", "any", "previously", "-", "set", "WHERE", "expressions" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/QueryBuilders/DeleteQuery.php#L119-L126
opulencephp/Opulence
src/Opulence/QueryBuilders/DeleteQuery.php
DeleteQuery.createConditionExpressions
private function createConditionExpressions(array $conditions) : array { $conditionExpressions = []; foreach ($conditions as $condition) { if ($condition instanceof ICondition) { $this->addUnnamedPlaceholderValues($condition->getParameters()); $conditionExpressions[] = $condition->getSql(); } elseif (is_string($condition)) { $conditionExpressions[] = $condition; } else { throw new InvalidArgumentException('Condition must either be string or ICondition object'); } } return $conditionExpressions; }
php
private function createConditionExpressions(array $conditions) : array { $conditionExpressions = []; foreach ($conditions as $condition) { if ($condition instanceof ICondition) { $this->addUnnamedPlaceholderValues($condition->getParameters()); $conditionExpressions[] = $condition->getSql(); } elseif (is_string($condition)) { $conditionExpressions[] = $condition; } else { throw new InvalidArgumentException('Condition must either be string or ICondition object'); } } return $conditionExpressions; }
[ "private", "function", "createConditionExpressions", "(", "array", "$", "conditions", ")", ":", "array", "{", "$", "conditionExpressions", "=", "[", "]", ";", "foreach", "(", "$", "conditions", "as", "$", "condition", ")", "{", "if", "(", "$", "condition", ...
Converts a list of condition strings or objects to their string representations @param array $conditions The list of strings of condition objects to convert @return array The list of condition expressions
[ "Converts", "a", "list", "of", "condition", "strings", "or", "objects", "to", "their", "string", "representations" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/QueryBuilders/DeleteQuery.php#L134-L150
opulencephp/Opulence
src/Opulence/Views/Factories/ViewFactory.php
ViewFactory.runBuilders
protected function runBuilders(string $name, string $resolvedPath, IView $view) : IView { $builders = []; // If there's a builder registered to the same name as the view if (isset($this->builders[$name])) { $builders = $this->builders[$name]; } else { $pathInfo = pathinfo($resolvedPath); $filename = $pathInfo['filename']; $basename = $pathInfo['basename']; /** * If there's a builder registered without the extension and it resolves to the correct view file path * Else if there's a builder registered with the extension and it resolves to the correct view file path */ if (isset($this->builders[$filename]) && $this->viewNameResolver->resolve($filename) == $resolvedPath) { $builders = $this->builders[$filename]; } elseif (isset($this->builders[$basename]) && $this->viewNameResolver->resolve($basename) == $resolvedPath) { $builders = $this->builders[$basename]; } } foreach ($builders as $callback) { $view = $callback($view); } return $view; }
php
protected function runBuilders(string $name, string $resolvedPath, IView $view) : IView { $builders = []; // If there's a builder registered to the same name as the view if (isset($this->builders[$name])) { $builders = $this->builders[$name]; } else { $pathInfo = pathinfo($resolvedPath); $filename = $pathInfo['filename']; $basename = $pathInfo['basename']; /** * If there's a builder registered without the extension and it resolves to the correct view file path * Else if there's a builder registered with the extension and it resolves to the correct view file path */ if (isset($this->builders[$filename]) && $this->viewNameResolver->resolve($filename) == $resolvedPath) { $builders = $this->builders[$filename]; } elseif (isset($this->builders[$basename]) && $this->viewNameResolver->resolve($basename) == $resolvedPath) { $builders = $this->builders[$basename]; } } foreach ($builders as $callback) { $view = $callback($view); } return $view; }
[ "protected", "function", "runBuilders", "(", "string", "$", "name", ",", "string", "$", "resolvedPath", ",", "IView", "$", "view", ")", ":", "IView", "{", "$", "builders", "=", "[", "]", ";", "// If there's a builder registered to the same name as the view", "if",...
Runs the builders for a view (if there any) @param string $name The name of the view file @param string $resolvedPath The resolved path to the view file @param IView $view The view to run builders on @return IView The built view
[ "Runs", "the", "builders", "for", "a", "view", "(", "if", "there", "any", ")" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Views/Factories/ViewFactory.php#L89-L117
opulencephp/Opulence
src/Opulence/Routing/Routes/RouteCollection.php
RouteCollection.add
public function add(ParsedRoute $route) { foreach ($route->getMethods() as $method) { $this->routes[$method][] = $route; if (!empty($route->getName())) { $this->namedRoutes[$route->getName()] =& $route; } } }
php
public function add(ParsedRoute $route) { foreach ($route->getMethods() as $method) { $this->routes[$method][] = $route; if (!empty($route->getName())) { $this->namedRoutes[$route->getName()] =& $route; } } }
[ "public", "function", "add", "(", "ParsedRoute", "$", "route", ")", "{", "foreach", "(", "$", "route", "->", "getMethods", "(", ")", "as", "$", "method", ")", "{", "$", "this", "->", "routes", "[", "$", "method", "]", "[", "]", "=", "$", "route", ...
Adds a route to the collection @param ParsedRoute $route The route to add
[ "Adds", "a", "route", "to", "the", "collection" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Routing/Routes/RouteCollection.php#L109-L118
opulencephp/Opulence
src/Opulence/Routing/Routes/RouteCollection.php
RouteCollection.get
public function get(string $method = null) : array { if ($method === null) { return $this->routes; } elseif (isset($this->routes[$method])) { return $this->routes[$method]; } else { return []; } }
php
public function get(string $method = null) : array { if ($method === null) { return $this->routes; } elseif (isset($this->routes[$method])) { return $this->routes[$method]; } else { return []; } }
[ "public", "function", "get", "(", "string", "$", "method", "=", "null", ")", ":", "array", "{", "if", "(", "$", "method", "===", "null", ")", "{", "return", "$", "this", "->", "routes", ";", "}", "elseif", "(", "isset", "(", "$", "this", "->", "r...
Gets all the routes @param string|null $method If specified, the list of routes for that method will be returned If null, all routes will be returned, keyed by method @return ParsedRoute[] The list of routes
[ "Gets", "all", "the", "routes" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Routing/Routes/RouteCollection.php#L127-L136
opulencephp/Opulence
src/Opulence/QueryBuilders/MySql/InsertQuery.php
InsertQuery.addUpdateColumnValues
public function addUpdateColumnValues(array $columnNamesToValues) : self { $this->duplicateKeyUpdateColumnNamesToValues = array_merge( $this->duplicateKeyUpdateColumnNamesToValues, $columnNamesToValues ); return $this; }
php
public function addUpdateColumnValues(array $columnNamesToValues) : self { $this->duplicateKeyUpdateColumnNamesToValues = array_merge( $this->duplicateKeyUpdateColumnNamesToValues, $columnNamesToValues ); return $this; }
[ "public", "function", "addUpdateColumnValues", "(", "array", "$", "columnNamesToValues", ")", ":", "self", "{", "$", "this", "->", "duplicateKeyUpdateColumnNamesToValues", "=", "array_merge", "(", "$", "this", "->", "duplicateKeyUpdateColumnNamesToValues", ",", "$", "...
Adds columns to update in the case a row already exists in the table @param array $columnNamesToValues The mapping of column names to their respective values in the case of an "ON DUPLICATE KEY UPDATE" clause @return self For method chaining
[ "Adds", "columns", "to", "update", "in", "the", "case", "a", "row", "already", "exists", "in", "the", "table" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/QueryBuilders/MySql/InsertQuery.php#L30-L38
opulencephp/Opulence
src/Opulence/QueryBuilders/Query.php
Query.addNamedPlaceholderValue
public function addNamedPlaceholderValue(string $placeholderName, $value, int $dataType = PDO::PARAM_STR) : self { if ($this->usingUnnamedPlaceholders === true) { throw new InvalidQueryException('Cannot mix unnamed placeholders with named placeholders'); } $this->usingUnnamedPlaceholders = false; $this->parameters[$placeholderName] = [$value, $dataType]; return $this; }
php
public function addNamedPlaceholderValue(string $placeholderName, $value, int $dataType = PDO::PARAM_STR) : self { if ($this->usingUnnamedPlaceholders === true) { throw new InvalidQueryException('Cannot mix unnamed placeholders with named placeholders'); } $this->usingUnnamedPlaceholders = false; $this->parameters[$placeholderName] = [$value, $dataType]; return $this; }
[ "public", "function", "addNamedPlaceholderValue", "(", "string", "$", "placeholderName", ",", "$", "value", ",", "int", "$", "dataType", "=", "PDO", "::", "PARAM_STR", ")", ":", "self", "{", "if", "(", "$", "this", "->", "usingUnnamedPlaceholders", "===", "t...
Adds a named placeholder's value Note that you cannot use a mix of named and unnamed placeholders in a query @param string $placeholderName The name of the placeholder (what comes after the ":") @param mixed $value The value of the placeholder @param int $dataType The PDO constant that indicates the type of data the value represents @return self For method chaining @throws InvalidQueryException Thrown if the user mixed unnamed placeholders with named placeholders
[ "Adds", "a", "named", "placeholder", "s", "value", "Note", "that", "you", "cannot", "use", "a", "mix", "of", "named", "and", "unnamed", "placeholders", "in", "a", "query" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/QueryBuilders/Query.php#L52-L62
opulencephp/Opulence
src/Opulence/QueryBuilders/Query.php
Query.addNamedPlaceholderValues
public function addNamedPlaceholderValues(array $placeholderNamesToValues) : self { foreach ($placeholderNamesToValues as $placeholderName => $value) { if (is_array($value)) { if (count($value) !== 2) { throw new InvalidQueryException('Incorrect number of items in value array'); } $this->addNamedPlaceholderValue($placeholderName, $value[0], $value[1]); } else { $this->addNamedPlaceholderValue($placeholderName, $value); } } return $this; }
php
public function addNamedPlaceholderValues(array $placeholderNamesToValues) : self { foreach ($placeholderNamesToValues as $placeholderName => $value) { if (is_array($value)) { if (count($value) !== 2) { throw new InvalidQueryException('Incorrect number of items in value array'); } $this->addNamedPlaceholderValue($placeholderName, $value[0], $value[1]); } else { $this->addNamedPlaceholderValue($placeholderName, $value); } } return $this; }
[ "public", "function", "addNamedPlaceholderValues", "(", "array", "$", "placeholderNamesToValues", ")", ":", "self", "{", "foreach", "(", "$", "placeholderNamesToValues", "as", "$", "placeholderName", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$",...
Adds named placeholders' values Note that you cannot use a mix of named and unnamed placeholders in a query @param array $placeholderNamesToValues The mapping of placeholder names to their respective values Optionally, the names can map to an array whose first item is the value and whose second value is the PDO constant indicating the type of data the value represents @return self For method chaining @throws InvalidQueryException Thrown if the user mixed unnamed placeholders with named placeholders or if the value is an array that doesn't contain the correct number of items
[ "Adds", "named", "placeholders", "values", "Note", "that", "you", "cannot", "use", "a", "mix", "of", "named", "and", "unnamed", "placeholders", "in", "a", "query" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/QueryBuilders/Query.php#L75-L90
opulencephp/Opulence
src/Opulence/QueryBuilders/Query.php
Query.addUnnamedPlaceholderValue
public function addUnnamedPlaceholderValue($value, int $dataType = PDO::PARAM_STR) : self { if ($this->usingUnnamedPlaceholders === false) { throw new InvalidQueryException('Cannot mix unnamed placeholders with named placeholders'); } $this->usingUnnamedPlaceholders = true; $this->parameters[] = [$value, $dataType]; return $this; }
php
public function addUnnamedPlaceholderValue($value, int $dataType = PDO::PARAM_STR) : self { if ($this->usingUnnamedPlaceholders === false) { throw new InvalidQueryException('Cannot mix unnamed placeholders with named placeholders'); } $this->usingUnnamedPlaceholders = true; $this->parameters[] = [$value, $dataType]; return $this; }
[ "public", "function", "addUnnamedPlaceholderValue", "(", "$", "value", ",", "int", "$", "dataType", "=", "PDO", "::", "PARAM_STR", ")", ":", "self", "{", "if", "(", "$", "this", "->", "usingUnnamedPlaceholders", "===", "false", ")", "{", "throw", "new", "I...
Adds an unnamed placeholder's value Note that you cannot use a mix of named and unnamed placeholders in a query @param mixed $value @param int $dataType The PDO constant that indicates the type of data the value represents @return self For method chaining @throws InvalidQueryException Thrown if the user mixed unnamed placeholders with named placeholders
[ "Adds", "an", "unnamed", "placeholder", "s", "value", "Note", "that", "you", "cannot", "use", "a", "mix", "of", "named", "and", "unnamed", "placeholders", "in", "a", "query" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/QueryBuilders/Query.php#L101-L111
opulencephp/Opulence
src/Opulence/QueryBuilders/Query.php
Query.addUnnamedPlaceholderValues
public function addUnnamedPlaceholderValues(array $placeholderValues) : self { foreach ($placeholderValues as $value) { if (is_array($value)) { if (count($value) !== 2) { throw new InvalidQueryException('Incorrect number of items in value array'); } $this->addUnnamedPlaceholderValue($value[0], $value[1]); } else { $this->addUnnamedPlaceholderValue($value); } } return $this; }
php
public function addUnnamedPlaceholderValues(array $placeholderValues) : self { foreach ($placeholderValues as $value) { if (is_array($value)) { if (count($value) !== 2) { throw new InvalidQueryException('Incorrect number of items in value array'); } $this->addUnnamedPlaceholderValue($value[0], $value[1]); } else { $this->addUnnamedPlaceholderValue($value); } } return $this; }
[ "public", "function", "addUnnamedPlaceholderValues", "(", "array", "$", "placeholderValues", ")", ":", "self", "{", "foreach", "(", "$", "placeholderValues", "as", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "if", "(", ...
Adds multiple unnamed placeholders' values Note that you cannot use a mix of named and unnamed placeholders in a query @param array $placeholderValues The list of placeholder values Optionally, each value can be contained in an array whose first item is the value and whose second value is the PDO constant indicating the type of data the value represents @return self For method chaining @throws InvalidQueryException Thrown if the user mixed unnamed placeholders with named placeholders or if the value is an array that doesn't contain the correct number of items
[ "Adds", "multiple", "unnamed", "placeholders", "values", "Note", "that", "you", "cannot", "use", "a", "mix", "of", "named", "and", "unnamed", "placeholders", "in", "a", "query" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/QueryBuilders/Query.php#L124-L139
opulencephp/Opulence
src/Opulence/QueryBuilders/Query.php
Query.removeNamedPlaceHolder
public function removeNamedPlaceHolder(string $placeholderName) : self { if ($this->usingUnnamedPlaceholders === true) { throw new InvalidQueryException('Cannot mix unnamed placeholders with named placeholders'); } unset($this->parameters[$placeholderName]); return $this; }
php
public function removeNamedPlaceHolder(string $placeholderName) : self { if ($this->usingUnnamedPlaceholders === true) { throw new InvalidQueryException('Cannot mix unnamed placeholders with named placeholders'); } unset($this->parameters[$placeholderName]); return $this; }
[ "public", "function", "removeNamedPlaceHolder", "(", "string", "$", "placeholderName", ")", ":", "self", "{", "if", "(", "$", "this", "->", "usingUnnamedPlaceholders", "===", "true", ")", "{", "throw", "new", "InvalidQueryException", "(", "'Cannot mix unnamed placeh...
Removes a named placeholder from the query @param string $placeholderName The name of the placeholder to remove @return self For method chaining @throws InvalidQueryException Thrown if the user mixed unnamed placeholders with named placeholders
[ "Removes", "a", "named", "placeholder", "from", "the", "query" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/QueryBuilders/Query.php#L158-L167
opulencephp/Opulence
src/Opulence/QueryBuilders/Query.php
Query.removeUnnamedPlaceHolder
public function removeUnnamedPlaceHolder(int $placeholderIndex) : self { if ($this->usingUnnamedPlaceholders === false) { throw new InvalidQueryException('Cannot mix unnamed placeholders with named placeholders'); } unset($this->parameters[$placeholderIndex]); // Re-index the array $this->parameters = array_values($this->parameters); return $this; }
php
public function removeUnnamedPlaceHolder(int $placeholderIndex) : self { if ($this->usingUnnamedPlaceholders === false) { throw new InvalidQueryException('Cannot mix unnamed placeholders with named placeholders'); } unset($this->parameters[$placeholderIndex]); // Re-index the array $this->parameters = array_values($this->parameters); return $this; }
[ "public", "function", "removeUnnamedPlaceHolder", "(", "int", "$", "placeholderIndex", ")", ":", "self", "{", "if", "(", "$", "this", "->", "usingUnnamedPlaceholders", "===", "false", ")", "{", "throw", "new", "InvalidQueryException", "(", "'Cannot mix unnamed place...
Removes an unnamed placeholder from the query @param int $placeholderIndex The index of the placeholder in the parameters to remove @return self For method chaining @throws InvalidQueryException Thrown if the user mixed unnamed placeholders with named placeholders
[ "Removes", "an", "unnamed", "placeholder", "from", "the", "query" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/QueryBuilders/Query.php#L176-L187
opulencephp/Opulence
src/Opulence/QueryBuilders/Query.php
Query.setTable
protected function setTable(string $tableName, string $tableAlias = '') { $this->tableName = $tableName; $this->tableAlias = $tableAlias; }
php
protected function setTable(string $tableName, string $tableAlias = '') { $this->tableName = $tableName; $this->tableAlias = $tableAlias; }
[ "protected", "function", "setTable", "(", "string", "$", "tableName", ",", "string", "$", "tableAlias", "=", "''", ")", "{", "$", "this", "->", "tableName", "=", "$", "tableName", ";", "$", "this", "->", "tableAlias", "=", "$", "tableAlias", ";", "}" ]
Sets the table we're querying @param string $tableName The name of the table we're querying @param string $tableAlias The table alias
[ "Sets", "the", "table", "we", "re", "querying" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/QueryBuilders/Query.php#L195-L199
opulencephp/Opulence
src/Opulence/Routing/Routes/CompiledRoute.php
CompiledRoute.getPathVar
public function getPathVar(string $name) { if (isset($this->pathVars[$name])) { return $this->pathVars[$name]; } return null; }
php
public function getPathVar(string $name) { if (isset($this->pathVars[$name])) { return $this->pathVars[$name]; } return null; }
[ "public", "function", "getPathVar", "(", "string", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "pathVars", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "pathVars", "[", "$", "name", "]", ";", "}", "ret...
Gets the value of a path variable @param string $name The name of the variable to get @return mixed|null The value of the variable if it exists, otherwise null
[ "Gets", "the", "value", "of", "a", "path", "variable" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Routing/Routes/CompiledRoute.php#L45-L52
opulencephp/Opulence
src/Opulence/Validation/Rules/Errors/ErrorTemplateRegistry.php
ErrorTemplateRegistry.getErrorTemplate
public function getErrorTemplate(string $field, string $ruleSlug) : string { if (isset($this->fieldTemplates[$field][$ruleSlug])) { return $this->fieldTemplates[$field][$ruleSlug]; } if (isset($this->globalTemplates[$ruleSlug])) { return $this->globalTemplates[$ruleSlug]; } return ''; }
php
public function getErrorTemplate(string $field, string $ruleSlug) : string { if (isset($this->fieldTemplates[$field][$ruleSlug])) { return $this->fieldTemplates[$field][$ruleSlug]; } if (isset($this->globalTemplates[$ruleSlug])) { return $this->globalTemplates[$ruleSlug]; } return ''; }
[ "public", "function", "getErrorTemplate", "(", "string", "$", "field", ",", "string", "$", "ruleSlug", ")", ":", "string", "{", "if", "(", "isset", "(", "$", "this", "->", "fieldTemplates", "[", "$", "field", "]", "[", "$", "ruleSlug", "]", ")", ")", ...
Gets the error template for a field and rule @param string $field The field whose template we want @param string $ruleSlug The rule slug whose template we want @return string The error template
[ "Gets", "the", "error", "template", "for", "a", "field", "and", "rule" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Validation/Rules/Errors/ErrorTemplateRegistry.php#L32-L43
opulencephp/Opulence
src/Opulence/Validation/Rules/Errors/ErrorTemplateRegistry.php
ErrorTemplateRegistry.registerErrorTemplatesFromConfig
public function registerErrorTemplatesFromConfig(array $config) { foreach ($config as $key => $template) { if (trim($key) === '') { throw new InvalidArgumentException('Error template config key cannot be empty'); } if (mb_strpos($key, '.') === false) { $this->registerGlobalErrorTemplate($key, $template); } else { $keyParts = explode('.', $key); if (count($keyParts) !== 2 || trim($keyParts[0]) === '' || trim($keyParts[1]) === '') { throw new InvalidArgumentException('Error template config key cannot be empty'); } $this->registerFieldErrorTemplate($keyParts[0], $keyParts[1], $template); } } }
php
public function registerErrorTemplatesFromConfig(array $config) { foreach ($config as $key => $template) { if (trim($key) === '') { throw new InvalidArgumentException('Error template config key cannot be empty'); } if (mb_strpos($key, '.') === false) { $this->registerGlobalErrorTemplate($key, $template); } else { $keyParts = explode('.', $key); if (count($keyParts) !== 2 || trim($keyParts[0]) === '' || trim($keyParts[1]) === '') { throw new InvalidArgumentException('Error template config key cannot be empty'); } $this->registerFieldErrorTemplate($keyParts[0], $keyParts[1], $template); } } }
[ "public", "function", "registerErrorTemplatesFromConfig", "(", "array", "$", "config", ")", "{", "foreach", "(", "$", "config", "as", "$", "key", "=>", "$", "template", ")", "{", "if", "(", "trim", "(", "$", "key", ")", "===", "''", ")", "{", "throw", ...
Registers error templates from a config array @param array $config The mapping of rules to error templates Global error templates should be formatted "{slug}" => "{template}" Field error templates should be formatted "{field}.{slug}" => "{template}" @throws InvalidArgumentException Thrown if the config was invalid
[ "Registers", "error", "templates", "from", "a", "config", "array" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Validation/Rules/Errors/ErrorTemplateRegistry.php#L53-L72
opulencephp/Opulence
src/Opulence/Validation/Rules/Errors/ErrorTemplateRegistry.php
ErrorTemplateRegistry.registerFieldErrorTemplate
public function registerFieldErrorTemplate(string $field, string $ruleSlug, string $template) { if (!isset($this->fieldTemplates[$field])) { $this->fieldTemplates[$field] = []; } $this->fieldTemplates[$field][$ruleSlug] = $template; }
php
public function registerFieldErrorTemplate(string $field, string $ruleSlug, string $template) { if (!isset($this->fieldTemplates[$field])) { $this->fieldTemplates[$field] = []; } $this->fieldTemplates[$field][$ruleSlug] = $template; }
[ "public", "function", "registerFieldErrorTemplate", "(", "string", "$", "field", ",", "string", "$", "ruleSlug", ",", "string", "$", "template", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "fieldTemplates", "[", "$", "field", "]", ")", ")"...
Registers an error template for a specific field and rule @param string $field The field whose template we're registering @param string $ruleSlug The rule slug whose template we're registering @param string $template The template to register
[ "Registers", "an", "error", "template", "for", "a", "specific", "field", "and", "rule" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Validation/Rules/Errors/ErrorTemplateRegistry.php#L81-L88
opulencephp/Opulence
src/Opulence/Views/Compilers/Fortune/DirectiveTranspilerRegistrant.php
DirectiveTranspilerRegistrant.registerDirectiveTranspilers
public function registerDirectiveTranspilers(ITranspiler $transpiler) { $transpiler->registerDirectiveTranspiler('else', function () { return '<?php else: ?>'; }); $transpiler->registerDirectiveTranspiler('elseif', function ($expression) { return '<?php elseif' . $expression . ': ?>'; }); $transpiler->registerDirectiveTranspiler('forelse', function () { return '<?php endforeach; if(array_pop($__opulenceForElseEmpty)): ?>'; }); $transpiler->registerDirectiveTranspiler('endforeach', function () { return '<?php endforeach; ?>'; }); $transpiler->registerDirectiveTranspiler('endif', function () { return '<?php endif; ?>'; }); $transpiler->registerDirectiveTranspiler('endfor', function () { return '<?php endfor; ?>'; }); $transpiler->registerDirectiveTranspiler('endpart', function () { return '<?php $__opulenceFortuneTranspiler->endPart(); ?>'; }); $transpiler->registerDirectiveTranspiler('endwhile', function () { return '<?php endwhile; ?>'; }); $transpiler->registerDirectiveTranspiler('extends', function ($expression) use ($transpiler) { // Create the parent $code = '$__opulenceViewParent = $__opulenceViewFactory->createView' . $expression . ';'; $code .= '$__opulenceFortuneTranspiler->addParent($__opulenceViewParent, $__opulenceView);'; $code .= 'extract($__opulenceView->getVars());'; $transpiler->prepend('<?php ' . $code . ' ?>'); // Compile the parent, keep track of the contents, and echo them in the appended text $code = '$__opulenceParentContents = isset($__opulenceParentContents) ? $__opulenceParentContents : [];'; $code .= '$__opulenceParentContents[] = $__opulenceFortuneTranspiler->transpile($__opulenceViewParent);'; $transpiler->prepend('<?php ' . $code . ' ?>'); // Echo the contents at the end of the content $code = 'echo eval("?>" . array_shift($__opulenceParentContents));'; $transpiler->append('<?php ' . $code . ' ?>'); return ''; }); $transpiler->registerDirectiveTranspiler('for', function ($expression) { return '<?php for' . $expression . ': ?>'; }); $transpiler->registerDirectiveTranspiler('foreach', function ($expression) { return '<?php foreach' . $expression . ': ?>'; }); $transpiler->registerDirectiveTranspiler('forif', function ($expression) { $code = '<?php if(!isset($__opulenceForElseEmpty)): $__opulenceForElseEmpty = []; endif;'; $code .= '$__opulenceForElseEmpty[] = true;'; $code .= 'foreach' . $expression . ':'; $code .= '$__opulenceForElseEmpty[count($__opulenceForElseEmpty) - 1] = false; ?>'; return $code; }); $transpiler->registerDirectiveTranspiler('if', function ($expression) { return '<?php if' . $expression . ': ?>'; }); $transpiler->registerDirectiveTranspiler('include', function ($expression) { // Check if a list of variables were passed in as a second parameter if ( preg_match( "/^\(((('|\")(.*)\\3)|\\$[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*),\s*(.+)\)$/U", $expression, $matches ) === 1 ) { $sharedVars = trim($matches[5]); $factoryCreateCall = 'createView(' . $matches[1] . ')'; } else { $sharedVars = '[]'; $factoryCreateCall = 'createView' . $expression; } // Create an isolate scope for the included view $code = 'call_user_func(function() use ($__opulenceViewFactory, $__opulenceFortuneTranspiler){'; $code .= '$__opulenceIncludedView = $__opulenceViewFactory->' . $factoryCreateCall . ';'; $code .= 'extract($__opulenceIncludedView->getVars());'; // Extract any shared vars, which will override any identically-named view vars $code .= 'if(count(func_get_arg(0)) > 0){extract(func_get_arg(0));}'; $code .= 'eval("?>" . $__opulenceFortuneTranspiler->transpile($__opulenceIncludedView));'; $code .= '}, ' . $sharedVars . ');'; return "<?php $code ?>"; }); $transpiler->registerDirectiveTranspiler('parent', function () { // This placeholder will be overwritten later return '__opulenceParentPlaceholder'; }); $transpiler->registerDirectiveTranspiler('part', function ($expression) { return '<?php $__opulenceFortuneTranspiler->startPart' . $expression . '; ?>'; }); $transpiler->registerDirectiveTranspiler('show', function ($expression) { $expression = empty($expression) ? '()' : $expression; return '<?php echo $__opulenceFortuneTranspiler->showPart' . $expression . '; ?>'; }); $transpiler->registerDirectiveTranspiler('while', function ($expression) { return '<?php while' . $expression . ': ?>'; }); }
php
public function registerDirectiveTranspilers(ITranspiler $transpiler) { $transpiler->registerDirectiveTranspiler('else', function () { return '<?php else: ?>'; }); $transpiler->registerDirectiveTranspiler('elseif', function ($expression) { return '<?php elseif' . $expression . ': ?>'; }); $transpiler->registerDirectiveTranspiler('forelse', function () { return '<?php endforeach; if(array_pop($__opulenceForElseEmpty)): ?>'; }); $transpiler->registerDirectiveTranspiler('endforeach', function () { return '<?php endforeach; ?>'; }); $transpiler->registerDirectiveTranspiler('endif', function () { return '<?php endif; ?>'; }); $transpiler->registerDirectiveTranspiler('endfor', function () { return '<?php endfor; ?>'; }); $transpiler->registerDirectiveTranspiler('endpart', function () { return '<?php $__opulenceFortuneTranspiler->endPart(); ?>'; }); $transpiler->registerDirectiveTranspiler('endwhile', function () { return '<?php endwhile; ?>'; }); $transpiler->registerDirectiveTranspiler('extends', function ($expression) use ($transpiler) { // Create the parent $code = '$__opulenceViewParent = $__opulenceViewFactory->createView' . $expression . ';'; $code .= '$__opulenceFortuneTranspiler->addParent($__opulenceViewParent, $__opulenceView);'; $code .= 'extract($__opulenceView->getVars());'; $transpiler->prepend('<?php ' . $code . ' ?>'); // Compile the parent, keep track of the contents, and echo them in the appended text $code = '$__opulenceParentContents = isset($__opulenceParentContents) ? $__opulenceParentContents : [];'; $code .= '$__opulenceParentContents[] = $__opulenceFortuneTranspiler->transpile($__opulenceViewParent);'; $transpiler->prepend('<?php ' . $code . ' ?>'); // Echo the contents at the end of the content $code = 'echo eval("?>" . array_shift($__opulenceParentContents));'; $transpiler->append('<?php ' . $code . ' ?>'); return ''; }); $transpiler->registerDirectiveTranspiler('for', function ($expression) { return '<?php for' . $expression . ': ?>'; }); $transpiler->registerDirectiveTranspiler('foreach', function ($expression) { return '<?php foreach' . $expression . ': ?>'; }); $transpiler->registerDirectiveTranspiler('forif', function ($expression) { $code = '<?php if(!isset($__opulenceForElseEmpty)): $__opulenceForElseEmpty = []; endif;'; $code .= '$__opulenceForElseEmpty[] = true;'; $code .= 'foreach' . $expression . ':'; $code .= '$__opulenceForElseEmpty[count($__opulenceForElseEmpty) - 1] = false; ?>'; return $code; }); $transpiler->registerDirectiveTranspiler('if', function ($expression) { return '<?php if' . $expression . ': ?>'; }); $transpiler->registerDirectiveTranspiler('include', function ($expression) { // Check if a list of variables were passed in as a second parameter if ( preg_match( "/^\(((('|\")(.*)\\3)|\\$[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*),\s*(.+)\)$/U", $expression, $matches ) === 1 ) { $sharedVars = trim($matches[5]); $factoryCreateCall = 'createView(' . $matches[1] . ')'; } else { $sharedVars = '[]'; $factoryCreateCall = 'createView' . $expression; } // Create an isolate scope for the included view $code = 'call_user_func(function() use ($__opulenceViewFactory, $__opulenceFortuneTranspiler){'; $code .= '$__opulenceIncludedView = $__opulenceViewFactory->' . $factoryCreateCall . ';'; $code .= 'extract($__opulenceIncludedView->getVars());'; // Extract any shared vars, which will override any identically-named view vars $code .= 'if(count(func_get_arg(0)) > 0){extract(func_get_arg(0));}'; $code .= 'eval("?>" . $__opulenceFortuneTranspiler->transpile($__opulenceIncludedView));'; $code .= '}, ' . $sharedVars . ');'; return "<?php $code ?>"; }); $transpiler->registerDirectiveTranspiler('parent', function () { // This placeholder will be overwritten later return '__opulenceParentPlaceholder'; }); $transpiler->registerDirectiveTranspiler('part', function ($expression) { return '<?php $__opulenceFortuneTranspiler->startPart' . $expression . '; ?>'; }); $transpiler->registerDirectiveTranspiler('show', function ($expression) { $expression = empty($expression) ? '()' : $expression; return '<?php echo $__opulenceFortuneTranspiler->showPart' . $expression . '; ?>'; }); $transpiler->registerDirectiveTranspiler('while', function ($expression) { return '<?php while' . $expression . ': ?>'; }); }
[ "public", "function", "registerDirectiveTranspilers", "(", "ITranspiler", "$", "transpiler", ")", "{", "$", "transpiler", "->", "registerDirectiveTranspiler", "(", "'else'", ",", "function", "(", ")", "{", "return", "'<?php else: ?>'", ";", "}", ")", ";", "$", "...
Registers the Fortune directive transpilers @param ITranspiler $transpiler The transpiler to register to
[ "Registers", "the", "Fortune", "directive", "transpilers" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Views/Compilers/Fortune/DirectiveTranspilerRegistrant.php#L23-L126
opulencephp/Opulence
src/Opulence/Orm/DataMappers/CachedSqlDataMapper.php
CachedSqlDataMapper.read
protected function read( string $funcName, array $getFuncArgs = [], bool $addDataToCacheOnMiss = true ) { // Always attempt to retrieve from cache first $data = $this->cacheDataMapper->$funcName(...$getFuncArgs); /** * If an entity wasn't returned or the list of entities was empty, we have no way of knowing if they really * don't exist or if they're just not in cache * So, we must try looking in the SQL data mapper */ if ($data === null || $data === []) { $data = $this->sqlDataMapper->$funcName(...$getFuncArgs); // Try to store the data back to cache if ($data === null) { return null; } if ($addDataToCacheOnMiss) { if (is_array($data)) { foreach ($data as $datum) { $this->cacheDataMapper->add($datum); } } else { $this->cacheDataMapper->add($data); } } } return $data; }
php
protected function read( string $funcName, array $getFuncArgs = [], bool $addDataToCacheOnMiss = true ) { // Always attempt to retrieve from cache first $data = $this->cacheDataMapper->$funcName(...$getFuncArgs); /** * If an entity wasn't returned or the list of entities was empty, we have no way of knowing if they really * don't exist or if they're just not in cache * So, we must try looking in the SQL data mapper */ if ($data === null || $data === []) { $data = $this->sqlDataMapper->$funcName(...$getFuncArgs); // Try to store the data back to cache if ($data === null) { return null; } if ($addDataToCacheOnMiss) { if (is_array($data)) { foreach ($data as $datum) { $this->cacheDataMapper->add($datum); } } else { $this->cacheDataMapper->add($data); } } } return $data; }
[ "protected", "function", "read", "(", "string", "$", "funcName", ",", "array", "$", "getFuncArgs", "=", "[", "]", ",", "bool", "$", "addDataToCacheOnMiss", "=", "true", ")", "{", "// Always attempt to retrieve from cache first", "$", "data", "=", "$", "this", ...
Attempts to retrieve an entity(ies) from the cache data mapper before resorting to an SQL database @param string $funcName The name of the method we want to call on our data mappers @param array $getFuncArgs The array of function arguments to pass in to our entity retrieval functions @param bool $addDataToCacheOnMiss True if we want to add the entity from the database to cache in case of a cache miss @return object|array|null The entity(ies) if it was found, otherwise null
[ "Attempts", "to", "retrieve", "an", "entity", "(", "ies", ")", "from", "the", "cache", "data", "mapper", "before", "resorting", "to", "an", "SQL", "database" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Orm/DataMappers/CachedSqlDataMapper.php#L197-L230
opulencephp/Opulence
src/Opulence/Orm/DataMappers/CachedSqlDataMapper.php
CachedSqlDataMapper.compareCacheAndSqlEntities
private function compareCacheAndSqlEntities(bool $doRefresh) : array { // If there was an issue grabbing all entities in cache, null will be returned $unkeyedCacheEntities = $this->cacheDataMapper->getAll(); if ($unkeyedCacheEntities === null) { $unkeyedCacheEntities = []; } $cacheEntities = $this->keyEntityArray($unkeyedCacheEntities); $sqlEntities = $this->keyEntityArray($this->sqlDataMapper->getAll()); $unsyncedEntities = [ 'missing' => [], 'differing' => [], 'additional' => [] ]; // Compare the entities in the SQL database to those in cache foreach ($sqlEntities as $sqlId => $sqlEntity) { if (isset($cacheEntities[$sqlId])) { // The entity appears in cache $cacheEntity = $cacheEntities[$sqlId]; if ($sqlEntity != $cacheEntity) { $unsyncedEntities['differing'][] = $sqlEntity; if ($doRefresh) { // Sync the entity in cache with the one in SQL $this->cacheDataMapper->delete($cacheEntity); $this->cacheDataMapper->add($sqlEntity); } } } else { // The entity was not in cache $unsyncedEntities['missing'][] = $sqlEntity; if ($doRefresh) { // Add the entity to cache $this->cacheDataMapper->add($sqlEntity); } } } // Find entities that only appear in cache $cacheOnlyIds = array_diff(array_keys($cacheEntities), array_keys($sqlEntities)); foreach ($cacheOnlyIds as $entityId) { $cacheEntity = $cacheEntities[$entityId]; $unsyncedEntities['additional'][] = $cacheEntity; if ($doRefresh) { // Remove the entity that only appears in cache $this->cacheDataMapper->delete($cacheEntity); } } return $unsyncedEntities; }
php
private function compareCacheAndSqlEntities(bool $doRefresh) : array { // If there was an issue grabbing all entities in cache, null will be returned $unkeyedCacheEntities = $this->cacheDataMapper->getAll(); if ($unkeyedCacheEntities === null) { $unkeyedCacheEntities = []; } $cacheEntities = $this->keyEntityArray($unkeyedCacheEntities); $sqlEntities = $this->keyEntityArray($this->sqlDataMapper->getAll()); $unsyncedEntities = [ 'missing' => [], 'differing' => [], 'additional' => [] ]; // Compare the entities in the SQL database to those in cache foreach ($sqlEntities as $sqlId => $sqlEntity) { if (isset($cacheEntities[$sqlId])) { // The entity appears in cache $cacheEntity = $cacheEntities[$sqlId]; if ($sqlEntity != $cacheEntity) { $unsyncedEntities['differing'][] = $sqlEntity; if ($doRefresh) { // Sync the entity in cache with the one in SQL $this->cacheDataMapper->delete($cacheEntity); $this->cacheDataMapper->add($sqlEntity); } } } else { // The entity was not in cache $unsyncedEntities['missing'][] = $sqlEntity; if ($doRefresh) { // Add the entity to cache $this->cacheDataMapper->add($sqlEntity); } } } // Find entities that only appear in cache $cacheOnlyIds = array_diff(array_keys($cacheEntities), array_keys($sqlEntities)); foreach ($cacheOnlyIds as $entityId) { $cacheEntity = $cacheEntities[$entityId]; $unsyncedEntities['additional'][] = $cacheEntity; if ($doRefresh) { // Remove the entity that only appears in cache $this->cacheDataMapper->delete($cacheEntity); } } return $unsyncedEntities; }
[ "private", "function", "compareCacheAndSqlEntities", "(", "bool", "$", "doRefresh", ")", ":", "array", "{", "// If there was an issue grabbing all entities in cache, null will be returned", "$", "unkeyedCacheEntities", "=", "$", "this", "->", "cacheDataMapper", "->", "getAll"...
Does the comparison of entities in cache to entities in the SQL database Also performs refresh if the user chooses to do so @param bool $doRefresh Whether or not to refresh any unsynced entities @return object[] The list of entities that were not already synced The "missing" list contains the entities that were not in cache The "differing" list contains the entities in cache that were not the same as SQL The "additional" list contains entities in cache that were not at all in SQL @throws OrmException Thrown if there was an error getting the unsynced entities
[ "Does", "the", "comparison", "of", "entities", "in", "cache", "to", "entities", "in", "the", "SQL", "database", "Also", "performs", "refresh", "if", "the", "user", "chooses", "to", "do", "so" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Orm/DataMappers/CachedSqlDataMapper.php#L273-L330
opulencephp/Opulence
src/Opulence/Orm/DataMappers/CachedSqlDataMapper.php
CachedSqlDataMapper.keyEntityArray
private function keyEntityArray(array $entities) : array { $keyedArray = []; foreach ($entities as $entity) { $keyedArray[$this->idAccessorRegistry->getEntityId($entity)] = $entity; } return $keyedArray; }
php
private function keyEntityArray(array $entities) : array { $keyedArray = []; foreach ($entities as $entity) { $keyedArray[$this->idAccessorRegistry->getEntityId($entity)] = $entity; } return $keyedArray; }
[ "private", "function", "keyEntityArray", "(", "array", "$", "entities", ")", ":", "array", "{", "$", "keyedArray", "=", "[", "]", ";", "foreach", "(", "$", "entities", "as", "$", "entity", ")", "{", "$", "keyedArray", "[", "$", "this", "->", "idAccesso...
Converts a list of entities to a keyed array of those entities The keys are the entity Ids @param object[] $entities The list of entities @return object[] The keyed array
[ "Converts", "a", "list", "of", "entities", "to", "a", "keyed", "array", "of", "those", "entities", "The", "keys", "are", "the", "entity", "Ids" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Orm/DataMappers/CachedSqlDataMapper.php#L339-L348
opulencephp/Opulence
src/Opulence/Framework/Console/Commands/MakeCommand.php
MakeCommand.compile
protected function compile(string $templateContents, string $fullyQualifiedClassName) : string { $explodedClass = explode('\\', $fullyQualifiedClassName); $namespace = implode('\\', array_slice($explodedClass, 0, -1)); $className = end($explodedClass); $compiledTemplate = str_replace('{{namespace}}', $namespace, $templateContents); $compiledTemplate = str_replace('{{class}}', $className, $compiledTemplate); return $compiledTemplate; }
php
protected function compile(string $templateContents, string $fullyQualifiedClassName) : string { $explodedClass = explode('\\', $fullyQualifiedClassName); $namespace = implode('\\', array_slice($explodedClass, 0, -1)); $className = end($explodedClass); $compiledTemplate = str_replace('{{namespace}}', $namespace, $templateContents); $compiledTemplate = str_replace('{{class}}', $className, $compiledTemplate); return $compiledTemplate; }
[ "protected", "function", "compile", "(", "string", "$", "templateContents", ",", "string", "$", "fullyQualifiedClassName", ")", ":", "string", "{", "$", "explodedClass", "=", "explode", "(", "'\\\\'", ",", "$", "fullyQualifiedClassName", ")", ";", "$", "namespac...
Compiles a template @param string $templateContents The template to compile @param string $fullyQualifiedClassName The fully-qualified class name @return string the compiled template
[ "Compiles", "a", "template" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Framework/Console/Commands/MakeCommand.php#L62-L71
opulencephp/Opulence
src/Opulence/Framework/Console/Commands/MakeCommand.php
MakeCommand.makeDirectories
protected function makeDirectories(string $path) { $directoryName = dirname($path); if (!$this->fileSystem->isDirectory($directoryName)) { $this->fileSystem->makeDirectory($directoryName, 0777, true); } }
php
protected function makeDirectories(string $path) { $directoryName = dirname($path); if (!$this->fileSystem->isDirectory($directoryName)) { $this->fileSystem->makeDirectory($directoryName, 0777, true); } }
[ "protected", "function", "makeDirectories", "(", "string", "$", "path", ")", "{", "$", "directoryName", "=", "dirname", "(", "$", "path", ")", ";", "if", "(", "!", "$", "this", "->", "fileSystem", "->", "isDirectory", "(", "$", "directoryName", ")", ")",...
Makes the necessary directories for a class @param string $path The fully-qualified class name
[ "Makes", "the", "necessary", "directories", "for", "a", "class" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Framework/Console/Commands/MakeCommand.php#L130-L137
opulencephp/Opulence
src/Opulence/Databases/Adapters/Pdo/Statement.php
Statement.bindValues
public function bindValues(array $values) { $isAssociativeArray = count(array_filter(array_keys($values), 'is_string')) > 0; foreach ($values as $parameterName => $value) { if (!is_array($value)) { $value = [$value, PDO::PARAM_STR]; } // If this is an indexed array, we need to offset the parameter name by 1 because it's 1-indexed if (!$isAssociativeArray) { ++$parameterName; } if (count($value) !== 2 || !$this->bindValue($parameterName, $value[0], $value[1])) { return false; } } return true; }
php
public function bindValues(array $values) { $isAssociativeArray = count(array_filter(array_keys($values), 'is_string')) > 0; foreach ($values as $parameterName => $value) { if (!is_array($value)) { $value = [$value, PDO::PARAM_STR]; } // If this is an indexed array, we need to offset the parameter name by 1 because it's 1-indexed if (!$isAssociativeArray) { ++$parameterName; } if (count($value) !== 2 || !$this->bindValue($parameterName, $value[0], $value[1])) { return false; } } return true; }
[ "public", "function", "bindValues", "(", "array", "$", "values", ")", "{", "$", "isAssociativeArray", "=", "count", "(", "array_filter", "(", "array_keys", "(", "$", "values", ")", ",", "'is_string'", ")", ")", ">", "0", ";", "foreach", "(", "$", "values...
Binds a list of values to the statement @param array $values The mapping of parameter name to a value or to an array If mapping to an array, the first item should be the value and the second should be the data type constant @return bool True if successful, otherwise false
[ "Binds", "a", "list", "of", "values", "to", "the", "statement" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Databases/Adapters/Pdo/Statement.php#L53-L73
opulencephp/Opulence
src/Opulence/Framework/Databases/Bootstrappers/MigrationBootstrapper.php
MigrationBootstrapper.getExecutedMigrationRepository
protected function getExecutedMigrationRepository(IContainer $container) : IExecutedMigrationRepository { $driverClass = getenv('DB_DRIVER') ?: PostgreSqlDriver::class; switch ($driverClass) { case MySqlDriver::class: $queryBuilder = new MySqlQueryBuilder(); $container->bindInstance(MySqlQueryBuilder::class, $queryBuilder); break; case PostgreSqlDriver::class: $queryBuilder = new PostgreSqlQueryBuilder(); $container->bindInstance(PostgreSqlQueryBuilder::class, $queryBuilder); break; default: throw new RuntimeException( "Invalid database driver type specified in environment var \"DB_DRIVER\": $driverClass" ); } $container->bindInstance(BaseQueryBuilder::class, $queryBuilder); return new SqlExecutedMigrationRepository( SqlExecutedMigrationRepository::DEFAULT_TABLE_NAME, $container->resolve(IConnection::class), $queryBuilder, new TypeMapperFactory() ); }
php
protected function getExecutedMigrationRepository(IContainer $container) : IExecutedMigrationRepository { $driverClass = getenv('DB_DRIVER') ?: PostgreSqlDriver::class; switch ($driverClass) { case MySqlDriver::class: $queryBuilder = new MySqlQueryBuilder(); $container->bindInstance(MySqlQueryBuilder::class, $queryBuilder); break; case PostgreSqlDriver::class: $queryBuilder = new PostgreSqlQueryBuilder(); $container->bindInstance(PostgreSqlQueryBuilder::class, $queryBuilder); break; default: throw new RuntimeException( "Invalid database driver type specified in environment var \"DB_DRIVER\": $driverClass" ); } $container->bindInstance(BaseQueryBuilder::class, $queryBuilder); return new SqlExecutedMigrationRepository( SqlExecutedMigrationRepository::DEFAULT_TABLE_NAME, $container->resolve(IConnection::class), $queryBuilder, new TypeMapperFactory() ); }
[ "protected", "function", "getExecutedMigrationRepository", "(", "IContainer", "$", "container", ")", ":", "IExecutedMigrationRepository", "{", "$", "driverClass", "=", "getenv", "(", "'DB_DRIVER'", ")", "?", ":", "PostgreSqlDriver", "::", "class", ";", "switch", "("...
Gets the executed migration repository to use in the migrator @param IContainer $container The IoC container @return IExecutedMigrationRepository The executed migration repository @throws RuntimeException Thrown if there was an error resolving the query builder
[ "Gets", "the", "executed", "migration", "repository", "to", "use", "in", "the", "migrator" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Framework/Databases/Bootstrappers/MigrationBootstrapper.php#L67-L94
opulencephp/Opulence
src/Opulence/Framework/Databases/Migrations/SqlExecutedMigrationRepository.php
SqlExecutedMigrationRepository.createTableIfDoesNotExist
protected function createTableIfDoesNotExist() : void { /** * Note: This is a somewhat hacky way to determine which database driver we're using * Ideally, in the future, the query builder will be able to create tables for us * Until then, we'll infer the database driver from the query builder type */ switch (get_class($this->queryBuilder)) { case MySqlQueryBuilder::class: $sql = 'CREATE TABLE IF NOT EXISTS ' . $this->tableName . ' (migration varchar(255), dateran timestamp NOT NULL, PRIMARY KEY (migration));'; break; case PostgreSqlQueryBuilder::class: $sql = 'CREATE TABLE IF NOT EXISTS ' . $this->tableName . ' (migration text primary key, dateran timestamp with time zone NOT NULL);'; break; default: throw new RuntimeException('Unexpected query builder type ' . get_class($this->queryBuilder)); } $statement = $this->connection->prepare($sql); $statement->execute(); }
php
protected function createTableIfDoesNotExist() : void { /** * Note: This is a somewhat hacky way to determine which database driver we're using * Ideally, in the future, the query builder will be able to create tables for us * Until then, we'll infer the database driver from the query builder type */ switch (get_class($this->queryBuilder)) { case MySqlQueryBuilder::class: $sql = 'CREATE TABLE IF NOT EXISTS ' . $this->tableName . ' (migration varchar(255), dateran timestamp NOT NULL, PRIMARY KEY (migration));'; break; case PostgreSqlQueryBuilder::class: $sql = 'CREATE TABLE IF NOT EXISTS ' . $this->tableName . ' (migration text primary key, dateran timestamp with time zone NOT NULL);'; break; default: throw new RuntimeException('Unexpected query builder type ' . get_class($this->queryBuilder)); } $statement = $this->connection->prepare($sql); $statement->execute(); }
[ "protected", "function", "createTableIfDoesNotExist", "(", ")", ":", "void", "{", "/**\n * Note: This is a somewhat hacky way to determine which database driver we're using\n * Ideally, in the future, the query builder will be able to create tables for us\n * Until then, we'l...
Creates the table that the migrations are stored in @throws RuntimeException Thrown if the query builder wasn't a MySQL or PostgreSQL query builder
[ "Creates", "the", "table", "that", "the", "migrations", "are", "stored", "in" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Framework/Databases/Migrations/SqlExecutedMigrationRepository.php#L128-L152
opulencephp/Opulence
src/Opulence/Console/Responses/Formatters/CommandFormatter.php
CommandFormatter.format
public function format(ICommand $command) : string { $text = $command->getName() . ' '; // Output the options foreach ($command->getOptions() as $option) { $text .= $this->formatOption($option) . ' '; } /** @var Argument[] $requiredArguments */ $requiredArguments = []; /** @var Argument[] $optionalArguments */ $optionalArguments = []; /** @var Argument $arrayArgument */ $arrayArgument = null; // Categorize each argument foreach ($command->getArguments() as $argument) { if ($argument->isRequired() && !$argument->isArray()) { $requiredArguments[] = $argument; } elseif ($argument->isOptional() && !$argument->isArray()) { $optionalArguments[] = $argument; } if ($argument->isArray()) { $arrayArgument = $argument; } } // Output the required arguments foreach ($requiredArguments as $argument) { $text .= $argument->getName() . ' '; } // Output the optional arguments foreach ($optionalArguments as $argument) { $text .= "[{$argument->getName()}] "; } // Output the array argument if ($arrayArgument !== null) { $text .= $this->formatArrayArgument($arrayArgument); } return trim($text); }
php
public function format(ICommand $command) : string { $text = $command->getName() . ' '; // Output the options foreach ($command->getOptions() as $option) { $text .= $this->formatOption($option) . ' '; } /** @var Argument[] $requiredArguments */ $requiredArguments = []; /** @var Argument[] $optionalArguments */ $optionalArguments = []; /** @var Argument $arrayArgument */ $arrayArgument = null; // Categorize each argument foreach ($command->getArguments() as $argument) { if ($argument->isRequired() && !$argument->isArray()) { $requiredArguments[] = $argument; } elseif ($argument->isOptional() && !$argument->isArray()) { $optionalArguments[] = $argument; } if ($argument->isArray()) { $arrayArgument = $argument; } } // Output the required arguments foreach ($requiredArguments as $argument) { $text .= $argument->getName() . ' '; } // Output the optional arguments foreach ($optionalArguments as $argument) { $text .= "[{$argument->getName()}] "; } // Output the array argument if ($arrayArgument !== null) { $text .= $this->formatArrayArgument($arrayArgument); } return trim($text); }
[ "public", "function", "format", "(", "ICommand", "$", "command", ")", ":", "string", "{", "$", "text", "=", "$", "command", "->", "getName", "(", ")", ".", "' '", ";", "// Output the options", "foreach", "(", "$", "command", "->", "getOptions", "(", ")",...
Gets the command as text @param ICommand $command The command to convert @return string The command as text
[ "Gets", "the", "command", "as", "text" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Console/Responses/Formatters/CommandFormatter.php#L28-L73
opulencephp/Opulence
src/Opulence/Console/Responses/Formatters/CommandFormatter.php
CommandFormatter.formatArrayArgument
private function formatArrayArgument(Argument $argument) : string { $arrayArgumentTextOne = $argument->getName() . '1'; $arrayArgumentTextN = $argument->getName() . 'N'; if ($argument->isOptional()) { $arrayArgumentTextOne = "[$arrayArgumentTextOne]"; $arrayArgumentTextN = "[$arrayArgumentTextN]"; } return "$arrayArgumentTextOne...$arrayArgumentTextN"; }
php
private function formatArrayArgument(Argument $argument) : string { $arrayArgumentTextOne = $argument->getName() . '1'; $arrayArgumentTextN = $argument->getName() . 'N'; if ($argument->isOptional()) { $arrayArgumentTextOne = "[$arrayArgumentTextOne]"; $arrayArgumentTextN = "[$arrayArgumentTextN]"; } return "$arrayArgumentTextOne...$arrayArgumentTextN"; }
[ "private", "function", "formatArrayArgument", "(", "Argument", "$", "argument", ")", ":", "string", "{", "$", "arrayArgumentTextOne", "=", "$", "argument", "->", "getName", "(", ")", ".", "'1'", ";", "$", "arrayArgumentTextN", "=", "$", "argument", "->", "ge...
Formats an array argument @param Argument $argument The argument to format @return string The formatted array argument
[ "Formats", "an", "array", "argument" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Console/Responses/Formatters/CommandFormatter.php#L81-L92
opulencephp/Opulence
src/Opulence/Console/Responses/Formatters/CommandFormatter.php
CommandFormatter.formatOption
private function formatOption(Option $option) : string { $text = "[--{$option->getName()}"; if ($option->valueIsOptional()) { $text .= '=' . $option->getDefaultValue(); } if ($option->getShortName() !== null) { $text .= "|-{$option->getShortName()}"; } $text .= ']'; return $text; }
php
private function formatOption(Option $option) : string { $text = "[--{$option->getName()}"; if ($option->valueIsOptional()) { $text .= '=' . $option->getDefaultValue(); } if ($option->getShortName() !== null) { $text .= "|-{$option->getShortName()}"; } $text .= ']'; return $text; }
[ "private", "function", "formatOption", "(", "Option", "$", "option", ")", ":", "string", "{", "$", "text", "=", "\"[--{$option->getName()}\"", ";", "if", "(", "$", "option", "->", "valueIsOptional", "(", ")", ")", "{", "$", "text", ".=", "'='", ".", "$",...
Formats an option @param Option $option The option to format @return string The formatted option
[ "Formats", "an", "option" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Console/Responses/Formatters/CommandFormatter.php#L100-L115
opulencephp/Opulence
src/Opulence/Routing/Dispatchers/RouteDispatcher.php
RouteDispatcher.callController
private function callController($controller, CompiledRoute $route) : Response { if (is_callable($controller)) { try { $reflection = new ReflectionFunction($controller); } catch (\ReflectionException $e) { throw new RouteException("Function {$controller} does not exist"); } $parameters = $this->resolveControllerParameters( $reflection->getParameters(), $route->getPathVars(), $route, true ); $response = $controller(...$parameters); } else { try { $reflection = new ReflectionMethod($controller, $route->getControllerMethod()); } catch (\ReflectionException $e) { throw new RouteException("Method {$route->getControllerMethod()} does not exist"); } $parameters = $this->resolveControllerParameters( $reflection->getParameters(), $route->getPathVars(), $route, false ); if ($reflection->isPrivate()) { throw new RouteException("Method {$route->getControllerMethod()} is private"); } if ($controller instanceof Controller) { $response = $controller->callMethod( $route->getControllerMethod(), $parameters ); } else { $response = $controller->{$route->getControllerMethod()}(...$parameters); } } if (is_string($response)) { $response = new Response($response); } return $response; }
php
private function callController($controller, CompiledRoute $route) : Response { if (is_callable($controller)) { try { $reflection = new ReflectionFunction($controller); } catch (\ReflectionException $e) { throw new RouteException("Function {$controller} does not exist"); } $parameters = $this->resolveControllerParameters( $reflection->getParameters(), $route->getPathVars(), $route, true ); $response = $controller(...$parameters); } else { try { $reflection = new ReflectionMethod($controller, $route->getControllerMethod()); } catch (\ReflectionException $e) { throw new RouteException("Method {$route->getControllerMethod()} does not exist"); } $parameters = $this->resolveControllerParameters( $reflection->getParameters(), $route->getPathVars(), $route, false ); if ($reflection->isPrivate()) { throw new RouteException("Method {$route->getControllerMethod()} is private"); } if ($controller instanceof Controller) { $response = $controller->callMethod( $route->getControllerMethod(), $parameters ); } else { $response = $controller->{$route->getControllerMethod()}(...$parameters); } } if (is_string($response)) { $response = new Response($response); } return $response; }
[ "private", "function", "callController", "(", "$", "controller", ",", "CompiledRoute", "$", "route", ")", ":", "Response", "{", "if", "(", "is_callable", "(", "$", "controller", ")", ")", "{", "try", "{", "$", "reflection", "=", "new", "ReflectionFunction", ...
Calls the method on the input controller @param Controller|Closure|mixed $controller The instance of the controller to call @param CompiledRoute $route The route being dispatched @return Response Returns the value from the controller method @throws RouteException Thrown if the method could not be called on the controller
[ "Calls", "the", "method", "on", "the", "input", "controller" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Routing/Dispatchers/RouteDispatcher.php#L75-L122
opulencephp/Opulence
src/Opulence/Routing/Dispatchers/RouteDispatcher.php
RouteDispatcher.resolveController
private function resolveController(string $controllerName, Request $request) { if (!class_exists($controllerName)) { throw new RouteException("Controller class $controllerName does not exist"); } $controller = $this->dependencyResolver->resolve($controllerName); if ($controller instanceof Controller) { $controller->setRequest($request); try { $controller->setViewFactory( $this->dependencyResolver->resolve(IViewFactory::class) ); } catch (DependencyResolutionException $ex) { // Don't do anything } try { $controller->setViewCompiler( $this->dependencyResolver->resolve(ICompiler::class) ); } catch (DependencyResolutionException $ex) { // Don't do anything } } return $controller; }
php
private function resolveController(string $controllerName, Request $request) { if (!class_exists($controllerName)) { throw new RouteException("Controller class $controllerName does not exist"); } $controller = $this->dependencyResolver->resolve($controllerName); if ($controller instanceof Controller) { $controller->setRequest($request); try { $controller->setViewFactory( $this->dependencyResolver->resolve(IViewFactory::class) ); } catch (DependencyResolutionException $ex) { // Don't do anything } try { $controller->setViewCompiler( $this->dependencyResolver->resolve(ICompiler::class) ); } catch (DependencyResolutionException $ex) { // Don't do anything } } return $controller; }
[ "private", "function", "resolveController", "(", "string", "$", "controllerName", ",", "Request", "$", "request", ")", "{", "if", "(", "!", "class_exists", "(", "$", "controllerName", ")", ")", "{", "throw", "new", "RouteException", "(", "\"Controller class $con...
Creates an instance of the input controller @param string $controllerName The fully-qualified name of the controller class to instantiate @param Request $request The request that's being routed @return Controller|mixed The instantiated controller @throws RouteException Thrown if the controller could not be instantiated
[ "Creates", "an", "instance", "of", "the", "input", "controller" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Routing/Dispatchers/RouteDispatcher.php#L132-L161
opulencephp/Opulence
src/Opulence/Routing/Dispatchers/RouteDispatcher.php
RouteDispatcher.resolveControllerParameters
private function resolveControllerParameters( array $reflectionParameters, array $pathVars, CompiledRoute $route, bool $acceptObjectParameters ) : array { $resolvedParameters = []; // Match the route variables to the method parameters foreach ($reflectionParameters as $parameter) { if ($acceptObjectParameters && $parameter->getClass() !== null) { $className = $parameter->getClass()->getName(); $resolvedParameters[$parameter->getPosition()] = $this->dependencyResolver->resolve($className); } elseif (isset($pathVars[$parameter->getName()])) { // There is a value set in the route $resolvedParameters[$parameter->getPosition()] = $pathVars[$parameter->getName()]; } elseif (($defaultValue = $route->getDefaultValue($parameter->getName())) !== null) { // There was a default value set in the route $resolvedParameters[$parameter->getPosition()] = $defaultValue; } elseif (!$parameter->isDefaultValueAvailable()) { // There is no value/default value for this variable throw new RouteException( "No value set for parameter {$parameter->getName()}" ); } } return $resolvedParameters; }
php
private function resolveControllerParameters( array $reflectionParameters, array $pathVars, CompiledRoute $route, bool $acceptObjectParameters ) : array { $resolvedParameters = []; // Match the route variables to the method parameters foreach ($reflectionParameters as $parameter) { if ($acceptObjectParameters && $parameter->getClass() !== null) { $className = $parameter->getClass()->getName(); $resolvedParameters[$parameter->getPosition()] = $this->dependencyResolver->resolve($className); } elseif (isset($pathVars[$parameter->getName()])) { // There is a value set in the route $resolvedParameters[$parameter->getPosition()] = $pathVars[$parameter->getName()]; } elseif (($defaultValue = $route->getDefaultValue($parameter->getName())) !== null) { // There was a default value set in the route $resolvedParameters[$parameter->getPosition()] = $defaultValue; } elseif (!$parameter->isDefaultValueAvailable()) { // There is no value/default value for this variable throw new RouteException( "No value set for parameter {$parameter->getName()}" ); } } return $resolvedParameters; }
[ "private", "function", "resolveControllerParameters", "(", "array", "$", "reflectionParameters", ",", "array", "$", "pathVars", ",", "CompiledRoute", "$", "route", ",", "bool", "$", "acceptObjectParameters", ")", ":", "array", "{", "$", "resolvedParameters", "=", ...
Gets the resolved parameters for a controller @param ReflectionParameter[] $reflectionParameters The reflection parameters @param array $pathVars The route path variables @param CompiledRoute $route The route whose parameters we're resolving @param bool $acceptObjectParameters Whether or not we'll accept objects as parameters @return array The mapping of parameter names to their resolved values @throws RouteException Thrown if the parameters could not be resolved
[ "Gets", "the", "resolved", "parameters", "for", "a", "controller" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Routing/Dispatchers/RouteDispatcher.php#L173-L201
opulencephp/Opulence
src/Opulence/Routing/Dispatchers/RouteDispatcher.php
RouteDispatcher.resolveMiddleware
private function resolveMiddleware(array $middleware) : array { $resolvedMiddleware = []; foreach ($middleware as $singleMiddleware) { if ($singleMiddleware instanceof MiddlewareParameters) { /** @var MiddlewareParameters $singleMiddleware */ /** @var ParameterizedMiddleware $tempMiddleware */ $tempMiddleware = $this->dependencyResolver->resolve($singleMiddleware->getMiddlewareClassName()); $tempMiddleware->setParameters($singleMiddleware->getParameters()); $singleMiddleware = $tempMiddleware; } elseif (is_string($singleMiddleware)) { $singleMiddleware = $this->dependencyResolver->resolve($singleMiddleware); } $resolvedMiddleware[] = $singleMiddleware; } return $resolvedMiddleware; }
php
private function resolveMiddleware(array $middleware) : array { $resolvedMiddleware = []; foreach ($middleware as $singleMiddleware) { if ($singleMiddleware instanceof MiddlewareParameters) { /** @var MiddlewareParameters $singleMiddleware */ /** @var ParameterizedMiddleware $tempMiddleware */ $tempMiddleware = $this->dependencyResolver->resolve($singleMiddleware->getMiddlewareClassName()); $tempMiddleware->setParameters($singleMiddleware->getParameters()); $singleMiddleware = $tempMiddleware; } elseif (is_string($singleMiddleware)) { $singleMiddleware = $this->dependencyResolver->resolve($singleMiddleware); } $resolvedMiddleware[] = $singleMiddleware; } return $resolvedMiddleware; }
[ "private", "function", "resolveMiddleware", "(", "array", "$", "middleware", ")", ":", "array", "{", "$", "resolvedMiddleware", "=", "[", "]", ";", "foreach", "(", "$", "middleware", "as", "$", "singleMiddleware", ")", "{", "if", "(", "$", "singleMiddleware"...
Resolves the list of middleware @param array $middleware The middleware to resolve @return IMiddleware[] The list of resolved middleware
[ "Resolves", "the", "list", "of", "middleware" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Routing/Dispatchers/RouteDispatcher.php#L209-L228
opulencephp/Opulence
src/Opulence/Views/Caching/FileCache.php
FileCache.getCompiledViewPaths
private function getCompiledViewPaths(string $path) : array { if (!is_dir($path)) { return []; } $files = []; $iter = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST, RecursiveIteratorIterator::CATCH_GET_CHILD ); $iter->setMaxDepth(0); foreach ($iter as $path => $item) { if ($item->isFile()) { $files[] = $path; } } return $files; }
php
private function getCompiledViewPaths(string $path) : array { if (!is_dir($path)) { return []; } $files = []; $iter = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST, RecursiveIteratorIterator::CATCH_GET_CHILD ); $iter->setMaxDepth(0); foreach ($iter as $path => $item) { if ($item->isFile()) { $files[] = $path; } } return $files; }
[ "private", "function", "getCompiledViewPaths", "(", "string", "$", "path", ")", ":", "array", "{", "if", "(", "!", "is_dir", "(", "$", "path", ")", ")", "{", "return", "[", "]", ";", "}", "$", "files", "=", "[", "]", ";", "$", "iter", "=", "new",...
Gets a list of view file paths that appear @param string $path The path to search @return array The list of view paths
[ "Gets", "a", "list", "of", "view", "file", "paths", "that", "appear" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Views/Caching/FileCache.php#L173-L194
opulencephp/Opulence
src/Opulence/Views/Caching/FileCache.php
FileCache.getViewPath
private function getViewPath(IView $view, bool $checkVars) : string { $data = ['u' => $view->getContents()]; if ($checkVars) { $data['v'] = $view->getVars(); } return $this->path . '/' . md5(http_build_query($data)); }
php
private function getViewPath(IView $view, bool $checkVars) : string { $data = ['u' => $view->getContents()]; if ($checkVars) { $data['v'] = $view->getVars(); } return $this->path . '/' . md5(http_build_query($data)); }
[ "private", "function", "getViewPath", "(", "IView", "$", "view", ",", "bool", "$", "checkVars", ")", ":", "string", "{", "$", "data", "=", "[", "'u'", "=>", "$", "view", "->", "getContents", "(", ")", "]", ";", "if", "(", "$", "checkVars", ")", "{"...
Gets path to cached view @param IView $view The view whose cached file path we want @param bool $checkVars Whether or not we want to also check for variable value equivalence when looking up cached views @return string The path to the cached view
[ "Gets", "path", "to", "cached", "view" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Views/Caching/FileCache.php#L203-L212
opulencephp/Opulence
src/Opulence/Views/Caching/FileCache.php
FileCache.isExpired
private function isExpired(string $viewPath) : bool { $lastModified = DateTime::createFromFormat('U', filemtime($viewPath)); return $lastModified < new DateTime('-' . $this->lifetime . ' seconds'); }
php
private function isExpired(string $viewPath) : bool { $lastModified = DateTime::createFromFormat('U', filemtime($viewPath)); return $lastModified < new DateTime('-' . $this->lifetime . ' seconds'); }
[ "private", "function", "isExpired", "(", "string", "$", "viewPath", ")", ":", "bool", "{", "$", "lastModified", "=", "DateTime", "::", "createFromFormat", "(", "'U'", ",", "filemtime", "(", "$", "viewPath", ")", ")", ";", "return", "$", "lastModified", "<"...
Checks whether or not a view path is expired @param string $viewPath The view path to check @return bool True if the path is expired, otherwise false
[ "Checks", "whether", "or", "not", "a", "view", "path", "is", "expired" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Views/Caching/FileCache.php#L220-L225
opulencephp/Opulence
src/Opulence/Http/Headers.php
Headers.add
public function add(string $name, $values, bool $shouldReplace = true) { $this->set($name, $values, $shouldReplace); }
php
public function add(string $name, $values, bool $shouldReplace = true) { $this->set($name, $values, $shouldReplace); }
[ "public", "function", "add", "(", "string", "$", "name", ",", "$", "values", ",", "bool", "$", "shouldReplace", "=", "true", ")", "{", "$", "this", "->", "set", "(", "$", "name", ",", "$", "values", ",", "$", "shouldReplace", ")", ";", "}" ]
Headers are allowed to have multiple values, so we must add support for that @inheritdoc @param string|array $values The value or values @param bool $shouldReplace Whether or not to replace the value
[ "Headers", "are", "allowed", "to", "have", "multiple", "values", "so", "we", "must", "add", "support", "for", "that" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Http/Headers.php#L46-L49
opulencephp/Opulence
src/Opulence/Http/Headers.php
Headers.set
public function set(string $name, $values, bool $shouldReplace = true) { $name = $this->normalizeName($name); $values = (array)$values; if ($shouldReplace || !$this->has($name)) { parent::set($name, $values); } else { parent::set($name, array_merge($this->values[$name], $values)); } }
php
public function set(string $name, $values, bool $shouldReplace = true) { $name = $this->normalizeName($name); $values = (array)$values; if ($shouldReplace || !$this->has($name)) { parent::set($name, $values); } else { parent::set($name, array_merge($this->values[$name], $values)); } }
[ "public", "function", "set", "(", "string", "$", "name", ",", "$", "values", ",", "bool", "$", "shouldReplace", "=", "true", ")", "{", "$", "name", "=", "$", "this", "->", "normalizeName", "(", "$", "name", ")", ";", "$", "values", "=", "(", "array...
Headers are allowed to have multiple values, so we must add support for that @inheritdoc @param string|array $values The value or values @param bool $shouldReplace Whether or not to replace the value
[ "Headers", "are", "allowed", "to", "have", "multiple", "values", "so", "we", "must", "add", "support", "for", "that" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Http/Headers.php#L93-L103
opulencephp/Opulence
src/Opulence/Console/Commands/AboutCommand.php
AboutCommand.getCommandText
private function getCommandText() : string { if (count($this->commandCollection->getAll()) === 0) { return ' <info>No commands</info>'; } /** * Sorts the commands by name * Uncategorized (commands without ":" in their names) always come first * * @param ICommand $a * @param ICommand $b * @return int The result of the comparison */ $sort = function ($a, $b) { if (strpos($a->getName(), ':') === false) { if (strpos($b->getName(), ':') === false) { // They're both uncategorized return $a->getName() < $b->getName() ? -1 : 1; } else { // B is categorized return -1; } } else { if (strpos($b->getName(), ':') === false) { // A is categorized return 1; } else { // They're both categorized return $a->getName() < $b->getName() ? -1 : 1; } } }; $commands = $this->commandCollection->getAll(); usort($commands, $sort); $categorizedCommandNames = []; $commandTexts = []; $firstCommandNamesToCategories = []; foreach ($commands as $command) { $commandNameParts = explode(':', $command->getName()); if (count($commandNameParts) > 1 && !in_array($commandNameParts[0], $firstCommandNamesToCategories)) { $categorizedCommandNames[] = $command->getName(); // If this is the first command for this category if (!in_array($commandNameParts[0], $firstCommandNamesToCategories)) { $firstCommandNamesToCategories[$command->getName()] = $commandNameParts[0]; } } $commandTexts[] = [$command->getName(), $command->getDescription()]; } return $this->paddingFormatter->format($commandTexts, function ($row) use ($categorizedCommandNames, $firstCommandNamesToCategories) { $output = ''; // If this is the first command of its category, display the category if (in_array(trim($row[0]), $categorizedCommandNames) && isset($firstCommandNamesToCategories[trim($row[0])]) ) { $output .= "<comment>{$firstCommandNamesToCategories[trim($row[0])]}</comment>" . PHP_EOL; } return $output . " <info>{$row[0]}</info> - {$row[1]}"; }); }
php
private function getCommandText() : string { if (count($this->commandCollection->getAll()) === 0) { return ' <info>No commands</info>'; } /** * Sorts the commands by name * Uncategorized (commands without ":" in their names) always come first * * @param ICommand $a * @param ICommand $b * @return int The result of the comparison */ $sort = function ($a, $b) { if (strpos($a->getName(), ':') === false) { if (strpos($b->getName(), ':') === false) { // They're both uncategorized return $a->getName() < $b->getName() ? -1 : 1; } else { // B is categorized return -1; } } else { if (strpos($b->getName(), ':') === false) { // A is categorized return 1; } else { // They're both categorized return $a->getName() < $b->getName() ? -1 : 1; } } }; $commands = $this->commandCollection->getAll(); usort($commands, $sort); $categorizedCommandNames = []; $commandTexts = []; $firstCommandNamesToCategories = []; foreach ($commands as $command) { $commandNameParts = explode(':', $command->getName()); if (count($commandNameParts) > 1 && !in_array($commandNameParts[0], $firstCommandNamesToCategories)) { $categorizedCommandNames[] = $command->getName(); // If this is the first command for this category if (!in_array($commandNameParts[0], $firstCommandNamesToCategories)) { $firstCommandNamesToCategories[$command->getName()] = $commandNameParts[0]; } } $commandTexts[] = [$command->getName(), $command->getDescription()]; } return $this->paddingFormatter->format($commandTexts, function ($row) use ($categorizedCommandNames, $firstCommandNamesToCategories) { $output = ''; // If this is the first command of its category, display the category if (in_array(trim($row[0]), $categorizedCommandNames) && isset($firstCommandNamesToCategories[trim($row[0])]) ) { $output .= "<comment>{$firstCommandNamesToCategories[trim($row[0])]}</comment>" . PHP_EOL; } return $output . " <info>{$row[0]}</info> - {$row[1]}"; }); }
[ "private", "function", "getCommandText", "(", ")", ":", "string", "{", "if", "(", "count", "(", "$", "this", "->", "commandCollection", "->", "getAll", "(", ")", ")", "===", "0", ")", "{", "return", "' <info>No commands</info>'", ";", "}", "/**\n * ...
Converts commands to text @return string The commands as text
[ "Converts", "commands", "to", "text" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Console/Commands/AboutCommand.php#L74-L142
opulencephp/Opulence
src/Opulence/Framework/Sessions/Http/Middleware/Session.php
Session.startSession
protected function startSession(Request $request) { $this->gc(); $this->session->setId($request->getCookies()->get($this->session->getName())); $this->sessionHandler->open(null, $this->session->getName()); $sessionVars = @unserialize($this->sessionHandler->read($this->session->getId())); if ($sessionVars === false) { $sessionVars = []; } $this->session->start($sessionVars); }
php
protected function startSession(Request $request) { $this->gc(); $this->session->setId($request->getCookies()->get($this->session->getName())); $this->sessionHandler->open(null, $this->session->getName()); $sessionVars = @unserialize($this->sessionHandler->read($this->session->getId())); if ($sessionVars === false) { $sessionVars = []; } $this->session->start($sessionVars); }
[ "protected", "function", "startSession", "(", "Request", "$", "request", ")", "{", "$", "this", "->", "gc", "(", ")", ";", "$", "this", "->", "session", "->", "setId", "(", "$", "request", "->", "getCookies", "(", ")", "->", "get", "(", "$", "this", ...
Starts the session @param Request $request The current request
[ "Starts", "the", "session" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Framework/Sessions/Http/Middleware/Session.php#L86-L98
opulencephp/Opulence
src/Opulence/Framework/Sessions/Http/Middleware/Session.php
Session.writeSession
protected function writeSession(Response $response) { $this->session->ageFlashData(); $this->sessionHandler->write($this->session->getId(), serialize($this->session->getAll())); $this->writeToResponse($response); }
php
protected function writeSession(Response $response) { $this->session->ageFlashData(); $this->sessionHandler->write($this->session->getId(), serialize($this->session->getAll())); $this->writeToResponse($response); }
[ "protected", "function", "writeSession", "(", "Response", "$", "response", ")", "{", "$", "this", "->", "session", "->", "ageFlashData", "(", ")", ";", "$", "this", "->", "sessionHandler", "->", "write", "(", "$", "this", "->", "session", "->", "getId", ...
Writes the session data to the response @param Response $response The response
[ "Writes", "the", "session", "data", "to", "the", "response" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Framework/Sessions/Http/Middleware/Session.php#L105-L110
opulencephp/Opulence
src/Opulence/Validation/Rules/RuleExtensionRegistry.php
RuleExtensionRegistry.getRule
public function getRule(string $ruleName) : IRule { if (!$this->hasRule($ruleName)) { throw new InvalidArgumentException("No rule extension with name \"$ruleName\" found"); } return $this->extensions[$ruleName]; }
php
public function getRule(string $ruleName) : IRule { if (!$this->hasRule($ruleName)) { throw new InvalidArgumentException("No rule extension with name \"$ruleName\" found"); } return $this->extensions[$ruleName]; }
[ "public", "function", "getRule", "(", "string", "$", "ruleName", ")", ":", "IRule", "{", "if", "(", "!", "$", "this", "->", "hasRule", "(", "$", "ruleName", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"No rule extension with name \\\"$rul...
Gets the rule extension with the input name @param string $ruleName The name of the rule @return IRule The rule extension @throws InvalidArgumentException Thrown if no extension is registered with the name
[ "Gets", "the", "rule", "extension", "with", "the", "input", "name" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Validation/Rules/RuleExtensionRegistry.php#L30-L37
opulencephp/Opulence
src/Opulence/Validation/Rules/RuleExtensionRegistry.php
RuleExtensionRegistry.registerRuleExtension
public function registerRuleExtension($rule, string $slug = '') { if ($rule instanceof IRule) { $slug = $rule->getSlug(); } if (is_callable($rule)) { $callback = $rule; $rule = new CallbackRule(); $rule->setArgs([$callback]); } if (!$rule instanceof IRule) { throw new InvalidArgumentException('Rule must either be a callback or implement IRule'); } $this->extensions[$slug] = $rule; }
php
public function registerRuleExtension($rule, string $slug = '') { if ($rule instanceof IRule) { $slug = $rule->getSlug(); } if (is_callable($rule)) { $callback = $rule; $rule = new CallbackRule(); $rule->setArgs([$callback]); } if (!$rule instanceof IRule) { throw new InvalidArgumentException('Rule must either be a callback or implement IRule'); } $this->extensions[$slug] = $rule; }
[ "public", "function", "registerRuleExtension", "(", "$", "rule", ",", "string", "$", "slug", "=", "''", ")", "{", "if", "(", "$", "rule", "instanceof", "IRule", ")", "{", "$", "slug", "=", "$", "rule", "->", "getSlug", "(", ")", ";", "}", "if", "("...
Registers a rule extension @param IRule|callable $rule Either the rule object or callback (that accepts a value and list of all values) and returns true if the rule passes, otherwise false @param string $slug The slug name of the rule (only used if the rule is a callback) @throws InvalidArgumentException Thrown if the rule was incorrectly formatted
[ "Registers", "a", "rule", "extension" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Validation/Rules/RuleExtensionRegistry.php#L58-L75
opulencephp/Opulence
src/Opulence/Ioc/Container.php
Container.addBinding
protected function addBinding(string $interface, IBinding $binding) { if (!isset($this->bindings[$this->currentTarget])) { $this->bindings[$this->currentTarget] = []; } $this->bindings[$this->currentTarget][$interface] = $binding; }
php
protected function addBinding(string $interface, IBinding $binding) { if (!isset($this->bindings[$this->currentTarget])) { $this->bindings[$this->currentTarget] = []; } $this->bindings[$this->currentTarget][$interface] = $binding; }
[ "protected", "function", "addBinding", "(", "string", "$", "interface", ",", "IBinding", "$", "binding", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "bindings", "[", "$", "this", "->", "currentTarget", "]", ")", ")", "{", "$", "this", ...
Adds a binding to an interface @param string $interface The interface to bind to @param IBinding $binding The binding to add
[ "Adds", "a", "binding", "to", "an", "interface" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Ioc/Container.php#L204-L211
opulencephp/Opulence
src/Opulence/Ioc/Container.php
Container.getBinding
protected function getBinding(string $interface) { // If there's a targeted binding, use it if ($this->currentTarget !== self::$emptyTarget && isset($this->bindings[$this->currentTarget][$interface])) { return $this->bindings[$this->currentTarget][$interface]; } // If there's a universal binding, use it if (isset($this->bindings[self::$emptyTarget][$interface])) { return $this->bindings[self::$emptyTarget][$interface]; } return null; }
php
protected function getBinding(string $interface) { // If there's a targeted binding, use it if ($this->currentTarget !== self::$emptyTarget && isset($this->bindings[$this->currentTarget][$interface])) { return $this->bindings[$this->currentTarget][$interface]; } // If there's a universal binding, use it if (isset($this->bindings[self::$emptyTarget][$interface])) { return $this->bindings[self::$emptyTarget][$interface]; } return null; }
[ "protected", "function", "getBinding", "(", "string", "$", "interface", ")", "{", "// If there's a targeted binding, use it", "if", "(", "$", "this", "->", "currentTarget", "!==", "self", "::", "$", "emptyTarget", "&&", "isset", "(", "$", "this", "->", "bindings...
Gets a binding for an interface @param string $interface The interface whose binding we want @return IBinding|null The binding if one exists, otherwise null
[ "Gets", "a", "binding", "for", "an", "interface" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Ioc/Container.php#L219-L232
opulencephp/Opulence
src/Opulence/Ioc/Container.php
Container.hasTargetedBinding
protected function hasTargetedBinding(string $interface, string $target = null) : bool { return isset($this->bindings[$target][$interface]); }
php
protected function hasTargetedBinding(string $interface, string $target = null) : bool { return isset($this->bindings[$target][$interface]); }
[ "protected", "function", "hasTargetedBinding", "(", "string", "$", "interface", ",", "string", "$", "target", "=", "null", ")", ":", "bool", "{", "return", "isset", "(", "$", "this", "->", "bindings", "[", "$", "target", "]", "[", "$", "interface", "]", ...
Gets whether or not a targeted binding exists @param string $interface The interface to check @param string|null $target The target whose bindings we're checking @return bool True if the targeted binding exists, otherwise false
[ "Gets", "whether", "or", "not", "a", "targeted", "binding", "exists" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Ioc/Container.php#L241-L244
opulencephp/Opulence
src/Opulence/Ioc/Container.php
Container.resolveClass
protected function resolveClass(string $class, array $primitives = []) { try { if (isset($this->constructorReflectionCache[$class])) { list($constructor, $parameters) = $this->constructorReflectionCache[$class]; } else { $reflectionClass = new ReflectionClass($class); if (!$reflectionClass->isInstantiable()) { throw new IocException( sprintf( '%s is not instantiable%s', $class, $this->currentTarget === null ? '' : " (dependency of {$this->currentTarget})" ) ); } $constructor = $reflectionClass->getConstructor(); $parameters = $constructor !== null ? $constructor->getParameters() : null; $this->constructorReflectionCache[$class] = [$constructor, $parameters]; } if ($constructor === null) { // No constructor, so instantiating is easy return new $class; } $constructorParameters = $this->resolveParameters($class, $parameters, $primitives); return new $class(...$constructorParameters); } catch (ReflectionException $ex) { throw new IocException("Failed to resolve class $class", 0, $ex); } }
php
protected function resolveClass(string $class, array $primitives = []) { try { if (isset($this->constructorReflectionCache[$class])) { list($constructor, $parameters) = $this->constructorReflectionCache[$class]; } else { $reflectionClass = new ReflectionClass($class); if (!$reflectionClass->isInstantiable()) { throw new IocException( sprintf( '%s is not instantiable%s', $class, $this->currentTarget === null ? '' : " (dependency of {$this->currentTarget})" ) ); } $constructor = $reflectionClass->getConstructor(); $parameters = $constructor !== null ? $constructor->getParameters() : null; $this->constructorReflectionCache[$class] = [$constructor, $parameters]; } if ($constructor === null) { // No constructor, so instantiating is easy return new $class; } $constructorParameters = $this->resolveParameters($class, $parameters, $primitives); return new $class(...$constructorParameters); } catch (ReflectionException $ex) { throw new IocException("Failed to resolve class $class", 0, $ex); } }
[ "protected", "function", "resolveClass", "(", "string", "$", "class", ",", "array", "$", "primitives", "=", "[", "]", ")", "{", "try", "{", "if", "(", "isset", "(", "$", "this", "->", "constructorReflectionCache", "[", "$", "class", "]", ")", ")", "{",...
Resolves a class @param string $class The class name to resolve @param array $primitives The list of constructor primitives @return object The resolved class @throws IocException Thrown if the class could not be resolved
[ "Resolves", "a", "class" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Ioc/Container.php#L254-L287
opulencephp/Opulence
src/Opulence/Ioc/Container.php
Container.resolveParameters
protected function resolveParameters( $class, array $unresolvedParameters, array $primitives ) : array { $resolvedParameters = []; foreach ($unresolvedParameters as $parameter) { $resolvedParameter = null; if ($parameter->getClass() === null) { // The parameter is a primitive $resolvedParameter = $this->resolvePrimitive($parameter, $primitives); } else { // The parameter is an object $parameterClassName = $parameter->getClass()->getName(); /** * We need to first check if the input class is a target for the parameter * If it is, resolve it using the input class as a target * Otherwise, attempt to resolve it universally */ if ($class !== null && $this->hasTargetedBinding($parameterClassName, $class)) { $resolvedParameter = $this->for($class, function (IContainer $container) use ($parameter) { return $container->resolve($parameter->getClass()->getName()); }); } else { $resolvedParameter = $this->resolve($parameterClassName); } } $resolvedParameters[] = $resolvedParameter; } return $resolvedParameters; }
php
protected function resolveParameters( $class, array $unresolvedParameters, array $primitives ) : array { $resolvedParameters = []; foreach ($unresolvedParameters as $parameter) { $resolvedParameter = null; if ($parameter->getClass() === null) { // The parameter is a primitive $resolvedParameter = $this->resolvePrimitive($parameter, $primitives); } else { // The parameter is an object $parameterClassName = $parameter->getClass()->getName(); /** * We need to first check if the input class is a target for the parameter * If it is, resolve it using the input class as a target * Otherwise, attempt to resolve it universally */ if ($class !== null && $this->hasTargetedBinding($parameterClassName, $class)) { $resolvedParameter = $this->for($class, function (IContainer $container) use ($parameter) { return $container->resolve($parameter->getClass()->getName()); }); } else { $resolvedParameter = $this->resolve($parameterClassName); } } $resolvedParameters[] = $resolvedParameter; } return $resolvedParameters; }
[ "protected", "function", "resolveParameters", "(", "$", "class", ",", "array", "$", "unresolvedParameters", ",", "array", "$", "primitives", ")", ":", "array", "{", "$", "resolvedParameters", "=", "[", "]", ";", "foreach", "(", "$", "unresolvedParameters", "as...
Resolves a list of parameters for a function call @param string|null $class The name of the class whose parameters we're resolving @param ReflectionParameter[] $unresolvedParameters The list of unresolved parameters @param array $primitives The list of primitive values @return array The list of parameters with all the dependencies resolved @throws IocException Thrown if there was an error resolving the parameters
[ "Resolves", "a", "list", "of", "parameters", "for", "a", "function", "call" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Ioc/Container.php#L298-L333
opulencephp/Opulence
src/Opulence/Ioc/Container.php
Container.resolvePrimitive
protected function resolvePrimitive(ReflectionParameter $parameter, array &$primitives) { if (count($primitives) > 0) { // Grab the next primitive return array_shift($primitives); } if ($parameter->isDefaultValueAvailable()) { // No value was found, so use the default value return $parameter->getDefaultValue(); } throw new IocException(sprintf('No default value available for %s in %s::%s()', $parameter->getName(), $parameter->getDeclaringClass()->getName(), $parameter->getDeclaringFunction()->getName() )); }
php
protected function resolvePrimitive(ReflectionParameter $parameter, array &$primitives) { if (count($primitives) > 0) { // Grab the next primitive return array_shift($primitives); } if ($parameter->isDefaultValueAvailable()) { // No value was found, so use the default value return $parameter->getDefaultValue(); } throw new IocException(sprintf('No default value available for %s in %s::%s()', $parameter->getName(), $parameter->getDeclaringClass()->getName(), $parameter->getDeclaringFunction()->getName() )); }
[ "protected", "function", "resolvePrimitive", "(", "ReflectionParameter", "$", "parameter", ",", "array", "&", "$", "primitives", ")", "{", "if", "(", "count", "(", "$", "primitives", ")", ">", "0", ")", "{", "// Grab the next primitive", "return", "array_shift",...
Resolves a primitive parameter @param ReflectionParameter $parameter The primitive parameter to resolve @param array $primitives The list of primitive values @return mixed The resolved primitive @throws IocException Thrown if there was a problem resolving the primitive
[ "Resolves", "a", "primitive", "parameter" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/Ioc/Container.php#L343-L360
opulencephp/Opulence
src/Opulence/QueryBuilders/SelectQuery.php
SelectQuery.addGroupBy
public function addGroupBy(string ...$expression) : self { $this->groupByClauses = array_merge($this->groupByClauses, $expression); return $this; }
php
public function addGroupBy(string ...$expression) : self { $this->groupByClauses = array_merge($this->groupByClauses, $expression); return $this; }
[ "public", "function", "addGroupBy", "(", "string", "...", "$", "expression", ")", ":", "self", "{", "$", "this", "->", "groupByClauses", "=", "array_merge", "(", "$", "this", "->", "groupByClauses", ",", "$", "expression", ")", ";", "return", "$", "this", ...
Adds to a "GROUP BY" clause @param string[] $expression,... A variable list of expressions of what to group by @return self For method chaining
[ "Adds", "to", "a", "GROUP", "BY", "clause" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/QueryBuilders/SelectQuery.php#L53-L58
opulencephp/Opulence
src/Opulence/QueryBuilders/SelectQuery.php
SelectQuery.addOrderBy
public function addOrderBy(string ...$expression) : self { $this->orderBy = array_merge($this->orderBy, $expression); return $this; }
php
public function addOrderBy(string ...$expression) : self { $this->orderBy = array_merge($this->orderBy, $expression); return $this; }
[ "public", "function", "addOrderBy", "(", "string", "...", "$", "expression", ")", ":", "self", "{", "$", "this", "->", "orderBy", "=", "array_merge", "(", "$", "this", "->", "orderBy", ",", "$", "expression", ")", ";", "return", "$", "this", ";", "}" ]
Adds to a "ORDER BY" clause @param string[] $expression,... A variable list of expressions to order by @return self For method chaining
[ "Adds", "to", "a", "ORDER", "BY", "clause" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/QueryBuilders/SelectQuery.php#L66-L71
opulencephp/Opulence
src/Opulence/QueryBuilders/SelectQuery.php
SelectQuery.addSelectExpression
public function addSelectExpression(string ...$expression) : self { $this->selectExpressions = array_merge($this->selectExpressions, $expression); return $this; }
php
public function addSelectExpression(string ...$expression) : self { $this->selectExpressions = array_merge($this->selectExpressions, $expression); return $this; }
[ "public", "function", "addSelectExpression", "(", "string", "...", "$", "expression", ")", ":", "self", "{", "$", "this", "->", "selectExpressions", "=", "array_merge", "(", "$", "this", "->", "selectExpressions", ",", "$", "expression", ")", ";", "return", ...
Adds more select expressions @param string[] $expression,... A variable list of select expressions @return self For method chaining
[ "Adds", "more", "select", "expressions" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/QueryBuilders/SelectQuery.php#L79-L84
opulencephp/Opulence
src/Opulence/QueryBuilders/SelectQuery.php
SelectQuery.andHaving
public function andHaving(...$conditions) : self { $this->havingConditions = $this->conditionalQueryBuilder->addConditionToClause( $this->havingConditions, 'AND', ...$this->createConditionExpressions($conditions) ); return $this; }
php
public function andHaving(...$conditions) : self { $this->havingConditions = $this->conditionalQueryBuilder->addConditionToClause( $this->havingConditions, 'AND', ...$this->createConditionExpressions($conditions) ); return $this; }
[ "public", "function", "andHaving", "(", "...", "$", "conditions", ")", ":", "self", "{", "$", "this", "->", "havingConditions", "=", "$", "this", "->", "conditionalQueryBuilder", "->", "addConditionToClause", "(", "$", "this", "->", "havingConditions", ",", "'...
Adds to a "HAVING" condition that will be "AND"ed with other conditions @param array $conditions,... A variable list of conditions to be met @return self For method chaining
[ "Adds", "to", "a", "HAVING", "condition", "that", "will", "be", "AND", "ed", "with", "other", "conditions" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/QueryBuilders/SelectQuery.php#L92-L99
opulencephp/Opulence
src/Opulence/QueryBuilders/SelectQuery.php
SelectQuery.from
public function from(string $tableName, string $tableAlias = '') : self { $this->setTable($tableName, $tableAlias); return $this; }
php
public function from(string $tableName, string $tableAlias = '') : self { $this->setTable($tableName, $tableAlias); return $this; }
[ "public", "function", "from", "(", "string", "$", "tableName", ",", "string", "$", "tableAlias", "=", "''", ")", ":", "self", "{", "$", "this", "->", "setTable", "(", "$", "tableName", ",", "$", "tableAlias", ")", ";", "return", "$", "this", ";", "}"...
Specifies which table we're selecting from @param string $tableName The name of the table we're selecting from @param string $tableAlias The alias of the table name @return self For method chaining
[ "Specifies", "which", "table", "we", "re", "selecting", "from" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/QueryBuilders/SelectQuery.php#L123-L128
opulencephp/Opulence
src/Opulence/QueryBuilders/SelectQuery.php
SelectQuery.having
public function having(...$conditions) : self { // We want to wipe out anything already in the condition list $this->havingConditions = []; $this->havingConditions = $this->conditionalQueryBuilder->addConditionToClause( $this->havingConditions, 'AND', ...$this->createConditionExpressions($conditions) ); return $this; }
php
public function having(...$conditions) : self { // We want to wipe out anything already in the condition list $this->havingConditions = []; $this->havingConditions = $this->conditionalQueryBuilder->addConditionToClause( $this->havingConditions, 'AND', ...$this->createConditionExpressions($conditions) ); return $this; }
[ "public", "function", "having", "(", "...", "$", "conditions", ")", ":", "self", "{", "// We want to wipe out anything already in the condition list", "$", "this", "->", "havingConditions", "=", "[", "]", ";", "$", "this", "->", "havingConditions", "=", "$", "this...
Starts a "HAVING" condition Only call this method once per query because it will overwrite any previously-set "HAVING" expressions @param array $conditions,... A variable list of conditions to be met @return self For method chaining
[ "Starts", "a", "HAVING", "condition", "Only", "call", "this", "method", "once", "per", "query", "because", "it", "will", "overwrite", "any", "previously", "-", "set", "HAVING", "expressions" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/QueryBuilders/SelectQuery.php#L199-L208
opulencephp/Opulence
src/Opulence/QueryBuilders/SelectQuery.php
SelectQuery.innerJoin
public function innerJoin(string $tableName, string $tableAlias, string $condition) : self { $this->joins['inner'][] = ['tableName' => $tableName, 'tableAlias' => $tableAlias, 'condition' => $condition]; return $this; }
php
public function innerJoin(string $tableName, string $tableAlias, string $condition) : self { $this->joins['inner'][] = ['tableName' => $tableName, 'tableAlias' => $tableAlias, 'condition' => $condition]; return $this; }
[ "public", "function", "innerJoin", "(", "string", "$", "tableName", ",", "string", "$", "tableAlias", ",", "string", "$", "condition", ")", ":", "self", "{", "$", "this", "->", "joins", "[", "'inner'", "]", "[", "]", "=", "[", "'tableName'", "=>", "$",...
Adds a inner join to the query @param string $tableName The name of the table we're joining @param string $tableAlias The alias of the table name @param string $condition The "ON" portion of the join @return self For method chaining
[ "Adds", "a", "inner", "join", "to", "the", "query" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/QueryBuilders/SelectQuery.php#L218-L223
opulencephp/Opulence
src/Opulence/QueryBuilders/SelectQuery.php
SelectQuery.join
public function join(string $tableName, string $tableAlias, string $condition) : self { return $this->innerJoin($tableName, $tableAlias, $condition); }
php
public function join(string $tableName, string $tableAlias, string $condition) : self { return $this->innerJoin($tableName, $tableAlias, $condition); }
[ "public", "function", "join", "(", "string", "$", "tableName", ",", "string", "$", "tableAlias", ",", "string", "$", "condition", ")", ":", "self", "{", "return", "$", "this", "->", "innerJoin", "(", "$", "tableName", ",", "$", "tableAlias", ",", "$", ...
Adds a join to the query This is the same thing as an inner join @param string $tableName The name of the table we're joining @param string $tableAlias The alias of the table name @param string $condition The "ON" portion of the join @return self For method chaining
[ "Adds", "a", "join", "to", "the", "query", "This", "is", "the", "same", "thing", "as", "an", "inner", "join" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/QueryBuilders/SelectQuery.php#L234-L237
opulencephp/Opulence
src/Opulence/QueryBuilders/SelectQuery.php
SelectQuery.leftJoin
public function leftJoin(string $tableName, string $tableAlias, string $condition) : self { $this->joins['left'][] = ['tableName' => $tableName, 'tableAlias' => $tableAlias, 'condition' => $condition]; return $this; }
php
public function leftJoin(string $tableName, string $tableAlias, string $condition) : self { $this->joins['left'][] = ['tableName' => $tableName, 'tableAlias' => $tableAlias, 'condition' => $condition]; return $this; }
[ "public", "function", "leftJoin", "(", "string", "$", "tableName", ",", "string", "$", "tableAlias", ",", "string", "$", "condition", ")", ":", "self", "{", "$", "this", "->", "joins", "[", "'left'", "]", "[", "]", "=", "[", "'tableName'", "=>", "$", ...
Adds a left join to the query @param string $tableName The name of the table we're joining @param string $tableAlias The alias of the table name @param string $condition The "ON" portion of the join @return self For method chaining
[ "Adds", "a", "left", "join", "to", "the", "query" ]
train
https://github.com/opulencephp/Opulence/blob/27c86747f893a78ab0bc9b8a90aae3cad6e7afb5/src/Opulence/QueryBuilders/SelectQuery.php#L247-L252