repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
doctrine/orm | lib/Doctrine/ORM/Query/SqlWalker.php | SqlWalker.walkSimpleCaseExpression | public function walkSimpleCaseExpression($simpleCaseExpression)
{
$sql = 'CASE ' . $this->walkStateFieldPathExpression($simpleCaseExpression->caseOperand);
foreach ($simpleCaseExpression->simpleWhenClauses as $simpleWhenClause) {
$sql .= ' WHEN ' . $this->walkSimpleArithmeticExpression(... | php | public function walkSimpleCaseExpression($simpleCaseExpression)
{
$sql = 'CASE ' . $this->walkStateFieldPathExpression($simpleCaseExpression->caseOperand);
foreach ($simpleCaseExpression->simpleWhenClauses as $simpleWhenClause) {
$sql .= ' WHEN ' . $this->walkSimpleArithmeticExpression(... | [
"public",
"function",
"walkSimpleCaseExpression",
"(",
"$",
"simpleCaseExpression",
")",
"{",
"$",
"sql",
"=",
"'CASE '",
".",
"$",
"this",
"->",
"walkStateFieldPathExpression",
"(",
"$",
"simpleCaseExpression",
"->",
"caseOperand",
")",
";",
"foreach",
"(",
"$",
... | Walks down a SimpleCaseExpression AST node and generates the corresponding SQL.
@param AST\SimpleCaseExpression $simpleCaseExpression
@return string The SQL. | [
"Walks",
"down",
"a",
"SimpleCaseExpression",
"AST",
"node",
"and",
"generates",
"the",
"corresponding",
"SQL",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/Query/SqlWalker.php#L1311-L1323 | train |
doctrine/orm | lib/Doctrine/ORM/Query/SqlWalker.php | SqlWalker.walkArithmeticPrimary | public function walkArithmeticPrimary($primary)
{
if ($primary instanceof AST\SimpleArithmeticExpression) {
return '(' . $this->walkSimpleArithmeticExpression($primary) . ')';
}
if ($primary instanceof AST\Node) {
return $primary->dispatch($this);
}
... | php | public function walkArithmeticPrimary($primary)
{
if ($primary instanceof AST\SimpleArithmeticExpression) {
return '(' . $this->walkSimpleArithmeticExpression($primary) . ')';
}
if ($primary instanceof AST\Node) {
return $primary->dispatch($this);
}
... | [
"public",
"function",
"walkArithmeticPrimary",
"(",
"$",
"primary",
")",
"{",
"if",
"(",
"$",
"primary",
"instanceof",
"AST",
"\\",
"SimpleArithmeticExpression",
")",
"{",
"return",
"'('",
".",
"$",
"this",
"->",
"walkSimpleArithmeticExpression",
"(",
"$",
"prim... | Walks down an ArithmeticPrimary that represents an AST node, thereby generating the appropriate SQL.
@param mixed $primary
@return string The SQL. | [
"Walks",
"down",
"an",
"ArithmeticPrimary",
"that",
"represents",
"an",
"AST",
"node",
"thereby",
"generating",
"the",
"appropriate",
"SQL",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/Query/SqlWalker.php#L2336-L2347 | train |
doctrine/orm | lib/Doctrine/ORM/EntityRepository.php | EntityRepository.resolveMagicCall | private function resolveMagicCall($method, $by, array $arguments)
{
if (! $arguments) {
throw InvalidMagicMethodCall::onMissingParameter($method . $by);
}
$fieldName = lcfirst(Inflector::classify($by));
if ($this->class->getProperty($fieldName) === null) {
t... | php | private function resolveMagicCall($method, $by, array $arguments)
{
if (! $arguments) {
throw InvalidMagicMethodCall::onMissingParameter($method . $by);
}
$fieldName = lcfirst(Inflector::classify($by));
if ($this->class->getProperty($fieldName) === null) {
t... | [
"private",
"function",
"resolveMagicCall",
"(",
"$",
"method",
",",
"$",
"by",
",",
"array",
"$",
"arguments",
")",
"{",
"if",
"(",
"!",
"$",
"arguments",
")",
"{",
"throw",
"InvalidMagicMethodCall",
"::",
"onMissingParameter",
"(",
"$",
"method",
".",
"$"... | Resolves a magic method call to the proper existent method at `EntityRepository`.
@param string $method The method to call
@param string $by The property name used as condition
@param mixed[] $arguments The arguments to pass at method call
@return mixed
@throws ORMException If the method called is invali... | [
"Resolves",
"a",
"magic",
"method",
"call",
"to",
"the",
"proper",
"existent",
"method",
"at",
"EntityRepository",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/EntityRepository.php#L253-L270 | train |
doctrine/orm | lib/Doctrine/ORM/Configuration.php | Configuration.setAutoGenerateProxyClasses | public function setAutoGenerateProxyClasses($autoGenerate) : void
{
$proxyManagerConfig = $this->getProxyManagerConfiguration();
switch ((int) $autoGenerate) {
case ProxyFactory::AUTOGENERATE_ALWAYS:
case ProxyFactory::AUTOGENERATE_FILE_NOT_EXISTS:
$proxyMana... | php | public function setAutoGenerateProxyClasses($autoGenerate) : void
{
$proxyManagerConfig = $this->getProxyManagerConfiguration();
switch ((int) $autoGenerate) {
case ProxyFactory::AUTOGENERATE_ALWAYS:
case ProxyFactory::AUTOGENERATE_FILE_NOT_EXISTS:
$proxyMana... | [
"public",
"function",
"setAutoGenerateProxyClasses",
"(",
"$",
"autoGenerate",
")",
":",
"void",
"{",
"$",
"proxyManagerConfig",
"=",
"$",
"this",
"->",
"getProxyManagerConfiguration",
"(",
")",
";",
"switch",
"(",
"(",
"int",
")",
"$",
"autoGenerate",
")",
"{... | Sets the strategy for automatically generating proxy classes.
@param bool|int $autoGenerate Possible values are constants of Doctrine\ORM\Proxy\Factory\ProxyFactory.
True is converted to AUTOGENERATE_ALWAYS, false to AUTOGENERATE_NEVER. | [
"Sets",
"the",
"strategy",
"for",
"automatically",
"generating",
"proxy",
"classes",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/Configuration.php#L117-L136 | train |
doctrine/orm | lib/Doctrine/ORM/Configuration.php | Configuration.newDefaultAnnotationDriver | public function newDefaultAnnotationDriver(array $paths = []) : AnnotationDriver
{
AnnotationRegistry::registerFile(__DIR__ . '/Annotation/DoctrineAnnotations.php');
$reader = new CachedReader(new AnnotationReader(), new ArrayCache());
return new AnnotationDriver($reader, $paths);
} | php | public function newDefaultAnnotationDriver(array $paths = []) : AnnotationDriver
{
AnnotationRegistry::registerFile(__DIR__ . '/Annotation/DoctrineAnnotations.php');
$reader = new CachedReader(new AnnotationReader(), new ArrayCache());
return new AnnotationDriver($reader, $paths);
} | [
"public",
"function",
"newDefaultAnnotationDriver",
"(",
"array",
"$",
"paths",
"=",
"[",
"]",
")",
":",
"AnnotationDriver",
"{",
"AnnotationRegistry",
"::",
"registerFile",
"(",
"__DIR__",
".",
"'/Annotation/DoctrineAnnotations.php'",
")",
";",
"$",
"reader",
"=",
... | Adds a new default annotation driver with a correctly configured annotation reader.
@param string[] $paths | [
"Adds",
"a",
"new",
"default",
"annotation",
"driver",
"with",
"a",
"correctly",
"configured",
"annotation",
"reader",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/Configuration.php#L162-L169 | train |
doctrine/orm | lib/Doctrine/ORM/Configuration.php | Configuration.addCustomStringFunction | public function addCustomStringFunction(string $functionName, $classNameOrFactory) : void
{
$this->customStringFunctions[strtolower($functionName)] = $classNameOrFactory;
} | php | public function addCustomStringFunction(string $functionName, $classNameOrFactory) : void
{
$this->customStringFunctions[strtolower($functionName)] = $classNameOrFactory;
} | [
"public",
"function",
"addCustomStringFunction",
"(",
"string",
"$",
"functionName",
",",
"$",
"classNameOrFactory",
")",
":",
"void",
"{",
"$",
"this",
"->",
"customStringFunctions",
"[",
"strtolower",
"(",
"$",
"functionName",
")",
"]",
"=",
"$",
"classNameOrF... | Registers a custom DQL function that produces a string value.
Such a function can then be used in any DQL statement in any place where string
functions are allowed.
DQL function names are case-insensitive.
@param string|callable $classNameOrFactory Class name or a callable that returns the function. | [
"Registers",
"a",
"custom",
"DQL",
"function",
"that",
"produces",
"a",
"string",
"value",
".",
"Such",
"a",
"function",
"can",
"then",
"be",
"used",
"in",
"any",
"DQL",
"statement",
"in",
"any",
"place",
"where",
"string",
"functions",
"are",
"allowed",
"... | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/Configuration.php#L270-L273 | train |
doctrine/orm | lib/Doctrine/ORM/Configuration.php | Configuration.setCustomStringFunctions | public function setCustomStringFunctions(array $functions) : void
{
foreach ($functions as $name => $className) {
$this->addCustomStringFunction($name, $className);
}
} | php | public function setCustomStringFunctions(array $functions) : void
{
foreach ($functions as $name => $className) {
$this->addCustomStringFunction($name, $className);
}
} | [
"public",
"function",
"setCustomStringFunctions",
"(",
"array",
"$",
"functions",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"functions",
"as",
"$",
"name",
"=>",
"$",
"className",
")",
"{",
"$",
"this",
"->",
"addCustomStringFunction",
"(",
"$",
"name",
... | Sets a map of custom DQL string functions.
Keys must be function names and values the FQCN of the implementing class.
The function names will be case-insensitive in DQL.
Any previously added string functions are discarded.
@param string[]|callable[] $functions The map of custom DQL string functions. | [
"Sets",
"a",
"map",
"of",
"custom",
"DQL",
"string",
"functions",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/Configuration.php#L295-L300 | train |
doctrine/orm | lib/Doctrine/ORM/Configuration.php | Configuration.setCustomNumericFunctions | public function setCustomNumericFunctions(array $functions) : void
{
foreach ($functions as $name => $className) {
$this->addCustomNumericFunction($name, $className);
}
} | php | public function setCustomNumericFunctions(array $functions) : void
{
foreach ($functions as $name => $className) {
$this->addCustomNumericFunction($name, $className);
}
} | [
"public",
"function",
"setCustomNumericFunctions",
"(",
"array",
"$",
"functions",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"functions",
"as",
"$",
"name",
"=>",
"$",
"className",
")",
"{",
"$",
"this",
"->",
"addCustomNumericFunction",
"(",
"$",
"name",
... | Sets a map of custom DQL numeric functions.
Keys must be function names and values the FQCN of the implementing class.
The function names will be case-insensitive in DQL.
Any previously added numeric functions are discarded.
@param string[]|callable[] $functions The map of custom DQL numeric functions. | [
"Sets",
"a",
"map",
"of",
"custom",
"DQL",
"numeric",
"functions",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/Configuration.php#L336-L341 | train |
doctrine/orm | lib/Doctrine/ORM/Configuration.php | Configuration.addCustomHydrationMode | public function addCustomHydrationMode(string $modeName, string $hydratorClassName) : void
{
$this->customHydrationModes[$modeName] = $hydratorClassName;
} | php | public function addCustomHydrationMode(string $modeName, string $hydratorClassName) : void
{
$this->customHydrationModes[$modeName] = $hydratorClassName;
} | [
"public",
"function",
"addCustomHydrationMode",
"(",
"string",
"$",
"modeName",
",",
"string",
"$",
"hydratorClassName",
")",
":",
"void",
"{",
"$",
"this",
"->",
"customHydrationModes",
"[",
"$",
"modeName",
"]",
"=",
"$",
"hydratorClassName",
";",
"}"
] | Adds a custom hydration mode. | [
"Adds",
"a",
"custom",
"hydration",
"mode",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/Configuration.php#L411-L414 | train |
doctrine/orm | lib/Doctrine/ORM/Configuration.php | Configuration.addFilter | public function addFilter(string $filterName, string $filterClassName) : void
{
$this->filters[$filterName] = $filterClassName;
} | php | public function addFilter(string $filterName, string $filterClassName) : void
{
$this->filters[$filterName] = $filterClassName;
} | [
"public",
"function",
"addFilter",
"(",
"string",
"$",
"filterName",
",",
"string",
"$",
"filterClassName",
")",
":",
"void",
"{",
"$",
"this",
"->",
"filters",
"[",
"$",
"filterName",
"]",
"=",
"$",
"filterClassName",
";",
"}"
] | Adds a filter to the list of possible filters. | [
"Adds",
"a",
"filter",
"to",
"the",
"list",
"of",
"possible",
"filters",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/Configuration.php#L432-L435 | train |
doctrine/orm | lib/Doctrine/ORM/Tools/Setup.php | Setup.createXMLMetadataConfiguration | public static function createXMLMetadataConfiguration(array $paths, $isDevMode = false, $proxyDir = null, ?Cache $cache = null)
{
$config = self::createConfiguration($isDevMode, $proxyDir, $cache);
$config->setMetadataDriverImpl(new XmlDriver($paths));
return $config;
} | php | public static function createXMLMetadataConfiguration(array $paths, $isDevMode = false, $proxyDir = null, ?Cache $cache = null)
{
$config = self::createConfiguration($isDevMode, $proxyDir, $cache);
$config->setMetadataDriverImpl(new XmlDriver($paths));
return $config;
} | [
"public",
"static",
"function",
"createXMLMetadataConfiguration",
"(",
"array",
"$",
"paths",
",",
"$",
"isDevMode",
"=",
"false",
",",
"$",
"proxyDir",
"=",
"null",
",",
"?",
"Cache",
"$",
"cache",
"=",
"null",
")",
"{",
"$",
"config",
"=",
"self",
"::"... | Creates a configuration with a xml metadata driver.
@param string[] $paths
@param bool $isDevMode
@param string $proxyDir
@return Configuration | [
"Creates",
"a",
"configuration",
"with",
"a",
"xml",
"metadata",
"driver",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/Tools/Setup.php#L52-L58 | train |
doctrine/orm | lib/Doctrine/ORM/PersistentObject.php | PersistentObject.injectEntityManager | public function injectEntityManager(EntityManagerInterface $entityManager, ClassMetadata $classMetadata) : void
{
if ($entityManager !== self::$entityManager) {
throw new RuntimeException(
'Trying to use PersistentObject with different EntityManager instances. ' .
... | php | public function injectEntityManager(EntityManagerInterface $entityManager, ClassMetadata $classMetadata) : void
{
if ($entityManager !== self::$entityManager) {
throw new RuntimeException(
'Trying to use PersistentObject with different EntityManager instances. ' .
... | [
"public",
"function",
"injectEntityManager",
"(",
"EntityManagerInterface",
"$",
"entityManager",
",",
"ClassMetadata",
"$",
"classMetadata",
")",
":",
"void",
"{",
"if",
"(",
"$",
"entityManager",
"!==",
"self",
"::",
"$",
"entityManager",
")",
"{",
"throw",
"n... | Injects the Doctrine Object Manager.
@throws RuntimeException | [
"Injects",
"the",
"Doctrine",
"Object",
"Manager",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/PersistentObject.php#L78-L88 | train |
doctrine/orm | lib/Doctrine/ORM/PersistentObject.php | PersistentObject.set | private function set($field, $args)
{
$this->initializeDoctrine();
$property = $this->cm->getProperty($field);
if (! $property) {
throw new BadMethodCallException("no field with name '" . $field . "' exists on '" . $this->cm->getClassName() . "'");
}
switch (tr... | php | private function set($field, $args)
{
$this->initializeDoctrine();
$property = $this->cm->getProperty($field);
if (! $property) {
throw new BadMethodCallException("no field with name '" . $field . "' exists on '" . $this->cm->getClassName() . "'");
}
switch (tr... | [
"private",
"function",
"set",
"(",
"$",
"field",
",",
"$",
"args",
")",
"{",
"$",
"this",
"->",
"initializeDoctrine",
"(",
")",
";",
"$",
"property",
"=",
"$",
"this",
"->",
"cm",
"->",
"getProperty",
"(",
"$",
"field",
")",
";",
"if",
"(",
"!",
... | Sets a persistent fields value.
@param string $field
@param mixed[] $args
@return object
@throws BadMethodCallException When no persistent field exists by that name.
@throws InvalidArgumentException When the wrong target object type is passed to an association. | [
"Sets",
"a",
"persistent",
"fields",
"value",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/PersistentObject.php#L101-L129 | train |
doctrine/orm | lib/Doctrine/ORM/PersistentObject.php | PersistentObject.get | private function get($field)
{
$this->initializeDoctrine();
$property = $this->cm->getProperty($field);
if (! $property) {
throw new BadMethodCallException("no field with name '" . $field . "' exists on '" . $this->cm->getClassName() . "'");
}
return $this->{$f... | php | private function get($field)
{
$this->initializeDoctrine();
$property = $this->cm->getProperty($field);
if (! $property) {
throw new BadMethodCallException("no field with name '" . $field . "' exists on '" . $this->cm->getClassName() . "'");
}
return $this->{$f... | [
"private",
"function",
"get",
"(",
"$",
"field",
")",
"{",
"$",
"this",
"->",
"initializeDoctrine",
"(",
")",
";",
"$",
"property",
"=",
"$",
"this",
"->",
"cm",
"->",
"getProperty",
"(",
"$",
"field",
")",
";",
"if",
"(",
"!",
"$",
"property",
")"... | Gets a persistent field value.
@param string $field
@return mixed
@throws BadMethodCallException When no persistent field exists by that name. | [
"Gets",
"a",
"persistent",
"field",
"value",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/PersistentObject.php#L140-L151 | train |
doctrine/orm | lib/Doctrine/ORM/PersistentObject.php | PersistentObject.completeOwningSide | private function completeOwningSide(AssociationMetadata $property, $targetObject)
{
// add this object on the owning side as well, for obvious infinite recursion
// reasons this is only done when called on the inverse side.
if ($property->isOwningSide()) {
return;
}
... | php | private function completeOwningSide(AssociationMetadata $property, $targetObject)
{
// add this object on the owning side as well, for obvious infinite recursion
// reasons this is only done when called on the inverse side.
if ($property->isOwningSide()) {
return;
}
... | [
"private",
"function",
"completeOwningSide",
"(",
"AssociationMetadata",
"$",
"property",
",",
"$",
"targetObject",
")",
"{",
"// add this object on the owning side as well, for obvious infinite recursion",
"// reasons this is only done when called on the inverse side.",
"if",
"(",
"... | If this is an inverse side association, completes the owning side.
@param object $targetObject | [
"If",
"this",
"is",
"an",
"inverse",
"side",
"association",
"completes",
"the",
"owning",
"side",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/PersistentObject.php#L158-L172 | train |
doctrine/orm | lib/Doctrine/ORM/PersistentObject.php | PersistentObject.add | private function add($field, $args)
{
$this->initializeDoctrine();
$property = $this->cm->getProperty($field);
if (! $property) {
throw new BadMethodCallException("no field with name '" . $field . "' exists on '" . $this->cm->getClassName() . "'");
}
if (! ($pr... | php | private function add($field, $args)
{
$this->initializeDoctrine();
$property = $this->cm->getProperty($field);
if (! $property) {
throw new BadMethodCallException("no field with name '" . $field . "' exists on '" . $this->cm->getClassName() . "'");
}
if (! ($pr... | [
"private",
"function",
"add",
"(",
"$",
"field",
",",
"$",
"args",
")",
"{",
"$",
"this",
"->",
"initializeDoctrine",
"(",
")",
";",
"$",
"property",
"=",
"$",
"this",
"->",
"cm",
"->",
"getProperty",
"(",
"$",
"field",
")",
";",
"if",
"(",
"!",
... | Adds an object to a collection.
@param string $field
@param mixed[] $args
@return object
@throws BadMethodCallException
@throws InvalidArgumentException | [
"Adds",
"an",
"object",
"to",
"a",
"collection",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/PersistentObject.php#L185-L214 | train |
doctrine/orm | lib/Doctrine/ORM/PersistentObject.php | PersistentObject.initializeDoctrine | private function initializeDoctrine()
{
if ($this->cm !== null) {
return;
}
if (! self::$entityManager) {
throw new RuntimeException('No runtime entity manager set. Call PersistentObject#setEntityManager().');
}
$this->cm = self::$entityManager->getC... | php | private function initializeDoctrine()
{
if ($this->cm !== null) {
return;
}
if (! self::$entityManager) {
throw new RuntimeException('No runtime entity manager set. Call PersistentObject#setEntityManager().');
}
$this->cm = self::$entityManager->getC... | [
"private",
"function",
"initializeDoctrine",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"cm",
"!==",
"null",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"self",
"::",
"$",
"entityManager",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'No run... | Initializes Doctrine Metadata for this class.
@throws RuntimeException | [
"Initializes",
"Doctrine",
"Metadata",
"for",
"this",
"class",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/PersistentObject.php#L221-L232 | train |
doctrine/orm | lib/Doctrine/ORM/Query/ResultSetMapping.php | ResultSetMapping.addEntityResult | public function addEntityResult($class, $alias, $resultAlias = null)
{
$this->aliasMap[$alias] = $class;
$this->entityMappings[$alias] = $resultAlias;
if ($resultAlias !== null) {
$this->isMixed = true;
}
return $this;
} | php | public function addEntityResult($class, $alias, $resultAlias = null)
{
$this->aliasMap[$alias] = $class;
$this->entityMappings[$alias] = $resultAlias;
if ($resultAlias !== null) {
$this->isMixed = true;
}
return $this;
} | [
"public",
"function",
"addEntityResult",
"(",
"$",
"class",
",",
"$",
"alias",
",",
"$",
"resultAlias",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"aliasMap",
"[",
"$",
"alias",
"]",
"=",
"$",
"class",
";",
"$",
"this",
"->",
"entityMappings",
"[",
"$... | Adds an entity result to this ResultSetMapping.
@param string $class The class name of the entity.
@param string $alias The alias for the class. The alias must be unique among all entity
results or joined entity results within this ResultSetMapping.
@param string|null $resultAlias The result alia... | [
"Adds",
"an",
"entity",
"result",
"to",
"this",
"ResultSetMapping",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/Query/ResultSetMapping.php#L179-L189 | train |
doctrine/orm | lib/Doctrine/ORM/Query/ResultSetMapping.php | ResultSetMapping.setDiscriminatorColumn | public function setDiscriminatorColumn($alias, $discrColumn)
{
$this->discriminatorColumns[$alias] = $discrColumn;
$this->columnOwnerMap[$discrColumn] = $alias;
return $this;
} | php | public function setDiscriminatorColumn($alias, $discrColumn)
{
$this->discriminatorColumns[$alias] = $discrColumn;
$this->columnOwnerMap[$discrColumn] = $alias;
return $this;
} | [
"public",
"function",
"setDiscriminatorColumn",
"(",
"$",
"alias",
",",
"$",
"discrColumn",
")",
"{",
"$",
"this",
"->",
"discriminatorColumns",
"[",
"$",
"alias",
"]",
"=",
"$",
"discrColumn",
";",
"$",
"this",
"->",
"columnOwnerMap",
"[",
"$",
"discrColumn... | Sets a discriminator column for an entity result or joined entity result.
The discriminator column will be used to determine the concrete class name to
instantiate.
@param string $alias The alias of the entity result or joined entity result the discriminator
column should be used for.
@param string $discrColumn ... | [
"Sets",
"a",
"discriminator",
"column",
"for",
"an",
"entity",
"result",
"or",
"joined",
"entity",
"result",
".",
"The",
"discriminator",
"column",
"will",
"be",
"used",
"to",
"determine",
"the",
"concrete",
"class",
"name",
"to",
"instantiate",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/Query/ResultSetMapping.php#L204-L210 | train |
doctrine/orm | lib/Doctrine/ORM/Query/ResultSetMapping.php | ResultSetMapping.addIndexBy | public function addIndexBy($alias, $fieldName)
{
$found = false;
foreach (array_merge($this->metaMappings, $this->fieldMappings) as $columnName => $columnFieldName) {
if (! ($columnFieldName === $fieldName && $this->columnOwnerMap[$columnName] === $alias)) {
continue;
... | php | public function addIndexBy($alias, $fieldName)
{
$found = false;
foreach (array_merge($this->metaMappings, $this->fieldMappings) as $columnName => $columnFieldName) {
if (! ($columnFieldName === $fieldName && $this->columnOwnerMap[$columnName] === $alias)) {
continue;
... | [
"public",
"function",
"addIndexBy",
"(",
"$",
"alias",
",",
"$",
"fieldName",
")",
"{",
"$",
"found",
"=",
"false",
";",
"foreach",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"metaMappings",
",",
"$",
"this",
"->",
"fieldMappings",
")",
"as",
"$",
"co... | Sets a field to use for indexing an entity result or joined entity result.
@param string $alias The alias of an entity result or joined entity result.
@param string $fieldName The name of the field to use for indexing.
@return ResultSetMapping This ResultSetMapping instance. | [
"Sets",
"a",
"field",
"to",
"use",
"for",
"indexing",
"an",
"entity",
"result",
"or",
"joined",
"entity",
"result",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/Query/ResultSetMapping.php#L220-L248 | train |
doctrine/orm | lib/Doctrine/ORM/Query/ResultSetMapping.php | ResultSetMapping.addFieldResult | public function addFieldResult($alias, $columnName, $fieldName, $declaringClass = null)
{
// column name (in result set) => field name
$this->fieldMappings[$columnName] = $fieldName;
// column name => alias of owner
$this->columnOwnerMap[$columnName] = $alias;
// field name =... | php | public function addFieldResult($alias, $columnName, $fieldName, $declaringClass = null)
{
// column name (in result set) => field name
$this->fieldMappings[$columnName] = $fieldName;
// column name => alias of owner
$this->columnOwnerMap[$columnName] = $alias;
// field name =... | [
"public",
"function",
"addFieldResult",
"(",
"$",
"alias",
",",
"$",
"columnName",
",",
"$",
"fieldName",
",",
"$",
"declaringClass",
"=",
"null",
")",
"{",
"// column name (in result set) => field name",
"$",
"this",
"->",
"fieldMappings",
"[",
"$",
"columnName",... | Adds a field to the result that belongs to an entity or joined entity.
@param string $alias The alias of the root entity or joined entity to which the field belongs.
@param string $columnName The name of the column in the SQL result set.
@param string $fieldName The name of the field o... | [
"Adds",
"a",
"field",
"to",
"the",
"result",
"that",
"belongs",
"to",
"an",
"entity",
"or",
"joined",
"entity",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/Query/ResultSetMapping.php#L325-L339 | train |
doctrine/orm | lib/Doctrine/ORM/Query/ResultSetMapping.php | ResultSetMapping.addJoinedEntityResult | public function addJoinedEntityResult($class, $alias, $parentAlias, $relation)
{
$this->aliasMap[$alias] = $class;
$this->parentAliasMap[$alias] = $parentAlias;
$this->relationMap[$alias] = $relation;
return $this;
} | php | public function addJoinedEntityResult($class, $alias, $parentAlias, $relation)
{
$this->aliasMap[$alias] = $class;
$this->parentAliasMap[$alias] = $parentAlias;
$this->relationMap[$alias] = $relation;
return $this;
} | [
"public",
"function",
"addJoinedEntityResult",
"(",
"$",
"class",
",",
"$",
"alias",
",",
"$",
"parentAlias",
",",
"$",
"relation",
")",
"{",
"$",
"this",
"->",
"aliasMap",
"[",
"$",
"alias",
"]",
"=",
"$",
"class",
";",
"$",
"this",
"->",
"parentAlias... | Adds a joined entity result.
@param string $class The class name of the joined entity.
@param string $alias The unique alias to use for the joined entity.
@param string $parentAlias The alias of the entity result that is the parent of this joined result.
@param string $relation The association field tha... | [
"Adds",
"a",
"joined",
"entity",
"result",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/Query/ResultSetMapping.php#L354-L361 | train |
doctrine/orm | lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php | OneToManyPersister.deleteJoinedEntityCollection | private function deleteJoinedEntityCollection(PersistentCollection $collection)
{
$association = $collection->getMapping();
$targetClass = $this->em->getClassMetadata($association->getTargetEntity());
$rootClass = $this->em->getClassMetadata($targetClass->getRootClassName());
... | php | private function deleteJoinedEntityCollection(PersistentCollection $collection)
{
$association = $collection->getMapping();
$targetClass = $this->em->getClassMetadata($association->getTargetEntity());
$rootClass = $this->em->getClassMetadata($targetClass->getRootClassName());
... | [
"private",
"function",
"deleteJoinedEntityCollection",
"(",
"PersistentCollection",
"$",
"collection",
")",
"{",
"$",
"association",
"=",
"$",
"collection",
"->",
"getMapping",
"(",
")",
";",
"$",
"targetClass",
"=",
"$",
"this",
"->",
"em",
"->",
"getClassMetad... | Delete Class Table Inheritance entities.
A temporary table is needed to keep IDs to be deleted in both parent and child class' tables.
Thanks Steve Ebersole (Hibernate) for idea on how to tackle reliably this scenario, we owe him a beer! =)
@return int
@throws DBALException | [
"Delete",
"Class",
"Table",
"Inheritance",
"entities",
".",
"A",
"temporary",
"table",
"is",
"needed",
"to",
"keep",
"IDs",
"to",
"be",
"deleted",
"in",
"both",
"parent",
"and",
"child",
"class",
"tables",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php#L221-L289 | train |
doctrine/orm | lib/Doctrine/ORM/LazyCriteriaCollection.php | LazyCriteriaCollection.count | public function count()
{
if ($this->isInitialized()) {
return $this->collection->count();
}
// Return cached result in case count query was already executed
if ($this->count !== null) {
return $this->count;
}
return $this->count = $this->ent... | php | public function count()
{
if ($this->isInitialized()) {
return $this->collection->count();
}
// Return cached result in case count query was already executed
if ($this->count !== null) {
return $this->count;
}
return $this->count = $this->ent... | [
"public",
"function",
"count",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isInitialized",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"collection",
"->",
"count",
"(",
")",
";",
"}",
"// Return cached result in case count query was already executed",
"... | Do an efficient count on the collection
@return int | [
"Do",
"an",
"efficient",
"count",
"on",
"the",
"collection"
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/LazyCriteriaCollection.php#L42-L54 | train |
doctrine/orm | lib/Doctrine/ORM/LazyCriteriaCollection.php | LazyCriteriaCollection.contains | public function contains($element)
{
if ($this->isInitialized()) {
return $this->collection->contains($element);
}
return $this->entityPersister->exists($element, $this->criteria);
} | php | public function contains($element)
{
if ($this->isInitialized()) {
return $this->collection->contains($element);
}
return $this->entityPersister->exists($element, $this->criteria);
} | [
"public",
"function",
"contains",
"(",
"$",
"element",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isInitialized",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"collection",
"->",
"contains",
"(",
"$",
"element",
")",
";",
"}",
"return",
"$",
"this"... | Do an optimized search of an element
@param object $element
@return bool | [
"Do",
"an",
"optimized",
"search",
"of",
"an",
"element"
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/LazyCriteriaCollection.php#L77-L84 | train |
doctrine/orm | lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php | ResultSetMappingBuilder.isInheritanceSupported | private function isInheritanceSupported(ClassMetadata $metadata)
{
if ($metadata->inheritanceType === InheritanceType::SINGLE_TABLE
&& in_array($metadata->getClassName(), $metadata->discriminatorMap, true)) {
return true;
}
return ! in_array($metadata->inheritanceTyp... | php | private function isInheritanceSupported(ClassMetadata $metadata)
{
if ($metadata->inheritanceType === InheritanceType::SINGLE_TABLE
&& in_array($metadata->getClassName(), $metadata->discriminatorMap, true)) {
return true;
}
return ! in_array($metadata->inheritanceTyp... | [
"private",
"function",
"isInheritanceSupported",
"(",
"ClassMetadata",
"$",
"metadata",
")",
"{",
"if",
"(",
"$",
"metadata",
"->",
"inheritanceType",
"===",
"InheritanceType",
"::",
"SINGLE_TABLE",
"&&",
"in_array",
"(",
"$",
"metadata",
"->",
"getClassName",
"("... | Checks if inheritance if supported.
@return bool | [
"Checks",
"if",
"inheritance",
"if",
"supported",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php#L181-L189 | train |
doctrine/orm | lib/Doctrine/ORM/Query.php | Query.processParameterMappings | private function processParameterMappings($paramMappings)
{
$sqlParams = [];
$types = [];
foreach ($this->parameters as $parameter) {
$key = $parameter->getName();
$value = $parameter->getValue();
$rsm = $this->getResultSetMapping();
... | php | private function processParameterMappings($paramMappings)
{
$sqlParams = [];
$types = [];
foreach ($this->parameters as $parameter) {
$key = $parameter->getName();
$value = $parameter->getValue();
$rsm = $this->getResultSetMapping();
... | [
"private",
"function",
"processParameterMappings",
"(",
"$",
"paramMappings",
")",
"{",
"$",
"sqlParams",
"=",
"[",
"]",
";",
"$",
"types",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"parameters",
"as",
"$",
"parameter",
")",
"{",
"$",
"key... | Processes query parameter mappings.
@param mixed[] $paramMappings
@return mixed[][]
@throws Query\QueryException | [
"Processes",
"query",
"parameter",
"mappings",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/Query.php#L361-L418 | train |
doctrine/orm | lib/Doctrine/ORM/Query.php | Query.iterate | public function iterate($parameters = null, $hydrationMode = self::HYDRATE_OBJECT)
{
$this->setHint(self::HINT_INTERNAL_ITERATION, true);
return parent::iterate($parameters, $hydrationMode);
} | php | public function iterate($parameters = null, $hydrationMode = self::HYDRATE_OBJECT)
{
$this->setHint(self::HINT_INTERNAL_ITERATION, true);
return parent::iterate($parameters, $hydrationMode);
} | [
"public",
"function",
"iterate",
"(",
"$",
"parameters",
"=",
"null",
",",
"$",
"hydrationMode",
"=",
"self",
"::",
"HYDRATE_OBJECT",
")",
"{",
"$",
"this",
"->",
"setHint",
"(",
"self",
"::",
"HINT_INTERNAL_ITERATION",
",",
"true",
")",
";",
"return",
"pa... | Executes the query and returns an IterableResult that can be used to incrementally
iterated over the result.
@param ArrayCollection|array|Parameter[]|mixed[]|null $parameters The query parameters.
@param int $hydrationMode The hydration mode to use.
@return IterableResult | [
"Executes",
"the",
"query",
"and",
"returns",
"an",
"IterableResult",
"that",
"can",
"be",
"used",
"to",
"incrementally",
"iterated",
"over",
"the",
"result",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/Query.php#L638-L643 | train |
doctrine/orm | lib/Doctrine/ORM/Query.php | Query.getLockMode | public function getLockMode()
{
$lockMode = $this->getHint(self::HINT_LOCK_MODE);
if ($lockMode === false) {
return null;
}
return $lockMode;
} | php | public function getLockMode()
{
$lockMode = $this->getHint(self::HINT_LOCK_MODE);
if ($lockMode === false) {
return null;
}
return $lockMode;
} | [
"public",
"function",
"getLockMode",
"(",
")",
"{",
"$",
"lockMode",
"=",
"$",
"this",
"->",
"getHint",
"(",
"self",
"::",
"HINT_LOCK_MODE",
")",
";",
"if",
"(",
"$",
"lockMode",
"===",
"false",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"l... | Get the current lock mode for this query.
@return int|null The current lock mode of this query or NULL if no specific lock mode is set. | [
"Get",
"the",
"current",
"lock",
"mode",
"for",
"this",
"query",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/Query.php#L694-L703 | train |
doctrine/orm | lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php | DatabaseDriver.setTables | public function setTables($entityTables, $manyToManyTables)
{
$this->tables = $this->manyToManyTables = $this->classToTableNames = [];
foreach ($entityTables as $table) {
$className = $this->getClassNameForTable($table->getName());
$this->classToTableNames[$className] = $ta... | php | public function setTables($entityTables, $manyToManyTables)
{
$this->tables = $this->manyToManyTables = $this->classToTableNames = [];
foreach ($entityTables as $table) {
$className = $this->getClassNameForTable($table->getName());
$this->classToTableNames[$className] = $ta... | [
"public",
"function",
"setTables",
"(",
"$",
"entityTables",
",",
"$",
"manyToManyTables",
")",
"{",
"$",
"this",
"->",
"tables",
"=",
"$",
"this",
"->",
"manyToManyTables",
"=",
"$",
"this",
"->",
"classToTableNames",
"=",
"[",
"]",
";",
"foreach",
"(",
... | Sets tables manually instead of relying on the reverse engineering capabilities of SchemaManager.
@param Table[] $entityTables
@param Table[] $manyToManyTables | [
"Sets",
"tables",
"manually",
"instead",
"of",
"relying",
"on",
"the",
"reverse",
"engineering",
"capabilities",
"of",
"SchemaManager",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php#L120-L134 | train |
doctrine/orm | lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php | DatabaseDriver.buildTable | private function buildTable(Mapping\ClassMetadata $metadata)
{
$tableName = $this->classToTableNames[$metadata->getClassName()];
$indexes = $this->tables[$tableName]->getIndexes();
$tableMetadata = new Mapping\TableMetadata();
$tableMetadata->setName($this->classToTableNam... | php | private function buildTable(Mapping\ClassMetadata $metadata)
{
$tableName = $this->classToTableNames[$metadata->getClassName()];
$indexes = $this->tables[$tableName]->getIndexes();
$tableMetadata = new Mapping\TableMetadata();
$tableMetadata->setName($this->classToTableNam... | [
"private",
"function",
"buildTable",
"(",
"Mapping",
"\\",
"ClassMetadata",
"$",
"metadata",
")",
"{",
"$",
"tableName",
"=",
"$",
"this",
"->",
"classToTableNames",
"[",
"$",
"metadata",
"->",
"getClassName",
"(",
")",
"]",
";",
"$",
"indexes",
"=",
"$",
... | Build table from a class metadata. | [
"Build",
"table",
"from",
"a",
"class",
"metadata",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php#L286-L310 | train |
doctrine/orm | lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php | DatabaseDriver.getFieldNameForColumn | private function getFieldNameForColumn($tableName, $columnName, $fk = false)
{
if (isset($this->fieldNamesForColumns[$tableName], $this->fieldNamesForColumns[$tableName][$columnName])) {
return $this->fieldNamesForColumns[$tableName][$columnName];
}
$columnName = strtolower($col... | php | private function getFieldNameForColumn($tableName, $columnName, $fk = false)
{
if (isset($this->fieldNamesForColumns[$tableName], $this->fieldNamesForColumns[$tableName][$columnName])) {
return $this->fieldNamesForColumns[$tableName][$columnName];
}
$columnName = strtolower($col... | [
"private",
"function",
"getFieldNameForColumn",
"(",
"$",
"tableName",
",",
"$",
"columnName",
",",
"$",
"fk",
"=",
"false",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"fieldNamesForColumns",
"[",
"$",
"tableName",
"]",
",",
"$",
"this",
"->",... | Return the mapped field name for a column, if it exists. Otherwise return camelized version.
@param string $tableName
@param string $columnName
@param bool $fk Whether the column is a foreignkey or not.
@return string | [
"Return",
"the",
"mapped",
"field",
"name",
"for",
"a",
"column",
"if",
"it",
"exists",
".",
"Otherwise",
"return",
"camelized",
"version",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php#L510-L524 | train |
doctrine/orm | lib/Doctrine/ORM/Mapping/Factory/ClassMetadataGenerator.php | ClassMetadataGenerator.generate | public function generate(ClassMetadataDefinition $definition) : string
{
$metadata = $this->mappingDriver->loadMetadataForClass(
$definition->entityClassName,
$definition->parentClassMetadata
);
return $this->metadataExporter->export($metadata);
} | php | public function generate(ClassMetadataDefinition $definition) : string
{
$metadata = $this->mappingDriver->loadMetadataForClass(
$definition->entityClassName,
$definition->parentClassMetadata
);
return $this->metadataExporter->export($metadata);
} | [
"public",
"function",
"generate",
"(",
"ClassMetadataDefinition",
"$",
"definition",
")",
":",
"string",
"{",
"$",
"metadata",
"=",
"$",
"this",
"->",
"mappingDriver",
"->",
"loadMetadataForClass",
"(",
"$",
"definition",
"->",
"entityClassName",
",",
"$",
"defi... | Generates class metadata code. | [
"Generates",
"class",
"metadata",
"code",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/Mapping/Factory/ClassMetadataGenerator.php#L32-L40 | train |
doctrine/orm | lib/Doctrine/ORM/UnitOfWork.php | UnitOfWork.computeScheduleInsertsChangeSets | private function computeScheduleInsertsChangeSets()
{
foreach ($this->entityInsertions as $entity) {
$class = $this->em->getClassMetadata(get_class($entity));
$this->computeChangeSet($class, $entity);
}
} | php | private function computeScheduleInsertsChangeSets()
{
foreach ($this->entityInsertions as $entity) {
$class = $this->em->getClassMetadata(get_class($entity));
$this->computeChangeSet($class, $entity);
}
} | [
"private",
"function",
"computeScheduleInsertsChangeSets",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"entityInsertions",
"as",
"$",
"entity",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"em",
"->",
"getClassMetadata",
"(",
"get_class",
"(",
"$",
... | Computes the changesets of all entities scheduled for insertion. | [
"Computes",
"the",
"changesets",
"of",
"all",
"entities",
"scheduled",
"for",
"insertion",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/UnitOfWork.php#L451-L458 | train |
doctrine/orm | lib/Doctrine/ORM/UnitOfWork.php | UnitOfWork.executeExtraUpdates | private function executeExtraUpdates()
{
foreach ($this->extraUpdates as $oid => $update) {
[$entity, $changeset] = $update;
$this->entityChangeSets[$oid] = $changeset;
$this->getEntityPersister(get_class($entity))->update($entity);
}
$this->extraUpdate... | php | private function executeExtraUpdates()
{
foreach ($this->extraUpdates as $oid => $update) {
[$entity, $changeset] = $update;
$this->entityChangeSets[$oid] = $changeset;
$this->getEntityPersister(get_class($entity))->update($entity);
}
$this->extraUpdate... | [
"private",
"function",
"executeExtraUpdates",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"extraUpdates",
"as",
"$",
"oid",
"=>",
"$",
"update",
")",
"{",
"[",
"$",
"entity",
",",
"$",
"changeset",
"]",
"=",
"$",
"update",
";",
"$",
"this",
"->... | Executes any extra updates that have been scheduled. | [
"Executes",
"any",
"extra",
"updates",
"that",
"have",
"been",
"scheduled",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/UnitOfWork.php#L463-L474 | train |
doctrine/orm | lib/Doctrine/ORM/UnitOfWork.php | UnitOfWork.executeUpdates | private function executeUpdates($class)
{
$className = $class->getClassName();
$persister = $this->getEntityPersister($className);
$preUpdateInvoke = $this->listenersInvoker->getSubscribedSystems($class, Events::preUpdate);
$postUpdateInvoke = $this->listenersInvoker->... | php | private function executeUpdates($class)
{
$className = $class->getClassName();
$persister = $this->getEntityPersister($className);
$preUpdateInvoke = $this->listenersInvoker->getSubscribedSystems($class, Events::preUpdate);
$postUpdateInvoke = $this->listenersInvoker->... | [
"private",
"function",
"executeUpdates",
"(",
"$",
"class",
")",
"{",
"$",
"className",
"=",
"$",
"class",
"->",
"getClassName",
"(",
")",
";",
"$",
"persister",
"=",
"$",
"this",
"->",
"getEntityPersister",
"(",
"$",
"className",
")",
";",
"$",
"preUpda... | Executes all entity updates for entities of the specified type.
@param ClassMetadata $class | [
"Executes",
"all",
"entity",
"updates",
"for",
"entities",
"of",
"the",
"specified",
"type",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/UnitOfWork.php#L990-L1018 | train |
doctrine/orm | lib/Doctrine/ORM/UnitOfWork.php | UnitOfWork.scheduleForInsert | public function scheduleForInsert($entity)
{
$oid = spl_object_id($entity);
if (isset($this->entityUpdates[$oid])) {
throw new InvalidArgumentException('Dirty entity can not be scheduled for insertion.');
}
if (isset($this->entityDeletions[$oid])) {
throw OR... | php | public function scheduleForInsert($entity)
{
$oid = spl_object_id($entity);
if (isset($this->entityUpdates[$oid])) {
throw new InvalidArgumentException('Dirty entity can not be scheduled for insertion.');
}
if (isset($this->entityDeletions[$oid])) {
throw OR... | [
"public",
"function",
"scheduleForInsert",
"(",
"$",
"entity",
")",
"{",
"$",
"oid",
"=",
"spl_object_id",
"(",
"$",
"entity",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"entityUpdates",
"[",
"$",
"oid",
"]",
")",
")",
"{",
"throw",
"new",... | Schedules an entity for insertion into the database.
If the entity already has an identifier, it will be added to the identity map.
@param object $entity The entity to schedule for insertion.
@throws ORMInvalidArgumentException
@throws InvalidArgumentException | [
"Schedules",
"an",
"entity",
"for",
"insertion",
"into",
"the",
"database",
".",
"If",
"the",
"entity",
"already",
"has",
"an",
"identifier",
"it",
"will",
"be",
"added",
"to",
"the",
"identity",
"map",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/UnitOfWork.php#L1146-L1174 | train |
doctrine/orm | lib/Doctrine/ORM/UnitOfWork.php | UnitOfWork.scheduleForUpdate | public function scheduleForUpdate($entity) : void
{
$oid = spl_object_id($entity);
if (! isset($this->entityIdentifiers[$oid])) {
throw ORMInvalidArgumentException::entityHasNoIdentity($entity, 'scheduling for update');
}
if (isset($this->entityDeletions[$oid])) {
... | php | public function scheduleForUpdate($entity) : void
{
$oid = spl_object_id($entity);
if (! isset($this->entityIdentifiers[$oid])) {
throw ORMInvalidArgumentException::entityHasNoIdentity($entity, 'scheduling for update');
}
if (isset($this->entityDeletions[$oid])) {
... | [
"public",
"function",
"scheduleForUpdate",
"(",
"$",
"entity",
")",
":",
"void",
"{",
"$",
"oid",
"=",
"spl_object_id",
"(",
"$",
"entity",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"entityIdentifiers",
"[",
"$",
"oid",
"]",
")",
")"... | Schedules an entity for being updated.
@param object $entity The entity to schedule for being updated.
@throws ORMInvalidArgumentException | [
"Schedules",
"an",
"entity",
"for",
"being",
"updated",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/UnitOfWork.php#L1195-L1210 | train |
doctrine/orm | lib/Doctrine/ORM/UnitOfWork.php | UnitOfWork.isEntityScheduled | public function isEntityScheduled($entity)
{
$oid = spl_object_id($entity);
return isset($this->entityInsertions[$oid])
|| isset($this->entityUpdates[$oid])
|| isset($this->entityDeletions[$oid]);
} | php | public function isEntityScheduled($entity)
{
$oid = spl_object_id($entity);
return isset($this->entityInsertions[$oid])
|| isset($this->entityUpdates[$oid])
|| isset($this->entityDeletions[$oid]);
} | [
"public",
"function",
"isEntityScheduled",
"(",
"$",
"entity",
")",
"{",
"$",
"oid",
"=",
"spl_object_id",
"(",
"$",
"entity",
")",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"entityInsertions",
"[",
"$",
"oid",
"]",
")",
"||",
"isset",
"(",
"$",
... | Checks whether an entity is scheduled for insertion, update or deletion.
@param object $entity
@return bool | [
"Checks",
"whether",
"an",
"entity",
"is",
"scheduled",
"for",
"insertion",
"update",
"or",
"deletion",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/UnitOfWork.php#L1316-L1323 | train |
doctrine/orm | lib/Doctrine/ORM/UnitOfWork.php | UnitOfWork.performCallbackOnCachedPersister | private function performCallbackOnCachedPersister(callable $callback)
{
if (! $this->hasCache) {
return;
}
foreach (array_merge($this->entityPersisters, $this->collectionPersisters) as $persister) {
if ($persister instanceof CachedPersister) {
$callba... | php | private function performCallbackOnCachedPersister(callable $callback)
{
if (! $this->hasCache) {
return;
}
foreach (array_merge($this->entityPersisters, $this->collectionPersisters) as $persister) {
if ($persister instanceof CachedPersister) {
$callba... | [
"private",
"function",
"performCallbackOnCachedPersister",
"(",
"callable",
"$",
"callback",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasCache",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"entityPersisters",
","... | Performs an action after the transaction. | [
"Performs",
"an",
"action",
"after",
"the",
"transaction",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/UnitOfWork.php#L2814-L2825 | train |
doctrine/orm | lib/Doctrine/ORM/Mapping/Driver/Annotation/AnnotationDriver.php | AnnotationDriver.convertTableAnnotationToTableMetadata | private function convertTableAnnotationToTableMetadata(
Annotation\Table $tableAnnot,
Mapping\TableMetadata $table
) : Mapping\TableMetadata {
if (! empty($tableAnnot->name)) {
$table->setName($tableAnnot->name);
}
if (! empty($tableAnnot->schema)) {
... | php | private function convertTableAnnotationToTableMetadata(
Annotation\Table $tableAnnot,
Mapping\TableMetadata $table
) : Mapping\TableMetadata {
if (! empty($tableAnnot->name)) {
$table->setName($tableAnnot->name);
}
if (! empty($tableAnnot->schema)) {
... | [
"private",
"function",
"convertTableAnnotationToTableMetadata",
"(",
"Annotation",
"\\",
"Table",
"$",
"tableAnnot",
",",
"Mapping",
"\\",
"TableMetadata",
"$",
"table",
")",
":",
"Mapping",
"\\",
"TableMetadata",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"tableAn... | Parse the given Table as TableMetadata | [
"Parse",
"the",
"given",
"Table",
"as",
"TableMetadata"
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/Mapping/Driver/Annotation/AnnotationDriver.php#L857-L893 | train |
doctrine/orm | lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php | AbstractEntityPersister.getHash | protected function getHash($query, $criteria, ?array $orderBy = null, $limit = null, $offset = null)
{
[$params] = $criteria instanceof Criteria
? $this->persister->expandCriteriaParameters($criteria)
: $this->persister->expandParameters($criteria);
return sha1($query . seri... | php | protected function getHash($query, $criteria, ?array $orderBy = null, $limit = null, $offset = null)
{
[$params] = $criteria instanceof Criteria
? $this->persister->expandCriteriaParameters($criteria)
: $this->persister->expandParameters($criteria);
return sha1($query . seri... | [
"protected",
"function",
"getHash",
"(",
"$",
"query",
",",
"$",
"criteria",
",",
"?",
"array",
"$",
"orderBy",
"=",
"null",
",",
"$",
"limit",
"=",
"null",
",",
"$",
"offset",
"=",
"null",
")",
"{",
"[",
"$",
"params",
"]",
"=",
"$",
"criteria",
... | Generates a string of currently query
@param string $query
@param string $criteria
@param mixed[] $orderBy
@param int $limit
@param int $offset
@return string | [
"Generates",
"a",
"string",
"of",
"currently",
"query"
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php#L256-L263 | train |
doctrine/orm | lib/Doctrine/ORM/Mapping/MappingException.php | MappingException.missingRequiredOption | public static function missingRequiredOption($field, $expectedOption, $hint = '')
{
$message = sprintf("The mapping of field '%s' is invalid: The option '%s' is required.", $field, $expectedOption);
if (! empty($hint)) {
$message .= ' (Hint: ' . $hint . ')';
}
return ne... | php | public static function missingRequiredOption($field, $expectedOption, $hint = '')
{
$message = sprintf("The mapping of field '%s' is invalid: The option '%s' is required.", $field, $expectedOption);
if (! empty($hint)) {
$message .= ' (Hint: ' . $hint . ')';
}
return ne... | [
"public",
"static",
"function",
"missingRequiredOption",
"(",
"$",
"field",
",",
"$",
"expectedOption",
",",
"$",
"hint",
"=",
"''",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"\"The mapping of field '%s' is invalid: The option '%s' is required.\"",
",",
"$",
"f... | Called if a required option was not found but is required
@param string $field Which field cannot be processed?
@param string $expectedOption Which option is required
@param string $hint Can optionally be used to supply a tip for common mistakes,
e.g. "Did you think of the plural s?"
@return Mappin... | [
"Called",
"if",
"a",
"required",
"option",
"was",
"not",
"found",
"but",
"is",
"required"
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/Mapping/MappingException.php#L281-L290 | train |
doctrine/orm | lib/Doctrine/ORM/Query/Parser.php | Parser.match | public function match($token)
{
$lookaheadType = $this->lexer->lookahead['type'];
// Short-circuit on first condition, usually types match
if ($lookaheadType === $token) {
$this->lexer->moveNext();
return;
}
// If parameter is not identifier (1-99) ... | php | public function match($token)
{
$lookaheadType = $this->lexer->lookahead['type'];
// Short-circuit on first condition, usually types match
if ($lookaheadType === $token) {
$this->lexer->moveNext();
return;
}
// If parameter is not identifier (1-99) ... | [
"public",
"function",
"match",
"(",
"$",
"token",
")",
"{",
"$",
"lookaheadType",
"=",
"$",
"this",
"->",
"lexer",
"->",
"lookahead",
"[",
"'type'",
"]",
";",
"// Short-circuit on first condition, usually types match",
"if",
"(",
"$",
"lookaheadType",
"===",
"$"... | Attempts to match the given token with the current lookahead token.
If they match, updates the lookahead token; otherwise raises a syntax
error.
@param int $token The token type.
@throws QueryException If the tokens don't match. | [
"Attempts",
"to",
"match",
"the",
"given",
"token",
"with",
"the",
"current",
"lookahead",
"token",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/Query/Parser.php#L282-L309 | train |
doctrine/orm | lib/Doctrine/ORM/Query/Parser.php | Parser.free | public function free($deep = false, $position = 0)
{
// WARNING! Use this method with care. It resets the scanner!
$this->lexer->resetPosition($position);
// Deep = true cleans peek and also any previously defined errors
if ($deep) {
$this->lexer->resetPeek();
}
... | php | public function free($deep = false, $position = 0)
{
// WARNING! Use this method with care. It resets the scanner!
$this->lexer->resetPosition($position);
// Deep = true cleans peek and also any previously defined errors
if ($deep) {
$this->lexer->resetPeek();
}
... | [
"public",
"function",
"free",
"(",
"$",
"deep",
"=",
"false",
",",
"$",
"position",
"=",
"0",
")",
"{",
"// WARNING! Use this method with care. It resets the scanner!",
"$",
"this",
"->",
"lexer",
"->",
"resetPosition",
"(",
"$",
"position",
")",
";",
"// Deep =... | Frees this parser, enabling it to be reused.
@param bool $deep Whether to clean peek and reset errors.
@param int $position Position to reset. | [
"Frees",
"this",
"parser",
"enabling",
"it",
"to",
"be",
"reused",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/Query/Parser.php#L317-L329 | train |
doctrine/orm | lib/Doctrine/ORM/Query/Parser.php | Parser.peekBeyondClosingParenthesis | private function peekBeyondClosingParenthesis($resetPeek = true)
{
$token = $this->lexer->peek();
$numUnmatched = 1;
while ($numUnmatched > 0 && $token !== null) {
switch ($token['type']) {
case Lexer::T_OPEN_PARENTHESIS:
++$numUnmatche... | php | private function peekBeyondClosingParenthesis($resetPeek = true)
{
$token = $this->lexer->peek();
$numUnmatched = 1;
while ($numUnmatched > 0 && $token !== null) {
switch ($token['type']) {
case Lexer::T_OPEN_PARENTHESIS:
++$numUnmatche... | [
"private",
"function",
"peekBeyondClosingParenthesis",
"(",
"$",
"resetPeek",
"=",
"true",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"lexer",
"->",
"peek",
"(",
")",
";",
"$",
"numUnmatched",
"=",
"1",
";",
"while",
"(",
"$",
"numUnmatched",
">",
... | Peeks beyond the matched closing parenthesis and returns the first token after that one.
@param bool $resetPeek Reset peek after finding the closing parenthesis.
@return mixed[] | [
"Peeks",
"beyond",
"the",
"matched",
"closing",
"parenthesis",
"and",
"returns",
"the",
"first",
"token",
"after",
"that",
"one",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/Query/Parser.php#L480-L507 | train |
doctrine/orm | lib/Doctrine/ORM/Query/Parser.php | Parser.isMathOperator | private function isMathOperator($token)
{
return in_array($token['type'], [Lexer::T_PLUS, Lexer::T_MINUS, Lexer::T_DIVIDE, Lexer::T_MULTIPLY], true);
} | php | private function isMathOperator($token)
{
return in_array($token['type'], [Lexer::T_PLUS, Lexer::T_MINUS, Lexer::T_DIVIDE, Lexer::T_MULTIPLY], true);
} | [
"private",
"function",
"isMathOperator",
"(",
"$",
"token",
")",
"{",
"return",
"in_array",
"(",
"$",
"token",
"[",
"'type'",
"]",
",",
"[",
"Lexer",
"::",
"T_PLUS",
",",
"Lexer",
"::",
"T_MINUS",
",",
"Lexer",
"::",
"T_DIVIDE",
",",
"Lexer",
"::",
"T_... | Checks if the given token indicates a mathematical operator.
@param mixed[] $token
@return bool TRUE if the token is a mathematical operator, FALSE otherwise. | [
"Checks",
"if",
"the",
"given",
"token",
"indicates",
"a",
"mathematical",
"operator",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/Query/Parser.php#L516-L519 | train |
doctrine/orm | lib/Doctrine/ORM/Query/Parser.php | Parser.AliasIdentificationVariable | public function AliasIdentificationVariable()
{
$this->match(Lexer::T_IDENTIFIER);
$aliasIdentVariable = $this->lexer->token['value'];
$exists = isset($this->queryComponents[$aliasIdentVariable]);
if ($exists) {
$this->semanticalError(sprintf("'%s' is alread... | php | public function AliasIdentificationVariable()
{
$this->match(Lexer::T_IDENTIFIER);
$aliasIdentVariable = $this->lexer->token['value'];
$exists = isset($this->queryComponents[$aliasIdentVariable]);
if ($exists) {
$this->semanticalError(sprintf("'%s' is alread... | [
"public",
"function",
"AliasIdentificationVariable",
"(",
")",
"{",
"$",
"this",
"->",
"match",
"(",
"Lexer",
"::",
"T_IDENTIFIER",
")",
";",
"$",
"aliasIdentVariable",
"=",
"$",
"this",
"->",
"lexer",
"->",
"token",
"[",
"'value'",
"]",
";",
"$",
"exists"... | AliasIdentificationVariable = identifier
@return string | [
"AliasIdentificationVariable",
"=",
"identifier"
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/Query/Parser.php#L908-L920 | train |
doctrine/orm | lib/Doctrine/ORM/Query/Parser.php | Parser.validateAbstractSchemaName | private function validateAbstractSchemaName($schemaName) : void
{
if (class_exists($schemaName, true) || interface_exists($schemaName, true)) {
return;
}
try {
$this->getEntityManager()->getClassMetadata($schemaName);
return;
} catch (MappingExce... | php | private function validateAbstractSchemaName($schemaName) : void
{
if (class_exists($schemaName, true) || interface_exists($schemaName, true)) {
return;
}
try {
$this->getEntityManager()->getClassMetadata($schemaName);
return;
} catch (MappingExce... | [
"private",
"function",
"validateAbstractSchemaName",
"(",
"$",
"schemaName",
")",
":",
"void",
"{",
"if",
"(",
"class_exists",
"(",
"$",
"schemaName",
",",
"true",
")",
"||",
"interface_exists",
"(",
"$",
"schemaName",
",",
"true",
")",
")",
"{",
"return",
... | Validates an AbstractSchemaName, making sure the class exists.
@param string $schemaName The name to validate.
@throws QueryException If the name does not exist. | [
"Validates",
"an",
"AbstractSchemaName",
"making",
"sure",
"the",
"class",
"exists",
"."
] | 8bb91280ed1d359c421f4b49ffca6d4453f1ef16 | https://github.com/doctrine/orm/blob/8bb91280ed1d359c421f4b49ffca6d4453f1ef16/lib/Doctrine/ORM/Query/Parser.php#L955-L973 | train |
barryvdh/laravel-cors | src/HandlePreflight.php | HandlePreflight.handle | public function handle($request, Closure $next)
{
if ($this->cors->isPreflightRequest($request)) {
return $this->cors->handlePreflightRequest($request);
}
return $next($request);
} | php | public function handle($request, Closure $next)
{
if ($this->cors->isPreflightRequest($request)) {
return $this->cors->handlePreflightRequest($request);
}
return $next($request);
} | [
"public",
"function",
"handle",
"(",
"$",
"request",
",",
"Closure",
"$",
"next",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"cors",
"->",
"isPreflightRequest",
"(",
"$",
"request",
")",
")",
"{",
"return",
"$",
"this",
"->",
"cors",
"->",
"handlePrefligh... | Handle an incoming Preflight request.
@param \Illuminate\Http\Request $request
@param \Closure $next
@return mixed | [
"Handle",
"an",
"incoming",
"Preflight",
"request",
"."
] | c95ac944f2f20a17949aae6645692dfd3b402bca | https://github.com/barryvdh/laravel-cors/blob/c95ac944f2f20a17949aae6645692dfd3b402bca/src/HandlePreflight.php#L23-L30 | train |
thephpleague/oauth2-server | src/Grant/AuthCodeGrant.php | AuthCodeGrant.respondToAccessTokenRequest | public function respondToAccessTokenRequest(
ServerRequestInterface $request,
ResponseTypeInterface $responseType,
DateInterval $accessTokenTTL
) {
// Validate request
$client = $this->validateClient($request);
$encryptedAuthCode = $this->getRequestParameter('code', $... | php | public function respondToAccessTokenRequest(
ServerRequestInterface $request,
ResponseTypeInterface $responseType,
DateInterval $accessTokenTTL
) {
// Validate request
$client = $this->validateClient($request);
$encryptedAuthCode = $this->getRequestParameter('code', $... | [
"public",
"function",
"respondToAccessTokenRequest",
"(",
"ServerRequestInterface",
"$",
"request",
",",
"ResponseTypeInterface",
"$",
"responseType",
",",
"DateInterval",
"$",
"accessTokenTTL",
")",
"{",
"// Validate request",
"$",
"client",
"=",
"$",
"this",
"->",
"... | Respond to an access token request.
@param ServerRequestInterface $request
@param ResponseTypeInterface $responseType
@param DateInterval $accessTokenTTL
@throws OAuthServerException
@return ResponseTypeInterface | [
"Respond",
"to",
"an",
"access",
"token",
"request",
"."
] | 2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf | https://github.com/thephpleague/oauth2-server/blob/2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf/src/Grant/AuthCodeGrant.php#L74-L165 | train |
thephpleague/oauth2-server | src/Grant/AuthCodeGrant.php | AuthCodeGrant.validateAuthorizationCode | private function validateAuthorizationCode(
$authCodePayload,
ClientEntityInterface $client,
ServerRequestInterface $request
) {
if (time() > $authCodePayload->expire_time) {
throw OAuthServerException::invalidRequest('code', 'Authorization code has expired');
}
... | php | private function validateAuthorizationCode(
$authCodePayload,
ClientEntityInterface $client,
ServerRequestInterface $request
) {
if (time() > $authCodePayload->expire_time) {
throw OAuthServerException::invalidRequest('code', 'Authorization code has expired');
}
... | [
"private",
"function",
"validateAuthorizationCode",
"(",
"$",
"authCodePayload",
",",
"ClientEntityInterface",
"$",
"client",
",",
"ServerRequestInterface",
"$",
"request",
")",
"{",
"if",
"(",
"time",
"(",
")",
">",
"$",
"authCodePayload",
"->",
"expire_time",
")... | Validate the authorization code.
@param stdClass $authCodePayload
@param ClientEntityInterface $client
@param ServerRequestInterface $request | [
"Validate",
"the",
"authorization",
"code",
"."
] | 2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf | https://github.com/thephpleague/oauth2-server/blob/2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf/src/Grant/AuthCodeGrant.php#L174-L200 | train |
thephpleague/oauth2-server | src/Grant/AuthCodeGrant.php | AuthCodeGrant.getClientRedirectUri | private function getClientRedirectUri(AuthorizationRequest $authorizationRequest)
{
return \is_array($authorizationRequest->getClient()->getRedirectUri())
? $authorizationRequest->getClient()->getRedirectUri()[0]
: $authorizationRequest->getClient()->getRedirectUri();
} | php | private function getClientRedirectUri(AuthorizationRequest $authorizationRequest)
{
return \is_array($authorizationRequest->getClient()->getRedirectUri())
? $authorizationRequest->getClient()->getRedirectUri()[0]
: $authorizationRequest->getClient()->getRedirectUri();
} | [
"private",
"function",
"getClientRedirectUri",
"(",
"AuthorizationRequest",
"$",
"authorizationRequest",
")",
"{",
"return",
"\\",
"is_array",
"(",
"$",
"authorizationRequest",
"->",
"getClient",
"(",
")",
"->",
"getRedirectUri",
"(",
")",
")",
"?",
"$",
"authoriz... | Get the client redirect URI if not set in the request.
@param AuthorizationRequest $authorizationRequest
@return string | [
"Get",
"the",
"client",
"redirect",
"URI",
"if",
"not",
"set",
"in",
"the",
"request",
"."
] | 2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf | https://github.com/thephpleague/oauth2-server/blob/2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf/src/Grant/AuthCodeGrant.php#L384-L389 | train |
thephpleague/oauth2-server | src/CryptTrait.php | CryptTrait.encrypt | protected function encrypt($unencryptedData)
{
try {
if ($this->encryptionKey instanceof Key) {
return Crypto::encrypt($unencryptedData, $this->encryptionKey);
}
return Crypto::encryptWithPassword($unencryptedData, $this->encryptionKey);
} catch (... | php | protected function encrypt($unencryptedData)
{
try {
if ($this->encryptionKey instanceof Key) {
return Crypto::encrypt($unencryptedData, $this->encryptionKey);
}
return Crypto::encryptWithPassword($unencryptedData, $this->encryptionKey);
} catch (... | [
"protected",
"function",
"encrypt",
"(",
"$",
"unencryptedData",
")",
"{",
"try",
"{",
"if",
"(",
"$",
"this",
"->",
"encryptionKey",
"instanceof",
"Key",
")",
"{",
"return",
"Crypto",
"::",
"encrypt",
"(",
"$",
"unencryptedData",
",",
"$",
"this",
"->",
... | Encrypt data with encryptionKey.
@param string $unencryptedData
@throws LogicException
@return string | [
"Encrypt",
"data",
"with",
"encryptionKey",
"."
] | 2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf | https://github.com/thephpleague/oauth2-server/blob/2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf/src/CryptTrait.php#L35-L46 | train |
thephpleague/oauth2-server | src/CryptTrait.php | CryptTrait.decrypt | protected function decrypt($encryptedData)
{
try {
if ($this->encryptionKey instanceof Key) {
return Crypto::decrypt($encryptedData, $this->encryptionKey);
}
return Crypto::decryptWithPassword($encryptedData, $this->encryptionKey);
} catch (Except... | php | protected function decrypt($encryptedData)
{
try {
if ($this->encryptionKey instanceof Key) {
return Crypto::decrypt($encryptedData, $this->encryptionKey);
}
return Crypto::decryptWithPassword($encryptedData, $this->encryptionKey);
} catch (Except... | [
"protected",
"function",
"decrypt",
"(",
"$",
"encryptedData",
")",
"{",
"try",
"{",
"if",
"(",
"$",
"this",
"->",
"encryptionKey",
"instanceof",
"Key",
")",
"{",
"return",
"Crypto",
"::",
"decrypt",
"(",
"$",
"encryptedData",
",",
"$",
"this",
"->",
"en... | Decrypt data with encryptionKey.
@param string $encryptedData
@throws LogicException
@return string | [
"Decrypt",
"data",
"with",
"encryptionKey",
"."
] | 2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf | https://github.com/thephpleague/oauth2-server/blob/2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf/src/CryptTrait.php#L57-L68 | train |
thephpleague/oauth2-server | src/Exception/OAuthServerException.php | OAuthServerException.getPayload | public function getPayload()
{
$payload = $this->payload;
// The "message" property is deprecated and replaced by "error_description"
// TODO: remove "message" property
if (isset($payload['error_description']) && !isset($payload['message'])) {
$payload['message'] = $payl... | php | public function getPayload()
{
$payload = $this->payload;
// The "message" property is deprecated and replaced by "error_description"
// TODO: remove "message" property
if (isset($payload['error_description']) && !isset($payload['message'])) {
$payload['message'] = $payl... | [
"public",
"function",
"getPayload",
"(",
")",
"{",
"$",
"payload",
"=",
"$",
"this",
"->",
"payload",
";",
"// The \"message\" property is deprecated and replaced by \"error_description\"",
"// TODO: remove \"message\" property",
"if",
"(",
"isset",
"(",
"$",
"payload",
"... | Returns the current payload.
@return array | [
"Returns",
"the",
"current",
"payload",
"."
] | 2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf | https://github.com/thephpleague/oauth2-server/blob/2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf/src/Exception/OAuthServerException.php#L75-L86 | train |
thephpleague/oauth2-server | src/Exception/OAuthServerException.php | OAuthServerException.invalidRequest | public static function invalidRequest($parameter, $hint = null, Throwable $previous = null)
{
$errorMessage = 'The request is missing a required parameter, includes an invalid parameter value, ' .
'includes a parameter more than once, or is otherwise malformed.';
$hint = ($hint === null)... | php | public static function invalidRequest($parameter, $hint = null, Throwable $previous = null)
{
$errorMessage = 'The request is missing a required parameter, includes an invalid parameter value, ' .
'includes a parameter more than once, or is otherwise malformed.';
$hint = ($hint === null)... | [
"public",
"static",
"function",
"invalidRequest",
"(",
"$",
"parameter",
",",
"$",
"hint",
"=",
"null",
",",
"Throwable",
"$",
"previous",
"=",
"null",
")",
"{",
"$",
"errorMessage",
"=",
"'The request is missing a required parameter, includes an invalid parameter value... | Invalid request error.
@param string $parameter The invalid parameter
@param null|string $hint
@param Throwable $previous Previous exception
@return static | [
"Invalid",
"request",
"error",
"."
] | 2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf | https://github.com/thephpleague/oauth2-server/blob/2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf/src/Exception/OAuthServerException.php#L120-L127 | train |
thephpleague/oauth2-server | src/Exception/OAuthServerException.php | OAuthServerException.invalidScope | public static function invalidScope($scope, $redirectUri = null)
{
$errorMessage = 'The requested scope is invalid, unknown, or malformed';
if (empty($scope)) {
$hint = 'Specify a scope in the request or set a default scope';
} else {
$hint = sprintf(
... | php | public static function invalidScope($scope, $redirectUri = null)
{
$errorMessage = 'The requested scope is invalid, unknown, or malformed';
if (empty($scope)) {
$hint = 'Specify a scope in the request or set a default scope';
} else {
$hint = sprintf(
... | [
"public",
"static",
"function",
"invalidScope",
"(",
"$",
"scope",
",",
"$",
"redirectUri",
"=",
"null",
")",
"{",
"$",
"errorMessage",
"=",
"'The requested scope is invalid, unknown, or malformed'",
";",
"if",
"(",
"empty",
"(",
"$",
"scope",
")",
")",
"{",
"... | Invalid scope error.
@param string $scope The bad scope
@param null|string $redirectUri A HTTP URI to redirect the user back to
@return static | [
"Invalid",
"scope",
"error",
"."
] | 2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf | https://github.com/thephpleague/oauth2-server/blob/2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf/src/Exception/OAuthServerException.php#L149-L163 | train |
thephpleague/oauth2-server | src/Exception/OAuthServerException.php | OAuthServerException.accessDenied | public static function accessDenied($hint = null, $redirectUri = null, Throwable $previous = null)
{
return new static(
'The resource owner or authorization server denied the request.',
9,
'access_denied',
401,
$hint,
$redirectUri,
... | php | public static function accessDenied($hint = null, $redirectUri = null, Throwable $previous = null)
{
return new static(
'The resource owner or authorization server denied the request.',
9,
'access_denied',
401,
$hint,
$redirectUri,
... | [
"public",
"static",
"function",
"accessDenied",
"(",
"$",
"hint",
"=",
"null",
",",
"$",
"redirectUri",
"=",
"null",
",",
"Throwable",
"$",
"previous",
"=",
"null",
")",
"{",
"return",
"new",
"static",
"(",
"'The resource owner or authorization server denied the r... | Access denied.
@param null|string $hint
@param null|string $redirectUri
@param Throwable $previous
@return static | [
"Access",
"denied",
"."
] | 2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf | https://github.com/thephpleague/oauth2-server/blob/2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf/src/Exception/OAuthServerException.php#L221-L232 | train |
thephpleague/oauth2-server | src/Exception/OAuthServerException.php | OAuthServerException.generateHttpResponse | public function generateHttpResponse(ResponseInterface $response, $useFragment = false, $jsonOptions = 0)
{
$headers = $this->getHttpHeaders();
$payload = $this->getPayload();
if ($this->redirectUri !== null) {
if ($useFragment === true) {
$this->redirectUri .= ... | php | public function generateHttpResponse(ResponseInterface $response, $useFragment = false, $jsonOptions = 0)
{
$headers = $this->getHttpHeaders();
$payload = $this->getPayload();
if ($this->redirectUri !== null) {
if ($useFragment === true) {
$this->redirectUri .= ... | [
"public",
"function",
"generateHttpResponse",
"(",
"ResponseInterface",
"$",
"response",
",",
"$",
"useFragment",
"=",
"false",
",",
"$",
"jsonOptions",
"=",
"0",
")",
"{",
"$",
"headers",
"=",
"$",
"this",
"->",
"getHttpHeaders",
"(",
")",
";",
"$",
"payl... | Generate a HTTP response.
@param ResponseInterface $response
@param bool $useFragment True if errors should be in the URI fragment instead of query string
@param int $jsonOptions options passed to json_encode
@return ResponseInterface | [
"Generate",
"a",
"HTTP",
"response",
"."
] | 2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf | https://github.com/thephpleague/oauth2-server/blob/2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf/src/Exception/OAuthServerException.php#L271-L294 | train |
thephpleague/oauth2-server | src/Exception/OAuthServerException.php | OAuthServerException.getHttpHeaders | public function getHttpHeaders()
{
$headers = [
'Content-type' => 'application/json',
];
// Add "WWW-Authenticate" header
//
// RFC 6749, section 5.2.:
// "If the client attempted to authenticate via the 'Authorization'
// request header field, th... | php | public function getHttpHeaders()
{
$headers = [
'Content-type' => 'application/json',
];
// Add "WWW-Authenticate" header
//
// RFC 6749, section 5.2.:
// "If the client attempted to authenticate via the 'Authorization'
// request header field, th... | [
"public",
"function",
"getHttpHeaders",
"(",
")",
"{",
"$",
"headers",
"=",
"[",
"'Content-type'",
"=>",
"'application/json'",
",",
"]",
";",
"// Add \"WWW-Authenticate\" header",
"//",
"// RFC 6749, section 5.2.:",
"// \"If the client attempted to authenticate via the 'Authori... | Get all headers that have to be send with the error response.
@return array Array with header values | [
"Get",
"all",
"headers",
"that",
"have",
"to",
"be",
"send",
"with",
"the",
"error",
"response",
"."
] | 2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf | https://github.com/thephpleague/oauth2-server/blob/2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf/src/Exception/OAuthServerException.php#L301-L323 | train |
thephpleague/oauth2-server | src/Grant/AbstractGrant.php | AbstractGrant.validateClient | protected function validateClient(ServerRequestInterface $request)
{
list($basicAuthUser, $basicAuthPassword) = $this->getBasicAuthCredentials($request);
$clientId = $this->getRequestParameter('client_id', $request, $basicAuthUser);
if ($clientId === null) {
throw OAuthServerExc... | php | protected function validateClient(ServerRequestInterface $request)
{
list($basicAuthUser, $basicAuthPassword) = $this->getBasicAuthCredentials($request);
$clientId = $this->getRequestParameter('client_id', $request, $basicAuthUser);
if ($clientId === null) {
throw OAuthServerExc... | [
"protected",
"function",
"validateClient",
"(",
"ServerRequestInterface",
"$",
"request",
")",
"{",
"list",
"(",
"$",
"basicAuthUser",
",",
"$",
"basicAuthPassword",
")",
"=",
"$",
"this",
"->",
"getBasicAuthCredentials",
"(",
"$",
"request",
")",
";",
"$",
"c... | Validate the client.
@param ServerRequestInterface $request
@throws OAuthServerException
@return ClientEntityInterface | [
"Validate",
"the",
"client",
"."
] | 2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf | https://github.com/thephpleague/oauth2-server/blob/2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf/src/Grant/AbstractGrant.php#L178-L209 | train |
thephpleague/oauth2-server | src/Grant/AbstractGrant.php | AbstractGrant.validateRedirectUri | protected function validateRedirectUri(
string $redirectUri,
ClientEntityInterface $client,
ServerRequestInterface $request
) {
if (\is_string($client->getRedirectUri())
&& (strcmp($client->getRedirectUri(), $redirectUri) !== 0)
) {
$this->getEmitter()... | php | protected function validateRedirectUri(
string $redirectUri,
ClientEntityInterface $client,
ServerRequestInterface $request
) {
if (\is_string($client->getRedirectUri())
&& (strcmp($client->getRedirectUri(), $redirectUri) !== 0)
) {
$this->getEmitter()... | [
"protected",
"function",
"validateRedirectUri",
"(",
"string",
"$",
"redirectUri",
",",
"ClientEntityInterface",
"$",
"client",
",",
"ServerRequestInterface",
"$",
"request",
")",
"{",
"if",
"(",
"\\",
"is_string",
"(",
"$",
"client",
"->",
"getRedirectUri",
"(",
... | Validate redirectUri from the request.
If a redirect URI is provided ensure it matches what is pre-registered
@param string $redirectUri
@param ClientEntityInterface $client
@param ServerRequestInterface $request
@throws OAuthServerException | [
"Validate",
"redirectUri",
"from",
"the",
"request",
".",
"If",
"a",
"redirect",
"URI",
"is",
"provided",
"ensure",
"it",
"matches",
"what",
"is",
"pre",
"-",
"registered"
] | 2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf | https://github.com/thephpleague/oauth2-server/blob/2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf/src/Grant/AbstractGrant.php#L221-L237 | train |
thephpleague/oauth2-server | src/Grant/AbstractGrant.php | AbstractGrant.validateScopes | public function validateScopes($scopes, $redirectUri = null)
{
if (!\is_array($scopes)) {
$scopes = $this->convertScopesQueryStringToArray($scopes);
}
$validScopes = [];
foreach ($scopes as $scopeItem) {
$scope = $this->scopeRepository->getScopeEntityByIdent... | php | public function validateScopes($scopes, $redirectUri = null)
{
if (!\is_array($scopes)) {
$scopes = $this->convertScopesQueryStringToArray($scopes);
}
$validScopes = [];
foreach ($scopes as $scopeItem) {
$scope = $this->scopeRepository->getScopeEntityByIdent... | [
"public",
"function",
"validateScopes",
"(",
"$",
"scopes",
",",
"$",
"redirectUri",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"\\",
"is_array",
"(",
"$",
"scopes",
")",
")",
"{",
"$",
"scopes",
"=",
"$",
"this",
"->",
"convertScopesQueryStringToArray",
"("... | Validate scopes in the request.
@param string|array $scopes
@param string $redirectUri
@throws OAuthServerException
@return ScopeEntityInterface[] | [
"Validate",
"scopes",
"in",
"the",
"request",
"."
] | 2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf | https://github.com/thephpleague/oauth2-server/blob/2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf/src/Grant/AbstractGrant.php#L249-L268 | train |
thephpleague/oauth2-server | src/Grant/AbstractGrant.php | AbstractGrant.convertScopesQueryStringToArray | private function convertScopesQueryStringToArray($scopes)
{
return array_filter(explode(self::SCOPE_DELIMITER_STRING, trim($scopes)), function ($scope) {
return !empty($scope);
});
} | php | private function convertScopesQueryStringToArray($scopes)
{
return array_filter(explode(self::SCOPE_DELIMITER_STRING, trim($scopes)), function ($scope) {
return !empty($scope);
});
} | [
"private",
"function",
"convertScopesQueryStringToArray",
"(",
"$",
"scopes",
")",
"{",
"return",
"array_filter",
"(",
"explode",
"(",
"self",
"::",
"SCOPE_DELIMITER_STRING",
",",
"trim",
"(",
"$",
"scopes",
")",
")",
",",
"function",
"(",
"$",
"scope",
")",
... | Converts a scopes query string to an array to easily iterate for validation.
@param string $scopes
@return array | [
"Converts",
"a",
"scopes",
"query",
"string",
"to",
"an",
"array",
"to",
"easily",
"iterate",
"for",
"validation",
"."
] | 2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf | https://github.com/thephpleague/oauth2-server/blob/2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf/src/Grant/AbstractGrant.php#L277-L282 | train |
thephpleague/oauth2-server | src/Grant/AbstractGrant.php | AbstractGrant.getRequestParameter | protected function getRequestParameter($parameter, ServerRequestInterface $request, $default = null)
{
$requestParameters = (array) $request->getParsedBody();
return $requestParameters[$parameter] ?? $default;
} | php | protected function getRequestParameter($parameter, ServerRequestInterface $request, $default = null)
{
$requestParameters = (array) $request->getParsedBody();
return $requestParameters[$parameter] ?? $default;
} | [
"protected",
"function",
"getRequestParameter",
"(",
"$",
"parameter",
",",
"ServerRequestInterface",
"$",
"request",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"requestParameters",
"=",
"(",
"array",
")",
"$",
"request",
"->",
"getParsedBody",
"(",
")",... | Retrieve request parameter.
@param string $parameter
@param ServerRequestInterface $request
@param mixed $default
@return null|string | [
"Retrieve",
"request",
"parameter",
"."
] | 2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf | https://github.com/thephpleague/oauth2-server/blob/2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf/src/Grant/AbstractGrant.php#L293-L298 | train |
thephpleague/oauth2-server | src/Grant/AbstractGrant.php | AbstractGrant.getQueryStringParameter | protected function getQueryStringParameter($parameter, ServerRequestInterface $request, $default = null)
{
return isset($request->getQueryParams()[$parameter]) ? $request->getQueryParams()[$parameter] : $default;
} | php | protected function getQueryStringParameter($parameter, ServerRequestInterface $request, $default = null)
{
return isset($request->getQueryParams()[$parameter]) ? $request->getQueryParams()[$parameter] : $default;
} | [
"protected",
"function",
"getQueryStringParameter",
"(",
"$",
"parameter",
",",
"ServerRequestInterface",
"$",
"request",
",",
"$",
"default",
"=",
"null",
")",
"{",
"return",
"isset",
"(",
"$",
"request",
"->",
"getQueryParams",
"(",
")",
"[",
"$",
"parameter... | Retrieve query string parameter.
@param string $parameter
@param ServerRequestInterface $request
@param mixed $default
@return null|string | [
"Retrieve",
"query",
"string",
"parameter",
"."
] | 2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf | https://github.com/thephpleague/oauth2-server/blob/2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf/src/Grant/AbstractGrant.php#L342-L345 | train |
thephpleague/oauth2-server | src/Grant/AbstractGrant.php | AbstractGrant.getCookieParameter | protected function getCookieParameter($parameter, ServerRequestInterface $request, $default = null)
{
return isset($request->getCookieParams()[$parameter]) ? $request->getCookieParams()[$parameter] : $default;
} | php | protected function getCookieParameter($parameter, ServerRequestInterface $request, $default = null)
{
return isset($request->getCookieParams()[$parameter]) ? $request->getCookieParams()[$parameter] : $default;
} | [
"protected",
"function",
"getCookieParameter",
"(",
"$",
"parameter",
",",
"ServerRequestInterface",
"$",
"request",
",",
"$",
"default",
"=",
"null",
")",
"{",
"return",
"isset",
"(",
"$",
"request",
"->",
"getCookieParams",
"(",
")",
"[",
"$",
"parameter",
... | Retrieve cookie parameter.
@param string $parameter
@param ServerRequestInterface $request
@param mixed $default
@return null|string | [
"Retrieve",
"cookie",
"parameter",
"."
] | 2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf | https://github.com/thephpleague/oauth2-server/blob/2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf/src/Grant/AbstractGrant.php#L356-L359 | train |
thephpleague/oauth2-server | src/Grant/AbstractGrant.php | AbstractGrant.getServerParameter | protected function getServerParameter($parameter, ServerRequestInterface $request, $default = null)
{
return isset($request->getServerParams()[$parameter]) ? $request->getServerParams()[$parameter] : $default;
} | php | protected function getServerParameter($parameter, ServerRequestInterface $request, $default = null)
{
return isset($request->getServerParams()[$parameter]) ? $request->getServerParams()[$parameter] : $default;
} | [
"protected",
"function",
"getServerParameter",
"(",
"$",
"parameter",
",",
"ServerRequestInterface",
"$",
"request",
",",
"$",
"default",
"=",
"null",
")",
"{",
"return",
"isset",
"(",
"$",
"request",
"->",
"getServerParams",
"(",
")",
"[",
"$",
"parameter",
... | Retrieve server parameter.
@param string $parameter
@param ServerRequestInterface $request
@param mixed $default
@return null|string | [
"Retrieve",
"server",
"parameter",
"."
] | 2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf | https://github.com/thephpleague/oauth2-server/blob/2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf/src/Grant/AbstractGrant.php#L370-L373 | train |
thephpleague/oauth2-server | src/Grant/AbstractGrant.php | AbstractGrant.generateUniqueIdentifier | protected function generateUniqueIdentifier($length = 40)
{
try {
return bin2hex(random_bytes($length));
// @codeCoverageIgnoreStart
} catch (TypeError $e) {
throw OAuthServerException::serverError('An unexpected error has occurred', $e);
} catch (Error $e... | php | protected function generateUniqueIdentifier($length = 40)
{
try {
return bin2hex(random_bytes($length));
// @codeCoverageIgnoreStart
} catch (TypeError $e) {
throw OAuthServerException::serverError('An unexpected error has occurred', $e);
} catch (Error $e... | [
"protected",
"function",
"generateUniqueIdentifier",
"(",
"$",
"length",
"=",
"40",
")",
"{",
"try",
"{",
"return",
"bin2hex",
"(",
"random_bytes",
"(",
"$",
"length",
")",
")",
";",
"// @codeCoverageIgnoreStart",
"}",
"catch",
"(",
"TypeError",
"$",
"e",
")... | Generate a new unique identifier.
@param int $length
@throws OAuthServerException
@return string | [
"Generate",
"a",
"new",
"unique",
"identifier",
"."
] | 2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf | https://github.com/thephpleague/oauth2-server/blob/2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf/src/Grant/AbstractGrant.php#L513-L527 | train |
thephpleague/oauth2-server | src/AuthorizationServer.php | AuthorizationServer.enableGrantType | public function enableGrantType(GrantTypeInterface $grantType, DateInterval $accessTokenTTL = null)
{
if ($accessTokenTTL instanceof DateInterval === false) {
$accessTokenTTL = new DateInterval('PT1H');
}
$grantType->setAccessTokenRepository($this->accessTokenRepository);
... | php | public function enableGrantType(GrantTypeInterface $grantType, DateInterval $accessTokenTTL = null)
{
if ($accessTokenTTL instanceof DateInterval === false) {
$accessTokenTTL = new DateInterval('PT1H');
}
$grantType->setAccessTokenRepository($this->accessTokenRepository);
... | [
"public",
"function",
"enableGrantType",
"(",
"GrantTypeInterface",
"$",
"grantType",
",",
"DateInterval",
"$",
"accessTokenTTL",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"accessTokenTTL",
"instanceof",
"DateInterval",
"===",
"false",
")",
"{",
"$",
"accessTokenTTL"... | Enable a grant type on the server.
@param GrantTypeInterface $grantType
@param null|DateInterval $accessTokenTTL | [
"Enable",
"a",
"grant",
"type",
"on",
"the",
"server",
"."
] | 2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf | https://github.com/thephpleague/oauth2-server/blob/2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf/src/AuthorizationServer.php#L126-L142 | train |
thephpleague/oauth2-server | src/AuthorizationServer.php | AuthorizationServer.validateAuthorizationRequest | public function validateAuthorizationRequest(ServerRequestInterface $request)
{
foreach ($this->enabledGrantTypes as $grantType) {
if ($grantType->canRespondToAuthorizationRequest($request)) {
return $grantType->validateAuthorizationRequest($request);
}
}
... | php | public function validateAuthorizationRequest(ServerRequestInterface $request)
{
foreach ($this->enabledGrantTypes as $grantType) {
if ($grantType->canRespondToAuthorizationRequest($request)) {
return $grantType->validateAuthorizationRequest($request);
}
}
... | [
"public",
"function",
"validateAuthorizationRequest",
"(",
"ServerRequestInterface",
"$",
"request",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"enabledGrantTypes",
"as",
"$",
"grantType",
")",
"{",
"if",
"(",
"$",
"grantType",
"->",
"canRespondToAuthorizationRequ... | Validate an authorization request
@param ServerRequestInterface $request
@throws OAuthServerException
@return AuthorizationRequest | [
"Validate",
"an",
"authorization",
"request"
] | 2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf | https://github.com/thephpleague/oauth2-server/blob/2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf/src/AuthorizationServer.php#L153-L162 | train |
thephpleague/oauth2-server | src/AuthorizationServer.php | AuthorizationServer.completeAuthorizationRequest | public function completeAuthorizationRequest(AuthorizationRequest $authRequest, ResponseInterface $response)
{
return $this->enabledGrantTypes[$authRequest->getGrantTypeId()]
->completeAuthorizationRequest($authRequest)
->generateHttpResponse($response);
} | php | public function completeAuthorizationRequest(AuthorizationRequest $authRequest, ResponseInterface $response)
{
return $this->enabledGrantTypes[$authRequest->getGrantTypeId()]
->completeAuthorizationRequest($authRequest)
->generateHttpResponse($response);
} | [
"public",
"function",
"completeAuthorizationRequest",
"(",
"AuthorizationRequest",
"$",
"authRequest",
",",
"ResponseInterface",
"$",
"response",
")",
"{",
"return",
"$",
"this",
"->",
"enabledGrantTypes",
"[",
"$",
"authRequest",
"->",
"getGrantTypeId",
"(",
")",
"... | Complete an authorization request
@param AuthorizationRequest $authRequest
@param ResponseInterface $response
@return ResponseInterface | [
"Complete",
"an",
"authorization",
"request"
] | 2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf | https://github.com/thephpleague/oauth2-server/blob/2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf/src/AuthorizationServer.php#L172-L177 | train |
thephpleague/oauth2-server | src/AuthorizationServer.php | AuthorizationServer.respondToAccessTokenRequest | public function respondToAccessTokenRequest(ServerRequestInterface $request, ResponseInterface $response)
{
foreach ($this->enabledGrantTypes as $grantType) {
if (!$grantType->canRespondToAccessTokenRequest($request)) {
continue;
}
$tokenResponse = $grantT... | php | public function respondToAccessTokenRequest(ServerRequestInterface $request, ResponseInterface $response)
{
foreach ($this->enabledGrantTypes as $grantType) {
if (!$grantType->canRespondToAccessTokenRequest($request)) {
continue;
}
$tokenResponse = $grantT... | [
"public",
"function",
"respondToAccessTokenRequest",
"(",
"ServerRequestInterface",
"$",
"request",
",",
"ResponseInterface",
"$",
"response",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"enabledGrantTypes",
"as",
"$",
"grantType",
")",
"{",
"if",
"(",
"!",
"$"... | Return an access token response.
@param ServerRequestInterface $request
@param ResponseInterface $response
@throws OAuthServerException
@return ResponseInterface | [
"Return",
"an",
"access",
"token",
"response",
"."
] | 2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf | https://github.com/thephpleague/oauth2-server/blob/2eb1cf79e59d807d89c256e7ac5e2bf8bdbd4acf/src/AuthorizationServer.php#L189-L207 | train |
laravel/socialite | src/Two/LinkedInProvider.php | LinkedInProvider.getBasicProfile | protected function getBasicProfile($token)
{
$url = 'https://api.linkedin.com/v2/me?projection=(id,firstName,lastName,profilePicture(displayImage~:playableStreams))';
$response = $this->getHttpClient()->get($url, [
'headers' => [
'Authorization' => 'Bearer '.$token,
... | php | protected function getBasicProfile($token)
{
$url = 'https://api.linkedin.com/v2/me?projection=(id,firstName,lastName,profilePicture(displayImage~:playableStreams))';
$response = $this->getHttpClient()->get($url, [
'headers' => [
'Authorization' => 'Bearer '.$token,
... | [
"protected",
"function",
"getBasicProfile",
"(",
"$",
"token",
")",
"{",
"$",
"url",
"=",
"'https://api.linkedin.com/v2/me?projection=(id,firstName,lastName,profilePicture(displayImage~:playableStreams))'",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"getHttpClient",
"(",
... | Get the basic profile fields for the user.
@param string $token
@return array | [
"Get",
"the",
"basic",
"profile",
"fields",
"for",
"the",
"user",
"."
] | 690c46cb572fb2f8a1a5520ff4b2446406ce5afd | https://github.com/laravel/socialite/blob/690c46cb572fb2f8a1a5520ff4b2446406ce5afd/src/Two/LinkedInProvider.php#L67-L79 | train |
laravel/socialite | src/Two/LinkedInProvider.php | LinkedInProvider.getEmailAddress | protected function getEmailAddress($token)
{
$url = 'https://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(handle~))';
$response = $this->getHttpClient()->get($url, [
'headers' => [
'Authorization' => 'Bearer '.$token,
'X-RestLi-Protoco... | php | protected function getEmailAddress($token)
{
$url = 'https://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(handle~))';
$response = $this->getHttpClient()->get($url, [
'headers' => [
'Authorization' => 'Bearer '.$token,
'X-RestLi-Protoco... | [
"protected",
"function",
"getEmailAddress",
"(",
"$",
"token",
")",
"{",
"$",
"url",
"=",
"'https://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(handle~))'",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"getHttpClient",
"(",
")",
"->",
"get",
"(",... | Get the email address for the user.
@param string $token
@return array | [
"Get",
"the",
"email",
"address",
"for",
"the",
"user",
"."
] | 690c46cb572fb2f8a1a5520ff4b2446406ce5afd | https://github.com/laravel/socialite/blob/690c46cb572fb2f8a1a5520ff4b2446406ce5afd/src/Two/LinkedInProvider.php#L87-L99 | train |
laravel/socialite | src/AbstractUser.php | AbstractUser.map | public function map(array $attributes)
{
foreach ($attributes as $key => $value) {
$this->{$key} = $value;
}
return $this;
} | php | public function map(array $attributes)
{
foreach ($attributes as $key => $value) {
$this->{$key} = $value;
}
return $this;
} | [
"public",
"function",
"map",
"(",
"array",
"$",
"attributes",
")",
"{",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"{",
"$",
"key",
"}",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"this"... | Map the given array onto the user's properties.
@param array $attributes
@return $this | [
"Map",
"the",
"given",
"array",
"onto",
"the",
"user",
"s",
"properties",
"."
] | 690c46cb572fb2f8a1a5520ff4b2446406ce5afd | https://github.com/laravel/socialite/blob/690c46cb572fb2f8a1a5520ff4b2446406ce5afd/src/AbstractUser.php#L130-L137 | train |
laravel/socialite | src/One/AbstractProvider.php | AbstractProvider.userFromTokenAndSecret | public function userFromTokenAndSecret($token, $secret)
{
$tokenCredentials = new TokenCredentials();
$tokenCredentials->setIdentifier($token);
$tokenCredentials->setSecret($secret);
$user = $this->server->getUserDetails(
$tokenCredentials, $this->shouldBypassCache($tok... | php | public function userFromTokenAndSecret($token, $secret)
{
$tokenCredentials = new TokenCredentials();
$tokenCredentials->setIdentifier($token);
$tokenCredentials->setSecret($secret);
$user = $this->server->getUserDetails(
$tokenCredentials, $this->shouldBypassCache($tok... | [
"public",
"function",
"userFromTokenAndSecret",
"(",
"$",
"token",
",",
"$",
"secret",
")",
"{",
"$",
"tokenCredentials",
"=",
"new",
"TokenCredentials",
"(",
")",
";",
"$",
"tokenCredentials",
"->",
"setIdentifier",
"(",
"$",
"token",
")",
";",
"$",
"tokenC... | Get a Social User instance from a known access token and secret.
@param string $token
@param string $secret
@return \Laravel\Socialite\One\User | [
"Get",
"a",
"Social",
"User",
"instance",
"from",
"a",
"known",
"access",
"token",
"and",
"secret",
"."
] | 690c46cb572fb2f8a1a5520ff4b2446406ce5afd | https://github.com/laravel/socialite/blob/690c46cb572fb2f8a1a5520ff4b2446406ce5afd/src/One/AbstractProvider.php#L99-L120 | train |
laravel/socialite | src/One/AbstractProvider.php | AbstractProvider.shouldBypassCache | protected function shouldBypassCache($token, $secret)
{
$newHash = sha1($token.'_'.$secret);
if (! empty($this->userHash) && $newHash !== $this->userHash) {
$this->userHash = $newHash;
return true;
}
$this->userHash = $this->userHash ?: $newHash;
r... | php | protected function shouldBypassCache($token, $secret)
{
$newHash = sha1($token.'_'.$secret);
if (! empty($this->userHash) && $newHash !== $this->userHash) {
$this->userHash = $newHash;
return true;
}
$this->userHash = $this->userHash ?: $newHash;
r... | [
"protected",
"function",
"shouldBypassCache",
"(",
"$",
"token",
",",
"$",
"secret",
")",
"{",
"$",
"newHash",
"=",
"sha1",
"(",
"$",
"token",
".",
"'_'",
".",
"$",
"secret",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"userHash",
")... | Determine if the user information cache should be bypassed.
@param string $token
@param string $secret
@return bool | [
"Determine",
"if",
"the",
"user",
"information",
"cache",
"should",
"be",
"bypassed",
"."
] | 690c46cb572fb2f8a1a5520ff4b2446406ce5afd | https://github.com/laravel/socialite/blob/690c46cb572fb2f8a1a5520ff4b2446406ce5afd/src/One/AbstractProvider.php#L153-L166 | train |
laravel/socialite | src/One/User.php | User.setToken | public function setToken($token, $tokenSecret)
{
$this->token = $token;
$this->tokenSecret = $tokenSecret;
return $this;
} | php | public function setToken($token, $tokenSecret)
{
$this->token = $token;
$this->tokenSecret = $tokenSecret;
return $this;
} | [
"public",
"function",
"setToken",
"(",
"$",
"token",
",",
"$",
"tokenSecret",
")",
"{",
"$",
"this",
"->",
"token",
"=",
"$",
"token",
";",
"$",
"this",
"->",
"tokenSecret",
"=",
"$",
"tokenSecret",
";",
"return",
"$",
"this",
";",
"}"
] | Set the token on the user.
@param string $token
@param string $tokenSecret
@return $this | [
"Set",
"the",
"token",
"on",
"the",
"user",
"."
] | 690c46cb572fb2f8a1a5520ff4b2446406ce5afd | https://github.com/laravel/socialite/blob/690c46cb572fb2f8a1a5520ff4b2446406ce5afd/src/One/User.php#L30-L36 | train |
laravel/socialite | src/SocialiteManager.php | SocialiteManager.createTwitterDriver | protected function createTwitterDriver()
{
$config = $this->app['config']['services.twitter'];
return new TwitterProvider(
$this->app['request'], new TwitterServer($this->formatConfig($config))
);
} | php | protected function createTwitterDriver()
{
$config = $this->app['config']['services.twitter'];
return new TwitterProvider(
$this->app['request'], new TwitterServer($this->formatConfig($config))
);
} | [
"protected",
"function",
"createTwitterDriver",
"(",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"app",
"[",
"'config'",
"]",
"[",
"'services.twitter'",
"]",
";",
"return",
"new",
"TwitterProvider",
"(",
"$",
"this",
"->",
"app",
"[",
"'request'",
"]"... | Create an instance of the specified driver.
@return \Laravel\Socialite\One\AbstractProvider | [
"Create",
"an",
"instance",
"of",
"the",
"specified",
"driver",
"."
] | 690c46cb572fb2f8a1a5520ff4b2446406ce5afd | https://github.com/laravel/socialite/blob/690c46cb572fb2f8a1a5520ff4b2446406ce5afd/src/SocialiteManager.php#L136-L143 | train |
laravel/socialite | src/SocialiteManager.php | SocialiteManager.formatRedirectUrl | protected function formatRedirectUrl(array $config)
{
$redirect = value($config['redirect']);
return Str::startsWith($redirect, '/')
? $this->app['url']->to($redirect)
: $redirect;
} | php | protected function formatRedirectUrl(array $config)
{
$redirect = value($config['redirect']);
return Str::startsWith($redirect, '/')
? $this->app['url']->to($redirect)
: $redirect;
} | [
"protected",
"function",
"formatRedirectUrl",
"(",
"array",
"$",
"config",
")",
"{",
"$",
"redirect",
"=",
"value",
"(",
"$",
"config",
"[",
"'redirect'",
"]",
")",
";",
"return",
"Str",
"::",
"startsWith",
"(",
"$",
"redirect",
",",
"'/'",
")",
"?",
"... | Format the callback URL, resolving a relative URI if needed.
@param array $config
@return string | [
"Format",
"the",
"callback",
"URL",
"resolving",
"a",
"relative",
"URI",
"if",
"needed",
"."
] | 690c46cb572fb2f8a1a5520ff4b2446406ce5afd | https://github.com/laravel/socialite/blob/690c46cb572fb2f8a1a5520ff4b2446406ce5afd/src/SocialiteManager.php#L166-L173 | train |
laravel/socialite | src/Two/AbstractProvider.php | AbstractProvider.scopes | public function scopes($scopes)
{
$this->scopes = array_unique(array_merge($this->scopes, (array) $scopes));
return $this;
} | php | public function scopes($scopes)
{
$this->scopes = array_unique(array_merge($this->scopes, (array) $scopes));
return $this;
} | [
"public",
"function",
"scopes",
"(",
"$",
"scopes",
")",
"{",
"$",
"this",
"->",
"scopes",
"=",
"array_unique",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"scopes",
",",
"(",
"array",
")",
"$",
"scopes",
")",
")",
";",
"return",
"$",
"this",
";",
... | Merge the scopes of the requested access.
@param array|string $scopes
@return $this | [
"Merge",
"the",
"scopes",
"of",
"the",
"requested",
"access",
"."
] | 690c46cb572fb2f8a1a5520ff4b2446406ce5afd | https://github.com/laravel/socialite/blob/690c46cb572fb2f8a1a5520ff4b2446406ce5afd/src/Two/AbstractProvider.php#L303-L308 | train |
wp-cli/wp-cli | php/WP_CLI/Bootstrap/BootstrapState.php | BootstrapState.getValue | public function getValue( $key, $fallback = null ) {
return array_key_exists( $key, $this->state )
? $this->state[ $key ]
: $fallback;
} | php | public function getValue( $key, $fallback = null ) {
return array_key_exists( $key, $this->state )
? $this->state[ $key ]
: $fallback;
} | [
"public",
"function",
"getValue",
"(",
"$",
"key",
",",
"$",
"fallback",
"=",
"null",
")",
"{",
"return",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"state",
")",
"?",
"$",
"this",
"->",
"state",
"[",
"$",
"key",
"]",
":",
"$",
... | Get the state value for a given key.
@param string $key Key to get the state from.
@param mixed $fallback Fallback value to use if the key is not defined.
@return mixed | [
"Get",
"the",
"state",
"value",
"for",
"a",
"given",
"key",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Bootstrap/BootstrapState.php#L41-L45 | train |
wp-cli/wp-cli | php/WP_CLI/FileCache.php | FileCache.has | public function has( $key, $ttl = null ) {
if ( ! $this->enabled ) {
return false;
}
$filename = $this->filename( $key );
if ( ! file_exists( $filename ) ) {
return false;
}
// use ttl param or global ttl
if ( null === $ttl ) {
$ttl = $this->ttl;
} elseif ( $this->ttl > 0 ) {
$ttl = min( ... | php | public function has( $key, $ttl = null ) {
if ( ! $this->enabled ) {
return false;
}
$filename = $this->filename( $key );
if ( ! file_exists( $filename ) ) {
return false;
}
// use ttl param or global ttl
if ( null === $ttl ) {
$ttl = $this->ttl;
} elseif ( $this->ttl > 0 ) {
$ttl = min( ... | [
"public",
"function",
"has",
"(",
"$",
"key",
",",
"$",
"ttl",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"enabled",
")",
"{",
"return",
"false",
";",
"}",
"$",
"filename",
"=",
"$",
"this",
"->",
"filename",
"(",
"$",
"key",
")"... | Check if a file is in cache and return its filename
@param string $key cache key
@param int $ttl time to live
@return bool|string filename or false | [
"Check",
"if",
"a",
"file",
"is",
"in",
"cache",
"and",
"return",
"its",
"filename"
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/FileCache.php#L89-L118 | train |
wp-cli/wp-cli | php/WP_CLI/FileCache.php | FileCache.read | public function read( $key, $ttl = null ) {
$filename = $this->has( $key, $ttl );
if ( $filename ) {
return file_get_contents( $filename );
}
return false;
} | php | public function read( $key, $ttl = null ) {
$filename = $this->has( $key, $ttl );
if ( $filename ) {
return file_get_contents( $filename );
}
return false;
} | [
"public",
"function",
"read",
"(",
"$",
"key",
",",
"$",
"ttl",
"=",
"null",
")",
"{",
"$",
"filename",
"=",
"$",
"this",
"->",
"has",
"(",
"$",
"key",
",",
"$",
"ttl",
")",
";",
"if",
"(",
"$",
"filename",
")",
"{",
"return",
"file_get_contents"... | Read from cache file
@param string $key cache key
@param int $ttl time to live
@return bool|string file contents or false | [
"Read",
"from",
"cache",
"file"
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/FileCache.php#L144-L152 | train |
wp-cli/wp-cli | php/WP_CLI/FileCache.php | FileCache.remove | public function remove( $key ) {
if ( ! $this->enabled ) {
return false;
}
$filename = $this->filename( $key );
if ( file_exists( $filename ) ) {
return unlink( $filename );
}
return false;
} | php | public function remove( $key ) {
if ( ! $this->enabled ) {
return false;
}
$filename = $this->filename( $key );
if ( file_exists( $filename ) ) {
return unlink( $filename );
}
return false;
} | [
"public",
"function",
"remove",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"enabled",
")",
"{",
"return",
"false",
";",
"}",
"$",
"filename",
"=",
"$",
"this",
"->",
"filename",
"(",
"$",
"key",
")",
";",
"if",
"(",
"file_exist... | Remove file from cache
@param string $key cache key
@return bool | [
"Remove",
"file",
"from",
"cache"
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/FileCache.php#L195-L207 | train |
wp-cli/wp-cli | php/WP_CLI/FileCache.php | FileCache.clean | public function clean() {
if ( ! $this->enabled ) {
return false;
}
$ttl = $this->ttl;
$max_size = $this->max_size;
// unlink expired files
if ( $ttl > 0 ) {
try {
$expire = new \DateTime();
} catch ( \Exception $e ) {
\WP_CLI::error( $e->getMessage() );
}
$expire->modify( '-' ... | php | public function clean() {
if ( ! $this->enabled ) {
return false;
}
$ttl = $this->ttl;
$max_size = $this->max_size;
// unlink expired files
if ( $ttl > 0 ) {
try {
$expire = new \DateTime();
} catch ( \Exception $e ) {
\WP_CLI::error( $e->getMessage() );
}
$expire->modify( '-' ... | [
"public",
"function",
"clean",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"enabled",
")",
"{",
"return",
"false",
";",
"}",
"$",
"ttl",
"=",
"$",
"this",
"->",
"ttl",
";",
"$",
"max_size",
"=",
"$",
"this",
"->",
"max_size",
";",
"// unlin... | Clean cache based on time to live and max size
@return bool | [
"Clean",
"cache",
"based",
"on",
"time",
"to",
"live",
"and",
"max",
"size"
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/FileCache.php#L214-L252 | train |
wp-cli/wp-cli | php/WP_CLI/FileCache.php | FileCache.clear | public function clear() {
if ( ! $this->enabled ) {
return false;
}
$finder = $this->get_finder();
foreach ( $finder as $file ) {
unlink( $file->getRealPath() );
}
return true;
} | php | public function clear() {
if ( ! $this->enabled ) {
return false;
}
$finder = $this->get_finder();
foreach ( $finder as $file ) {
unlink( $file->getRealPath() );
}
return true;
} | [
"public",
"function",
"clear",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"enabled",
")",
"{",
"return",
"false",
";",
"}",
"$",
"finder",
"=",
"$",
"this",
"->",
"get_finder",
"(",
")",
";",
"foreach",
"(",
"$",
"finder",
"as",
"$",
"file... | Remove all cached files.
@return bool | [
"Remove",
"all",
"cached",
"files",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/FileCache.php#L259-L271 | train |
wp-cli/wp-cli | php/WP_CLI/FileCache.php | FileCache.prune | public function prune() {
if ( ! $this->enabled ) {
return false;
}
/** @var Finder $finder */
$finder = $this->get_finder()->sortByName();
$files_to_delete = array();
foreach ( $finder as $file ) {
$pieces = explode( '-', $file->getBasename( $file->getExtension() ) );
$timestamp = end( $piec... | php | public function prune() {
if ( ! $this->enabled ) {
return false;
}
/** @var Finder $finder */
$finder = $this->get_finder()->sortByName();
$files_to_delete = array();
foreach ( $finder as $file ) {
$pieces = explode( '-', $file->getBasename( $file->getExtension() ) );
$timestamp = end( $piec... | [
"public",
"function",
"prune",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"enabled",
")",
"{",
"return",
"false",
";",
"}",
"/** @var Finder $finder */",
"$",
"finder",
"=",
"$",
"this",
"->",
"get_finder",
"(",
")",
"->",
"sortByName",
"(",
")"... | Remove all cached files except for the newest version of one.
@return bool | [
"Remove",
"all",
"cached",
"files",
"except",
"for",
"the",
"newest",
"version",
"of",
"one",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/FileCache.php#L278-L308 | train |
wp-cli/wp-cli | php/WP_CLI/FileCache.php | FileCache.ensure_dir_exists | protected function ensure_dir_exists( $dir ) {
if ( ! is_dir( $dir ) ) {
// Disable the cache if a null device like /dev/null is being used.
if ( preg_match( '{(^|[\\\\/])(\$null|nul|NUL|/dev/null)([\\\\/]|$)}', $dir ) ) {
return false;
}
if ( ! @mkdir( $dir, 0777, true ) ) {
$error = error_get_l... | php | protected function ensure_dir_exists( $dir ) {
if ( ! is_dir( $dir ) ) {
// Disable the cache if a null device like /dev/null is being used.
if ( preg_match( '{(^|[\\\\/])(\$null|nul|NUL|/dev/null)([\\\\/]|$)}', $dir ) ) {
return false;
}
if ( ! @mkdir( $dir, 0777, true ) ) {
$error = error_get_l... | [
"protected",
"function",
"ensure_dir_exists",
"(",
"$",
"dir",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dir",
")",
")",
"{",
"// Disable the cache if a null device like /dev/null is being used.",
"if",
"(",
"preg_match",
"(",
"'{(^|[\\\\\\\\/])(\\$null|nul|NUL|/de... | Ensure directory exists
@param string $dir directory
@return bool | [
"Ensure",
"directory",
"exists"
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/FileCache.php#L316-L331 | train |
wp-cli/wp-cli | php/WP_CLI/FileCache.php | FileCache.prepare_write | protected function prepare_write( $key ) {
if ( ! $this->enabled ) {
return false;
}
$filename = $this->filename( $key );
if ( ! $this->ensure_dir_exists( dirname( $filename ) ) ) {
return false;
}
return $filename;
} | php | protected function prepare_write( $key ) {
if ( ! $this->enabled ) {
return false;
}
$filename = $this->filename( $key );
if ( ! $this->ensure_dir_exists( dirname( $filename ) ) ) {
return false;
}
return $filename;
} | [
"protected",
"function",
"prepare_write",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"enabled",
")",
"{",
"return",
"false",
";",
"}",
"$",
"filename",
"=",
"$",
"this",
"->",
"filename",
"(",
"$",
"key",
")",
";",
"if",
"(",
"... | Prepare cache write
@param string $key cache key
@return bool|string filename or false | [
"Prepare",
"cache",
"write"
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/FileCache.php#L339-L351 | train |
wp-cli/wp-cli | php/WP_CLI/FileCache.php | FileCache.validate_key | protected function validate_key( $key ) {
$url_parts = Utils\parse_url( $key, -1, false );
if ( ! empty( $url_parts['scheme'] ) ) { // is url
$parts = array( 'misc' );
$parts[] = $url_parts['scheme'] . '-' . $url_parts['host'] .
( empty( $url_parts['port'] ) ? '' : '-' . $url_parts['port'] );
$parts[... | php | protected function validate_key( $key ) {
$url_parts = Utils\parse_url( $key, -1, false );
if ( ! empty( $url_parts['scheme'] ) ) { // is url
$parts = array( 'misc' );
$parts[] = $url_parts['scheme'] . '-' . $url_parts['host'] .
( empty( $url_parts['port'] ) ? '' : '-' . $url_parts['port'] );
$parts[... | [
"protected",
"function",
"validate_key",
"(",
"$",
"key",
")",
"{",
"$",
"url_parts",
"=",
"Utils",
"\\",
"parse_url",
"(",
"$",
"key",
",",
"-",
"1",
",",
"false",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"url_parts",
"[",
"'scheme'",
"]",
")"... | Validate cache key
@param string $key cache key
@return string relative filename | [
"Validate",
"cache",
"key"
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/FileCache.php#L359-L375 | train |
wp-cli/wp-cli | php/WP_CLI/Loggers/Execution.php | Execution.write | protected function write( $handle, $str ) {
switch ( $handle ) {
case STDOUT:
$this->stdout .= $str;
break;
case STDERR:
$this->stderr .= $str;
break;
}
} | php | protected function write( $handle, $str ) {
switch ( $handle ) {
case STDOUT:
$this->stdout .= $str;
break;
case STDERR:
$this->stderr .= $str;
break;
}
} | [
"protected",
"function",
"write",
"(",
"$",
"handle",
",",
"$",
"str",
")",
"{",
"switch",
"(",
"$",
"handle",
")",
"{",
"case",
"STDOUT",
":",
"$",
"this",
"->",
"stdout",
".=",
"$",
"str",
";",
"break",
";",
"case",
"STDERR",
":",
"$",
"this",
... | Write a string to a resource.
@param resource $handle Commonly STDOUT or STDERR.
@param string $str Message to write. | [
"Write",
"a",
"string",
"to",
"a",
"resource",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Loggers/Execution.php#L45-L54 | train |
wp-cli/wp-cli | php/WP_CLI/Inflector.php | Inflector.ucwords | public static function ucwords( $string, $delimiters = " \n\t\r\0\x0B-" ) {
return preg_replace_callback(
'/[^' . preg_quote( $delimiters, '/' ) . ']+/',
function( $matches ) {
return ucfirst( $matches[0] );
},
$string
);
} | php | public static function ucwords( $string, $delimiters = " \n\t\r\0\x0B-" ) {
return preg_replace_callback(
'/[^' . preg_quote( $delimiters, '/' ) . ']+/',
function( $matches ) {
return ucfirst( $matches[0] );
},
$string
);
} | [
"public",
"static",
"function",
"ucwords",
"(",
"$",
"string",
",",
"$",
"delimiters",
"=",
"\" \\n\\t\\r\\0\\x0B-\"",
")",
"{",
"return",
"preg_replace_callback",
"(",
"'/[^'",
".",
"preg_quote",
"(",
"$",
"delimiters",
",",
"'/'",
")",
".",
"']+/'",
",",
"... | Uppercases words with configurable delimeters between words.
Takes a string and capitalizes all of the words, like PHP's built-in
ucwords function. This extends that behavior, however, by allowing the
word delimeters to be configured, rather than only separating on
whitespace.
Here is an example:
<code>
<?php
$strin... | [
"Uppercases",
"words",
"with",
"configurable",
"delimeters",
"between",
"words",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Inflector.php#L368-L376 | train |
wp-cli/wp-cli | php/WP_CLI/Inflector.php | Inflector.pluralize | public static function pluralize( $word ) {
if ( isset( self::$cache['pluralize'][ $word ] ) ) {
return self::$cache['pluralize'][ $word ];
}
if ( ! isset( self::$plural['merged']['irregular'] ) ) {
self::$plural['merged']['irregular'] = self::$plural['irregular'];
}
if ( ! isset( self::$plural['merge... | php | public static function pluralize( $word ) {
if ( isset( self::$cache['pluralize'][ $word ] ) ) {
return self::$cache['pluralize'][ $word ];
}
if ( ! isset( self::$plural['merged']['irregular'] ) ) {
self::$plural['merged']['irregular'] = self::$plural['irregular'];
}
if ( ! isset( self::$plural['merge... | [
"public",
"static",
"function",
"pluralize",
"(",
"$",
"word",
")",
"{",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"cache",
"[",
"'pluralize'",
"]",
"[",
"$",
"word",
"]",
")",
")",
"{",
"return",
"self",
"::",
"$",
"cache",
"[",
"'pluralize'",
"... | Returns a word in plural form.
@param string $word The word in singular form.
@return string The word in plural form. | [
"Returns",
"a",
"word",
"in",
"plural",
"form",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/Inflector.php#L457-L494 | train |
wp-cli/wp-cli | php/WP_CLI/SynopsisValidator.php | SynopsisValidator.enough_positionals | public function enough_positionals( $args ) {
$positional = $this->query_spec(
array(
'type' => 'positional',
'optional' => false,
)
);
return count( $args ) >= count( $positional );
} | php | public function enough_positionals( $args ) {
$positional = $this->query_spec(
array(
'type' => 'positional',
'optional' => false,
)
);
return count( $args ) >= count( $positional );
} | [
"public",
"function",
"enough_positionals",
"(",
"$",
"args",
")",
"{",
"$",
"positional",
"=",
"$",
"this",
"->",
"query_spec",
"(",
"array",
"(",
"'type'",
"=>",
"'positional'",
",",
"'optional'",
"=>",
"false",
",",
")",
")",
";",
"return",
"count",
"... | Check whether there are enough positional arguments.
@param array $args Positional arguments.
@return bool | [
"Check",
"whether",
"there",
"are",
"enough",
"positional",
"arguments",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/SynopsisValidator.php#L44-L53 | train |
wp-cli/wp-cli | php/WP_CLI/SynopsisValidator.php | SynopsisValidator.unknown_positionals | public function unknown_positionals( $args ) {
$positional_repeating = $this->query_spec(
array(
'type' => 'positional',
'repeating' => true,
)
);
// At least one positional supports as many as possible.
if ( ! empty( $positional_repeating ) ) {
return array();
}
$positional = $this-... | php | public function unknown_positionals( $args ) {
$positional_repeating = $this->query_spec(
array(
'type' => 'positional',
'repeating' => true,
)
);
// At least one positional supports as many as possible.
if ( ! empty( $positional_repeating ) ) {
return array();
}
$positional = $this-... | [
"public",
"function",
"unknown_positionals",
"(",
"$",
"args",
")",
"{",
"$",
"positional_repeating",
"=",
"$",
"this",
"->",
"query_spec",
"(",
"array",
"(",
"'type'",
"=>",
"'positional'",
",",
"'repeating'",
"=>",
"true",
",",
")",
")",
";",
"// At least ... | Check for any unknown positionals.
@param array $args Positional arguments.
@return array | [
"Check",
"for",
"any",
"unknown",
"positionals",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/SynopsisValidator.php#L61-L82 | train |
wp-cli/wp-cli | php/WP_CLI/SynopsisValidator.php | SynopsisValidator.validate_assoc | public function validate_assoc( $assoc_args ) {
$assoc_spec = $this->query_spec(
array(
'type' => 'assoc',
)
);
$errors = array(
'fatal' => array(),
'warning' => array(),
);
$to_unset = array();
foreach ( $assoc_spec as $param ) {
$key = $param['name'];
if ( ! isset( $assoc_args[... | php | public function validate_assoc( $assoc_args ) {
$assoc_spec = $this->query_spec(
array(
'type' => 'assoc',
)
);
$errors = array(
'fatal' => array(),
'warning' => array(),
);
$to_unset = array();
foreach ( $assoc_spec as $param ) {
$key = $param['name'];
if ( ! isset( $assoc_args[... | [
"public",
"function",
"validate_assoc",
"(",
"$",
"assoc_args",
")",
"{",
"$",
"assoc_spec",
"=",
"$",
"this",
"->",
"query_spec",
"(",
"array",
"(",
"'type'",
"=>",
"'assoc'",
",",
")",
")",
";",
"$",
"errors",
"=",
"array",
"(",
"'fatal'",
"=>",
"arr... | Check that all required keys are present and that they have values.
@param array $assoc_args Parameters passed to command.
@return array | [
"Check",
"that",
"all",
"required",
"keys",
"are",
"present",
"and",
"that",
"they",
"have",
"values",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/SynopsisValidator.php#L90-L122 | train |
wp-cli/wp-cli | php/WP_CLI/SynopsisValidator.php | SynopsisValidator.unknown_assoc | public function unknown_assoc( $assoc_args ) {
$generic = $this->query_spec(
array(
'type' => 'generic',
)
);
if ( count( $generic ) ) {
return array();
}
$known_assoc = array();
foreach ( $this->spec as $param ) {
if ( in_array( $param['type'], array( 'assoc', 'flag' ), true ) ) {
$k... | php | public function unknown_assoc( $assoc_args ) {
$generic = $this->query_spec(
array(
'type' => 'generic',
)
);
if ( count( $generic ) ) {
return array();
}
$known_assoc = array();
foreach ( $this->spec as $param ) {
if ( in_array( $param['type'], array( 'assoc', 'flag' ), true ) ) {
$k... | [
"public",
"function",
"unknown_assoc",
"(",
"$",
"assoc_args",
")",
"{",
"$",
"generic",
"=",
"$",
"this",
"->",
"query_spec",
"(",
"array",
"(",
"'type'",
"=>",
"'generic'",
",",
")",
")",
";",
"if",
"(",
"count",
"(",
"$",
"generic",
")",
")",
"{",... | Check whether there are unknown parameters supplied.
@param array $assoc_args Parameters passed to command.
@return array|false | [
"Check",
"whether",
"there",
"are",
"unknown",
"parameters",
"supplied",
"."
] | 564bf7b7cf1ac833071d1afed5d649d2a7198e15 | https://github.com/wp-cli/wp-cli/blob/564bf7b7cf1ac833071d1afed5d649d2a7198e15/php/WP_CLI/SynopsisValidator.php#L130-L150 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.