repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
listlengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
listlengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
aedart/laravel-helpers | src/Traits/Broadcasting/BroadcastFactoryTrait.php | BroadcastFactoryTrait.getBroadcastFactory | public function getBroadcastFactory(): ?Factory
{
if (!$this->hasBroadcastFactory()) {
$this->setBroadcastFactory($this->getDefaultBroadcastFactory());
}
return $this->broadcastFactory;
} | php | public function getBroadcastFactory(): ?Factory
{
if (!$this->hasBroadcastFactory()) {
$this->setBroadcastFactory($this->getDefaultBroadcastFactory());
}
return $this->broadcastFactory;
} | [
"public",
"function",
"getBroadcastFactory",
"(",
")",
":",
"?",
"Factory",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasBroadcastFactory",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setBroadcastFactory",
"(",
"$",
"this",
"->",
"getDefaultBroadcastFactory",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"broadcastFactory",
";",
"}"
]
| Get broadcast factory
If no broadcast factory has been set, this method will
set and return a default broadcast factory, if any such
value is available
@see getDefaultBroadcastFactory()
@return Factory|null broadcast factory or null if none broadcast factory has been set | [
"Get",
"broadcast",
"factory"
]
| train | https://github.com/aedart/laravel-helpers/blob/8b81a2d6658f3f8cb62b6be2c34773aaa2df219a/src/Traits/Broadcasting/BroadcastFactoryTrait.php#L54-L60 |
webforge-labs/psc-cms | lib/Psc/CMS/Item/Adapter.php | Adapter.getTabButton | public function getTabButton() {
if (!isset($this->tabButton)) {
if ($this->context === self::CONTEXT_DELETE) {
$this->tabButton = new DeleteTabButton($this);
} else {
$this->tabButton = new TabButton($this);
}
}
return $this->tabButton;
} | php | public function getTabButton() {
if (!isset($this->tabButton)) {
if ($this->context === self::CONTEXT_DELETE) {
$this->tabButton = new DeleteTabButton($this);
} else {
$this->tabButton = new TabButton($this);
}
}
return $this->tabButton;
} | [
"public",
"function",
"getTabButton",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"tabButton",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"context",
"===",
"self",
"::",
"CONTEXT_DELETE",
")",
"{",
"$",
"this",
"->",
"tabButton",
"=",
"new",
"DeleteTabButton",
"(",
"$",
"this",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"tabButton",
"=",
"new",
"TabButton",
"(",
"$",
"this",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"tabButton",
";",
"}"
]
| Gibt einen Button zurück der einen Tab des Entities aufmachen kann (defaults nicht zu default ;))
@return Psc\UI\ButtonInterface | [
"Gibt",
"einen",
"Button",
"zurück",
"der",
"einen",
"Tab",
"des",
"Entities",
"aufmachen",
"kann",
"(",
"defaults",
"nicht",
"zu",
"default",
";",
"))"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/Item/Adapter.php#L57-L66 |
webforge-labs/psc-cms | lib/Psc/CMS/Item/Adapter.php | Adapter.getTabRequestMeta | public function getTabRequestMeta() {
if (!isset($this->tabRequestMeta)) {
if ($this->context === self::CONTEXT_ACTION) {
$this->tabRequestMeta = $this->entityMeta->getActionRequestMeta($this->requestMetaAction, $this->entity);
} else {
$this->tabRequestMeta = $this->entityMeta->getDefaultRequestMeta($this->entity);
}
}
return $this->tabRequestMeta;
} | php | public function getTabRequestMeta() {
if (!isset($this->tabRequestMeta)) {
if ($this->context === self::CONTEXT_ACTION) {
$this->tabRequestMeta = $this->entityMeta->getActionRequestMeta($this->requestMetaAction, $this->entity);
} else {
$this->tabRequestMeta = $this->entityMeta->getDefaultRequestMeta($this->entity);
}
}
return $this->tabRequestMeta;
} | [
"public",
"function",
"getTabRequestMeta",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"tabRequestMeta",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"context",
"===",
"self",
"::",
"CONTEXT_ACTION",
")",
"{",
"$",
"this",
"->",
"tabRequestMeta",
"=",
"$",
"this",
"->",
"entityMeta",
"->",
"getActionRequestMeta",
"(",
"$",
"this",
"->",
"requestMetaAction",
",",
"$",
"this",
"->",
"entity",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"tabRequestMeta",
"=",
"$",
"this",
"->",
"entityMeta",
"->",
"getDefaultRequestMeta",
"(",
"$",
"this",
"->",
"entity",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"tabRequestMeta",
";",
"}"
]
| Gibt die RequestMeta für den aktuellen Kontext für ein Entity zurück
bei context: action muss requestMetaAction gesetzt sein
@return Psc\CMS\RequestMeta | [
"Gibt",
"die",
"RequestMeta",
"für",
"den",
"aktuellen",
"Kontext",
"für",
"ein",
"Entity",
"zurück"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/Item/Adapter.php#L136-L145 |
webforge-labs/psc-cms | lib/Psc/CMS/Item/Adapter.php | Adapter.getTabLabel | public function getTabLabel() {
if (isset($this->tabLabel)) {
return $this->tabLabel;
} else {
return $this->entity->getContextLabel(EntityMeta::CONTEXT_TAB);
}
} | php | public function getTabLabel() {
if (isset($this->tabLabel)) {
return $this->tabLabel;
} else {
return $this->entity->getContextLabel(EntityMeta::CONTEXT_TAB);
}
} | [
"public",
"function",
"getTabLabel",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"tabLabel",
")",
")",
"{",
"return",
"$",
"this",
"->",
"tabLabel",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"entity",
"->",
"getContextLabel",
"(",
"EntityMeta",
"::",
"CONTEXT_TAB",
")",
";",
"}",
"}"
]
| Befragt das Entity mit getTabLabel() nach diesem label
@return string | [
"Befragt",
"das",
"Entity",
"mit",
"getTabLabel",
"()",
"nach",
"diesem",
"label"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/Item/Adapter.php#L207-L213 |
steeffeen/FancyManiaLinks | FML/Script/Features/MenuElement.php | MenuElement.setItem | public function setItem(Control $item)
{
$item->checkId();
if ($item instanceof Scriptable) {
$item->setScriptEvents(true);
}
$this->item = $item;
return $this;
} | php | public function setItem(Control $item)
{
$item->checkId();
if ($item instanceof Scriptable) {
$item->setScriptEvents(true);
}
$this->item = $item;
return $this;
} | [
"public",
"function",
"setItem",
"(",
"Control",
"$",
"item",
")",
"{",
"$",
"item",
"->",
"checkId",
"(",
")",
";",
"if",
"(",
"$",
"item",
"instanceof",
"Scriptable",
")",
"{",
"$",
"item",
"->",
"setScriptEvents",
"(",
"true",
")",
";",
"}",
"$",
"this",
"->",
"item",
"=",
"$",
"item",
";",
"return",
"$",
"this",
";",
"}"
]
| Set the Item Control
@api
@param Control $item Item Control
@return static | [
"Set",
"the",
"Item",
"Control"
]
| train | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/MenuElement.php#L63-L71 |
dunkelfrosch/phpcoverfish | src/PHPCoverFish/Validator/Base/BaseCoverFishValidator.php | BaseCoverFishValidator.setMapping | public function setMapping(array $mappingOptions)
{
$coverMapping = new CoverFishMapping();
$coverMapping->setAnnotation($mappingOptions['coverToken']);
$coverMapping->setMethod($mappingOptions['coverMethod']);
$coverMapping->setAccessor($mappingOptions['coverAccessor']);
$coverMapping->setClass($mappingOptions['coverClass']);
$coverMapping->setClassFQN($mappingOptions['coverClassFQN']);
$coverMapping->setValidatorMatch($mappingOptions['validatorMatch']);
$coverMapping->setValidatorClass($mappingOptions['validatorClass']);
$coverMapping->setValidatorResult($this->validateMapping($coverMapping));
return $coverMapping;
} | php | public function setMapping(array $mappingOptions)
{
$coverMapping = new CoverFishMapping();
$coverMapping->setAnnotation($mappingOptions['coverToken']);
$coverMapping->setMethod($mappingOptions['coverMethod']);
$coverMapping->setAccessor($mappingOptions['coverAccessor']);
$coverMapping->setClass($mappingOptions['coverClass']);
$coverMapping->setClassFQN($mappingOptions['coverClassFQN']);
$coverMapping->setValidatorMatch($mappingOptions['validatorMatch']);
$coverMapping->setValidatorClass($mappingOptions['validatorClass']);
$coverMapping->setValidatorResult($this->validateMapping($coverMapping));
return $coverMapping;
} | [
"public",
"function",
"setMapping",
"(",
"array",
"$",
"mappingOptions",
")",
"{",
"$",
"coverMapping",
"=",
"new",
"CoverFishMapping",
"(",
")",
";",
"$",
"coverMapping",
"->",
"setAnnotation",
"(",
"$",
"mappingOptions",
"[",
"'coverToken'",
"]",
")",
";",
"$",
"coverMapping",
"->",
"setMethod",
"(",
"$",
"mappingOptions",
"[",
"'coverMethod'",
"]",
")",
";",
"$",
"coverMapping",
"->",
"setAccessor",
"(",
"$",
"mappingOptions",
"[",
"'coverAccessor'",
"]",
")",
";",
"$",
"coverMapping",
"->",
"setClass",
"(",
"$",
"mappingOptions",
"[",
"'coverClass'",
"]",
")",
";",
"$",
"coverMapping",
"->",
"setClassFQN",
"(",
"$",
"mappingOptions",
"[",
"'coverClassFQN'",
"]",
")",
";",
"$",
"coverMapping",
"->",
"setValidatorMatch",
"(",
"$",
"mappingOptions",
"[",
"'validatorMatch'",
"]",
")",
";",
"$",
"coverMapping",
"->",
"setValidatorClass",
"(",
"$",
"mappingOptions",
"[",
"'validatorClass'",
"]",
")",
";",
"$",
"coverMapping",
"->",
"setValidatorResult",
"(",
"$",
"this",
"->",
"validateMapping",
"(",
"$",
"coverMapping",
")",
")",
";",
"return",
"$",
"coverMapping",
";",
"}"
]
| @param array $mappingOptions
@return CoverFishMapping | [
"@param",
"array",
"$mappingOptions"
]
| train | https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Validator/Base/BaseCoverFishValidator.php#L95-L108 |
dunkelfrosch/phpcoverfish | src/PHPCoverFish/Validator/Base/BaseCoverFishValidator.php | BaseCoverFishValidator.validateDefaultCoverClassMapping | public function validateDefaultCoverClassMapping(CoverFishMapping $coverMapping, CoverFishResult $coverFishResult)
{
if (empty($coverMapping->getClassFQN())) {
$coverFishResult = $this->setValidationError(
$coverFishResult,
empty($coverMapping->getClass())
? CoverFishMessageError::PHPUNIT_VALIDATOR_MISSING_DEFAULT_COVER_CLASS_PROBLEM
: CoverFishMessageError::PHPUNIT_REFLECTION_CLASS_NOT_DEFINED
);
}
return $coverFishResult;
} | php | public function validateDefaultCoverClassMapping(CoverFishMapping $coverMapping, CoverFishResult $coverFishResult)
{
if (empty($coverMapping->getClassFQN())) {
$coverFishResult = $this->setValidationError(
$coverFishResult,
empty($coverMapping->getClass())
? CoverFishMessageError::PHPUNIT_VALIDATOR_MISSING_DEFAULT_COVER_CLASS_PROBLEM
: CoverFishMessageError::PHPUNIT_REFLECTION_CLASS_NOT_DEFINED
);
}
return $coverFishResult;
} | [
"public",
"function",
"validateDefaultCoverClassMapping",
"(",
"CoverFishMapping",
"$",
"coverMapping",
",",
"CoverFishResult",
"$",
"coverFishResult",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"coverMapping",
"->",
"getClassFQN",
"(",
")",
")",
")",
"{",
"$",
"coverFishResult",
"=",
"$",
"this",
"->",
"setValidationError",
"(",
"$",
"coverFishResult",
",",
"empty",
"(",
"$",
"coverMapping",
"->",
"getClass",
"(",
")",
")",
"?",
"CoverFishMessageError",
"::",
"PHPUNIT_VALIDATOR_MISSING_DEFAULT_COVER_CLASS_PROBLEM",
":",
"CoverFishMessageError",
"::",
"PHPUNIT_REFLECTION_CLASS_NOT_DEFINED",
")",
";",
"}",
"return",
"$",
"coverFishResult",
";",
"}"
]
| @param CoverFishMapping $coverMapping
@param CoverFishResult $coverFishResult
@return CoverFishResult | [
"@param",
"CoverFishMapping",
"$coverMapping",
"@param",
"CoverFishResult",
"$coverFishResult"
]
| train | https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Validator/Base/BaseCoverFishValidator.php#L124-L136 |
dunkelfrosch/phpcoverfish | src/PHPCoverFish/Validator/Base/BaseCoverFishValidator.php | BaseCoverFishValidator.validateClassFQNMapping | public function validateClassFQNMapping(CoverFishMapping $coverMapping, CoverFishResult $coverFishResult)
{
$classReflectionResult = $this->validateReflectionClass($coverMapping->getClassFQN());
if ($classReflectionResult instanceof CoverFishMessageError) {
$coverFishResult = $this->setValidationError(
$coverFishResult,
$classReflectionResult->getMessageCode()
);
}
return $coverFishResult;
} | php | public function validateClassFQNMapping(CoverFishMapping $coverMapping, CoverFishResult $coverFishResult)
{
$classReflectionResult = $this->validateReflectionClass($coverMapping->getClassFQN());
if ($classReflectionResult instanceof CoverFishMessageError) {
$coverFishResult = $this->setValidationError(
$coverFishResult,
$classReflectionResult->getMessageCode()
);
}
return $coverFishResult;
} | [
"public",
"function",
"validateClassFQNMapping",
"(",
"CoverFishMapping",
"$",
"coverMapping",
",",
"CoverFishResult",
"$",
"coverFishResult",
")",
"{",
"$",
"classReflectionResult",
"=",
"$",
"this",
"->",
"validateReflectionClass",
"(",
"$",
"coverMapping",
"->",
"getClassFQN",
"(",
")",
")",
";",
"if",
"(",
"$",
"classReflectionResult",
"instanceof",
"CoverFishMessageError",
")",
"{",
"$",
"coverFishResult",
"=",
"$",
"this",
"->",
"setValidationError",
"(",
"$",
"coverFishResult",
",",
"$",
"classReflectionResult",
"->",
"getMessageCode",
"(",
")",
")",
";",
"}",
"return",
"$",
"coverFishResult",
";",
"}"
]
| @todo: mappingResult could be false, set a specific/real coverFishError here ...
@param CoverFishMapping $coverMapping
@param CoverFishResult $coverFishResult
@return CoverFishResult | [
"@todo",
":",
"mappingResult",
"could",
"be",
"false",
"set",
"a",
"specific",
"/",
"real",
"coverFishError",
"here",
"..."
]
| train | https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Validator/Base/BaseCoverFishValidator.php#L146-L157 |
dunkelfrosch/phpcoverfish | src/PHPCoverFish/Validator/Base/BaseCoverFishValidator.php | BaseCoverFishValidator.validateClassAccessorVisibility | public function validateClassAccessorVisibility(CoverFishMapping $coverMapping, CoverFishResult $coverFishResult)
{
$methodReflectionResult = $this->validateReflectionClassForAccessorVisibility($coverMapping->getClassFQN(), $coverMapping->getAccessor());
if ($methodReflectionResult instanceof CoverFishMessageError) {
$coverFishResult = $this->setValidationError(
$coverFishResult,
$methodReflectionResult->getMessageCode()
);
}
return $coverFishResult;
} | php | public function validateClassAccessorVisibility(CoverFishMapping $coverMapping, CoverFishResult $coverFishResult)
{
$methodReflectionResult = $this->validateReflectionClassForAccessorVisibility($coverMapping->getClassFQN(), $coverMapping->getAccessor());
if ($methodReflectionResult instanceof CoverFishMessageError) {
$coverFishResult = $this->setValidationError(
$coverFishResult,
$methodReflectionResult->getMessageCode()
);
}
return $coverFishResult;
} | [
"public",
"function",
"validateClassAccessorVisibility",
"(",
"CoverFishMapping",
"$",
"coverMapping",
",",
"CoverFishResult",
"$",
"coverFishResult",
")",
"{",
"$",
"methodReflectionResult",
"=",
"$",
"this",
"->",
"validateReflectionClassForAccessorVisibility",
"(",
"$",
"coverMapping",
"->",
"getClassFQN",
"(",
")",
",",
"$",
"coverMapping",
"->",
"getAccessor",
"(",
")",
")",
";",
"if",
"(",
"$",
"methodReflectionResult",
"instanceof",
"CoverFishMessageError",
")",
"{",
"$",
"coverFishResult",
"=",
"$",
"this",
"->",
"setValidationError",
"(",
"$",
"coverFishResult",
",",
"$",
"methodReflectionResult",
"->",
"getMessageCode",
"(",
")",
")",
";",
"}",
"return",
"$",
"coverFishResult",
";",
"}"
]
| @param CoverFishMapping $coverMapping
@param CoverFishResult $coverFishResult
@return CoverFishResult | [
"@param",
"CoverFishMapping",
"$coverMapping",
"@param",
"CoverFishResult",
"$coverFishResult"
]
| train | https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Validator/Base/BaseCoverFishValidator.php#L165-L176 |
dunkelfrosch/phpcoverfish | src/PHPCoverFish/Validator/Base/BaseCoverFishValidator.php | BaseCoverFishValidator.validateClassMethod | public function validateClassMethod(CoverFishMapping $coverMapping, CoverFishResult $coverFishResult)
{
$methodReflectionResult = $this->validateReflectionMethod($coverMapping->getClassFQN(), $coverMapping->getMethod());
if ($methodReflectionResult instanceof CoverFishMessageError) {
$coverFishResult = $this->setValidationError(
$coverFishResult,
$methodReflectionResult->getMessageCode()
);
}
return $coverFishResult;
} | php | public function validateClassMethod(CoverFishMapping $coverMapping, CoverFishResult $coverFishResult)
{
$methodReflectionResult = $this->validateReflectionMethod($coverMapping->getClassFQN(), $coverMapping->getMethod());
if ($methodReflectionResult instanceof CoverFishMessageError) {
$coverFishResult = $this->setValidationError(
$coverFishResult,
$methodReflectionResult->getMessageCode()
);
}
return $coverFishResult;
} | [
"public",
"function",
"validateClassMethod",
"(",
"CoverFishMapping",
"$",
"coverMapping",
",",
"CoverFishResult",
"$",
"coverFishResult",
")",
"{",
"$",
"methodReflectionResult",
"=",
"$",
"this",
"->",
"validateReflectionMethod",
"(",
"$",
"coverMapping",
"->",
"getClassFQN",
"(",
")",
",",
"$",
"coverMapping",
"->",
"getMethod",
"(",
")",
")",
";",
"if",
"(",
"$",
"methodReflectionResult",
"instanceof",
"CoverFishMessageError",
")",
"{",
"$",
"coverFishResult",
"=",
"$",
"this",
"->",
"setValidationError",
"(",
"$",
"coverFishResult",
",",
"$",
"methodReflectionResult",
"->",
"getMessageCode",
"(",
")",
")",
";",
"}",
"return",
"$",
"coverFishResult",
";",
"}"
]
| @param CoverFishMapping $coverMapping
@param CoverFishResult $coverFishResult
@return CoverFishResult | [
"@param",
"CoverFishMapping",
"$coverMapping",
"@param",
"CoverFishResult",
"$coverFishResult"
]
| train | https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Validator/Base/BaseCoverFishValidator.php#L184-L195 |
dunkelfrosch/phpcoverfish | src/PHPCoverFish/Validator/Base/BaseCoverFishValidator.php | BaseCoverFishValidator.validateEmptyDocBlock | public function validateEmptyDocBlock(CoverFishMapping $coverMapping, CoverFishResult $coverFishResult)
{
if (null === ($coverMapping->getAnnotation())) {
$coverFishResult = $this->setValidationWarning(
$coverFishResult,
CoverFishMessageWarning::PHPUNIT_NO_DOCBLOCK_FOR_METHOD
);
}
return $coverFishResult;
} | php | public function validateEmptyDocBlock(CoverFishMapping $coverMapping, CoverFishResult $coverFishResult)
{
if (null === ($coverMapping->getAnnotation())) {
$coverFishResult = $this->setValidationWarning(
$coverFishResult,
CoverFishMessageWarning::PHPUNIT_NO_DOCBLOCK_FOR_METHOD
);
}
return $coverFishResult;
} | [
"public",
"function",
"validateEmptyDocBlock",
"(",
"CoverFishMapping",
"$",
"coverMapping",
",",
"CoverFishResult",
"$",
"coverFishResult",
")",
"{",
"if",
"(",
"null",
"===",
"(",
"$",
"coverMapping",
"->",
"getAnnotation",
"(",
")",
")",
")",
"{",
"$",
"coverFishResult",
"=",
"$",
"this",
"->",
"setValidationWarning",
"(",
"$",
"coverFishResult",
",",
"CoverFishMessageWarning",
"::",
"PHPUNIT_NO_DOCBLOCK_FOR_METHOD",
")",
";",
"}",
"return",
"$",
"coverFishResult",
";",
"}"
]
| @param CoverFishMapping $coverMapping
@param CoverFishResult $coverFishResult
@return CoverFishResult | [
"@param",
"CoverFishMapping",
"$coverMapping",
"@param",
"CoverFishResult",
"$coverFishResult"
]
| train | https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Validator/Base/BaseCoverFishValidator.php#L203-L213 |
dunkelfrosch/phpcoverfish | src/PHPCoverFish/Validator/Base/BaseCoverFishValidator.php | BaseCoverFishValidator.validateMapping | public function validateMapping(CoverFishMapping $coverMapping)
{
/** @var CoverFishResult $coverFishResult */
$coverFishResult = new CoverFishResult();
// prepare base results, clear all validation errors and warnings
$coverFishResult = $this->prepareCoverFishResult($coverFishResult);
// E-01: check for classFQN/DefaultCoverClass existence/mapping validation-error
$coverFishResult = $this->validateDefaultCoverClassMapping($coverMapping, $coverFishResult);
// E-02: check for invalid classFQN validation-error
$coverFishResult = $this->validateClassFQNMapping($coverMapping, $coverFishResult);
// E-03: check for invalid accessor validation-error
$coverFishResult = $this->validateClassAccessorVisibility($coverMapping, $coverFishResult);
// E-04: check for invalid method validation-error
$coverFishResult = $this->validateClassMethod($coverMapping, $coverFishResult);
return $coverFishResult;
} | php | public function validateMapping(CoverFishMapping $coverMapping)
{
/** @var CoverFishResult $coverFishResult */
$coverFishResult = new CoverFishResult();
// prepare base results, clear all validation errors and warnings
$coverFishResult = $this->prepareCoverFishResult($coverFishResult);
// E-01: check for classFQN/DefaultCoverClass existence/mapping validation-error
$coverFishResult = $this->validateDefaultCoverClassMapping($coverMapping, $coverFishResult);
// E-02: check for invalid classFQN validation-error
$coverFishResult = $this->validateClassFQNMapping($coverMapping, $coverFishResult);
// E-03: check for invalid accessor validation-error
$coverFishResult = $this->validateClassAccessorVisibility($coverMapping, $coverFishResult);
// E-04: check for invalid method validation-error
$coverFishResult = $this->validateClassMethod($coverMapping, $coverFishResult);
return $coverFishResult;
} | [
"public",
"function",
"validateMapping",
"(",
"CoverFishMapping",
"$",
"coverMapping",
")",
"{",
"/** @var CoverFishResult $coverFishResult */",
"$",
"coverFishResult",
"=",
"new",
"CoverFishResult",
"(",
")",
";",
"// prepare base results, clear all validation errors and warnings",
"$",
"coverFishResult",
"=",
"$",
"this",
"->",
"prepareCoverFishResult",
"(",
"$",
"coverFishResult",
")",
";",
"// E-01: check for classFQN/DefaultCoverClass existence/mapping validation-error",
"$",
"coverFishResult",
"=",
"$",
"this",
"->",
"validateDefaultCoverClassMapping",
"(",
"$",
"coverMapping",
",",
"$",
"coverFishResult",
")",
";",
"// E-02: check for invalid classFQN validation-error",
"$",
"coverFishResult",
"=",
"$",
"this",
"->",
"validateClassFQNMapping",
"(",
"$",
"coverMapping",
",",
"$",
"coverFishResult",
")",
";",
"// E-03: check for invalid accessor validation-error",
"$",
"coverFishResult",
"=",
"$",
"this",
"->",
"validateClassAccessorVisibility",
"(",
"$",
"coverMapping",
",",
"$",
"coverFishResult",
")",
";",
"// E-04: check for invalid method validation-error",
"$",
"coverFishResult",
"=",
"$",
"this",
"->",
"validateClassMethod",
"(",
"$",
"coverMapping",
",",
"$",
"coverFishResult",
")",
";",
"return",
"$",
"coverFishResult",
";",
"}"
]
| main validator mapping "engine", if any of our cover validator checks will fail,
return corresponding result immediately ...
@param CoverFishMapping $coverMapping
@return CoverFishResult | [
"main",
"validator",
"mapping",
"engine",
"if",
"any",
"of",
"our",
"cover",
"validator",
"checks",
"will",
"fail",
"return",
"corresponding",
"result",
"immediately",
"..."
]
| train | https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Validator/Base/BaseCoverFishValidator.php#L223-L239 |
dunkelfrosch/phpcoverfish | src/PHPCoverFish/Validator/Base/BaseCoverFishValidator.php | BaseCoverFishValidator.prepareCoverFishResult | public function prepareCoverFishResult(CoverFishResult $coverFishResult)
{
$this->clearValidationErrors($coverFishResult);
$this->clearValidationWarnings($coverFishResult);
return $coverFishResult;
} | php | public function prepareCoverFishResult(CoverFishResult $coverFishResult)
{
$this->clearValidationErrors($coverFishResult);
$this->clearValidationWarnings($coverFishResult);
return $coverFishResult;
} | [
"public",
"function",
"prepareCoverFishResult",
"(",
"CoverFishResult",
"$",
"coverFishResult",
")",
"{",
"$",
"this",
"->",
"clearValidationErrors",
"(",
"$",
"coverFishResult",
")",
";",
"$",
"this",
"->",
"clearValidationWarnings",
"(",
"$",
"coverFishResult",
")",
";",
"return",
"$",
"coverFishResult",
";",
"}"
]
| @param CoverFishResult $coverFishResult
@return CoverFishResult | [
"@param",
"CoverFishResult",
"$coverFishResult"
]
| train | https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Validator/Base/BaseCoverFishValidator.php#L246-L252 |
dunkelfrosch/phpcoverfish | src/PHPCoverFish/Validator/Base/BaseCoverFishValidator.php | BaseCoverFishValidator.validateReflectionMethod | public function validateReflectionMethod($classFQN, $method)
{
if (null === $classFQN || null === $method) {
return false;
}
try {
$reflectionMethod = new \ReflectionMethod($classFQN, $method);
} catch (\ReflectionException $re) {
return new CoverFishMessageError(CoverFishMessageError::PHPUNIT_REFLECTION_METHOD_NOT_FOUND, $method);
}
return $reflectionMethod;
} | php | public function validateReflectionMethod($classFQN, $method)
{
if (null === $classFQN || null === $method) {
return false;
}
try {
$reflectionMethod = new \ReflectionMethod($classFQN, $method);
} catch (\ReflectionException $re) {
return new CoverFishMessageError(CoverFishMessageError::PHPUNIT_REFLECTION_METHOD_NOT_FOUND, $method);
}
return $reflectionMethod;
} | [
"public",
"function",
"validateReflectionMethod",
"(",
"$",
"classFQN",
",",
"$",
"method",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"classFQN",
"||",
"null",
"===",
"$",
"method",
")",
"{",
"return",
"false",
";",
"}",
"try",
"{",
"$",
"reflectionMethod",
"=",
"new",
"\\",
"ReflectionMethod",
"(",
"$",
"classFQN",
",",
"$",
"method",
")",
";",
"}",
"catch",
"(",
"\\",
"ReflectionException",
"$",
"re",
")",
"{",
"return",
"new",
"CoverFishMessageError",
"(",
"CoverFishMessageError",
"::",
"PHPUNIT_REFLECTION_METHOD_NOT_FOUND",
",",
"$",
"method",
")",
";",
"}",
"return",
"$",
"reflectionMethod",
";",
"}"
]
| @param string $classFQN
@param string $method
@return CoverFishMessageError|\ReflectionMethod|false | [
"@param",
"string",
"$classFQN",
"@param",
"string",
"$method"
]
| train | https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Validator/Base/BaseCoverFishValidator.php#L270-L283 |
dunkelfrosch/phpcoverfish | src/PHPCoverFish/Validator/Base/BaseCoverFishValidator.php | BaseCoverFishValidator.validateReflectionClassForAccessorPublic | public function validateReflectionClassForAccessorPublic(\ReflectionClass $reflectionClass)
{
if (empty($methods = $reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC))) {
return new CoverFishMessageError(
CoverFishMessageError::PHPUNIT_REFLECTION_NO_PUBLIC_METHODS_FOUND, null
);
}
return true;
} | php | public function validateReflectionClassForAccessorPublic(\ReflectionClass $reflectionClass)
{
if (empty($methods = $reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC))) {
return new CoverFishMessageError(
CoverFishMessageError::PHPUNIT_REFLECTION_NO_PUBLIC_METHODS_FOUND, null
);
}
return true;
} | [
"public",
"function",
"validateReflectionClassForAccessorPublic",
"(",
"\\",
"ReflectionClass",
"$",
"reflectionClass",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"methods",
"=",
"$",
"reflectionClass",
"->",
"getMethods",
"(",
"\\",
"ReflectionMethod",
"::",
"IS_PUBLIC",
")",
")",
")",
"{",
"return",
"new",
"CoverFishMessageError",
"(",
"CoverFishMessageError",
"::",
"PHPUNIT_REFLECTION_NO_PUBLIC_METHODS_FOUND",
",",
"null",
")",
";",
"}",
"return",
"true",
";",
"}"
]
| @param \ReflectionClass $reflectionClass
@return bool|CoverFishMessageError | [
"@param",
"\\",
"ReflectionClass",
"$reflectionClass"
]
| train | https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Validator/Base/BaseCoverFishValidator.php#L290-L299 |
dunkelfrosch/phpcoverfish | src/PHPCoverFish/Validator/Base/BaseCoverFishValidator.php | BaseCoverFishValidator.validateReflectionClassForAccessorNotPublic | public function validateReflectionClassForAccessorNotPublic(\ReflectionClass $reflectionClass)
{
$methods = array_merge(
$reflectionClass->getMethods(\ReflectionMethod::IS_PRIVATE),
$reflectionClass->getMethods(\ReflectionMethod::IS_PROTECTED)
);
if (empty($methods)) {
return new CoverFishMessageError(
CoverFishMessageError::PHPUNIT_REFLECTION_NO_NOT_PUBLIC_METHODS_FOUND, null
);
}
return true;
} | php | public function validateReflectionClassForAccessorNotPublic(\ReflectionClass $reflectionClass)
{
$methods = array_merge(
$reflectionClass->getMethods(\ReflectionMethod::IS_PRIVATE),
$reflectionClass->getMethods(\ReflectionMethod::IS_PROTECTED)
);
if (empty($methods)) {
return new CoverFishMessageError(
CoverFishMessageError::PHPUNIT_REFLECTION_NO_NOT_PUBLIC_METHODS_FOUND, null
);
}
return true;
} | [
"public",
"function",
"validateReflectionClassForAccessorNotPublic",
"(",
"\\",
"ReflectionClass",
"$",
"reflectionClass",
")",
"{",
"$",
"methods",
"=",
"array_merge",
"(",
"$",
"reflectionClass",
"->",
"getMethods",
"(",
"\\",
"ReflectionMethod",
"::",
"IS_PRIVATE",
")",
",",
"$",
"reflectionClass",
"->",
"getMethods",
"(",
"\\",
"ReflectionMethod",
"::",
"IS_PROTECTED",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"methods",
")",
")",
"{",
"return",
"new",
"CoverFishMessageError",
"(",
"CoverFishMessageError",
"::",
"PHPUNIT_REFLECTION_NO_NOT_PUBLIC_METHODS_FOUND",
",",
"null",
")",
";",
"}",
"return",
"true",
";",
"}"
]
| @param \ReflectionClass $reflectionClass
@return bool|CoverFishMessageError | [
"@param",
"\\",
"ReflectionClass",
"$reflectionClass"
]
| train | https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Validator/Base/BaseCoverFishValidator.php#L306-L320 |
dunkelfrosch/phpcoverfish | src/PHPCoverFish/Validator/Base/BaseCoverFishValidator.php | BaseCoverFishValidator.validateReflectionClassForAccessorProtected | public function validateReflectionClassForAccessorProtected(\ReflectionClass $reflectionClass)
{
if (empty($methods = $reflectionClass->getMethods(\ReflectionMethod::IS_PROTECTED))) {
return new CoverFishMessageError(
CoverFishMessageError::PHPUNIT_REFLECTION_NO_PROTECTED_METHODS_FOUND, null
);
}
return true;
} | php | public function validateReflectionClassForAccessorProtected(\ReflectionClass $reflectionClass)
{
if (empty($methods = $reflectionClass->getMethods(\ReflectionMethod::IS_PROTECTED))) {
return new CoverFishMessageError(
CoverFishMessageError::PHPUNIT_REFLECTION_NO_PROTECTED_METHODS_FOUND, null
);
}
return true;
} | [
"public",
"function",
"validateReflectionClassForAccessorProtected",
"(",
"\\",
"ReflectionClass",
"$",
"reflectionClass",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"methods",
"=",
"$",
"reflectionClass",
"->",
"getMethods",
"(",
"\\",
"ReflectionMethod",
"::",
"IS_PROTECTED",
")",
")",
")",
"{",
"return",
"new",
"CoverFishMessageError",
"(",
"CoverFishMessageError",
"::",
"PHPUNIT_REFLECTION_NO_PROTECTED_METHODS_FOUND",
",",
"null",
")",
";",
"}",
"return",
"true",
";",
"}"
]
| @param \ReflectionClass $reflectionClass
@return bool|CoverFishMessageError | [
"@param",
"\\",
"ReflectionClass",
"$reflectionClass"
]
| train | https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Validator/Base/BaseCoverFishValidator.php#L327-L336 |
dunkelfrosch/phpcoverfish | src/PHPCoverFish/Validator/Base/BaseCoverFishValidator.php | BaseCoverFishValidator.validateReflectionClassForAccessorNotProtected | public function validateReflectionClassForAccessorNotProtected(\ReflectionClass $reflectionClass)
{
$methods = array_merge(
$reflectionClass->getMethods(\ReflectionMethod::IS_PRIVATE),
$reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC)
);
if (empty($methods)) {
return new CoverFishMessageError(
CoverFishMessageError::PHPUNIT_REFLECTION_NO_NOT_PROTECTED_METHODS_FOUND, null
);
}
return true;
} | php | public function validateReflectionClassForAccessorNotProtected(\ReflectionClass $reflectionClass)
{
$methods = array_merge(
$reflectionClass->getMethods(\ReflectionMethod::IS_PRIVATE),
$reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC)
);
if (empty($methods)) {
return new CoverFishMessageError(
CoverFishMessageError::PHPUNIT_REFLECTION_NO_NOT_PROTECTED_METHODS_FOUND, null
);
}
return true;
} | [
"public",
"function",
"validateReflectionClassForAccessorNotProtected",
"(",
"\\",
"ReflectionClass",
"$",
"reflectionClass",
")",
"{",
"$",
"methods",
"=",
"array_merge",
"(",
"$",
"reflectionClass",
"->",
"getMethods",
"(",
"\\",
"ReflectionMethod",
"::",
"IS_PRIVATE",
")",
",",
"$",
"reflectionClass",
"->",
"getMethods",
"(",
"\\",
"ReflectionMethod",
"::",
"IS_PUBLIC",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"methods",
")",
")",
"{",
"return",
"new",
"CoverFishMessageError",
"(",
"CoverFishMessageError",
"::",
"PHPUNIT_REFLECTION_NO_NOT_PROTECTED_METHODS_FOUND",
",",
"null",
")",
";",
"}",
"return",
"true",
";",
"}"
]
| @param \ReflectionClass $reflectionClass
@return bool|CoverFishMessageError | [
"@param",
"\\",
"ReflectionClass",
"$reflectionClass"
]
| train | https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Validator/Base/BaseCoverFishValidator.php#L343-L357 |
dunkelfrosch/phpcoverfish | src/PHPCoverFish/Validator/Base/BaseCoverFishValidator.php | BaseCoverFishValidator.validateReflectionClassForAccessorPrivate | public function validateReflectionClassForAccessorPrivate(\ReflectionClass $reflectionClass)
{
if (empty($methods = $reflectionClass->getMethods(\ReflectionMethod::IS_PRIVATE))) {
return new CoverFishMessageError(
CoverFishMessageError::PHPUNIT_REFLECTION_NO_PRIVATE_METHODS_FOUND, null
);
}
return true;
} | php | public function validateReflectionClassForAccessorPrivate(\ReflectionClass $reflectionClass)
{
if (empty($methods = $reflectionClass->getMethods(\ReflectionMethod::IS_PRIVATE))) {
return new CoverFishMessageError(
CoverFishMessageError::PHPUNIT_REFLECTION_NO_PRIVATE_METHODS_FOUND, null
);
}
return true;
} | [
"public",
"function",
"validateReflectionClassForAccessorPrivate",
"(",
"\\",
"ReflectionClass",
"$",
"reflectionClass",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"methods",
"=",
"$",
"reflectionClass",
"->",
"getMethods",
"(",
"\\",
"ReflectionMethod",
"::",
"IS_PRIVATE",
")",
")",
")",
"{",
"return",
"new",
"CoverFishMessageError",
"(",
"CoverFishMessageError",
"::",
"PHPUNIT_REFLECTION_NO_PRIVATE_METHODS_FOUND",
",",
"null",
")",
";",
"}",
"return",
"true",
";",
"}"
]
| @param \ReflectionClass $reflectionClass
@return bool|CoverFishMessageError | [
"@param",
"\\",
"ReflectionClass",
"$reflectionClass"
]
| train | https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Validator/Base/BaseCoverFishValidator.php#L364-L373 |
dunkelfrosch/phpcoverfish | src/PHPCoverFish/Validator/Base/BaseCoverFishValidator.php | BaseCoverFishValidator.validateReflectionClassForAccessorNotPrivate | public function validateReflectionClassForAccessorNotPrivate(\ReflectionClass $reflectionClass)
{
$methods = array_merge(
$reflectionClass->getMethods(\ReflectionMethod::IS_PROTECTED),
$reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC)
);
if (empty($methods)) {
return new CoverFishMessageError(
CoverFishMessageError::PHPUNIT_REFLECTION_NO_NOT_PRIVATE_METHODS_FOUND, null
);
}
return true;
} | php | public function validateReflectionClassForAccessorNotPrivate(\ReflectionClass $reflectionClass)
{
$methods = array_merge(
$reflectionClass->getMethods(\ReflectionMethod::IS_PROTECTED),
$reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC)
);
if (empty($methods)) {
return new CoverFishMessageError(
CoverFishMessageError::PHPUNIT_REFLECTION_NO_NOT_PRIVATE_METHODS_FOUND, null
);
}
return true;
} | [
"public",
"function",
"validateReflectionClassForAccessorNotPrivate",
"(",
"\\",
"ReflectionClass",
"$",
"reflectionClass",
")",
"{",
"$",
"methods",
"=",
"array_merge",
"(",
"$",
"reflectionClass",
"->",
"getMethods",
"(",
"\\",
"ReflectionMethod",
"::",
"IS_PROTECTED",
")",
",",
"$",
"reflectionClass",
"->",
"getMethods",
"(",
"\\",
"ReflectionMethod",
"::",
"IS_PUBLIC",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"methods",
")",
")",
"{",
"return",
"new",
"CoverFishMessageError",
"(",
"CoverFishMessageError",
"::",
"PHPUNIT_REFLECTION_NO_NOT_PRIVATE_METHODS_FOUND",
",",
"null",
")",
";",
"}",
"return",
"true",
";",
"}"
]
| @param \ReflectionClass $reflectionClass
@return bool|CoverFishMessageError | [
"@param",
"\\",
"ReflectionClass",
"$reflectionClass"
]
| train | https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Validator/Base/BaseCoverFishValidator.php#L380-L394 |
dunkelfrosch/phpcoverfish | src/PHPCoverFish/Validator/Base/BaseCoverFishValidator.php | BaseCoverFishValidator.validateReflectionClassForAccessorVisibility | public function validateReflectionClassForAccessorVisibility($classFQN, $accessor)
{
$reflectionClass = $this->getReflectionClass($classFQN);
if ($reflectionClass instanceof CoverFishMessageError) {
return $reflectionClass;
}
$accessorResult = null;
switch ($accessor) {
case 'public':
$accessorResult = $this->validateReflectionClassForAccessorPublic($reflectionClass);
break;
case 'protected':
$accessorResult = $this->validateReflectionClassForAccessorProtected($reflectionClass);
break;
case 'private':
$accessorResult = $this->validateReflectionClassForAccessorPrivate($reflectionClass);
break;
case '!public':
$accessorResult = $this->validateReflectionClassForAccessorNotPublic($reflectionClass);
break;
case '!protected':
$accessorResult = $this->validateReflectionClassForAccessorNotProtected($reflectionClass);
break;
case '!private':
$accessorResult = $this->validateReflectionClassForAccessorNotPrivate($reflectionClass);
break;
default:
return false;
}
if ($accessorResult instanceof CoverFishMessageError) {
return $accessorResult;
}
return true;
} | php | public function validateReflectionClassForAccessorVisibility($classFQN, $accessor)
{
$reflectionClass = $this->getReflectionClass($classFQN);
if ($reflectionClass instanceof CoverFishMessageError) {
return $reflectionClass;
}
$accessorResult = null;
switch ($accessor) {
case 'public':
$accessorResult = $this->validateReflectionClassForAccessorPublic($reflectionClass);
break;
case 'protected':
$accessorResult = $this->validateReflectionClassForAccessorProtected($reflectionClass);
break;
case 'private':
$accessorResult = $this->validateReflectionClassForAccessorPrivate($reflectionClass);
break;
case '!public':
$accessorResult = $this->validateReflectionClassForAccessorNotPublic($reflectionClass);
break;
case '!protected':
$accessorResult = $this->validateReflectionClassForAccessorNotProtected($reflectionClass);
break;
case '!private':
$accessorResult = $this->validateReflectionClassForAccessorNotPrivate($reflectionClass);
break;
default:
return false;
}
if ($accessorResult instanceof CoverFishMessageError) {
return $accessorResult;
}
return true;
} | [
"public",
"function",
"validateReflectionClassForAccessorVisibility",
"(",
"$",
"classFQN",
",",
"$",
"accessor",
")",
"{",
"$",
"reflectionClass",
"=",
"$",
"this",
"->",
"getReflectionClass",
"(",
"$",
"classFQN",
")",
";",
"if",
"(",
"$",
"reflectionClass",
"instanceof",
"CoverFishMessageError",
")",
"{",
"return",
"$",
"reflectionClass",
";",
"}",
"$",
"accessorResult",
"=",
"null",
";",
"switch",
"(",
"$",
"accessor",
")",
"{",
"case",
"'public'",
":",
"$",
"accessorResult",
"=",
"$",
"this",
"->",
"validateReflectionClassForAccessorPublic",
"(",
"$",
"reflectionClass",
")",
";",
"break",
";",
"case",
"'protected'",
":",
"$",
"accessorResult",
"=",
"$",
"this",
"->",
"validateReflectionClassForAccessorProtected",
"(",
"$",
"reflectionClass",
")",
";",
"break",
";",
"case",
"'private'",
":",
"$",
"accessorResult",
"=",
"$",
"this",
"->",
"validateReflectionClassForAccessorPrivate",
"(",
"$",
"reflectionClass",
")",
";",
"break",
";",
"case",
"'!public'",
":",
"$",
"accessorResult",
"=",
"$",
"this",
"->",
"validateReflectionClassForAccessorNotPublic",
"(",
"$",
"reflectionClass",
")",
";",
"break",
";",
"case",
"'!protected'",
":",
"$",
"accessorResult",
"=",
"$",
"this",
"->",
"validateReflectionClassForAccessorNotProtected",
"(",
"$",
"reflectionClass",
")",
";",
"break",
";",
"case",
"'!private'",
":",
"$",
"accessorResult",
"=",
"$",
"this",
"->",
"validateReflectionClassForAccessorNotPrivate",
"(",
"$",
"reflectionClass",
")",
";",
"break",
";",
"default",
":",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"accessorResult",
"instanceof",
"CoverFishMessageError",
")",
"{",
"return",
"$",
"accessorResult",
";",
"}",
"return",
"true",
";",
"}"
]
| @param string $classFQN
@param string $accessor
@return bool|CoverFishMessageError | [
"@param",
"string",
"$classFQN",
"@param",
"string",
"$accessor"
]
| train | https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Validator/Base/BaseCoverFishValidator.php#L402-L445 |
dunkelfrosch/phpcoverfish | src/PHPCoverFish/Validator/Base/BaseCoverFishValidator.php | BaseCoverFishValidator.setValidationError | public function setValidationError(CoverFishResult $coverFishResult, $errorCode, $errorMessage = null)
{
// skip validation if incoming mapping result is already invalid!
if (false === $coverFishResult->isPass()) {
return $coverFishResult;
}
$coverFishResult->setPass(false);
$coverFishResult->addError(new CoverFishMessageError($errorCode, $errorMessage));
return $coverFishResult;
} | php | public function setValidationError(CoverFishResult $coverFishResult, $errorCode, $errorMessage = null)
{
// skip validation if incoming mapping result is already invalid!
if (false === $coverFishResult->isPass()) {
return $coverFishResult;
}
$coverFishResult->setPass(false);
$coverFishResult->addError(new CoverFishMessageError($errorCode, $errorMessage));
return $coverFishResult;
} | [
"public",
"function",
"setValidationError",
"(",
"CoverFishResult",
"$",
"coverFishResult",
",",
"$",
"errorCode",
",",
"$",
"errorMessage",
"=",
"null",
")",
"{",
"// skip validation if incoming mapping result is already invalid!",
"if",
"(",
"false",
"===",
"$",
"coverFishResult",
"->",
"isPass",
"(",
")",
")",
"{",
"return",
"$",
"coverFishResult",
";",
"}",
"$",
"coverFishResult",
"->",
"setPass",
"(",
"false",
")",
";",
"$",
"coverFishResult",
"->",
"addError",
"(",
"new",
"CoverFishMessageError",
"(",
"$",
"errorCode",
",",
"$",
"errorMessage",
")",
")",
";",
"return",
"$",
"coverFishResult",
";",
"}"
]
| @param CoverFishResult $coverFishResult
@param int $errorCode
@param string|null $errorMessage
@return CoverFishResult | [
"@param",
"CoverFishResult",
"$coverFishResult",
"@param",
"int",
"$errorCode",
"@param",
"string|null",
"$errorMessage"
]
| train | https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Validator/Base/BaseCoverFishValidator.php#L480-L491 |
dunkelfrosch/phpcoverfish | src/PHPCoverFish/Validator/Base/BaseCoverFishValidator.php | BaseCoverFishValidator.setValidationWarning | public function setValidationWarning(CoverFishResult $coverFishResult, $warningCode, $warningMessage = null)
{
$coverFishResult->addWarning(new CoverFishMessageWarning($warningCode, $warningMessage));
return $coverFishResult;
} | php | public function setValidationWarning(CoverFishResult $coverFishResult, $warningCode, $warningMessage = null)
{
$coverFishResult->addWarning(new CoverFishMessageWarning($warningCode, $warningMessage));
return $coverFishResult;
} | [
"public",
"function",
"setValidationWarning",
"(",
"CoverFishResult",
"$",
"coverFishResult",
",",
"$",
"warningCode",
",",
"$",
"warningMessage",
"=",
"null",
")",
"{",
"$",
"coverFishResult",
"->",
"addWarning",
"(",
"new",
"CoverFishMessageWarning",
"(",
"$",
"warningCode",
",",
"$",
"warningMessage",
")",
")",
";",
"return",
"$",
"coverFishResult",
";",
"}"
]
| @param CoverFishResult $coverFishResult
@param int $warningCode
@param string|null $warningMessage
@return CoverFishResult | [
"@param",
"CoverFishResult",
"$coverFishResult",
"@param",
"int",
"$warningCode",
"@param",
"string|null",
"$warningMessage"
]
| train | https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Validator/Base/BaseCoverFishValidator.php#L500-L505 |
dunkelfrosch/phpcoverfish | src/PHPCoverFish/Validator/Base/BaseCoverFishValidator.php | BaseCoverFishValidator.getReflectionClass | public function getReflectionClass($classFQN)
{
try {
$reflectionClass = new \ReflectionClass($classFQN);
} catch (\ReflectionException $re) {
return new CoverFishMessageError(CoverFishMessageError::PHPUNIT_REFLECTION_CLASS_NOT_FOUND, $classFQN);
}
return $reflectionClass;
} | php | public function getReflectionClass($classFQN)
{
try {
$reflectionClass = new \ReflectionClass($classFQN);
} catch (\ReflectionException $re) {
return new CoverFishMessageError(CoverFishMessageError::PHPUNIT_REFLECTION_CLASS_NOT_FOUND, $classFQN);
}
return $reflectionClass;
} | [
"public",
"function",
"getReflectionClass",
"(",
"$",
"classFQN",
")",
"{",
"try",
"{",
"$",
"reflectionClass",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"classFQN",
")",
";",
"}",
"catch",
"(",
"\\",
"ReflectionException",
"$",
"re",
")",
"{",
"return",
"new",
"CoverFishMessageError",
"(",
"CoverFishMessageError",
"::",
"PHPUNIT_REFLECTION_CLASS_NOT_FOUND",
",",
"$",
"classFQN",
")",
";",
"}",
"return",
"$",
"reflectionClass",
";",
"}"
]
| @param string $classFQN
@return CoverFishMessageError|\ReflectionClass | [
"@param",
"string",
"$classFQN"
]
| train | https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Validator/Base/BaseCoverFishValidator.php#L512-L521 |
yuncms/framework | src/notifications/channels/DatabaseChannel.php | DatabaseChannel.send | public function send(NotifiableInterface $notifiable, Notification $notification)
{
/** @var ActiveRecord $modelClass */
$notifiable = $notifiable->routeNotificationFor('database');
return DatabaseNotification::create([
'id' => $notification->id,
'verb' => $notification->verb,
'template' => $notification->getTemplate(),
'notifiable_id' => $notifiable['notifiable_id'],
'notifiable_class' => $notifiable['notifiable_class'],
'data' => $notification->getData(),
]);
} | php | public function send(NotifiableInterface $notifiable, Notification $notification)
{
/** @var ActiveRecord $modelClass */
$notifiable = $notifiable->routeNotificationFor('database');
return DatabaseNotification::create([
'id' => $notification->id,
'verb' => $notification->verb,
'template' => $notification->getTemplate(),
'notifiable_id' => $notifiable['notifiable_id'],
'notifiable_class' => $notifiable['notifiable_class'],
'data' => $notification->getData(),
]);
} | [
"public",
"function",
"send",
"(",
"NotifiableInterface",
"$",
"notifiable",
",",
"Notification",
"$",
"notification",
")",
"{",
"/** @var ActiveRecord $modelClass */",
"$",
"notifiable",
"=",
"$",
"notifiable",
"->",
"routeNotificationFor",
"(",
"'database'",
")",
";",
"return",
"DatabaseNotification",
"::",
"create",
"(",
"[",
"'id'",
"=>",
"$",
"notification",
"->",
"id",
",",
"'verb'",
"=>",
"$",
"notification",
"->",
"verb",
",",
"'template'",
"=>",
"$",
"notification",
"->",
"getTemplate",
"(",
")",
",",
"'notifiable_id'",
"=>",
"$",
"notifiable",
"[",
"'notifiable_id'",
"]",
",",
"'notifiable_class'",
"=>",
"$",
"notifiable",
"[",
"'notifiable_class'",
"]",
",",
"'data'",
"=>",
"$",
"notification",
"->",
"getData",
"(",
")",
",",
"]",
")",
";",
"}"
]
| Send the given notification.
@param NotifiableInterface $notifiable
@param Notification $notification
@return mixed | [
"Send",
"the",
"given",
"notification",
"."
]
| train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/notifications/channels/DatabaseChannel.php#L31-L44 |
maniaplanet/matchmaking-lobby | MatchMakingLobby/GUI/AbstractGUI.php | AbstractGUI.createLabel | final function createLabel($message, $login = null, $countdown = null, $isAnimated = false, $hideOnF6 = true, $showBackgroud = false)
{
$this->removeLabel($login);
$ui = Windows\Label::Create($login);
$ui->setPosition(0, 40);
$ui->setMessage($message, $countdown);
$ui->animated = $isAnimated;
$ui->hideOnF6 = $hideOnF6;
$ui->showBackground = $showBackgroud;
$ui->show();
} | php | final function createLabel($message, $login = null, $countdown = null, $isAnimated = false, $hideOnF6 = true, $showBackgroud = false)
{
$this->removeLabel($login);
$ui = Windows\Label::Create($login);
$ui->setPosition(0, 40);
$ui->setMessage($message, $countdown);
$ui->animated = $isAnimated;
$ui->hideOnF6 = $hideOnF6;
$ui->showBackground = $showBackgroud;
$ui->show();
} | [
"final",
"function",
"createLabel",
"(",
"$",
"message",
",",
"$",
"login",
"=",
"null",
",",
"$",
"countdown",
"=",
"null",
",",
"$",
"isAnimated",
"=",
"false",
",",
"$",
"hideOnF6",
"=",
"true",
",",
"$",
"showBackgroud",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"removeLabel",
"(",
"$",
"login",
")",
";",
"$",
"ui",
"=",
"Windows",
"\\",
"Label",
"::",
"Create",
"(",
"$",
"login",
")",
";",
"$",
"ui",
"->",
"setPosition",
"(",
"0",
",",
"40",
")",
";",
"$",
"ui",
"->",
"setMessage",
"(",
"$",
"message",
",",
"$",
"countdown",
")",
";",
"$",
"ui",
"->",
"animated",
"=",
"$",
"isAnimated",
";",
"$",
"ui",
"->",
"hideOnF6",
"=",
"$",
"hideOnF6",
";",
"$",
"ui",
"->",
"showBackground",
"=",
"$",
"showBackgroud",
";",
"$",
"ui",
"->",
"show",
"(",
")",
";",
"}"
]
| Display a text message in the center of the player's screen
If countdown is set, the message will be refresh every second the end of the countdown
@param string $login
@param string $message
@param int $countdown
@param bool $isAnimated If true the text will be animated | [
"Display",
"a",
"text",
"message",
"in",
"the",
"center",
"of",
"the",
"player",
"s",
"screen",
"If",
"countdown",
"is",
"set",
"the",
"message",
"will",
"be",
"refresh",
"every",
"second",
"the",
"end",
"of",
"the",
"countdown"
]
| train | https://github.com/maniaplanet/matchmaking-lobby/blob/384f22cdd2cfb0204a071810549eaf1eb01d8b7f/MatchMakingLobby/GUI/AbstractGUI.php#L190-L200 |
maniaplanet/matchmaking-lobby | MatchMakingLobby/GUI/AbstractGUI.php | AbstractGUI.updateLobbyWindow | final function updateLobbyWindow($serverName, $playersCount, $playingPlayersCount, $averageTime)
{
$lobbyWindow = Windows\LobbyWindow::Create();
Windows\LobbyWindow::setServerName($serverName);
Windows\LobbyWindow::setAverageWaitingTime($averageTime == -1 ? -1 : ceil($averageTime/60));
Windows\LobbyWindow::setPlayingPlayerCount($playingPlayersCount);
Windows\LobbyWindow::setReadyPlayerCount($playersCount);
$lobbyWindow->show();
} | php | final function updateLobbyWindow($serverName, $playersCount, $playingPlayersCount, $averageTime)
{
$lobbyWindow = Windows\LobbyWindow::Create();
Windows\LobbyWindow::setServerName($serverName);
Windows\LobbyWindow::setAverageWaitingTime($averageTime == -1 ? -1 : ceil($averageTime/60));
Windows\LobbyWindow::setPlayingPlayerCount($playingPlayersCount);
Windows\LobbyWindow::setReadyPlayerCount($playersCount);
$lobbyWindow->show();
} | [
"final",
"function",
"updateLobbyWindow",
"(",
"$",
"serverName",
",",
"$",
"playersCount",
",",
"$",
"playingPlayersCount",
",",
"$",
"averageTime",
")",
"{",
"$",
"lobbyWindow",
"=",
"Windows",
"\\",
"LobbyWindow",
"::",
"Create",
"(",
")",
";",
"Windows",
"\\",
"LobbyWindow",
"::",
"setServerName",
"(",
"$",
"serverName",
")",
";",
"Windows",
"\\",
"LobbyWindow",
"::",
"setAverageWaitingTime",
"(",
"$",
"averageTime",
"==",
"-",
"1",
"?",
"-",
"1",
":",
"ceil",
"(",
"$",
"averageTime",
"/",
"60",
")",
")",
";",
"Windows",
"\\",
"LobbyWindow",
"::",
"setPlayingPlayerCount",
"(",
"$",
"playingPlayersCount",
")",
";",
"Windows",
"\\",
"LobbyWindow",
"::",
"setReadyPlayerCount",
"(",
"$",
"playersCount",
")",
";",
"$",
"lobbyWindow",
"->",
"show",
"(",
")",
";",
"}"
]
| Display the lobby Window on the right of the screen
@param string $serverName
@param int $playersCount Number of players ready on the lobby
@param int $totalPlayerCount Total number of player on the matchmaking system
@param int $playingPlayersCount Number of player in match | [
"Display",
"the",
"lobby",
"Window",
"on",
"the",
"right",
"of",
"the",
"screen"
]
| train | https://github.com/maniaplanet/matchmaking-lobby/blob/384f22cdd2cfb0204a071810549eaf1eb01d8b7f/MatchMakingLobby/GUI/AbstractGUI.php#L269-L277 |
maniaplanet/matchmaking-lobby | MatchMakingLobby/GUI/AbstractGUI.php | AbstractGUI.updatePlayerList | final function updatePlayerList(array $blockedPlayerList, $setLocalAllyAction, $unsetLocalAllyAction, $maxAllyCount, $player = '')
{
if($player)
{
$playerLists = Windows\PlayerList::Get($player);
}
else
{
$playerLists = Windows\PlayerList::GetAll();
}
foreach($playerLists as $playerList)
{
$recipient = $playerList->getRecipient();
$allies = \ManiaLivePlugins\MatchMakingLobby\Services\AllyService::getInstance()->getAll($recipient);
$loginsWithUnsetAction = array_map(function (\ManiaLivePlugins\MatchMakingLobby\Services\Ally $a)
{
if($a->type == \ManiaLivePlugins\MatchMakingLobby\Services\Ally::TYPE_LOCAL)
{
return $a->login;
}
}, $allies);
$loginsWithNoAction = array_map(function (\ManiaLivePlugins\MatchMakingLobby\Services\Ally $a)
{
if($a->type == \ManiaLivePlugins\MatchMakingLobby\Services\Ally::TYPE_GENERAL)
{
return $a->login;
}
}, $allies);
$bilateralAllies = array_map(function (\ManiaLivePlugins\MatchMakingLobby\Services\Ally $a)
{
if($a->isBilateral)
{
return $a->login;
}
}, $allies);
$storage = Storage::getInstance();
foreach(array_merge($storage->players, $storage->spectators) as $player)
{
if(PlayerInfo::Get($player->login)->isAway())
{
continue;
}
$ladderPoints = $player->ladderStats['PlayerRankings'][0]['Score'];
$playerInfo = PlayerInfo::Get($player->login);
$state = Player::STATE_NOT_READY;
if($playerInfo->isReady()) $state = Player::STATE_READY;
if($playerInfo->isInMatch) $state = Player::STATE_IN_MATCH;
if(array_key_exists($player->login, $blockedPlayerList)) $state = Player::STATE_BLOCKED;
if($player->login == $recipient)
{
$action = null;
$isAlly = false;
}
elseif(in_array($player->login, $loginsWithNoAction))
{
$action = null;
$isAlly = true;
}
elseif(in_array($player->login, $loginsWithUnsetAction))
{
$action = $unsetLocalAllyAction;
$isAlly = true;
}
else
{
$action = (count($allies) >= $maxAllyCount ? null : $setLocalAllyAction);
$isAlly = false;
}
$isBilateral = in_array($player->login, $bilateralAllies);
$playerList->setPlayer($player->login, $player->nickName, $ladderPoints, $state, $action, $isAlly, $isBilateral);
}
}
Windows\PlayerList::RedrawAll();
} | php | final function updatePlayerList(array $blockedPlayerList, $setLocalAllyAction, $unsetLocalAllyAction, $maxAllyCount, $player = '')
{
if($player)
{
$playerLists = Windows\PlayerList::Get($player);
}
else
{
$playerLists = Windows\PlayerList::GetAll();
}
foreach($playerLists as $playerList)
{
$recipient = $playerList->getRecipient();
$allies = \ManiaLivePlugins\MatchMakingLobby\Services\AllyService::getInstance()->getAll($recipient);
$loginsWithUnsetAction = array_map(function (\ManiaLivePlugins\MatchMakingLobby\Services\Ally $a)
{
if($a->type == \ManiaLivePlugins\MatchMakingLobby\Services\Ally::TYPE_LOCAL)
{
return $a->login;
}
}, $allies);
$loginsWithNoAction = array_map(function (\ManiaLivePlugins\MatchMakingLobby\Services\Ally $a)
{
if($a->type == \ManiaLivePlugins\MatchMakingLobby\Services\Ally::TYPE_GENERAL)
{
return $a->login;
}
}, $allies);
$bilateralAllies = array_map(function (\ManiaLivePlugins\MatchMakingLobby\Services\Ally $a)
{
if($a->isBilateral)
{
return $a->login;
}
}, $allies);
$storage = Storage::getInstance();
foreach(array_merge($storage->players, $storage->spectators) as $player)
{
if(PlayerInfo::Get($player->login)->isAway())
{
continue;
}
$ladderPoints = $player->ladderStats['PlayerRankings'][0]['Score'];
$playerInfo = PlayerInfo::Get($player->login);
$state = Player::STATE_NOT_READY;
if($playerInfo->isReady()) $state = Player::STATE_READY;
if($playerInfo->isInMatch) $state = Player::STATE_IN_MATCH;
if(array_key_exists($player->login, $blockedPlayerList)) $state = Player::STATE_BLOCKED;
if($player->login == $recipient)
{
$action = null;
$isAlly = false;
}
elseif(in_array($player->login, $loginsWithNoAction))
{
$action = null;
$isAlly = true;
}
elseif(in_array($player->login, $loginsWithUnsetAction))
{
$action = $unsetLocalAllyAction;
$isAlly = true;
}
else
{
$action = (count($allies) >= $maxAllyCount ? null : $setLocalAllyAction);
$isAlly = false;
}
$isBilateral = in_array($player->login, $bilateralAllies);
$playerList->setPlayer($player->login, $player->nickName, $ladderPoints, $state, $action, $isAlly, $isBilateral);
}
}
Windows\PlayerList::RedrawAll();
} | [
"final",
"function",
"updatePlayerList",
"(",
"array",
"$",
"blockedPlayerList",
",",
"$",
"setLocalAllyAction",
",",
"$",
"unsetLocalAllyAction",
",",
"$",
"maxAllyCount",
",",
"$",
"player",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"player",
")",
"{",
"$",
"playerLists",
"=",
"Windows",
"\\",
"PlayerList",
"::",
"Get",
"(",
"$",
"player",
")",
";",
"}",
"else",
"{",
"$",
"playerLists",
"=",
"Windows",
"\\",
"PlayerList",
"::",
"GetAll",
"(",
")",
";",
"}",
"foreach",
"(",
"$",
"playerLists",
"as",
"$",
"playerList",
")",
"{",
"$",
"recipient",
"=",
"$",
"playerList",
"->",
"getRecipient",
"(",
")",
";",
"$",
"allies",
"=",
"\\",
"ManiaLivePlugins",
"\\",
"MatchMakingLobby",
"\\",
"Services",
"\\",
"AllyService",
"::",
"getInstance",
"(",
")",
"->",
"getAll",
"(",
"$",
"recipient",
")",
";",
"$",
"loginsWithUnsetAction",
"=",
"array_map",
"(",
"function",
"(",
"\\",
"ManiaLivePlugins",
"\\",
"MatchMakingLobby",
"\\",
"Services",
"\\",
"Ally",
"$",
"a",
")",
"{",
"if",
"(",
"$",
"a",
"->",
"type",
"==",
"\\",
"ManiaLivePlugins",
"\\",
"MatchMakingLobby",
"\\",
"Services",
"\\",
"Ally",
"::",
"TYPE_LOCAL",
")",
"{",
"return",
"$",
"a",
"->",
"login",
";",
"}",
"}",
",",
"$",
"allies",
")",
";",
"$",
"loginsWithNoAction",
"=",
"array_map",
"(",
"function",
"(",
"\\",
"ManiaLivePlugins",
"\\",
"MatchMakingLobby",
"\\",
"Services",
"\\",
"Ally",
"$",
"a",
")",
"{",
"if",
"(",
"$",
"a",
"->",
"type",
"==",
"\\",
"ManiaLivePlugins",
"\\",
"MatchMakingLobby",
"\\",
"Services",
"\\",
"Ally",
"::",
"TYPE_GENERAL",
")",
"{",
"return",
"$",
"a",
"->",
"login",
";",
"}",
"}",
",",
"$",
"allies",
")",
";",
"$",
"bilateralAllies",
"=",
"array_map",
"(",
"function",
"(",
"\\",
"ManiaLivePlugins",
"\\",
"MatchMakingLobby",
"\\",
"Services",
"\\",
"Ally",
"$",
"a",
")",
"{",
"if",
"(",
"$",
"a",
"->",
"isBilateral",
")",
"{",
"return",
"$",
"a",
"->",
"login",
";",
"}",
"}",
",",
"$",
"allies",
")",
";",
"$",
"storage",
"=",
"Storage",
"::",
"getInstance",
"(",
")",
";",
"foreach",
"(",
"array_merge",
"(",
"$",
"storage",
"->",
"players",
",",
"$",
"storage",
"->",
"spectators",
")",
"as",
"$",
"player",
")",
"{",
"if",
"(",
"PlayerInfo",
"::",
"Get",
"(",
"$",
"player",
"->",
"login",
")",
"->",
"isAway",
"(",
")",
")",
"{",
"continue",
";",
"}",
"$",
"ladderPoints",
"=",
"$",
"player",
"->",
"ladderStats",
"[",
"'PlayerRankings'",
"]",
"[",
"0",
"]",
"[",
"'Score'",
"]",
";",
"$",
"playerInfo",
"=",
"PlayerInfo",
"::",
"Get",
"(",
"$",
"player",
"->",
"login",
")",
";",
"$",
"state",
"=",
"Player",
"::",
"STATE_NOT_READY",
";",
"if",
"(",
"$",
"playerInfo",
"->",
"isReady",
"(",
")",
")",
"$",
"state",
"=",
"Player",
"::",
"STATE_READY",
";",
"if",
"(",
"$",
"playerInfo",
"->",
"isInMatch",
")",
"$",
"state",
"=",
"Player",
"::",
"STATE_IN_MATCH",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"player",
"->",
"login",
",",
"$",
"blockedPlayerList",
")",
")",
"$",
"state",
"=",
"Player",
"::",
"STATE_BLOCKED",
";",
"if",
"(",
"$",
"player",
"->",
"login",
"==",
"$",
"recipient",
")",
"{",
"$",
"action",
"=",
"null",
";",
"$",
"isAlly",
"=",
"false",
";",
"}",
"elseif",
"(",
"in_array",
"(",
"$",
"player",
"->",
"login",
",",
"$",
"loginsWithNoAction",
")",
")",
"{",
"$",
"action",
"=",
"null",
";",
"$",
"isAlly",
"=",
"true",
";",
"}",
"elseif",
"(",
"in_array",
"(",
"$",
"player",
"->",
"login",
",",
"$",
"loginsWithUnsetAction",
")",
")",
"{",
"$",
"action",
"=",
"$",
"unsetLocalAllyAction",
";",
"$",
"isAlly",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"action",
"=",
"(",
"count",
"(",
"$",
"allies",
")",
">=",
"$",
"maxAllyCount",
"?",
"null",
":",
"$",
"setLocalAllyAction",
")",
";",
"$",
"isAlly",
"=",
"false",
";",
"}",
"$",
"isBilateral",
"=",
"in_array",
"(",
"$",
"player",
"->",
"login",
",",
"$",
"bilateralAllies",
")",
";",
"$",
"playerList",
"->",
"setPlayer",
"(",
"$",
"player",
"->",
"login",
",",
"$",
"player",
"->",
"nickName",
",",
"$",
"ladderPoints",
",",
"$",
"state",
",",
"$",
"action",
",",
"$",
"isAlly",
",",
"$",
"isBilateral",
")",
";",
"}",
"}",
"Windows",
"\\",
"PlayerList",
"::",
"RedrawAll",
"(",
")",
";",
"}"
]
| update the Player list
@param string $login
@param string[] $blockedPlayerList | [
"update",
"the",
"Player",
"list"
]
| train | https://github.com/maniaplanet/matchmaking-lobby/blob/384f22cdd2cfb0204a071810549eaf1eb01d8b7f/MatchMakingLobby/GUI/AbstractGUI.php#L377-L454 |
maniaplanet/matchmaking-lobby | MatchMakingLobby/GUI/AbstractGUI.php | AbstractGUI.removePlayerFromPlayerList | final function removePlayerFromPlayerList($login)
{
Windows\PlayerList::Erase($login);
$playerLists = Windows\PlayerList::GetAll();
foreach($playerLists as $playerList)
{
$playerList->removePlayer($login);
}
Windows\PlayerList::RedrawAll();
} | php | final function removePlayerFromPlayerList($login)
{
Windows\PlayerList::Erase($login);
$playerLists = Windows\PlayerList::GetAll();
foreach($playerLists as $playerList)
{
$playerList->removePlayer($login);
}
Windows\PlayerList::RedrawAll();
} | [
"final",
"function",
"removePlayerFromPlayerList",
"(",
"$",
"login",
")",
"{",
"Windows",
"\\",
"PlayerList",
"::",
"Erase",
"(",
"$",
"login",
")",
";",
"$",
"playerLists",
"=",
"Windows",
"\\",
"PlayerList",
"::",
"GetAll",
"(",
")",
";",
"foreach",
"(",
"$",
"playerLists",
"as",
"$",
"playerList",
")",
"{",
"$",
"playerList",
"->",
"removePlayer",
"(",
"$",
"login",
")",
";",
"}",
"Windows",
"\\",
"PlayerList",
"::",
"RedrawAll",
"(",
")",
";",
"}"
]
| Remove a player from the playerlist and destroy his list
@param string $login | [
"Remove",
"a",
"player",
"from",
"the",
"playerlist",
"and",
"destroy",
"his",
"list"
]
| train | https://github.com/maniaplanet/matchmaking-lobby/blob/384f22cdd2cfb0204a071810549eaf1eb01d8b7f/MatchMakingLobby/GUI/AbstractGUI.php#L460-L469 |
qcubed/orm | src/Database/DatabaseBase.php | DatabaseBase.transactionCommit | public final function transactionCommit()
{
if (1 == $this->intTransactionDepth) {
$this->executeTransactionCommit();
}
if ($this->intTransactionDepth <= 0) {
throw new Caller("The transaction commit call is called before the transaction begin was called.");
}
$this->intTransactionDepth--;
} | php | public final function transactionCommit()
{
if (1 == $this->intTransactionDepth) {
$this->executeTransactionCommit();
}
if ($this->intTransactionDepth <= 0) {
throw new Caller("The transaction commit call is called before the transaction begin was called.");
}
$this->intTransactionDepth--;
} | [
"public",
"final",
"function",
"transactionCommit",
"(",
")",
"{",
"if",
"(",
"1",
"==",
"$",
"this",
"->",
"intTransactionDepth",
")",
"{",
"$",
"this",
"->",
"executeTransactionCommit",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"intTransactionDepth",
"<=",
"0",
")",
"{",
"throw",
"new",
"Caller",
"(",
"\"The transaction commit call is called before the transaction begin was called.\"",
")",
";",
"}",
"$",
"this",
"->",
"intTransactionDepth",
"--",
";",
"}"
]
| This function commits the database transaction.
@throws Caller
@return void Nothing | [
"This",
"function",
"commits",
"the",
"database",
"transaction",
"."
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Database/DatabaseBase.php#L217-L226 |
qcubed/orm | src/Database/DatabaseBase.php | DatabaseBase.escapeIdentifiers | public function escapeIdentifiers($mixIdentifiers)
{
if (is_array($mixIdentifiers)) {
return array_map(array($this, 'EscapeIdentifier'), $mixIdentifiers);
} else {
return $this->escapeIdentifier($mixIdentifiers);
}
} | php | public function escapeIdentifiers($mixIdentifiers)
{
if (is_array($mixIdentifiers)) {
return array_map(array($this, 'EscapeIdentifier'), $mixIdentifiers);
} else {
return $this->escapeIdentifier($mixIdentifiers);
}
} | [
"public",
"function",
"escapeIdentifiers",
"(",
"$",
"mixIdentifiers",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"mixIdentifiers",
")",
")",
"{",
"return",
"array_map",
"(",
"array",
"(",
"$",
"this",
",",
"'EscapeIdentifier'",
")",
",",
"$",
"mixIdentifiers",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"escapeIdentifier",
"(",
"$",
"mixIdentifiers",
")",
";",
"}",
"}"
]
| Given an array of identifiers, this method returns array of escaped identifiers
For corner case handling, if a single identifier is supplied, a single escaped identifier is returned
@param array|string $mixIdentifiers Array of escaped identifiers (array) or one unescaped identifier (string)
@return array|string Array of escaped identifiers (array) or one escaped identifier (string) | [
"Given",
"an",
"array",
"of",
"identifiers",
"this",
"method",
"returns",
"array",
"of",
"escaped",
"identifiers",
"For",
"corner",
"case",
"handling",
"if",
"a",
"single",
"identifier",
"is",
"supplied",
"a",
"single",
"escaped",
"identifier",
"is",
"returned"
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Database/DatabaseBase.php#L272-L279 |
qcubed/orm | src/Database/DatabaseBase.php | DatabaseBase.escapeValues | public function escapeValues($mixValues)
{
if (is_array($mixValues)) {
return array_map(array($this, 'SqlVariable'), $mixValues);
} else {
return $this->sqlVariable($mixValues);
}
} | php | public function escapeValues($mixValues)
{
if (is_array($mixValues)) {
return array_map(array($this, 'SqlVariable'), $mixValues);
} else {
return $this->sqlVariable($mixValues);
}
} | [
"public",
"function",
"escapeValues",
"(",
"$",
"mixValues",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"mixValues",
")",
")",
"{",
"return",
"array_map",
"(",
"array",
"(",
"$",
"this",
",",
"'SqlVariable'",
")",
",",
"$",
"mixValues",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"sqlVariable",
"(",
"$",
"mixValues",
")",
";",
"}",
"}"
]
| Escapes values (or single value) which we can then send to the database
@param array|mixed $mixValues Array of values (or a single value) to be escaped
@return array|string Array of (or a single) escaped value(s) | [
"Escapes",
"values",
"(",
"or",
"single",
"value",
")",
"which",
"we",
"can",
"then",
"send",
"to",
"the",
"database"
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Database/DatabaseBase.php#L288-L295 |
qcubed/orm | src/Database/DatabaseBase.php | DatabaseBase.escapeIdentifiersAndValues | public function escapeIdentifiersAndValues($mixColumnsAndValuesArray)
{
$result = array();
foreach ($mixColumnsAndValuesArray as $strColumn => $mixValue) {
$result[$this->escapeIdentifier($strColumn)] = $this->sqlVariable($mixValue);
}
return $result;
} | php | public function escapeIdentifiersAndValues($mixColumnsAndValuesArray)
{
$result = array();
foreach ($mixColumnsAndValuesArray as $strColumn => $mixValue) {
$result[$this->escapeIdentifier($strColumn)] = $this->sqlVariable($mixValue);
}
return $result;
} | [
"public",
"function",
"escapeIdentifiersAndValues",
"(",
"$",
"mixColumnsAndValuesArray",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"mixColumnsAndValuesArray",
"as",
"$",
"strColumn",
"=>",
"$",
"mixValue",
")",
"{",
"$",
"result",
"[",
"$",
"this",
"->",
"escapeIdentifier",
"(",
"$",
"strColumn",
")",
"]",
"=",
"$",
"this",
"->",
"sqlVariable",
"(",
"$",
"mixValue",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
]
| Escapes both column and values when supplied as an array
@param array $mixColumnsAndValuesArray Array with column=>value format with both (column and value) sides unescaped
@return array Array with column=>value format data with both column and value escaped | [
"Escapes",
"both",
"column",
"and",
"values",
"when",
"supplied",
"as",
"an",
"array"
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Database/DatabaseBase.php#L304-L311 |
qcubed/orm | src/Database/DatabaseBase.php | DatabaseBase.insertOrUpdate | public function insertOrUpdate($strTable, $mixColumnsAndValuesArray, $strPKNames = null)
{
$strEscapedArray = $this->escapeIdentifiersAndValues($mixColumnsAndValuesArray);
$strColumns = array_keys($strEscapedArray);
$strUpdateStatement = '';
foreach ($strEscapedArray as $strColumn => $strValue) {
if ($strUpdateStatement) {
$strUpdateStatement .= ', ';
}
$strUpdateStatement .= $strColumn . ' = ' . $strValue;
}
if (is_null($strPKNames)) {
$strMatchCondition = 'target_.' . $strColumns[0] . ' = source_.' . $strColumns[0];
} else {
if (is_array($strPKNames)) {
$strMatchCondition = '';
foreach ($strPKNames as $strPKName) {
if ($strMatchCondition) {
$strMatchCondition .= ' AND ';
}
$strMatchCondition .= 'target_.' . $this->escapeIdentifier($strPKName) . ' = source_.' . $this->escapeIdentifier($strPKName);
}
} else {
$strMatchCondition = 'target_.' . $this->escapeIdentifier($strPKNames) . ' = source_.' . $this->escapeIdentifier($strPKNames);
}
}
$strTable = $this->EscapeIdentifierBegin . $strTable . $this->EscapeIdentifierEnd;
$strSql = sprintf('MERGE INTO %s AS target_ USING %s AS source_ ON %s WHEN MATCHED THEN UPDATE SET %s WHEN NOT MATCHED THEN INSERT (%s) VALUES (%s)',
$strTable, $strTable,
$strMatchCondition, $strUpdateStatement,
implode(', ', $strColumns),
implode(', ', array_values($strEscapedArray))
);
$this->executeNonQuery($strSql);
} | php | public function insertOrUpdate($strTable, $mixColumnsAndValuesArray, $strPKNames = null)
{
$strEscapedArray = $this->escapeIdentifiersAndValues($mixColumnsAndValuesArray);
$strColumns = array_keys($strEscapedArray);
$strUpdateStatement = '';
foreach ($strEscapedArray as $strColumn => $strValue) {
if ($strUpdateStatement) {
$strUpdateStatement .= ', ';
}
$strUpdateStatement .= $strColumn . ' = ' . $strValue;
}
if (is_null($strPKNames)) {
$strMatchCondition = 'target_.' . $strColumns[0] . ' = source_.' . $strColumns[0];
} else {
if (is_array($strPKNames)) {
$strMatchCondition = '';
foreach ($strPKNames as $strPKName) {
if ($strMatchCondition) {
$strMatchCondition .= ' AND ';
}
$strMatchCondition .= 'target_.' . $this->escapeIdentifier($strPKName) . ' = source_.' . $this->escapeIdentifier($strPKName);
}
} else {
$strMatchCondition = 'target_.' . $this->escapeIdentifier($strPKNames) . ' = source_.' . $this->escapeIdentifier($strPKNames);
}
}
$strTable = $this->EscapeIdentifierBegin . $strTable . $this->EscapeIdentifierEnd;
$strSql = sprintf('MERGE INTO %s AS target_ USING %s AS source_ ON %s WHEN MATCHED THEN UPDATE SET %s WHEN NOT MATCHED THEN INSERT (%s) VALUES (%s)',
$strTable, $strTable,
$strMatchCondition, $strUpdateStatement,
implode(', ', $strColumns),
implode(', ', array_values($strEscapedArray))
);
$this->executeNonQuery($strSql);
} | [
"public",
"function",
"insertOrUpdate",
"(",
"$",
"strTable",
",",
"$",
"mixColumnsAndValuesArray",
",",
"$",
"strPKNames",
"=",
"null",
")",
"{",
"$",
"strEscapedArray",
"=",
"$",
"this",
"->",
"escapeIdentifiersAndValues",
"(",
"$",
"mixColumnsAndValuesArray",
")",
";",
"$",
"strColumns",
"=",
"array_keys",
"(",
"$",
"strEscapedArray",
")",
";",
"$",
"strUpdateStatement",
"=",
"''",
";",
"foreach",
"(",
"$",
"strEscapedArray",
"as",
"$",
"strColumn",
"=>",
"$",
"strValue",
")",
"{",
"if",
"(",
"$",
"strUpdateStatement",
")",
"{",
"$",
"strUpdateStatement",
".=",
"', '",
";",
"}",
"$",
"strUpdateStatement",
".=",
"$",
"strColumn",
".",
"' = '",
".",
"$",
"strValue",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"strPKNames",
")",
")",
"{",
"$",
"strMatchCondition",
"=",
"'target_.'",
".",
"$",
"strColumns",
"[",
"0",
"]",
".",
"' = source_.'",
".",
"$",
"strColumns",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"if",
"(",
"is_array",
"(",
"$",
"strPKNames",
")",
")",
"{",
"$",
"strMatchCondition",
"=",
"''",
";",
"foreach",
"(",
"$",
"strPKNames",
"as",
"$",
"strPKName",
")",
"{",
"if",
"(",
"$",
"strMatchCondition",
")",
"{",
"$",
"strMatchCondition",
".=",
"' AND '",
";",
"}",
"$",
"strMatchCondition",
".=",
"'target_.'",
".",
"$",
"this",
"->",
"escapeIdentifier",
"(",
"$",
"strPKName",
")",
".",
"' = source_.'",
".",
"$",
"this",
"->",
"escapeIdentifier",
"(",
"$",
"strPKName",
")",
";",
"}",
"}",
"else",
"{",
"$",
"strMatchCondition",
"=",
"'target_.'",
".",
"$",
"this",
"->",
"escapeIdentifier",
"(",
"$",
"strPKNames",
")",
".",
"' = source_.'",
".",
"$",
"this",
"->",
"escapeIdentifier",
"(",
"$",
"strPKNames",
")",
";",
"}",
"}",
"$",
"strTable",
"=",
"$",
"this",
"->",
"EscapeIdentifierBegin",
".",
"$",
"strTable",
".",
"$",
"this",
"->",
"EscapeIdentifierEnd",
";",
"$",
"strSql",
"=",
"sprintf",
"(",
"'MERGE INTO %s AS target_ USING %s AS source_ ON %s WHEN MATCHED THEN UPDATE SET %s WHEN NOT MATCHED THEN INSERT (%s) VALUES (%s)'",
",",
"$",
"strTable",
",",
"$",
"strTable",
",",
"$",
"strMatchCondition",
",",
"$",
"strUpdateStatement",
",",
"implode",
"(",
"', '",
",",
"$",
"strColumns",
")",
",",
"implode",
"(",
"', '",
",",
"array_values",
"(",
"$",
"strEscapedArray",
")",
")",
")",
";",
"$",
"this",
"->",
"executeNonQuery",
"(",
"$",
"strSql",
")",
";",
"}"
]
| INSERTs or UPDATEs a table
@param string $strTable Table name
@param array $mixColumnsAndValuesArray column=>value array
(they are given to 'EscapeIdentifiersAndValues' method)
@param null|string|array $strPKNames Name(s) of primary key column(s) (expressed as string or array) | [
"INSERTs",
"or",
"UPDATEs",
"a",
"table"
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Database/DatabaseBase.php#L321-L355 |
qcubed/orm | src/Database/DatabaseBase.php | DatabaseBase.query | public final function query($strQuery)
{
$timerName = null;
if (!$this->blnConnectedFlag) {
$this->connect();
}
if ($this->blnEnableProfiling) {
$timerName = 'queryExec' . mt_rand();
Timer::start($timerName);
}
$result = $this->executeQuery($strQuery);
if ($this->blnEnableProfiling) {
$dblQueryTime = Timer::stop($timerName);
Timer::reset($timerName);
// Log Query (for Profiling, if applicable)
$this->logQuery($strQuery, $dblQueryTime);
}
return $result;
} | php | public final function query($strQuery)
{
$timerName = null;
if (!$this->blnConnectedFlag) {
$this->connect();
}
if ($this->blnEnableProfiling) {
$timerName = 'queryExec' . mt_rand();
Timer::start($timerName);
}
$result = $this->executeQuery($strQuery);
if ($this->blnEnableProfiling) {
$dblQueryTime = Timer::stop($timerName);
Timer::reset($timerName);
// Log Query (for Profiling, if applicable)
$this->logQuery($strQuery, $dblQueryTime);
}
return $result;
} | [
"public",
"final",
"function",
"query",
"(",
"$",
"strQuery",
")",
"{",
"$",
"timerName",
"=",
"null",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"blnConnectedFlag",
")",
"{",
"$",
"this",
"->",
"connect",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"blnEnableProfiling",
")",
"{",
"$",
"timerName",
"=",
"'queryExec'",
".",
"mt_rand",
"(",
")",
";",
"Timer",
"::",
"start",
"(",
"$",
"timerName",
")",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"executeQuery",
"(",
"$",
"strQuery",
")",
";",
"if",
"(",
"$",
"this",
"->",
"blnEnableProfiling",
")",
"{",
"$",
"dblQueryTime",
"=",
"Timer",
"::",
"stop",
"(",
"$",
"timerName",
")",
";",
"Timer",
"::",
"reset",
"(",
"$",
"timerName",
")",
";",
"// Log Query (for Profiling, if applicable)",
"$",
"this",
"->",
"logQuery",
"(",
"$",
"strQuery",
",",
"$",
"dblQueryTime",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
]
| Sends the 'SELECT' query to the database and returns the result
@param string $strQuery query string
@return ResultBase | [
"Sends",
"the",
"SELECT",
"query",
"to",
"the",
"database",
"and",
"returns",
"the",
"result"
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Database/DatabaseBase.php#L364-L388 |
qcubed/orm | src/Database/DatabaseBase.php | DatabaseBase.nonQuery | public final function nonQuery($strNonQuery)
{
if (!$this->blnConnectedFlag) {
$this->connect();
}
$timerName = '';
if ($this->blnEnableProfiling) {
$timerName = 'queryExec' . mt_rand();
Timer::start($timerName);
}
$result = $this->executeNonQuery($strNonQuery);
if ($this->blnEnableProfiling) {
$dblQueryTime = Timer::stop($timerName);
Timer::reset($timerName);
// Log Query (for Profiling, if applicable)
$this->logQuery($strNonQuery, $dblQueryTime);
}
return $result;
} | php | public final function nonQuery($strNonQuery)
{
if (!$this->blnConnectedFlag) {
$this->connect();
}
$timerName = '';
if ($this->blnEnableProfiling) {
$timerName = 'queryExec' . mt_rand();
Timer::start($timerName);
}
$result = $this->executeNonQuery($strNonQuery);
if ($this->blnEnableProfiling) {
$dblQueryTime = Timer::stop($timerName);
Timer::reset($timerName);
// Log Query (for Profiling, if applicable)
$this->logQuery($strNonQuery, $dblQueryTime);
}
return $result;
} | [
"public",
"final",
"function",
"nonQuery",
"(",
"$",
"strNonQuery",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"blnConnectedFlag",
")",
"{",
"$",
"this",
"->",
"connect",
"(",
")",
";",
"}",
"$",
"timerName",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"blnEnableProfiling",
")",
"{",
"$",
"timerName",
"=",
"'queryExec'",
".",
"mt_rand",
"(",
")",
";",
"Timer",
"::",
"start",
"(",
"$",
"timerName",
")",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"executeNonQuery",
"(",
"$",
"strNonQuery",
")",
";",
"if",
"(",
"$",
"this",
"->",
"blnEnableProfiling",
")",
"{",
"$",
"dblQueryTime",
"=",
"Timer",
"::",
"stop",
"(",
"$",
"timerName",
")",
";",
"Timer",
"::",
"reset",
"(",
"$",
"timerName",
")",
";",
"// Log Query (for Profiling, if applicable)",
"$",
"this",
"->",
"logQuery",
"(",
"$",
"strNonQuery",
",",
"$",
"dblQueryTime",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
]
| This is basically the same as 'Query' but is used when SQL statements other than 'SELECT'
@param string $strNonQuery The SQL to be sent
@return mixed
@throws Caller | [
"This",
"is",
"basically",
"the",
"same",
"as",
"Query",
"but",
"is",
"used",
"when",
"SQL",
"statements",
"other",
"than",
"SELECT",
"@param",
"string",
"$strNonQuery",
"The",
"SQL",
"to",
"be",
"sent"
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Database/DatabaseBase.php#L397-L419 |
qcubed/orm | src/Database/DatabaseBase.php | DatabaseBase.logQuery | private function logQuery($strQuery, $dblQueryTime)
{
if ($this->blnEnableProfiling) {
// Dereference-ize Backtrace Information
$objDebugBacktrace = debug_backtrace();
// get rid of unnecessary backtrace info in case of:
// query
if ((count($objDebugBacktrace) > 3) &&
(array_key_exists('function', $objDebugBacktrace[2])) &&
(($objDebugBacktrace[2]['function'] == 'QueryArray') ||
($objDebugBacktrace[2]['function'] == 'QuerySingle') ||
($objDebugBacktrace[2]['function'] == 'QueryCount'))
) {
$objBacktrace = $objDebugBacktrace[3];
} else {
if (isset($objDebugBacktrace[2])) // non query
{
$objBacktrace = $objDebugBacktrace[2];
} else // ad hoc query
{
$objBacktrace = $objDebugBacktrace[1];
}
}
// get rid of reference to current object in backtrace array
if (isset($objBacktrace['object'])) {
$objBacktrace['object'] = null;
}
for ($intIndex = 0, $intMax = count($objBacktrace['args']); $intIndex < $intMax; $intIndex++) {
$obj = $objBacktrace['args'][$intIndex];
if (is_null($obj)) {
$obj = 'null';
} else {
if (gettype($obj) == 'integer') {
} else {
if (gettype($obj) == 'object') {
$obj = 'Object: ' . get_class($obj);
if (method_exists($obj, '__toString')) {
$obj .= '- ' . $obj;
}
} else {
if (is_array($obj)) {
$obj = 'Array';
} else {
$obj = sprintf("'%s'", $obj);
}
}
}
}
$objBacktrace['args'][$intIndex] = $obj;
}
// Push it onto the profiling information array
$arrProfile = array(
'objBacktrace' => $objBacktrace,
'strQuery' => $strQuery,
'dblTimeInfo' => $dblQueryTime
);
array_push($this->strProfileArray, $arrProfile);
}
} | php | private function logQuery($strQuery, $dblQueryTime)
{
if ($this->blnEnableProfiling) {
// Dereference-ize Backtrace Information
$objDebugBacktrace = debug_backtrace();
// get rid of unnecessary backtrace info in case of:
// query
if ((count($objDebugBacktrace) > 3) &&
(array_key_exists('function', $objDebugBacktrace[2])) &&
(($objDebugBacktrace[2]['function'] == 'QueryArray') ||
($objDebugBacktrace[2]['function'] == 'QuerySingle') ||
($objDebugBacktrace[2]['function'] == 'QueryCount'))
) {
$objBacktrace = $objDebugBacktrace[3];
} else {
if (isset($objDebugBacktrace[2])) // non query
{
$objBacktrace = $objDebugBacktrace[2];
} else // ad hoc query
{
$objBacktrace = $objDebugBacktrace[1];
}
}
// get rid of reference to current object in backtrace array
if (isset($objBacktrace['object'])) {
$objBacktrace['object'] = null;
}
for ($intIndex = 0, $intMax = count($objBacktrace['args']); $intIndex < $intMax; $intIndex++) {
$obj = $objBacktrace['args'][$intIndex];
if (is_null($obj)) {
$obj = 'null';
} else {
if (gettype($obj) == 'integer') {
} else {
if (gettype($obj) == 'object') {
$obj = 'Object: ' . get_class($obj);
if (method_exists($obj, '__toString')) {
$obj .= '- ' . $obj;
}
} else {
if (is_array($obj)) {
$obj = 'Array';
} else {
$obj = sprintf("'%s'", $obj);
}
}
}
}
$objBacktrace['args'][$intIndex] = $obj;
}
// Push it onto the profiling information array
$arrProfile = array(
'objBacktrace' => $objBacktrace,
'strQuery' => $strQuery,
'dblTimeInfo' => $dblQueryTime
);
array_push($this->strProfileArray, $arrProfile);
}
} | [
"private",
"function",
"logQuery",
"(",
"$",
"strQuery",
",",
"$",
"dblQueryTime",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"blnEnableProfiling",
")",
"{",
"// Dereference-ize Backtrace Information",
"$",
"objDebugBacktrace",
"=",
"debug_backtrace",
"(",
")",
";",
"// get rid of unnecessary backtrace info in case of:",
"// query",
"if",
"(",
"(",
"count",
"(",
"$",
"objDebugBacktrace",
")",
">",
"3",
")",
"&&",
"(",
"array_key_exists",
"(",
"'function'",
",",
"$",
"objDebugBacktrace",
"[",
"2",
"]",
")",
")",
"&&",
"(",
"(",
"$",
"objDebugBacktrace",
"[",
"2",
"]",
"[",
"'function'",
"]",
"==",
"'QueryArray'",
")",
"||",
"(",
"$",
"objDebugBacktrace",
"[",
"2",
"]",
"[",
"'function'",
"]",
"==",
"'QuerySingle'",
")",
"||",
"(",
"$",
"objDebugBacktrace",
"[",
"2",
"]",
"[",
"'function'",
"]",
"==",
"'QueryCount'",
")",
")",
")",
"{",
"$",
"objBacktrace",
"=",
"$",
"objDebugBacktrace",
"[",
"3",
"]",
";",
"}",
"else",
"{",
"if",
"(",
"isset",
"(",
"$",
"objDebugBacktrace",
"[",
"2",
"]",
")",
")",
"// non query",
"{",
"$",
"objBacktrace",
"=",
"$",
"objDebugBacktrace",
"[",
"2",
"]",
";",
"}",
"else",
"// ad hoc query",
"{",
"$",
"objBacktrace",
"=",
"$",
"objDebugBacktrace",
"[",
"1",
"]",
";",
"}",
"}",
"// get rid of reference to current object in backtrace array",
"if",
"(",
"isset",
"(",
"$",
"objBacktrace",
"[",
"'object'",
"]",
")",
")",
"{",
"$",
"objBacktrace",
"[",
"'object'",
"]",
"=",
"null",
";",
"}",
"for",
"(",
"$",
"intIndex",
"=",
"0",
",",
"$",
"intMax",
"=",
"count",
"(",
"$",
"objBacktrace",
"[",
"'args'",
"]",
")",
";",
"$",
"intIndex",
"<",
"$",
"intMax",
";",
"$",
"intIndex",
"++",
")",
"{",
"$",
"obj",
"=",
"$",
"objBacktrace",
"[",
"'args'",
"]",
"[",
"$",
"intIndex",
"]",
";",
"if",
"(",
"is_null",
"(",
"$",
"obj",
")",
")",
"{",
"$",
"obj",
"=",
"'null'",
";",
"}",
"else",
"{",
"if",
"(",
"gettype",
"(",
"$",
"obj",
")",
"==",
"'integer'",
")",
"{",
"}",
"else",
"{",
"if",
"(",
"gettype",
"(",
"$",
"obj",
")",
"==",
"'object'",
")",
"{",
"$",
"obj",
"=",
"'Object: '",
".",
"get_class",
"(",
"$",
"obj",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"obj",
",",
"'__toString'",
")",
")",
"{",
"$",
"obj",
".=",
"'- '",
".",
"$",
"obj",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"is_array",
"(",
"$",
"obj",
")",
")",
"{",
"$",
"obj",
"=",
"'Array'",
";",
"}",
"else",
"{",
"$",
"obj",
"=",
"sprintf",
"(",
"\"'%s'\"",
",",
"$",
"obj",
")",
";",
"}",
"}",
"}",
"}",
"$",
"objBacktrace",
"[",
"'args'",
"]",
"[",
"$",
"intIndex",
"]",
"=",
"$",
"obj",
";",
"}",
"// Push it onto the profiling information array",
"$",
"arrProfile",
"=",
"array",
"(",
"'objBacktrace'",
"=>",
"$",
"objBacktrace",
",",
"'strQuery'",
"=>",
"$",
"strQuery",
",",
"'dblTimeInfo'",
"=>",
"$",
"dblQueryTime",
")",
";",
"array_push",
"(",
"$",
"this",
"->",
"strProfileArray",
",",
"$",
"arrProfile",
")",
";",
"}",
"}"
]
| If EnableProfiling is on, then log the query to the profile array
@param string $strQuery
@param double $dblQueryTime query execution time in milliseconds
@return void | [
"If",
"EnableProfiling",
"is",
"on",
"then",
"log",
"the",
"query",
"to",
"the",
"profile",
"array"
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Database/DatabaseBase.php#L545-L609 |
qcubed/orm | src/Database/DatabaseBase.php | DatabaseBase.sqlVariable | public function sqlVariable($mixData, $blnIncludeEquality = false, $blnReverseEquality = false)
{
// Are we SqlVariabling a BOOLEAN value?
if (is_bool($mixData)) {
// Yes
if ($blnIncludeEquality) {
// We must include the inequality
if ($blnReverseEquality) {
// Do a "Reverse Equality"
// Check against NULL, True then False
if (is_null($mixData)) {
return 'IS NOT NULL';
} else {
if ($mixData) {
return '= 0';
} else {
return '!= 0';
}
}
} else {
// Check against NULL, True then False
if (is_null($mixData)) {
return 'IS NULL';
} else {
if ($mixData) {
return '!= 0';
} else {
return '= 0';
}
}
}
} else {
// Check against NULL, True then False
if (is_null($mixData)) {
return 'NULL';
} else {
if ($mixData) {
return '1';
} else {
return '0';
}
}
}
}
// Check for Equality Inclusion
if ($blnIncludeEquality) {
if ($blnReverseEquality) {
if (is_null($mixData)) {
$strToReturn = 'IS NOT ';
} else {
$strToReturn = '!= ';
}
} else {
if (is_null($mixData)) {
$strToReturn = 'IS ';
} else {
$strToReturn = '= ';
}
}
} else {
$strToReturn = '';
}
// Check for NULL Value
if (is_null($mixData)) {
return $strToReturn . 'NULL';
}
// Check for NUMERIC Value
if (is_integer($mixData) || is_float($mixData)) {
return $strToReturn . sprintf('%s', $mixData);
}
// Check for DATE Value
if ($mixData instanceof QDateTime) {
/** @var QDateTime $mixData */
if ($mixData->isTimeNull()) {
if ($mixData->isDateNull()) {
return $strToReturn . 'NULL'; // null date and time is a null value
}
return $strToReturn . sprintf("'%s'", $mixData->qFormat('YYYY-MM-DD'));
} elseif ($mixData->isDateNull()) {
return $strToReturn . sprintf("'%s'", $mixData->qFormat('hhhh:mm:ss'));
}
return $strToReturn . sprintf("'%s'", $mixData->qFormat(QDateTime::FORMAT_ISO));
}
// an array. Assume we are using it in an array context, like an IN clause
if (is_array($mixData)) {
$items = [];
foreach ($mixData as $item) {
$items[] = $this->sqlVariable($item); // recurse
}
return '(' . implode(',', $items) . ')';
}
// Assume it's some kind of string value
return $strToReturn . sprintf("'%s'", addslashes($mixData));
} | php | public function sqlVariable($mixData, $blnIncludeEquality = false, $blnReverseEquality = false)
{
// Are we SqlVariabling a BOOLEAN value?
if (is_bool($mixData)) {
// Yes
if ($blnIncludeEquality) {
// We must include the inequality
if ($blnReverseEquality) {
// Do a "Reverse Equality"
// Check against NULL, True then False
if (is_null($mixData)) {
return 'IS NOT NULL';
} else {
if ($mixData) {
return '= 0';
} else {
return '!= 0';
}
}
} else {
// Check against NULL, True then False
if (is_null($mixData)) {
return 'IS NULL';
} else {
if ($mixData) {
return '!= 0';
} else {
return '= 0';
}
}
}
} else {
// Check against NULL, True then False
if (is_null($mixData)) {
return 'NULL';
} else {
if ($mixData) {
return '1';
} else {
return '0';
}
}
}
}
// Check for Equality Inclusion
if ($blnIncludeEquality) {
if ($blnReverseEquality) {
if (is_null($mixData)) {
$strToReturn = 'IS NOT ';
} else {
$strToReturn = '!= ';
}
} else {
if (is_null($mixData)) {
$strToReturn = 'IS ';
} else {
$strToReturn = '= ';
}
}
} else {
$strToReturn = '';
}
// Check for NULL Value
if (is_null($mixData)) {
return $strToReturn . 'NULL';
}
// Check for NUMERIC Value
if (is_integer($mixData) || is_float($mixData)) {
return $strToReturn . sprintf('%s', $mixData);
}
// Check for DATE Value
if ($mixData instanceof QDateTime) {
/** @var QDateTime $mixData */
if ($mixData->isTimeNull()) {
if ($mixData->isDateNull()) {
return $strToReturn . 'NULL'; // null date and time is a null value
}
return $strToReturn . sprintf("'%s'", $mixData->qFormat('YYYY-MM-DD'));
} elseif ($mixData->isDateNull()) {
return $strToReturn . sprintf("'%s'", $mixData->qFormat('hhhh:mm:ss'));
}
return $strToReturn . sprintf("'%s'", $mixData->qFormat(QDateTime::FORMAT_ISO));
}
// an array. Assume we are using it in an array context, like an IN clause
if (is_array($mixData)) {
$items = [];
foreach ($mixData as $item) {
$items[] = $this->sqlVariable($item); // recurse
}
return '(' . implode(',', $items) . ')';
}
// Assume it's some kind of string value
return $strToReturn . sprintf("'%s'", addslashes($mixData));
} | [
"public",
"function",
"sqlVariable",
"(",
"$",
"mixData",
",",
"$",
"blnIncludeEquality",
"=",
"false",
",",
"$",
"blnReverseEquality",
"=",
"false",
")",
"{",
"// Are we SqlVariabling a BOOLEAN value?",
"if",
"(",
"is_bool",
"(",
"$",
"mixData",
")",
")",
"{",
"// Yes",
"if",
"(",
"$",
"blnIncludeEquality",
")",
"{",
"// We must include the inequality",
"if",
"(",
"$",
"blnReverseEquality",
")",
"{",
"// Do a \"Reverse Equality\"",
"// Check against NULL, True then False",
"if",
"(",
"is_null",
"(",
"$",
"mixData",
")",
")",
"{",
"return",
"'IS NOT NULL'",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"mixData",
")",
"{",
"return",
"'= 0'",
";",
"}",
"else",
"{",
"return",
"'!= 0'",
";",
"}",
"}",
"}",
"else",
"{",
"// Check against NULL, True then False",
"if",
"(",
"is_null",
"(",
"$",
"mixData",
")",
")",
"{",
"return",
"'IS NULL'",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"mixData",
")",
"{",
"return",
"'!= 0'",
";",
"}",
"else",
"{",
"return",
"'= 0'",
";",
"}",
"}",
"}",
"}",
"else",
"{",
"// Check against NULL, True then False",
"if",
"(",
"is_null",
"(",
"$",
"mixData",
")",
")",
"{",
"return",
"'NULL'",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"mixData",
")",
"{",
"return",
"'1'",
";",
"}",
"else",
"{",
"return",
"'0'",
";",
"}",
"}",
"}",
"}",
"// Check for Equality Inclusion",
"if",
"(",
"$",
"blnIncludeEquality",
")",
"{",
"if",
"(",
"$",
"blnReverseEquality",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"mixData",
")",
")",
"{",
"$",
"strToReturn",
"=",
"'IS NOT '",
";",
"}",
"else",
"{",
"$",
"strToReturn",
"=",
"'!= '",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"is_null",
"(",
"$",
"mixData",
")",
")",
"{",
"$",
"strToReturn",
"=",
"'IS '",
";",
"}",
"else",
"{",
"$",
"strToReturn",
"=",
"'= '",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"strToReturn",
"=",
"''",
";",
"}",
"// Check for NULL Value",
"if",
"(",
"is_null",
"(",
"$",
"mixData",
")",
")",
"{",
"return",
"$",
"strToReturn",
".",
"'NULL'",
";",
"}",
"// Check for NUMERIC Value",
"if",
"(",
"is_integer",
"(",
"$",
"mixData",
")",
"||",
"is_float",
"(",
"$",
"mixData",
")",
")",
"{",
"return",
"$",
"strToReturn",
".",
"sprintf",
"(",
"'%s'",
",",
"$",
"mixData",
")",
";",
"}",
"// Check for DATE Value",
"if",
"(",
"$",
"mixData",
"instanceof",
"QDateTime",
")",
"{",
"/** @var QDateTime $mixData */",
"if",
"(",
"$",
"mixData",
"->",
"isTimeNull",
"(",
")",
")",
"{",
"if",
"(",
"$",
"mixData",
"->",
"isDateNull",
"(",
")",
")",
"{",
"return",
"$",
"strToReturn",
".",
"'NULL'",
";",
"// null date and time is a null value",
"}",
"return",
"$",
"strToReturn",
".",
"sprintf",
"(",
"\"'%s'\"",
",",
"$",
"mixData",
"->",
"qFormat",
"(",
"'YYYY-MM-DD'",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"mixData",
"->",
"isDateNull",
"(",
")",
")",
"{",
"return",
"$",
"strToReturn",
".",
"sprintf",
"(",
"\"'%s'\"",
",",
"$",
"mixData",
"->",
"qFormat",
"(",
"'hhhh:mm:ss'",
")",
")",
";",
"}",
"return",
"$",
"strToReturn",
".",
"sprintf",
"(",
"\"'%s'\"",
",",
"$",
"mixData",
"->",
"qFormat",
"(",
"QDateTime",
"::",
"FORMAT_ISO",
")",
")",
";",
"}",
"// an array. Assume we are using it in an array context, like an IN clause",
"if",
"(",
"is_array",
"(",
"$",
"mixData",
")",
")",
"{",
"$",
"items",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"mixData",
"as",
"$",
"item",
")",
"{",
"$",
"items",
"[",
"]",
"=",
"$",
"this",
"->",
"sqlVariable",
"(",
"$",
"item",
")",
";",
"// recurse",
"}",
"return",
"'('",
".",
"implode",
"(",
"','",
",",
"$",
"items",
")",
".",
"')'",
";",
"}",
"// Assume it's some kind of string value",
"return",
"$",
"strToReturn",
".",
"sprintf",
"(",
"\"'%s'\"",
",",
"addslashes",
"(",
"$",
"mixData",
")",
")",
";",
"}"
]
| Properly escapes $mixData to be used as a SQL query parameter.
If IncludeEquality is set (usually not), then include an equality operator.
So for most data, it would just be "=". But, for example,
if $mixData is NULL, then most RDBMS's require the use of "IS".
@param mixed $mixData
@param boolean $blnIncludeEquality whether or not to include an equality operator
@param boolean $blnReverseEquality whether the included equality operator should be a "NOT EQUAL", e.g. "!="
@return string the properly formatted SQL variable | [
"Properly",
"escapes",
"$mixData",
"to",
"be",
"used",
"as",
"a",
"SQL",
"query",
"parameter",
".",
"If",
"IncludeEquality",
"is",
"set",
"(",
"usually",
"not",
")",
"then",
"include",
"an",
"equality",
"operator",
".",
"So",
"for",
"most",
"data",
"it",
"would",
"just",
"be",
"=",
".",
"But",
"for",
"example",
"if",
"$mixData",
"is",
"NULL",
"then",
"most",
"RDBMS",
"s",
"require",
"the",
"use",
"of",
"IS",
"."
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Database/DatabaseBase.php#L622-L723 |
qcubed/orm | src/Database/DatabaseBase.php | DatabaseBase.outputProfiling | public function outputProfiling($blnPrintOutput = true)
{
$strPath = isset($_SERVER['REQUEST_URI']) ?
$_SERVER['REQUEST_URI'] :
$_SERVER['PHP_SELF'];
$strOut = '<div class="qDbProfile">';
if ($this->blnEnableProfiling) {
$strOut .= sprintf('<form method="post" id="frmDbProfile%s" action="%s/profile.php"><div>',
$this->intDatabaseIndex, QCUBED_PHP_URL);
$strOut .= sprintf('<input type="hidden" name="strProfileData" value="%s" />',
base64_encode(serialize($this->strProfileArray)));
$strOut .= sprintf('<input type="hidden" name="intDatabaseIndex" value="%s" />', $this->intDatabaseIndex);
$strOut .= sprintf('<input type="hidden" name="strReferrer" value="%s" /></div></form>',
htmlentities($strPath));
$intCount = round(count($this->strProfileArray));
if ($intCount == 0) {
$strQueryString = 'No queries';
} else {
if ($intCount == 1) {
$strQueryString = '1 query';
} else {
$strQueryString = $intCount . ' queries';
}
}
$strOut .= sprintf('<b>PROFILING INFORMATION FOR DATABASE CONNECTION #%s</b>: %s performed. Please <a href="#" onclick="var frmDbProfile = document.getElementById(\'frmDbProfile%s\'); frmDbProfile.target = \'_blank\'; frmDbProfile.submit(); return false;">click here to view profiling detail</a><br />',
$this->intDatabaseIndex, $strQueryString, $this->intDatabaseIndex);
} else {
$strOut .= '<form></form><b>Profiling was not enabled for this database connection (#' . $this->intDatabaseIndex . ').</b> To enable, ensure that ENABLE_PROFILING is set to TRUE.';
}
$strOut .= '</div>';
$strOut .= '<script>$j(function() {$j(".qDbProfile").draggable();});</script>'; // make it draggable so you can move it out of the way if needed.
if ($blnPrintOutput) {
print ($strOut);
return null;
} else {
return $strOut;
}
} | php | public function outputProfiling($blnPrintOutput = true)
{
$strPath = isset($_SERVER['REQUEST_URI']) ?
$_SERVER['REQUEST_URI'] :
$_SERVER['PHP_SELF'];
$strOut = '<div class="qDbProfile">';
if ($this->blnEnableProfiling) {
$strOut .= sprintf('<form method="post" id="frmDbProfile%s" action="%s/profile.php"><div>',
$this->intDatabaseIndex, QCUBED_PHP_URL);
$strOut .= sprintf('<input type="hidden" name="strProfileData" value="%s" />',
base64_encode(serialize($this->strProfileArray)));
$strOut .= sprintf('<input type="hidden" name="intDatabaseIndex" value="%s" />', $this->intDatabaseIndex);
$strOut .= sprintf('<input type="hidden" name="strReferrer" value="%s" /></div></form>',
htmlentities($strPath));
$intCount = round(count($this->strProfileArray));
if ($intCount == 0) {
$strQueryString = 'No queries';
} else {
if ($intCount == 1) {
$strQueryString = '1 query';
} else {
$strQueryString = $intCount . ' queries';
}
}
$strOut .= sprintf('<b>PROFILING INFORMATION FOR DATABASE CONNECTION #%s</b>: %s performed. Please <a href="#" onclick="var frmDbProfile = document.getElementById(\'frmDbProfile%s\'); frmDbProfile.target = \'_blank\'; frmDbProfile.submit(); return false;">click here to view profiling detail</a><br />',
$this->intDatabaseIndex, $strQueryString, $this->intDatabaseIndex);
} else {
$strOut .= '<form></form><b>Profiling was not enabled for this database connection (#' . $this->intDatabaseIndex . ').</b> To enable, ensure that ENABLE_PROFILING is set to TRUE.';
}
$strOut .= '</div>';
$strOut .= '<script>$j(function() {$j(".qDbProfile").draggable();});</script>'; // make it draggable so you can move it out of the way if needed.
if ($blnPrintOutput) {
print ($strOut);
return null;
} else {
return $strOut;
}
} | [
"public",
"function",
"outputProfiling",
"(",
"$",
"blnPrintOutput",
"=",
"true",
")",
"{",
"$",
"strPath",
"=",
"isset",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
")",
"?",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
":",
"$",
"_SERVER",
"[",
"'PHP_SELF'",
"]",
";",
"$",
"strOut",
"=",
"'<div class=\"qDbProfile\">'",
";",
"if",
"(",
"$",
"this",
"->",
"blnEnableProfiling",
")",
"{",
"$",
"strOut",
".=",
"sprintf",
"(",
"'<form method=\"post\" id=\"frmDbProfile%s\" action=\"%s/profile.php\"><div>'",
",",
"$",
"this",
"->",
"intDatabaseIndex",
",",
"QCUBED_PHP_URL",
")",
";",
"$",
"strOut",
".=",
"sprintf",
"(",
"'<input type=\"hidden\" name=\"strProfileData\" value=\"%s\" />'",
",",
"base64_encode",
"(",
"serialize",
"(",
"$",
"this",
"->",
"strProfileArray",
")",
")",
")",
";",
"$",
"strOut",
".=",
"sprintf",
"(",
"'<input type=\"hidden\" name=\"intDatabaseIndex\" value=\"%s\" />'",
",",
"$",
"this",
"->",
"intDatabaseIndex",
")",
";",
"$",
"strOut",
".=",
"sprintf",
"(",
"'<input type=\"hidden\" name=\"strReferrer\" value=\"%s\" /></div></form>'",
",",
"htmlentities",
"(",
"$",
"strPath",
")",
")",
";",
"$",
"intCount",
"=",
"round",
"(",
"count",
"(",
"$",
"this",
"->",
"strProfileArray",
")",
")",
";",
"if",
"(",
"$",
"intCount",
"==",
"0",
")",
"{",
"$",
"strQueryString",
"=",
"'No queries'",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"intCount",
"==",
"1",
")",
"{",
"$",
"strQueryString",
"=",
"'1 query'",
";",
"}",
"else",
"{",
"$",
"strQueryString",
"=",
"$",
"intCount",
".",
"' queries'",
";",
"}",
"}",
"$",
"strOut",
".=",
"sprintf",
"(",
"'<b>PROFILING INFORMATION FOR DATABASE CONNECTION #%s</b>: %s performed. Please <a href=\"#\" onclick=\"var frmDbProfile = document.getElementById(\\'frmDbProfile%s\\'); frmDbProfile.target = \\'_blank\\'; frmDbProfile.submit(); return false;\">click here to view profiling detail</a><br />'",
",",
"$",
"this",
"->",
"intDatabaseIndex",
",",
"$",
"strQueryString",
",",
"$",
"this",
"->",
"intDatabaseIndex",
")",
";",
"}",
"else",
"{",
"$",
"strOut",
".=",
"'<form></form><b>Profiling was not enabled for this database connection (#'",
".",
"$",
"this",
"->",
"intDatabaseIndex",
".",
"').</b> To enable, ensure that ENABLE_PROFILING is set to TRUE.'",
";",
"}",
"$",
"strOut",
".=",
"'</div>'",
";",
"$",
"strOut",
".=",
"'<script>$j(function() {$j(\".qDbProfile\").draggable();});</script>'",
";",
"// make it draggable so you can move it out of the way if needed.",
"if",
"(",
"$",
"blnPrintOutput",
")",
"{",
"print",
"(",
"$",
"strOut",
")",
";",
"return",
"null",
";",
"}",
"else",
"{",
"return",
"$",
"strOut",
";",
"}",
"}"
]
| Displays the OutputProfiling results, plus a link which will popup the details of the profiling.
@param bool $blnPrintOutput
@return null|string | [
"Displays",
"the",
"OutputProfiling",
"results",
"plus",
"a",
"link",
"which",
"will",
"popup",
"the",
"details",
"of",
"the",
"profiling",
"."
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Database/DatabaseBase.php#L754-L796 |
qcubed/orm | src/Database/DatabaseBase.php | DatabaseBase.extractCommentOptions | public static function extractCommentOptions($strComment)
{
$ret[0] = null; // comment string without options
$ret[1] = null; // the options array
if (($strComment) &&
($pos1 = strpos($strComment, '{')) !== false &&
($pos2 = strrpos($strComment, '}', $pos1))
) {
$strJson = substr($strComment, $pos1, $pos2 - $pos1 + 1);
$a = json_decode($strJson, true);
if ($a) {
$ret[0] = substr($strComment, 0, $pos1) . substr($strComment,
$pos2 + 1); // return comment without options
$ret[1] = $a;
} else {
$ret[0] = $strComment;
}
}
return $ret;
} | php | public static function extractCommentOptions($strComment)
{
$ret[0] = null; // comment string without options
$ret[1] = null; // the options array
if (($strComment) &&
($pos1 = strpos($strComment, '{')) !== false &&
($pos2 = strrpos($strComment, '}', $pos1))
) {
$strJson = substr($strComment, $pos1, $pos2 - $pos1 + 1);
$a = json_decode($strJson, true);
if ($a) {
$ret[0] = substr($strComment, 0, $pos1) . substr($strComment,
$pos2 + 1); // return comment without options
$ret[1] = $a;
} else {
$ret[0] = $strComment;
}
}
return $ret;
} | [
"public",
"static",
"function",
"extractCommentOptions",
"(",
"$",
"strComment",
")",
"{",
"$",
"ret",
"[",
"0",
"]",
"=",
"null",
";",
"// comment string without options",
"$",
"ret",
"[",
"1",
"]",
"=",
"null",
";",
"// the options array",
"if",
"(",
"(",
"$",
"strComment",
")",
"&&",
"(",
"$",
"pos1",
"=",
"strpos",
"(",
"$",
"strComment",
",",
"'{'",
")",
")",
"!==",
"false",
"&&",
"(",
"$",
"pos2",
"=",
"strrpos",
"(",
"$",
"strComment",
",",
"'}'",
",",
"$",
"pos1",
")",
")",
")",
"{",
"$",
"strJson",
"=",
"substr",
"(",
"$",
"strComment",
",",
"$",
"pos1",
",",
"$",
"pos2",
"-",
"$",
"pos1",
"+",
"1",
")",
";",
"$",
"a",
"=",
"json_decode",
"(",
"$",
"strJson",
",",
"true",
")",
";",
"if",
"(",
"$",
"a",
")",
"{",
"$",
"ret",
"[",
"0",
"]",
"=",
"substr",
"(",
"$",
"strComment",
",",
"0",
",",
"$",
"pos1",
")",
".",
"substr",
"(",
"$",
"strComment",
",",
"$",
"pos2",
"+",
"1",
")",
";",
"// return comment without options",
"$",
"ret",
"[",
"1",
"]",
"=",
"$",
"a",
";",
"}",
"else",
"{",
"$",
"ret",
"[",
"0",
"]",
"=",
"$",
"strComment",
";",
"}",
"}",
"return",
"$",
"ret",
";",
"}"
]
| Utility function to extract the json embedded options structure from the comments.
Usage:
<code>
list($strComment, $options) = Base::extractCommentOptions($strComment);
</code>
@param string $strComment The comment to analyze
@return array A two item array, with first item the comment with the options removed, and 2nd item the options array. | [
"Utility",
"function",
"to",
"extract",
"the",
"json",
"embedded",
"options",
"structure",
"from",
"the",
"comments",
"."
]
| train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Database/DatabaseBase.php#L824-L846 |
lode/fem | example-project/application/routing.php | routing.get_custom_routes | protected function get_custom_routes() {
$routes = [];
// map to a file
$routes['GET']['foo'] = 'bar';
// map to a method
$accept = fem\request::get_primary_accept(); // html, json, etc.
$routes['GET']['foo'] = 'bar->'.$accept;
$routes['GET']['foo'] = 'bar::'.$accept;
// map to an inline function
$routes['GET']['foo'] = function($url, $method){};
$routes['GET']['foo'] = function($url, $method, $arguments){ echo 'baz'; };
return $routes;
} | php | protected function get_custom_routes() {
$routes = [];
// map to a file
$routes['GET']['foo'] = 'bar';
// map to a method
$accept = fem\request::get_primary_accept(); // html, json, etc.
$routes['GET']['foo'] = 'bar->'.$accept;
$routes['GET']['foo'] = 'bar::'.$accept;
// map to an inline function
$routes['GET']['foo'] = function($url, $method){};
$routes['GET']['foo'] = function($url, $method, $arguments){ echo 'baz'; };
return $routes;
} | [
"protected",
"function",
"get_custom_routes",
"(",
")",
"{",
"$",
"routes",
"=",
"[",
"]",
";",
"// map to a file",
"$",
"routes",
"[",
"'GET'",
"]",
"[",
"'foo'",
"]",
"=",
"'bar'",
";",
"// map to a method",
"$",
"accept",
"=",
"fem",
"\\",
"request",
"::",
"get_primary_accept",
"(",
")",
";",
"// html, json, etc.",
"$",
"routes",
"[",
"'GET'",
"]",
"[",
"'foo'",
"]",
"=",
"'bar->'",
".",
"$",
"accept",
";",
"$",
"routes",
"[",
"'GET'",
"]",
"[",
"'foo'",
"]",
"=",
"'bar::'",
".",
"$",
"accept",
";",
"// map to an inline function",
"$",
"routes",
"[",
"'GET'",
"]",
"[",
"'foo'",
"]",
"=",
"function",
"(",
"$",
"url",
",",
"$",
"method",
")",
"{",
"}",
";",
"$",
"routes",
"[",
"'GET'",
"]",
"[",
"'foo'",
"]",
"=",
"function",
"(",
"$",
"url",
",",
"$",
"method",
",",
"$",
"arguments",
")",
"{",
"echo",
"'baz'",
";",
"}",
";",
"return",
"$",
"routes",
";",
"}"
]
| user defined mapping url to handler
@return array with keys for each supported http method ..
.. and inside, key-value pairs of url-regex => handler
for example `$routes['GET']['foo'] = 'bar';` ..
.. maps the GET url 'foo' to the file 'bar'
the url-regex doesn't need regex boundaries like '/foo/'
@see \alsvanzelf\fem\routing::get_handler_type() for the different ways to define a handler | [
"user",
"defined",
"mapping",
"url",
"to",
"handler"
]
| train | https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/example-project/application/routing.php#L23-L39 |
ruvents/ruwork-polyfill-form-dti-bundle | DependencyInjection/Compiler/RemoveDoctrineOrmDTIGuesserPass.php | RemoveDoctrineOrmDTIGuesserPass.process | public function process(ContainerBuilder $container)
{
$id = 'ruwork_polyfill_form_dti.guesser.doctrine_orm';
if (!$container->has($id)) {
return;
}
if (!defined(Type::class.'::DATETIME_IMMUTABLE')) {
$container->removeDefinition($id);
}
if (!$container->has('doctrine')) {
$container->removeDefinition($id);
}
} | php | public function process(ContainerBuilder $container)
{
$id = 'ruwork_polyfill_form_dti.guesser.doctrine_orm';
if (!$container->has($id)) {
return;
}
if (!defined(Type::class.'::DATETIME_IMMUTABLE')) {
$container->removeDefinition($id);
}
if (!$container->has('doctrine')) {
$container->removeDefinition($id);
}
} | [
"public",
"function",
"process",
"(",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"id",
"=",
"'ruwork_polyfill_form_dti.guesser.doctrine_orm'",
";",
"if",
"(",
"!",
"$",
"container",
"->",
"has",
"(",
"$",
"id",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"defined",
"(",
"Type",
"::",
"class",
".",
"'::DATETIME_IMMUTABLE'",
")",
")",
"{",
"$",
"container",
"->",
"removeDefinition",
"(",
"$",
"id",
")",
";",
"}",
"if",
"(",
"!",
"$",
"container",
"->",
"has",
"(",
"'doctrine'",
")",
")",
"{",
"$",
"container",
"->",
"removeDefinition",
"(",
"$",
"id",
")",
";",
"}",
"}"
]
| {@inheritdoc} | [
"{"
]
| train | https://github.com/ruvents/ruwork-polyfill-form-dti-bundle/blob/3d5517d628a9982d17cb79b5991b88c6b79f5384/DependencyInjection/Compiler/RemoveDoctrineOrmDTIGuesserPass.php#L14-L29 |
nooku/nooku-installer | src/Nooku/Composer/Installer.php | Installer.getDelegate | public function getDelegate($packageType)
{
if (!isset($this->_instances[$packageType]))
{
if (isset($this->_delegates[$packageType]))
{
$classname = $this->_delegates[$packageType];
$instance = new $classname($this->io, $this->composer, 'nooku-framework');
$this->_instances[$packageType] = $instance;
}
else throw new \InvalidArgumentException('Unknown package type `'.$packageType.'`.');
}
return $this->_instances[$packageType];
} | php | public function getDelegate($packageType)
{
if (!isset($this->_instances[$packageType]))
{
if (isset($this->_delegates[$packageType]))
{
$classname = $this->_delegates[$packageType];
$instance = new $classname($this->io, $this->composer, 'nooku-framework');
$this->_instances[$packageType] = $instance;
}
else throw new \InvalidArgumentException('Unknown package type `'.$packageType.'`.');
}
return $this->_instances[$packageType];
} | [
"public",
"function",
"getDelegate",
"(",
"$",
"packageType",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_instances",
"[",
"$",
"packageType",
"]",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_delegates",
"[",
"$",
"packageType",
"]",
")",
")",
"{",
"$",
"classname",
"=",
"$",
"this",
"->",
"_delegates",
"[",
"$",
"packageType",
"]",
";",
"$",
"instance",
"=",
"new",
"$",
"classname",
"(",
"$",
"this",
"->",
"io",
",",
"$",
"this",
"->",
"composer",
",",
"'nooku-framework'",
")",
";",
"$",
"this",
"->",
"_instances",
"[",
"$",
"packageType",
"]",
"=",
"$",
"instance",
";",
"}",
"else",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Unknown package type `'",
".",
"$",
"packageType",
".",
"'`.'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_instances",
"[",
"$",
"packageType",
"]",
";",
"}"
]
| Returns a specialized LibraryInstaller subclass to deal with the given package type.
@return Composer\Installer\LibraryInstaller
@throws \InvalidArgumentException | [
"Returns",
"a",
"specialized",
"LibraryInstaller",
"subclass",
"to",
"deal",
"with",
"the",
"given",
"package",
"type",
"."
]
| train | https://github.com/nooku/nooku-installer/blob/2aa82ed08983bccd51905426cfff4980ba960d89/src/Nooku/Composer/Installer.php#L50-L65 |
nooku/nooku-installer | src/Nooku/Composer/Installer.php | Installer.install | public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
{
$this->getDelegate($package->getType())->install($repo, $package);
} | php | public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
{
$this->getDelegate($package->getType())->install($repo, $package);
} | [
"public",
"function",
"install",
"(",
"InstalledRepositoryInterface",
"$",
"repo",
",",
"PackageInterface",
"$",
"package",
")",
"{",
"$",
"this",
"->",
"getDelegate",
"(",
"$",
"package",
"->",
"getType",
"(",
")",
")",
"->",
"install",
"(",
"$",
"repo",
",",
"$",
"package",
")",
";",
"}"
]
| {@inheritDoc} | [
"{"
]
| train | https://github.com/nooku/nooku-installer/blob/2aa82ed08983bccd51905426cfff4980ba960d89/src/Nooku/Composer/Installer.php#L78-L81 |
nooku/nooku-installer | src/Nooku/Composer/Installer.php | Installer.update | public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
{
$this->getDelegate($initial->getType())->update($repo, $initial, $target);
} | php | public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
{
$this->getDelegate($initial->getType())->update($repo, $initial, $target);
} | [
"public",
"function",
"update",
"(",
"InstalledRepositoryInterface",
"$",
"repo",
",",
"PackageInterface",
"$",
"initial",
",",
"PackageInterface",
"$",
"target",
")",
"{",
"$",
"this",
"->",
"getDelegate",
"(",
"$",
"initial",
"->",
"getType",
"(",
")",
")",
"->",
"update",
"(",
"$",
"repo",
",",
"$",
"initial",
",",
"$",
"target",
")",
";",
"}"
]
| {@inheritDoc} | [
"{"
]
| train | https://github.com/nooku/nooku-installer/blob/2aa82ed08983bccd51905426cfff4980ba960d89/src/Nooku/Composer/Installer.php#L86-L89 |
nooku/nooku-installer | src/Nooku/Composer/Installer.php | Installer.isInstalled | public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
{
return $this->getDelegate($package->getType())->isInstalled($repo, $package);
} | php | public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
{
return $this->getDelegate($package->getType())->isInstalled($repo, $package);
} | [
"public",
"function",
"isInstalled",
"(",
"InstalledRepositoryInterface",
"$",
"repo",
",",
"PackageInterface",
"$",
"package",
")",
"{",
"return",
"$",
"this",
"->",
"getDelegate",
"(",
"$",
"package",
"->",
"getType",
"(",
")",
")",
"->",
"isInstalled",
"(",
"$",
"repo",
",",
"$",
"package",
")",
";",
"}"
]
| {@inheritDoc} | [
"{"
]
| train | https://github.com/nooku/nooku-installer/blob/2aa82ed08983bccd51905426cfff4980ba960d89/src/Nooku/Composer/Installer.php#L102-L105 |
gajus/brick | src/System.php | System.setDirectory | public function setDirectory ($directory) {
if (strpos($directory, '/') !== 0) {
throw new Exception\InvalidArgumentException('Directory name must be an absolute path.');
}
if (!is_dir($directory)) {
throw new Exception\LogicException('Template directory does not exist.');
}
$this->directory = realpath($directory);
} | php | public function setDirectory ($directory) {
if (strpos($directory, '/') !== 0) {
throw new Exception\InvalidArgumentException('Directory name must be an absolute path.');
}
if (!is_dir($directory)) {
throw new Exception\LogicException('Template directory does not exist.');
}
$this->directory = realpath($directory);
} | [
"public",
"function",
"setDirectory",
"(",
"$",
"directory",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"directory",
",",
"'/'",
")",
"!==",
"0",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"'Directory name must be an absolute path.'",
")",
";",
"}",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"directory",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"LogicException",
"(",
"'Template directory does not exist.'",
")",
";",
"}",
"$",
"this",
"->",
"directory",
"=",
"realpath",
"(",
"$",
"directory",
")",
";",
"}"
]
| Template resolution is restricted to the paths under the template directory.
@param string $directory Absolute path to the template directory. | [
"Template",
"resolution",
"is",
"restricted",
"to",
"the",
"paths",
"under",
"the",
"template",
"directory",
"."
]
| train | https://github.com/gajus/brick/blob/8e1890b2993fb1e2049a3fd73ec048c95fb0a7df/src/System.php#L39-L49 |
krzysztofmazur/php-object-mapper | src/KrzysztofMazur/ObjectMapper/Mapping/MappingRepository.php | MappingRepository.getMapping | public function getMapping($sourceClass, $targetClass, $mapId = null)
{
if (!isset($this->mappings[$mapId])) {
throw MappingException::createNotSupportedMapping($sourceClass, $targetClass);
}
foreach ($this->mappings[$mapId] as $mapping) {
/** @var Mapping $mapping */
if ($mapping->supports($sourceClass, $targetClass)) {
return $mapping;
}
}
throw MappingException::createNotSupportedMapping($sourceClass, $targetClass);
} | php | public function getMapping($sourceClass, $targetClass, $mapId = null)
{
if (!isset($this->mappings[$mapId])) {
throw MappingException::createNotSupportedMapping($sourceClass, $targetClass);
}
foreach ($this->mappings[$mapId] as $mapping) {
/** @var Mapping $mapping */
if ($mapping->supports($sourceClass, $targetClass)) {
return $mapping;
}
}
throw MappingException::createNotSupportedMapping($sourceClass, $targetClass);
} | [
"public",
"function",
"getMapping",
"(",
"$",
"sourceClass",
",",
"$",
"targetClass",
",",
"$",
"mapId",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"mappings",
"[",
"$",
"mapId",
"]",
")",
")",
"{",
"throw",
"MappingException",
"::",
"createNotSupportedMapping",
"(",
"$",
"sourceClass",
",",
"$",
"targetClass",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"mappings",
"[",
"$",
"mapId",
"]",
"as",
"$",
"mapping",
")",
"{",
"/** @var Mapping $mapping */",
"if",
"(",
"$",
"mapping",
"->",
"supports",
"(",
"$",
"sourceClass",
",",
"$",
"targetClass",
")",
")",
"{",
"return",
"$",
"mapping",
";",
"}",
"}",
"throw",
"MappingException",
"::",
"createNotSupportedMapping",
"(",
"$",
"sourceClass",
",",
"$",
"targetClass",
")",
";",
"}"
]
| {@inheritdoc} | [
"{"
]
| train | https://github.com/krzysztofmazur/php-object-mapper/blob/2c22acad9634cfe8e9a75d72e665d450ada8d4e3/src/KrzysztofMazur/ObjectMapper/Mapping/MappingRepository.php#L55-L68 |
yuncms/framework | src/helpers/RBACHelper.php | RBACHelper.getDefaultRoutes | protected static function getDefaultRoutes()
{
if (self::$_defaultRoutes === null) {
$manager = self::getAuthManager();
$roles = $manager->defaultRoles;
if ($manager->cache && ($routes = $manager->cache->get($roles)) !== false) {
self::$_defaultRoutes = $routes;
} else {
$permissions = self::$_defaultRoutes = [];
foreach ($roles as $role) {
$permissions = array_merge($permissions, $manager->getPermissionsByRole($role));
}
foreach ($permissions as $item) {
if ($item->name[0] === '/') {
self::$_defaultRoutes[$item->name] = true;
}
}
if ($manager->cache) {
$manager->cache->set($roles, self::$_defaultRoutes, $manager->cacheDuration, new TagDependency([
'tags' => $manager->cacheTag
]));
}
}
}
return self::$_defaultRoutes;
} | php | protected static function getDefaultRoutes()
{
if (self::$_defaultRoutes === null) {
$manager = self::getAuthManager();
$roles = $manager->defaultRoles;
if ($manager->cache && ($routes = $manager->cache->get($roles)) !== false) {
self::$_defaultRoutes = $routes;
} else {
$permissions = self::$_defaultRoutes = [];
foreach ($roles as $role) {
$permissions = array_merge($permissions, $manager->getPermissionsByRole($role));
}
foreach ($permissions as $item) {
if ($item->name[0] === '/') {
self::$_defaultRoutes[$item->name] = true;
}
}
if ($manager->cache) {
$manager->cache->set($roles, self::$_defaultRoutes, $manager->cacheDuration, new TagDependency([
'tags' => $manager->cacheTag
]));
}
}
}
return self::$_defaultRoutes;
} | [
"protected",
"static",
"function",
"getDefaultRoutes",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"_defaultRoutes",
"===",
"null",
")",
"{",
"$",
"manager",
"=",
"self",
"::",
"getAuthManager",
"(",
")",
";",
"$",
"roles",
"=",
"$",
"manager",
"->",
"defaultRoles",
";",
"if",
"(",
"$",
"manager",
"->",
"cache",
"&&",
"(",
"$",
"routes",
"=",
"$",
"manager",
"->",
"cache",
"->",
"get",
"(",
"$",
"roles",
")",
")",
"!==",
"false",
")",
"{",
"self",
"::",
"$",
"_defaultRoutes",
"=",
"$",
"routes",
";",
"}",
"else",
"{",
"$",
"permissions",
"=",
"self",
"::",
"$",
"_defaultRoutes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"roles",
"as",
"$",
"role",
")",
"{",
"$",
"permissions",
"=",
"array_merge",
"(",
"$",
"permissions",
",",
"$",
"manager",
"->",
"getPermissionsByRole",
"(",
"$",
"role",
")",
")",
";",
"}",
"foreach",
"(",
"$",
"permissions",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
"->",
"name",
"[",
"0",
"]",
"===",
"'/'",
")",
"{",
"self",
"::",
"$",
"_defaultRoutes",
"[",
"$",
"item",
"->",
"name",
"]",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"$",
"manager",
"->",
"cache",
")",
"{",
"$",
"manager",
"->",
"cache",
"->",
"set",
"(",
"$",
"roles",
",",
"self",
"::",
"$",
"_defaultRoutes",
",",
"$",
"manager",
"->",
"cacheDuration",
",",
"new",
"TagDependency",
"(",
"[",
"'tags'",
"=>",
"$",
"manager",
"->",
"cacheTag",
"]",
")",
")",
";",
"}",
"}",
"}",
"return",
"self",
"::",
"$",
"_defaultRoutes",
";",
"}"
]
| Get assigned routes by default roles
@return array | [
"Get",
"assigned",
"routes",
"by",
"default",
"roles"
]
| train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/helpers/RBACHelper.php#L51-L76 |
yuncms/framework | src/helpers/RBACHelper.php | RBACHelper.getRoutesByUser | public static function getRoutesByUser($userId)
{
if (!isset(self::$_userRoutes[$userId])) {
$manager = self::getAuthManager();
if ($manager->cache && ($routes = $manager->cache->get([__METHOD__, $userId])) !== false) {
self::$_userRoutes[$userId] = $routes;
} else {
$routes = static::getDefaultRoutes();
foreach ($manager->getPermissionsByUser($userId) as $item) {
if ($item->name[0] === '/') {
$routes[$item->name] = true;
}
}
self::$_userRoutes[$userId] = $routes;
if ($manager->cache) {
$manager->cache->set([__METHOD__, $userId], $routes, $manager->cacheDuration, new TagDependency([
'tags' => $manager->cacheTag
]));
}
}
}
return self::$_userRoutes[$userId];
} | php | public static function getRoutesByUser($userId)
{
if (!isset(self::$_userRoutes[$userId])) {
$manager = self::getAuthManager();
if ($manager->cache && ($routes = $manager->cache->get([__METHOD__, $userId])) !== false) {
self::$_userRoutes[$userId] = $routes;
} else {
$routes = static::getDefaultRoutes();
foreach ($manager->getPermissionsByUser($userId) as $item) {
if ($item->name[0] === '/') {
$routes[$item->name] = true;
}
}
self::$_userRoutes[$userId] = $routes;
if ($manager->cache) {
$manager->cache->set([__METHOD__, $userId], $routes, $manager->cacheDuration, new TagDependency([
'tags' => $manager->cacheTag
]));
}
}
}
return self::$_userRoutes[$userId];
} | [
"public",
"static",
"function",
"getRoutesByUser",
"(",
"$",
"userId",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"_userRoutes",
"[",
"$",
"userId",
"]",
")",
")",
"{",
"$",
"manager",
"=",
"self",
"::",
"getAuthManager",
"(",
")",
";",
"if",
"(",
"$",
"manager",
"->",
"cache",
"&&",
"(",
"$",
"routes",
"=",
"$",
"manager",
"->",
"cache",
"->",
"get",
"(",
"[",
"__METHOD__",
",",
"$",
"userId",
"]",
")",
")",
"!==",
"false",
")",
"{",
"self",
"::",
"$",
"_userRoutes",
"[",
"$",
"userId",
"]",
"=",
"$",
"routes",
";",
"}",
"else",
"{",
"$",
"routes",
"=",
"static",
"::",
"getDefaultRoutes",
"(",
")",
";",
"foreach",
"(",
"$",
"manager",
"->",
"getPermissionsByUser",
"(",
"$",
"userId",
")",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
"->",
"name",
"[",
"0",
"]",
"===",
"'/'",
")",
"{",
"$",
"routes",
"[",
"$",
"item",
"->",
"name",
"]",
"=",
"true",
";",
"}",
"}",
"self",
"::",
"$",
"_userRoutes",
"[",
"$",
"userId",
"]",
"=",
"$",
"routes",
";",
"if",
"(",
"$",
"manager",
"->",
"cache",
")",
"{",
"$",
"manager",
"->",
"cache",
"->",
"set",
"(",
"[",
"__METHOD__",
",",
"$",
"userId",
"]",
",",
"$",
"routes",
",",
"$",
"manager",
"->",
"cacheDuration",
",",
"new",
"TagDependency",
"(",
"[",
"'tags'",
"=>",
"$",
"manager",
"->",
"cacheTag",
"]",
")",
")",
";",
"}",
"}",
"}",
"return",
"self",
"::",
"$",
"_userRoutes",
"[",
"$",
"userId",
"]",
";",
"}"
]
| Get assigned routes of user.
@param integer $userId
@return array | [
"Get",
"assigned",
"routes",
"of",
"user",
"."
]
| train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/helpers/RBACHelper.php#L83-L105 |
yuncms/framework | src/helpers/RBACHelper.php | RBACHelper.invalidate | public static function invalidate()
{
$manager = self::getAuthManager();
if ($manager->cache !== null) {
TagDependency::invalidate($manager->cache, $manager->cacheTag);
}
} | php | public static function invalidate()
{
$manager = self::getAuthManager();
if ($manager->cache !== null) {
TagDependency::invalidate($manager->cache, $manager->cacheTag);
}
} | [
"public",
"static",
"function",
"invalidate",
"(",
")",
"{",
"$",
"manager",
"=",
"self",
"::",
"getAuthManager",
"(",
")",
";",
"if",
"(",
"$",
"manager",
"->",
"cache",
"!==",
"null",
")",
"{",
"TagDependency",
"::",
"invalidate",
"(",
"$",
"manager",
"->",
"cache",
",",
"$",
"manager",
"->",
"cacheTag",
")",
";",
"}",
"}"
]
| Use to invalidate cache. | [
"Use",
"to",
"invalidate",
"cache",
"."
]
| train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/helpers/RBACHelper.php#L241-L247 |
parsnick/steak | src/Console/Command.php | Command.setIo | protected function setIo(InputInterface $input, OutputInterface $output)
{
$this->input = $input;
$this->output = $output;
return $this;
} | php | protected function setIo(InputInterface $input, OutputInterface $output)
{
$this->input = $input;
$this->output = $output;
return $this;
} | [
"protected",
"function",
"setIo",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"this",
"->",
"input",
"=",
"$",
"input",
";",
"$",
"this",
"->",
"output",
"=",
"$",
"output",
";",
"return",
"$",
"this",
";",
"}"
]
| Attach IO to command for easier access between methods.
@param InputInterface $input
@param OutputInterface $output
@return $this | [
"Attach",
"IO",
"to",
"command",
"for",
"easier",
"access",
"between",
"methods",
"."
]
| train | https://github.com/parsnick/steak/blob/461869189a640938438187330f6c50aca97c5ccc/src/Console/Command.php#L55-L61 |
parsnick/steak | src/Console/Command.php | Command.createGulpProcess | protected function createGulpProcess($task, array $options = [])
{
$config = $this->container['config'];
return ProcessBuilder::create(array_flatten([
$config['gulp.bin'],
$task,
$options,
'--source', $config['source.directory'],
'--dest', $config['build.directory'],
'--gulpfile', $config['source.directory'] . DIRECTORY_SEPARATOR . $config['gulp.file'],
'--phpwd', getcwd(),
'--color',
]))
->getProcess();
} | php | protected function createGulpProcess($task, array $options = [])
{
$config = $this->container['config'];
return ProcessBuilder::create(array_flatten([
$config['gulp.bin'],
$task,
$options,
'--source', $config['source.directory'],
'--dest', $config['build.directory'],
'--gulpfile', $config['source.directory'] . DIRECTORY_SEPARATOR . $config['gulp.file'],
'--phpwd', getcwd(),
'--color',
]))
->getProcess();
} | [
"protected",
"function",
"createGulpProcess",
"(",
"$",
"task",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"container",
"[",
"'config'",
"]",
";",
"return",
"ProcessBuilder",
"::",
"create",
"(",
"array_flatten",
"(",
"[",
"$",
"config",
"[",
"'gulp.bin'",
"]",
",",
"$",
"task",
",",
"$",
"options",
",",
"'--source'",
",",
"$",
"config",
"[",
"'source.directory'",
"]",
",",
"'--dest'",
",",
"$",
"config",
"[",
"'build.directory'",
"]",
",",
"'--gulpfile'",
",",
"$",
"config",
"[",
"'source.directory'",
"]",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"config",
"[",
"'gulp.file'",
"]",
",",
"'--phpwd'",
",",
"getcwd",
"(",
")",
",",
"'--color'",
",",
"]",
")",
")",
"->",
"getProcess",
"(",
")",
";",
"}"
]
| Create a process builder for the given gulp task.
@param string $task
@param array $options
@return Process | [
"Create",
"a",
"process",
"builder",
"for",
"the",
"given",
"gulp",
"task",
"."
]
| train | https://github.com/parsnick/steak/blob/461869189a640938438187330f6c50aca97c5ccc/src/Console/Command.php#L70-L85 |
parsnick/steak | src/Console/Command.php | Command.runTimedTask | protected function runTimedTask(Closure $task)
{
$timer = new Stopwatch();
$timer->start('subtask');
$task();
return $timer->stop('subtask')->getDuration();
} | php | protected function runTimedTask(Closure $task)
{
$timer = new Stopwatch();
$timer->start('subtask');
$task();
return $timer->stop('subtask')->getDuration();
} | [
"protected",
"function",
"runTimedTask",
"(",
"Closure",
"$",
"task",
")",
"{",
"$",
"timer",
"=",
"new",
"Stopwatch",
"(",
")",
";",
"$",
"timer",
"->",
"start",
"(",
"'subtask'",
")",
";",
"$",
"task",
"(",
")",
";",
"return",
"$",
"timer",
"->",
"stop",
"(",
"'subtask'",
")",
"->",
"getDuration",
"(",
")",
";",
"}"
]
| Get the ms duration of the time taken for $task to execute.
@param Closure $task
@return int | [
"Get",
"the",
"ms",
"duration",
"of",
"the",
"time",
"taken",
"for",
"$task",
"to",
"execute",
"."
]
| train | https://github.com/parsnick/steak/blob/461869189a640938438187330f6c50aca97c5ccc/src/Console/Command.php#L109-L117 |
steeffeen/FancyManiaLinks | FML/Script/Features/ScriptFeature.php | ScriptFeature.collect | public static function collect()
{
$params = func_get_args();
$scriptFeatures = array();
foreach ($params as $object) {
if ($object instanceof ScriptFeature) {
$scriptFeatures = static::addScriptFeature($scriptFeatures, $object);
} else if ($object instanceof ScriptFeatureable) {
$scriptFeatures = static::addScriptFeature($scriptFeatures, $object->getScriptFeatures());
} else if (is_array($object)) {
foreach ($object as $subObject) {
$scriptFeatures = static::addScriptFeature($scriptFeatures, static::collect($subObject));
}
}
}
return $scriptFeatures;
} | php | public static function collect()
{
$params = func_get_args();
$scriptFeatures = array();
foreach ($params as $object) {
if ($object instanceof ScriptFeature) {
$scriptFeatures = static::addScriptFeature($scriptFeatures, $object);
} else if ($object instanceof ScriptFeatureable) {
$scriptFeatures = static::addScriptFeature($scriptFeatures, $object->getScriptFeatures());
} else if (is_array($object)) {
foreach ($object as $subObject) {
$scriptFeatures = static::addScriptFeature($scriptFeatures, static::collect($subObject));
}
}
}
return $scriptFeatures;
} | [
"public",
"static",
"function",
"collect",
"(",
")",
"{",
"$",
"params",
"=",
"func_get_args",
"(",
")",
";",
"$",
"scriptFeatures",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"params",
"as",
"$",
"object",
")",
"{",
"if",
"(",
"$",
"object",
"instanceof",
"ScriptFeature",
")",
"{",
"$",
"scriptFeatures",
"=",
"static",
"::",
"addScriptFeature",
"(",
"$",
"scriptFeatures",
",",
"$",
"object",
")",
";",
"}",
"else",
"if",
"(",
"$",
"object",
"instanceof",
"ScriptFeatureable",
")",
"{",
"$",
"scriptFeatures",
"=",
"static",
"::",
"addScriptFeature",
"(",
"$",
"scriptFeatures",
",",
"$",
"object",
"->",
"getScriptFeatures",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"is_array",
"(",
"$",
"object",
")",
")",
"{",
"foreach",
"(",
"$",
"object",
"as",
"$",
"subObject",
")",
"{",
"$",
"scriptFeatures",
"=",
"static",
"::",
"addScriptFeature",
"(",
"$",
"scriptFeatures",
",",
"static",
"::",
"collect",
"(",
"$",
"subObject",
")",
")",
";",
"}",
"}",
"}",
"return",
"$",
"scriptFeatures",
";",
"}"
]
| Collect the Script Features of the given objects
@return ScriptFeature[] | [
"Collect",
"the",
"Script",
"Features",
"of",
"the",
"given",
"objects"
]
| train | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/ScriptFeature.php#L23-L39 |
steeffeen/FancyManiaLinks | FML/Script/Features/ScriptFeature.php | ScriptFeature.addScriptFeature | public static function addScriptFeature(array $scriptFeatures, $newScriptFeatures)
{
if (!$newScriptFeatures) {
return $scriptFeatures;
}
if ($newScriptFeatures instanceof ScriptFeature) {
if (!in_array($newScriptFeatures, $scriptFeatures, true)) {
array_push($scriptFeatures, $newScriptFeatures);
}
} else if (is_array($newScriptFeatures)) {
foreach ($newScriptFeatures as $newScriptFeature) {
$scriptFeatures = static::addScriptFeature($scriptFeatures, $newScriptFeature);
}
}
return $scriptFeatures;
} | php | public static function addScriptFeature(array $scriptFeatures, $newScriptFeatures)
{
if (!$newScriptFeatures) {
return $scriptFeatures;
}
if ($newScriptFeatures instanceof ScriptFeature) {
if (!in_array($newScriptFeatures, $scriptFeatures, true)) {
array_push($scriptFeatures, $newScriptFeatures);
}
} else if (is_array($newScriptFeatures)) {
foreach ($newScriptFeatures as $newScriptFeature) {
$scriptFeatures = static::addScriptFeature($scriptFeatures, $newScriptFeature);
}
}
return $scriptFeatures;
} | [
"public",
"static",
"function",
"addScriptFeature",
"(",
"array",
"$",
"scriptFeatures",
",",
"$",
"newScriptFeatures",
")",
"{",
"if",
"(",
"!",
"$",
"newScriptFeatures",
")",
"{",
"return",
"$",
"scriptFeatures",
";",
"}",
"if",
"(",
"$",
"newScriptFeatures",
"instanceof",
"ScriptFeature",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"newScriptFeatures",
",",
"$",
"scriptFeatures",
",",
"true",
")",
")",
"{",
"array_push",
"(",
"$",
"scriptFeatures",
",",
"$",
"newScriptFeatures",
")",
";",
"}",
"}",
"else",
"if",
"(",
"is_array",
"(",
"$",
"newScriptFeatures",
")",
")",
"{",
"foreach",
"(",
"$",
"newScriptFeatures",
"as",
"$",
"newScriptFeature",
")",
"{",
"$",
"scriptFeatures",
"=",
"static",
"::",
"addScriptFeature",
"(",
"$",
"scriptFeatures",
",",
"$",
"newScriptFeature",
")",
";",
"}",
"}",
"return",
"$",
"scriptFeatures",
";",
"}"
]
| Add one or more Script Features to an Array of Features if they are not already contained
@param array $scriptFeatures
@param ScriptFeature||ScriptFeature[] $newScriptFeatures
@return array | [
"Add",
"one",
"or",
"more",
"Script",
"Features",
"to",
"an",
"Array",
"of",
"Features",
"if",
"they",
"are",
"not",
"already",
"contained"
]
| train | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/ScriptFeature.php#L48-L63 |
nyeholt/silverstripe-external-content | thirdparty/Zend/Validate/File/Size.php | Zend_Validate_File_Size.isValid | public function isValid($value, $file = null)
{
// Is file readable ?
require_once 'Zend/Loader.php';
if (!Zend_Loader::isReadable($value)) {
return $this->_throw($file, self::NOT_FOUND);
}
// limited to 4GB files
$size = sprintf("%u", @filesize($value));
// Check to see if it's smaller than min size
$min = $this->getMin(true);
$max = $this->getMax(true);
if (($min !== null) && ($size < $min)) {
if ($this->useByteString()) {
$this->_min = $this->_toByteString($min);
$this->_size = $this->_toByteString($size);
$this->_throw($file, self::TOO_SMALL);
$this->_min = $min;
$this->_size = $size;
} else {
$this->_throw($file, self::TOO_SMALL);
}
}
// Check to see if it's larger than max size
if (($max !== null) && ($max < $size)) {
if ($this->useByteString()) {
$this->_max = $this->_toByteString($max);
$this->_size = $this->_toByteString($size);
$this->_throw($file, self::TOO_BIG);
$this->_max = $max;
$this->_size = $size;
} else {
$this->_throw($file, self::TOO_BIG);
}
}
if (count($this->_messages) > 0) {
return false;
}
return true;
} | php | public function isValid($value, $file = null)
{
// Is file readable ?
require_once 'Zend/Loader.php';
if (!Zend_Loader::isReadable($value)) {
return $this->_throw($file, self::NOT_FOUND);
}
// limited to 4GB files
$size = sprintf("%u", @filesize($value));
// Check to see if it's smaller than min size
$min = $this->getMin(true);
$max = $this->getMax(true);
if (($min !== null) && ($size < $min)) {
if ($this->useByteString()) {
$this->_min = $this->_toByteString($min);
$this->_size = $this->_toByteString($size);
$this->_throw($file, self::TOO_SMALL);
$this->_min = $min;
$this->_size = $size;
} else {
$this->_throw($file, self::TOO_SMALL);
}
}
// Check to see if it's larger than max size
if (($max !== null) && ($max < $size)) {
if ($this->useByteString()) {
$this->_max = $this->_toByteString($max);
$this->_size = $this->_toByteString($size);
$this->_throw($file, self::TOO_BIG);
$this->_max = $max;
$this->_size = $size;
} else {
$this->_throw($file, self::TOO_BIG);
}
}
if (count($this->_messages) > 0) {
return false;
}
return true;
} | [
"public",
"function",
"isValid",
"(",
"$",
"value",
",",
"$",
"file",
"=",
"null",
")",
"{",
"// Is file readable ?",
"require_once",
"'Zend/Loader.php'",
";",
"if",
"(",
"!",
"Zend_Loader",
"::",
"isReadable",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_throw",
"(",
"$",
"file",
",",
"self",
"::",
"NOT_FOUND",
")",
";",
"}",
"// limited to 4GB files",
"$",
"size",
"=",
"sprintf",
"(",
"\"%u\"",
",",
"@",
"filesize",
"(",
"$",
"value",
")",
")",
";",
"// Check to see if it's smaller than min size",
"$",
"min",
"=",
"$",
"this",
"->",
"getMin",
"(",
"true",
")",
";",
"$",
"max",
"=",
"$",
"this",
"->",
"getMax",
"(",
"true",
")",
";",
"if",
"(",
"(",
"$",
"min",
"!==",
"null",
")",
"&&",
"(",
"$",
"size",
"<",
"$",
"min",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"useByteString",
"(",
")",
")",
"{",
"$",
"this",
"->",
"_min",
"=",
"$",
"this",
"->",
"_toByteString",
"(",
"$",
"min",
")",
";",
"$",
"this",
"->",
"_size",
"=",
"$",
"this",
"->",
"_toByteString",
"(",
"$",
"size",
")",
";",
"$",
"this",
"->",
"_throw",
"(",
"$",
"file",
",",
"self",
"::",
"TOO_SMALL",
")",
";",
"$",
"this",
"->",
"_min",
"=",
"$",
"min",
";",
"$",
"this",
"->",
"_size",
"=",
"$",
"size",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_throw",
"(",
"$",
"file",
",",
"self",
"::",
"TOO_SMALL",
")",
";",
"}",
"}",
"// Check to see if it's larger than max size",
"if",
"(",
"(",
"$",
"max",
"!==",
"null",
")",
"&&",
"(",
"$",
"max",
"<",
"$",
"size",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"useByteString",
"(",
")",
")",
"{",
"$",
"this",
"->",
"_max",
"=",
"$",
"this",
"->",
"_toByteString",
"(",
"$",
"max",
")",
";",
"$",
"this",
"->",
"_size",
"=",
"$",
"this",
"->",
"_toByteString",
"(",
"$",
"size",
")",
";",
"$",
"this",
"->",
"_throw",
"(",
"$",
"file",
",",
"self",
"::",
"TOO_BIG",
")",
";",
"$",
"this",
"->",
"_max",
"=",
"$",
"max",
";",
"$",
"this",
"->",
"_size",
"=",
"$",
"size",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_throw",
"(",
"$",
"file",
",",
"self",
"::",
"TOO_BIG",
")",
";",
"}",
"}",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"_messages",
")",
">",
"0",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
]
| Defined by Zend_Validate_Interface
Returns true if and only if the filesize of $value is at least min and
not bigger than max (when max is not null).
@param string $value Real file to check for size
@param array $file File data from Zend_File_Transfer
@return boolean | [
"Defined",
"by",
"Zend_Validate_Interface"
]
| train | https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Validate/File/Size.php#L275-L319 |
chubbyphp/chubbyphp-api-http | src/Manager/RequestManager.php | RequestManager.getDataFromRequestQuery | public function getDataFromRequestQuery(
ServerRequestInterface $request,
$object,
DenormalizerContextInterface $context = null
) {
return $this->deserializer->denormalize($object, $request->getQueryParams(), $context);
} | php | public function getDataFromRequestQuery(
ServerRequestInterface $request,
$object,
DenormalizerContextInterface $context = null
) {
return $this->deserializer->denormalize($object, $request->getQueryParams(), $context);
} | [
"public",
"function",
"getDataFromRequestQuery",
"(",
"ServerRequestInterface",
"$",
"request",
",",
"$",
"object",
",",
"DenormalizerContextInterface",
"$",
"context",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"deserializer",
"->",
"denormalize",
"(",
"$",
"object",
",",
"$",
"request",
"->",
"getQueryParams",
"(",
")",
",",
"$",
"context",
")",
";",
"}"
]
| @param ServerRequestInterface $request
@param object|string $object
@param DenormalizerContextInterface|null $context
@return object | [
"@param",
"ServerRequestInterface",
"$request",
"@param",
"object|string",
"$object",
"@param",
"DenormalizerContextInterface|null",
"$context"
]
| train | https://github.com/chubbyphp/chubbyphp-api-http/blob/675d657b686e96aa16be56d0e9e07aaa844266ed/src/Manager/RequestManager.php#L33-L39 |
chubbyphp/chubbyphp-api-http | src/Manager/RequestManager.php | RequestManager.getDataFromRequestBody | public function getDataFromRequestBody(
ServerRequestInterface $request,
$object,
string $contentType,
DenormalizerContextInterface $context = null
) {
return $this->deserializer->deserialize($object, (string) $request->getBody(), $contentType, $context);
} | php | public function getDataFromRequestBody(
ServerRequestInterface $request,
$object,
string $contentType,
DenormalizerContextInterface $context = null
) {
return $this->deserializer->deserialize($object, (string) $request->getBody(), $contentType, $context);
} | [
"public",
"function",
"getDataFromRequestBody",
"(",
"ServerRequestInterface",
"$",
"request",
",",
"$",
"object",
",",
"string",
"$",
"contentType",
",",
"DenormalizerContextInterface",
"$",
"context",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"deserializer",
"->",
"deserialize",
"(",
"$",
"object",
",",
"(",
"string",
")",
"$",
"request",
"->",
"getBody",
"(",
")",
",",
"$",
"contentType",
",",
"$",
"context",
")",
";",
"}"
]
| @param ServerRequestInterface $request
@param object|string $object
@param string $contentType
@param DenormalizerContextInterface|null $context
@return object | [
"@param",
"ServerRequestInterface",
"$request",
"@param",
"object|string",
"$object",
"@param",
"string",
"$contentType",
"@param",
"DenormalizerContextInterface|null",
"$context"
]
| train | https://github.com/chubbyphp/chubbyphp-api-http/blob/675d657b686e96aa16be56d0e9e07aaa844266ed/src/Manager/RequestManager.php#L49-L56 |
nyeholt/silverstripe-external-content | code/ECUtils.php | ECUtils.dbQuote | function dbQuote($filter = array(), $join = " AND ") {
$QUOTE_CHAR = defined('DB::USE_ANSI_SQL') ? '"' : '';
$string = '';
$sep = '';
foreach ($filter as $field => $value) {
// first break the field up into its two components
$operator = '';
if (is_string($field)) {
list($field, $operator) = explode(' ', trim($field));
}
$value = $this->recursiveQuote($value);
if (strpos($field, '.')) {
list($tb, $fl) = explode('.', $field);
$string .= $sep . $QUOTE_CHAR . $tb . $QUOTE_CHAR . '.' . $QUOTE_CHAR . $fl . $QUOTE_CHAR . " $operator " . $value;
} else {
if (is_numeric($field)) {
$string .= $sep . $value;
} else {
$string .= $sep . $QUOTE_CHAR . $field . $QUOTE_CHAR . " $operator " . $value;
}
}
$sep = $join;
}
return $string;
} | php | function dbQuote($filter = array(), $join = " AND ") {
$QUOTE_CHAR = defined('DB::USE_ANSI_SQL') ? '"' : '';
$string = '';
$sep = '';
foreach ($filter as $field => $value) {
// first break the field up into its two components
$operator = '';
if (is_string($field)) {
list($field, $operator) = explode(' ', trim($field));
}
$value = $this->recursiveQuote($value);
if (strpos($field, '.')) {
list($tb, $fl) = explode('.', $field);
$string .= $sep . $QUOTE_CHAR . $tb . $QUOTE_CHAR . '.' . $QUOTE_CHAR . $fl . $QUOTE_CHAR . " $operator " . $value;
} else {
if (is_numeric($field)) {
$string .= $sep . $value;
} else {
$string .= $sep . $QUOTE_CHAR . $field . $QUOTE_CHAR . " $operator " . $value;
}
}
$sep = $join;
}
return $string;
} | [
"function",
"dbQuote",
"(",
"$",
"filter",
"=",
"array",
"(",
")",
",",
"$",
"join",
"=",
"\" AND \"",
")",
"{",
"$",
"QUOTE_CHAR",
"=",
"defined",
"(",
"'DB::USE_ANSI_SQL'",
")",
"?",
"'\"'",
":",
"''",
";",
"$",
"string",
"=",
"''",
";",
"$",
"sep",
"=",
"''",
";",
"foreach",
"(",
"$",
"filter",
"as",
"$",
"field",
"=>",
"$",
"value",
")",
"{",
"// first break the field up into its two components",
"$",
"operator",
"=",
"''",
";",
"if",
"(",
"is_string",
"(",
"$",
"field",
")",
")",
"{",
"list",
"(",
"$",
"field",
",",
"$",
"operator",
")",
"=",
"explode",
"(",
"' '",
",",
"trim",
"(",
"$",
"field",
")",
")",
";",
"}",
"$",
"value",
"=",
"$",
"this",
"->",
"recursiveQuote",
"(",
"$",
"value",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"field",
",",
"'.'",
")",
")",
"{",
"list",
"(",
"$",
"tb",
",",
"$",
"fl",
")",
"=",
"explode",
"(",
"'.'",
",",
"$",
"field",
")",
";",
"$",
"string",
".=",
"$",
"sep",
".",
"$",
"QUOTE_CHAR",
".",
"$",
"tb",
".",
"$",
"QUOTE_CHAR",
".",
"'.'",
".",
"$",
"QUOTE_CHAR",
".",
"$",
"fl",
".",
"$",
"QUOTE_CHAR",
".",
"\" $operator \"",
".",
"$",
"value",
";",
"}",
"else",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"field",
")",
")",
"{",
"$",
"string",
".=",
"$",
"sep",
".",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"string",
".=",
"$",
"sep",
".",
"$",
"QUOTE_CHAR",
".",
"$",
"field",
".",
"$",
"QUOTE_CHAR",
".",
"\" $operator \"",
".",
"$",
"value",
";",
"}",
"}",
"$",
"sep",
"=",
"$",
"join",
";",
"}",
"return",
"$",
"string",
";",
"}"
]
| Quote up a filter of the form
array ("ParentID =" => 1)
@param unknown_type $filter
@return unknown_type | [
"Quote",
"up",
"a",
"filter",
"of",
"the",
"form"
]
| train | https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/ECUtils.php#L21-L51 |
phossa2/config | src/Config/Config.php | Config.get | public function get(/*# string */ $id, $default = null)
{
if ($this->has($id)) {
// cached from has()
$val = $this->cached_value;
// dereference
$this->deReferenceArray($val);
return null === $val ? $default : $val;
}
return $default;
} | php | public function get(/*# string */ $id, $default = null)
{
if ($this->has($id)) {
// cached from has()
$val = $this->cached_value;
// dereference
$this->deReferenceArray($val);
return null === $val ? $default : $val;
}
return $default;
} | [
"public",
"function",
"get",
"(",
"/*# string */",
"$",
"id",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"id",
")",
")",
"{",
"// cached from has()",
"$",
"val",
"=",
"$",
"this",
"->",
"cached_value",
";",
"// dereference",
"$",
"this",
"->",
"deReferenceArray",
"(",
"$",
"val",
")",
";",
"return",
"null",
"===",
"$",
"val",
"?",
"$",
"default",
":",
"$",
"val",
";",
"}",
"return",
"$",
"default",
";",
"}"
]
| {@inheritDoc} | [
"{"
]
| train | https://github.com/phossa2/config/blob/7c046fd2c97633b69545b4745d8bffe28e19b1df/src/Config/Config.php#L128-L140 |
phossa2/config | src/Config/Config.php | Config.has | public function has(/*# string */ $id)/*# : bool */
{
// checked already
if ($id === $this->cached_id) {
return null !== $this->cached_value;
}
// default result
$this->cached_id = $id;
$this->cached_value = null;
// try get config
try {
$this->loadConfig((string) $id);
$this->cached_value = $this->config->getNode((string) $id);
return null !== $this->cached_value;
} catch (\Exception $e) {
$this->throwError($e->getMessage(), $e->getCode());
return false;
}
} | php | public function has(/*# string */ $id)/*# : bool */
{
// checked already
if ($id === $this->cached_id) {
return null !== $this->cached_value;
}
// default result
$this->cached_id = $id;
$this->cached_value = null;
// try get config
try {
$this->loadConfig((string) $id);
$this->cached_value = $this->config->getNode((string) $id);
return null !== $this->cached_value;
} catch (\Exception $e) {
$this->throwError($e->getMessage(), $e->getCode());
return false;
}
} | [
"public",
"function",
"has",
"(",
"/*# string */",
"$",
"id",
")",
"/*# : bool */",
"{",
"// checked already",
"if",
"(",
"$",
"id",
"===",
"$",
"this",
"->",
"cached_id",
")",
"{",
"return",
"null",
"!==",
"$",
"this",
"->",
"cached_value",
";",
"}",
"// default result",
"$",
"this",
"->",
"cached_id",
"=",
"$",
"id",
";",
"$",
"this",
"->",
"cached_value",
"=",
"null",
";",
"// try get config",
"try",
"{",
"$",
"this",
"->",
"loadConfig",
"(",
"(",
"string",
")",
"$",
"id",
")",
";",
"$",
"this",
"->",
"cached_value",
"=",
"$",
"this",
"->",
"config",
"->",
"getNode",
"(",
"(",
"string",
")",
"$",
"id",
")",
";",
"return",
"null",
"!==",
"$",
"this",
"->",
"cached_value",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"throwError",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
"->",
"getCode",
"(",
")",
")",
";",
"return",
"false",
";",
"}",
"}"
]
| {@inheritDoc} | [
"{"
]
| train | https://github.com/phossa2/config/blob/7c046fd2c97633b69545b4745d8bffe28e19b1df/src/Config/Config.php#L145-L165 |
phossa2/config | src/Config/Config.php | Config.set | public function set(/*# string */ $id, $value)/*# : bool */
{
if ($this->isWritable()) {
// lazy load, no dereference
$this->loadConfig((string) $id);
// replace the node
$this->cached_id = null;
$this->config->addNode($id, $value);
return $this->has($id);
} else {
$this->throwError(
Message::get(Message::CONFIG_NOT_WRITABLE),
Message::CONFIG_NOT_WRITABLE
);
}
} | php | public function set(/*# string */ $id, $value)/*# : bool */
{
if ($this->isWritable()) {
// lazy load, no dereference
$this->loadConfig((string) $id);
// replace the node
$this->cached_id = null;
$this->config->addNode($id, $value);
return $this->has($id);
} else {
$this->throwError(
Message::get(Message::CONFIG_NOT_WRITABLE),
Message::CONFIG_NOT_WRITABLE
);
}
} | [
"public",
"function",
"set",
"(",
"/*# string */",
"$",
"id",
",",
"$",
"value",
")",
"/*# : bool */",
"{",
"if",
"(",
"$",
"this",
"->",
"isWritable",
"(",
")",
")",
"{",
"// lazy load, no dereference",
"$",
"this",
"->",
"loadConfig",
"(",
"(",
"string",
")",
"$",
"id",
")",
";",
"// replace the node",
"$",
"this",
"->",
"cached_id",
"=",
"null",
";",
"$",
"this",
"->",
"config",
"->",
"addNode",
"(",
"$",
"id",
",",
"$",
"value",
")",
";",
"return",
"$",
"this",
"->",
"has",
"(",
"$",
"id",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"throwError",
"(",
"Message",
"::",
"get",
"(",
"Message",
"::",
"CONFIG_NOT_WRITABLE",
")",
",",
"Message",
"::",
"CONFIG_NOT_WRITABLE",
")",
";",
"}",
"}"
]
| {@inheritDoc} | [
"{"
]
| train | https://github.com/phossa2/config/blob/7c046fd2c97633b69545b4745d8bffe28e19b1df/src/Config/Config.php#L170-L187 |
phossa2/config | src/Config/Config.php | Config.loadConfig | protected function loadConfig(/*# string */ $id)
{
// get group name
$group = $this->getGroupName($id);
// $group loaded ?
if (isset($this->loaded[$group])) {
return $this;
}
// mark as loaded
$this->loaded[$group] = true;
// loading the group
return $this->loadByGroup($group);
} | php | protected function loadConfig(/*# string */ $id)
{
// get group name
$group = $this->getGroupName($id);
// $group loaded ?
if (isset($this->loaded[$group])) {
return $this;
}
// mark as loaded
$this->loaded[$group] = true;
// loading the group
return $this->loadByGroup($group);
} | [
"protected",
"function",
"loadConfig",
"(",
"/*# string */",
"$",
"id",
")",
"{",
"// get group name",
"$",
"group",
"=",
"$",
"this",
"->",
"getGroupName",
"(",
"$",
"id",
")",
";",
"// $group loaded ?",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"loaded",
"[",
"$",
"group",
"]",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"// mark as loaded",
"$",
"this",
"->",
"loaded",
"[",
"$",
"group",
"]",
"=",
"true",
";",
"// loading the group",
"return",
"$",
"this",
"->",
"loadByGroup",
"(",
"$",
"group",
")",
";",
"}"
]
| Load config
@param string $id
@return $this
@throws LogicException if current $error_type is to throw exception
@access protected | [
"Load",
"config"
]
| train | https://github.com/phossa2/config/blob/7c046fd2c97633b69545b4745d8bffe28e19b1df/src/Config/Config.php#L211-L226 |
phossa2/config | src/Config/Config.php | Config.loadByGroup | protected function loadByGroup(/*# string */ $group)
{
// load super global
if ('' !== $group && '_' === $group[0]) {
return $this->loadGlobal($group);
}
// load from config
$conf = $this->loader->load($group);
foreach ($conf as $grp => $data) {
$this->config->addNode($grp, $data);
}
return $this;
} | php | protected function loadByGroup(/*# string */ $group)
{
// load super global
if ('' !== $group && '_' === $group[0]) {
return $this->loadGlobal($group);
}
// load from config
$conf = $this->loader->load($group);
foreach ($conf as $grp => $data) {
$this->config->addNode($grp, $data);
}
return $this;
} | [
"protected",
"function",
"loadByGroup",
"(",
"/*# string */",
"$",
"group",
")",
"{",
"// load super global",
"if",
"(",
"''",
"!==",
"$",
"group",
"&&",
"'_'",
"===",
"$",
"group",
"[",
"0",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"loadGlobal",
"(",
"$",
"group",
")",
";",
"}",
"// load from config",
"$",
"conf",
"=",
"$",
"this",
"->",
"loader",
"->",
"load",
"(",
"$",
"group",
")",
";",
"foreach",
"(",
"$",
"conf",
"as",
"$",
"grp",
"=>",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"config",
"->",
"addNode",
"(",
"$",
"grp",
",",
"$",
"data",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Load one group config, force loading all groups if $group == ''
@param string $group
@return $this
@throws \Exception group loading issues
@access protected | [
"Load",
"one",
"group",
"config",
"force",
"loading",
"all",
"groups",
"if",
"$group",
"=="
]
| train | https://github.com/phossa2/config/blob/7c046fd2c97633b69545b4745d8bffe28e19b1df/src/Config/Config.php#L236-L251 |
phossa2/config | src/Config/Config.php | Config.loadGlobal | protected function loadGlobal(/*# string */ $group)
{
if (!isset($GLOBALS[$group])) {
$this->throwError(
Message::get(Message::CONFIG_GLOBAL_UNKNOWN, $group),
Message::CONFIG_GLOBAL_UNKNOWN
);
}
// load super global
$this->config->addNode($group, $GLOBALS[$group]);
return $this;
} | php | protected function loadGlobal(/*# string */ $group)
{
if (!isset($GLOBALS[$group])) {
$this->throwError(
Message::get(Message::CONFIG_GLOBAL_UNKNOWN, $group),
Message::CONFIG_GLOBAL_UNKNOWN
);
}
// load super global
$this->config->addNode($group, $GLOBALS[$group]);
return $this;
} | [
"protected",
"function",
"loadGlobal",
"(",
"/*# string */",
"$",
"group",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"GLOBALS",
"[",
"$",
"group",
"]",
")",
")",
"{",
"$",
"this",
"->",
"throwError",
"(",
"Message",
"::",
"get",
"(",
"Message",
"::",
"CONFIG_GLOBAL_UNKNOWN",
",",
"$",
"group",
")",
",",
"Message",
"::",
"CONFIG_GLOBAL_UNKNOWN",
")",
";",
"}",
"// load super global",
"$",
"this",
"->",
"config",
"->",
"addNode",
"(",
"$",
"group",
",",
"$",
"GLOBALS",
"[",
"$",
"group",
"]",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Load super globals
@param string $group
@return $this
@throws LogicException if super global unknown
@access protected | [
"Load",
"super",
"globals"
]
| train | https://github.com/phossa2/config/blob/7c046fd2c97633b69545b4745d8bffe28e19b1df/src/Config/Config.php#L261-L274 |
phossa2/config | src/Config/Config.php | Config.getGroupName | protected function getGroupName(/*# string */ $id)/*# : string */
{
return explode(
$this->config->getDelimiter(),
ltrim($id, $this->config->getDelimiter())
)[0];
} | php | protected function getGroupName(/*# string */ $id)/*# : string */
{
return explode(
$this->config->getDelimiter(),
ltrim($id, $this->config->getDelimiter())
)[0];
} | [
"protected",
"function",
"getGroupName",
"(",
"/*# string */",
"$",
"id",
")",
"/*# : string */",
"{",
"return",
"explode",
"(",
"$",
"this",
"->",
"config",
"->",
"getDelimiter",
"(",
")",
",",
"ltrim",
"(",
"$",
"id",
",",
"$",
"this",
"->",
"config",
"->",
"getDelimiter",
"(",
")",
")",
")",
"[",
"0",
"]",
";",
"}"
]
| Get group name
- returns 'system' from $id 'system.dir.tmp'
- '.system.tmpdir' is invalid
@param string $id
@return string
@access protected | [
"Get",
"group",
"name"
]
| train | https://github.com/phossa2/config/blob/7c046fd2c97633b69545b4745d8bffe28e19b1df/src/Config/Config.php#L286-L292 |
phossa2/config | src/Config/Config.php | Config.referenceLookup | protected function referenceLookup(/*# string */ $name)
{
if ($this->hasDelegator()) {
// get delegator recursively
$delegator = $this->getDelegator(true);
$val = $delegator->get($name);
} else {
$val = $this->getReference($name);
}
return $val;
} | php | protected function referenceLookup(/*# string */ $name)
{
if ($this->hasDelegator()) {
// get delegator recursively
$delegator = $this->getDelegator(true);
$val = $delegator->get($name);
} else {
$val = $this->getReference($name);
}
return $val;
} | [
"protected",
"function",
"referenceLookup",
"(",
"/*# string */",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasDelegator",
"(",
")",
")",
"{",
"// get delegator recursively",
"$",
"delegator",
"=",
"$",
"this",
"->",
"getDelegator",
"(",
"true",
")",
";",
"$",
"val",
"=",
"$",
"delegator",
"->",
"get",
"(",
"$",
"name",
")",
";",
"}",
"else",
"{",
"$",
"val",
"=",
"$",
"this",
"->",
"getReference",
"(",
"$",
"name",
")",
";",
"}",
"return",
"$",
"val",
";",
"}"
]
| Override 'referenceLookup()' in ReferenceTrait.
Delegator support goes here
@since 2.0.10 using recursive getDelegator
{@inheritDoc} | [
"Override",
"referenceLookup",
"()",
"in",
"ReferenceTrait",
"."
]
| train | https://github.com/phossa2/config/blob/7c046fd2c97633b69545b4745d8bffe28e19b1df/src/Config/Config.php#L302-L312 |
phossa2/config | src/Config/Config.php | Config.resolveUnknown | protected function resolveUnknown(/*# string */ $name)
{
// warn if reference unknown
$this->throwError(
Message::get(Message::CONFIG_REFERENCE_UNKNOWN, $name),
Message::CONFIG_REFERENCE_UNKNOWN
);
return null;
} | php | protected function resolveUnknown(/*# string */ $name)
{
// warn if reference unknown
$this->throwError(
Message::get(Message::CONFIG_REFERENCE_UNKNOWN, $name),
Message::CONFIG_REFERENCE_UNKNOWN
);
return null;
} | [
"protected",
"function",
"resolveUnknown",
"(",
"/*# string */",
"$",
"name",
")",
"{",
"// warn if reference unknown",
"$",
"this",
"->",
"throwError",
"(",
"Message",
"::",
"get",
"(",
"Message",
"::",
"CONFIG_REFERENCE_UNKNOWN",
",",
"$",
"name",
")",
",",
"Message",
"::",
"CONFIG_REFERENCE_UNKNOWN",
")",
";",
"return",
"null",
";",
"}"
]
| throw exception if current $error_type is to throw exception
{@inheritDoc} | [
"throw",
"exception",
"if",
"current",
"$error_type",
"is",
"to",
"throw",
"exception"
]
| train | https://github.com/phossa2/config/blob/7c046fd2c97633b69545b4745d8bffe28e19b1df/src/Config/Config.php#L319-L328 |
phossa2/config | src/Config/Config.php | Config.throwError | protected function throwError(/*# string */ $message, /*# int */ $code)
{
switch ($this->error_type) {
case self::ERROR_WARNING:
trigger_error($message, \E_USER_WARNING);
break;
case self::ERROR_EXCEPTION:
throw new LogicException($message, $code);
default:
break;
}
return $this;
} | php | protected function throwError(/*# string */ $message, /*# int */ $code)
{
switch ($this->error_type) {
case self::ERROR_WARNING:
trigger_error($message, \E_USER_WARNING);
break;
case self::ERROR_EXCEPTION:
throw new LogicException($message, $code);
default:
break;
}
return $this;
} | [
"protected",
"function",
"throwError",
"(",
"/*# string */",
"$",
"message",
",",
"/*# int */",
"$",
"code",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"error_type",
")",
"{",
"case",
"self",
"::",
"ERROR_WARNING",
":",
"trigger_error",
"(",
"$",
"message",
",",
"\\",
"E_USER_WARNING",
")",
";",
"break",
";",
"case",
"self",
"::",
"ERROR_EXCEPTION",
":",
"throw",
"new",
"LogicException",
"(",
"$",
"message",
",",
"$",
"code",
")",
";",
"default",
":",
"break",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Dealing errors
@param string $message
@param int $code
@return $this
@throws LogicException if current $error_type is to throw exception
@access protected | [
"Dealing",
"errors"
]
| train | https://github.com/phossa2/config/blob/7c046fd2c97633b69545b4745d8bffe28e19b1df/src/Config/Config.php#L347-L359 |
fond-of/spryker-brand | src/FondOfSpryker/Zed/Brand/Business/Brand/BrandReader.php | BrandReader.getBrandCollection | public function getBrandCollection(BrandCollectionTransfer $brandCollectionTransfer): BrandCollectionTransfer
{
$brandCollectionTransfer = $this->brandRepository->getBrandCollection($brandCollectionTransfer);
if (!empty($brandCollectionTransfer->getBrands())) {
foreach ($brandCollectionTransfer->getBrands() as $brandTransfer) {
$this->brandExpander->expand($brandTransfer);
}
}
return $brandCollectionTransfer;
} | php | public function getBrandCollection(BrandCollectionTransfer $brandCollectionTransfer): BrandCollectionTransfer
{
$brandCollectionTransfer = $this->brandRepository->getBrandCollection($brandCollectionTransfer);
if (!empty($brandCollectionTransfer->getBrands())) {
foreach ($brandCollectionTransfer->getBrands() as $brandTransfer) {
$this->brandExpander->expand($brandTransfer);
}
}
return $brandCollectionTransfer;
} | [
"public",
"function",
"getBrandCollection",
"(",
"BrandCollectionTransfer",
"$",
"brandCollectionTransfer",
")",
":",
"BrandCollectionTransfer",
"{",
"$",
"brandCollectionTransfer",
"=",
"$",
"this",
"->",
"brandRepository",
"->",
"getBrandCollection",
"(",
"$",
"brandCollectionTransfer",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"brandCollectionTransfer",
"->",
"getBrands",
"(",
")",
")",
")",
"{",
"foreach",
"(",
"$",
"brandCollectionTransfer",
"->",
"getBrands",
"(",
")",
"as",
"$",
"brandTransfer",
")",
"{",
"$",
"this",
"->",
"brandExpander",
"->",
"expand",
"(",
"$",
"brandTransfer",
")",
";",
"}",
"}",
"return",
"$",
"brandCollectionTransfer",
";",
"}"
]
| @param \Generated\Shared\Transfer\BrandCollectionTransfer $brandCollectionTransfer
@return \Generated\Shared\Transfer\BrandCollectionTransfer | [
"@param",
"\\",
"Generated",
"\\",
"Shared",
"\\",
"Transfer",
"\\",
"BrandCollectionTransfer",
"$brandCollectionTransfer"
]
| train | https://github.com/fond-of/spryker-brand/blob/0ae25c381649b70845016606de9cf4e7dfdccffa/src/FondOfSpryker/Zed/Brand/Business/Brand/BrandReader.php#L47-L58 |
ARCANEDEV/Sanitizer | src/Factory.php | Factory.extend | public function extend($name, $filter)
{
$this->checkName($name);
if ( ! $filter instanceof Closure) {
$this->isFilterable($filter);
}
$this->filters[$name] = $filter;
} | php | public function extend($name, $filter)
{
$this->checkName($name);
if ( ! $filter instanceof Closure) {
$this->isFilterable($filter);
}
$this->filters[$name] = $filter;
} | [
"public",
"function",
"extend",
"(",
"$",
"name",
",",
"$",
"filter",
")",
"{",
"$",
"this",
"->",
"checkName",
"(",
"$",
"name",
")",
";",
"if",
"(",
"!",
"$",
"filter",
"instanceof",
"Closure",
")",
"{",
"$",
"this",
"->",
"isFilterable",
"(",
"$",
"filter",
")",
";",
"}",
"$",
"this",
"->",
"filters",
"[",
"$",
"name",
"]",
"=",
"$",
"filter",
";",
"}"
]
| Add a custom filters to all Sanitizers created with this Factory.
@param string $name
@param \Closure|Filterable|string $filter
@throws \Arcanedev\Sanitizer\Exceptions\InvalidFilterException | [
"Add",
"a",
"custom",
"filters",
"to",
"all",
"Sanitizers",
"created",
"with",
"this",
"Factory",
"."
]
| train | https://github.com/ARCANEDEV/Sanitizer/blob/e21990ce6d881366d52a7f4e5040b07cc3ecca96/src/Factory.php#L64-L73 |
ARCANEDEV/Sanitizer | src/Factory.php | Factory.isFilterable | private function isFilterable($filter)
{
if (is_string($filter) && ! class_exists($filter)) {
throw new Exceptions\InvalidFilterException(
"The [$filter] class does not exits."
);
}
if ( ! in_array(Filterable::class, class_implements($filter))) {
throw new Exceptions\InvalidFilterException(
'The filter must be a Closure or a class implementing the Filterable interface.'
);
}
} | php | private function isFilterable($filter)
{
if (is_string($filter) && ! class_exists($filter)) {
throw new Exceptions\InvalidFilterException(
"The [$filter] class does not exits."
);
}
if ( ! in_array(Filterable::class, class_implements($filter))) {
throw new Exceptions\InvalidFilterException(
'The filter must be a Closure or a class implementing the Filterable interface.'
);
}
} | [
"private",
"function",
"isFilterable",
"(",
"$",
"filter",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"filter",
")",
"&&",
"!",
"class_exists",
"(",
"$",
"filter",
")",
")",
"{",
"throw",
"new",
"Exceptions",
"\\",
"InvalidFilterException",
"(",
"\"The [$filter] class does not exits.\"",
")",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"Filterable",
"::",
"class",
",",
"class_implements",
"(",
"$",
"filter",
")",
")",
")",
"{",
"throw",
"new",
"Exceptions",
"\\",
"InvalidFilterException",
"(",
"'The filter must be a Closure or a class implementing the Filterable interface.'",
")",
";",
"}",
"}"
]
| Check if filter is filterable.
@param mixed $filter
@throws \Arcanedev\Sanitizer\Exceptions\InvalidFilterException | [
"Check",
"if",
"filter",
"is",
"filterable",
"."
]
| train | https://github.com/ARCANEDEV/Sanitizer/blob/e21990ce6d881366d52a7f4e5040b07cc3ecca96/src/Factory.php#L102-L115 |
aryelgois/yasql-php | src/Builder.php | Builder.build | public function build(string $config, array $vendors = null)
{
$config_path = realpath($config);
if ($config !== '' && $config_path !== false) {
$config_path = realpath($config);
if (in_array($config_path, $this->track)) {
$this->log .= "Skiping repeated config file '$config_path'\n";
return;
}
$this->track[] = $config_path;
$this->log .= "Load config file '$config_path'\n";
$config = Yaml::parse(file_get_contents($config_path));
$indent = $config['indentation'] ?? null;
} else {
$this->log = trim($this->log) . "\n";
}
if (!empty($config['databases'] ?? [])) {
$generated = '';
foreach ($config['databases'] as $database) {
$path = $database['path'] ?? $database;
if ($path[0] !== '/') {
$path = dirname($config_path) . '/' . $path;
}
$file = realpath($path);
if ($file === false) {
$this->log .= "E: Database '$path' not found\n";
continue;
}
$sql = Controller::generate(
file_get_contents($file),
$database['name'] ?? null,
$indent
);
$post_list = (array) ($database['post'] ?? []);
foreach ($post_list as $post) {
if (is_array($post)) {
$post_name = $class = $post['call'];
if (!is_subclass_of($class, Populator::class)) {
$this->log .= "E: Class '$class' does not extend "
. Populator::class . "\n";
continue;
}
$obj = new $class();
$post_sql = '';
foreach ((array) $post['with'] as $with) {
if ($with[0] !== '/') {
$with = dirname($config_path) . '/' . $with;
}
$obj->load($with);
$post_sql .= "--\n-- With '" . basename($with)
. "'\n--\n\n" . trim($obj->run()) . "\n\n";
}
} else {
if ($post[0] !== '/') {
$post = dirname($config_path) . '/' . $post;
}
$post_file = realpath($post);
if ($post_file === false) {
$this->log .= "W: Post file '$post' not found\n";
continue;
}
$post_name = basename($post);
$post_sql = file_get_contents($post_file);
}
$sql .= "\n--\n-- Post '$post_name'\n--\n\n"
. trim($post_sql) . "\n";
}
$outfile = basename(substr($file, 0, strrpos($file, '.')))
. '.sql';
file_put_contents($this->output . '/' . $outfile, $sql);
$generated .= "- $outfile\n";
}
$this->log .= "Files generated:\n$generated";
}
if ($this->vendor === false) {
return;
}
$vendors = array_merge_recursive(
array_fill_keys($vendors ?? [], null),
$config['vendors'] ?? []
);
foreach ($vendors as $vendor => $vendor_configs) {
$this->log .= "\nSwitch to vendor $vendor\n\n";
if ($vendor_configs === null) {
$vendor_configs = [null];
}
foreach ((array) $vendor_configs as $vendor_config) {
$this->build("$this->vendor/$vendor/"
. ($vendor_config ?? 'config/databases.yml'));
}
}
} | php | public function build(string $config, array $vendors = null)
{
$config_path = realpath($config);
if ($config !== '' && $config_path !== false) {
$config_path = realpath($config);
if (in_array($config_path, $this->track)) {
$this->log .= "Skiping repeated config file '$config_path'\n";
return;
}
$this->track[] = $config_path;
$this->log .= "Load config file '$config_path'\n";
$config = Yaml::parse(file_get_contents($config_path));
$indent = $config['indentation'] ?? null;
} else {
$this->log = trim($this->log) . "\n";
}
if (!empty($config['databases'] ?? [])) {
$generated = '';
foreach ($config['databases'] as $database) {
$path = $database['path'] ?? $database;
if ($path[0] !== '/') {
$path = dirname($config_path) . '/' . $path;
}
$file = realpath($path);
if ($file === false) {
$this->log .= "E: Database '$path' not found\n";
continue;
}
$sql = Controller::generate(
file_get_contents($file),
$database['name'] ?? null,
$indent
);
$post_list = (array) ($database['post'] ?? []);
foreach ($post_list as $post) {
if (is_array($post)) {
$post_name = $class = $post['call'];
if (!is_subclass_of($class, Populator::class)) {
$this->log .= "E: Class '$class' does not extend "
. Populator::class . "\n";
continue;
}
$obj = new $class();
$post_sql = '';
foreach ((array) $post['with'] as $with) {
if ($with[0] !== '/') {
$with = dirname($config_path) . '/' . $with;
}
$obj->load($with);
$post_sql .= "--\n-- With '" . basename($with)
. "'\n--\n\n" . trim($obj->run()) . "\n\n";
}
} else {
if ($post[0] !== '/') {
$post = dirname($config_path) . '/' . $post;
}
$post_file = realpath($post);
if ($post_file === false) {
$this->log .= "W: Post file '$post' not found\n";
continue;
}
$post_name = basename($post);
$post_sql = file_get_contents($post_file);
}
$sql .= "\n--\n-- Post '$post_name'\n--\n\n"
. trim($post_sql) . "\n";
}
$outfile = basename(substr($file, 0, strrpos($file, '.')))
. '.sql';
file_put_contents($this->output . '/' . $outfile, $sql);
$generated .= "- $outfile\n";
}
$this->log .= "Files generated:\n$generated";
}
if ($this->vendor === false) {
return;
}
$vendors = array_merge_recursive(
array_fill_keys($vendors ?? [], null),
$config['vendors'] ?? []
);
foreach ($vendors as $vendor => $vendor_configs) {
$this->log .= "\nSwitch to vendor $vendor\n\n";
if ($vendor_configs === null) {
$vendor_configs = [null];
}
foreach ((array) $vendor_configs as $vendor_config) {
$this->build("$this->vendor/$vendor/"
. ($vendor_config ?? 'config/databases.yml'));
}
}
} | [
"public",
"function",
"build",
"(",
"string",
"$",
"config",
",",
"array",
"$",
"vendors",
"=",
"null",
")",
"{",
"$",
"config_path",
"=",
"realpath",
"(",
"$",
"config",
")",
";",
"if",
"(",
"$",
"config",
"!==",
"''",
"&&",
"$",
"config_path",
"!==",
"false",
")",
"{",
"$",
"config_path",
"=",
"realpath",
"(",
"$",
"config",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"config_path",
",",
"$",
"this",
"->",
"track",
")",
")",
"{",
"$",
"this",
"->",
"log",
".=",
"\"Skiping repeated config file '$config_path'\\n\"",
";",
"return",
";",
"}",
"$",
"this",
"->",
"track",
"[",
"]",
"=",
"$",
"config_path",
";",
"$",
"this",
"->",
"log",
".=",
"\"Load config file '$config_path'\\n\"",
";",
"$",
"config",
"=",
"Yaml",
"::",
"parse",
"(",
"file_get_contents",
"(",
"$",
"config_path",
")",
")",
";",
"$",
"indent",
"=",
"$",
"config",
"[",
"'indentation'",
"]",
"??",
"null",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"log",
"=",
"trim",
"(",
"$",
"this",
"->",
"log",
")",
".",
"\"\\n\"",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"config",
"[",
"'databases'",
"]",
"??",
"[",
"]",
")",
")",
"{",
"$",
"generated",
"=",
"''",
";",
"foreach",
"(",
"$",
"config",
"[",
"'databases'",
"]",
"as",
"$",
"database",
")",
"{",
"$",
"path",
"=",
"$",
"database",
"[",
"'path'",
"]",
"??",
"$",
"database",
";",
"if",
"(",
"$",
"path",
"[",
"0",
"]",
"!==",
"'/'",
")",
"{",
"$",
"path",
"=",
"dirname",
"(",
"$",
"config_path",
")",
".",
"'/'",
".",
"$",
"path",
";",
"}",
"$",
"file",
"=",
"realpath",
"(",
"$",
"path",
")",
";",
"if",
"(",
"$",
"file",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"log",
".=",
"\"E: Database '$path' not found\\n\"",
";",
"continue",
";",
"}",
"$",
"sql",
"=",
"Controller",
"::",
"generate",
"(",
"file_get_contents",
"(",
"$",
"file",
")",
",",
"$",
"database",
"[",
"'name'",
"]",
"??",
"null",
",",
"$",
"indent",
")",
";",
"$",
"post_list",
"=",
"(",
"array",
")",
"(",
"$",
"database",
"[",
"'post'",
"]",
"??",
"[",
"]",
")",
";",
"foreach",
"(",
"$",
"post_list",
"as",
"$",
"post",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"post",
")",
")",
"{",
"$",
"post_name",
"=",
"$",
"class",
"=",
"$",
"post",
"[",
"'call'",
"]",
";",
"if",
"(",
"!",
"is_subclass_of",
"(",
"$",
"class",
",",
"Populator",
"::",
"class",
")",
")",
"{",
"$",
"this",
"->",
"log",
".=",
"\"E: Class '$class' does not extend \"",
".",
"Populator",
"::",
"class",
".",
"\"\\n\"",
";",
"continue",
";",
"}",
"$",
"obj",
"=",
"new",
"$",
"class",
"(",
")",
";",
"$",
"post_sql",
"=",
"''",
";",
"foreach",
"(",
"(",
"array",
")",
"$",
"post",
"[",
"'with'",
"]",
"as",
"$",
"with",
")",
"{",
"if",
"(",
"$",
"with",
"[",
"0",
"]",
"!==",
"'/'",
")",
"{",
"$",
"with",
"=",
"dirname",
"(",
"$",
"config_path",
")",
".",
"'/'",
".",
"$",
"with",
";",
"}",
"$",
"obj",
"->",
"load",
"(",
"$",
"with",
")",
";",
"$",
"post_sql",
".=",
"\"--\\n-- With '\"",
".",
"basename",
"(",
"$",
"with",
")",
".",
"\"'\\n--\\n\\n\"",
".",
"trim",
"(",
"$",
"obj",
"->",
"run",
"(",
")",
")",
".",
"\"\\n\\n\"",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"$",
"post",
"[",
"0",
"]",
"!==",
"'/'",
")",
"{",
"$",
"post",
"=",
"dirname",
"(",
"$",
"config_path",
")",
".",
"'/'",
".",
"$",
"post",
";",
"}",
"$",
"post_file",
"=",
"realpath",
"(",
"$",
"post",
")",
";",
"if",
"(",
"$",
"post_file",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"log",
".=",
"\"W: Post file '$post' not found\\n\"",
";",
"continue",
";",
"}",
"$",
"post_name",
"=",
"basename",
"(",
"$",
"post",
")",
";",
"$",
"post_sql",
"=",
"file_get_contents",
"(",
"$",
"post_file",
")",
";",
"}",
"$",
"sql",
".=",
"\"\\n--\\n-- Post '$post_name'\\n--\\n\\n\"",
".",
"trim",
"(",
"$",
"post_sql",
")",
".",
"\"\\n\"",
";",
"}",
"$",
"outfile",
"=",
"basename",
"(",
"substr",
"(",
"$",
"file",
",",
"0",
",",
"strrpos",
"(",
"$",
"file",
",",
"'.'",
")",
")",
")",
".",
"'.sql'",
";",
"file_put_contents",
"(",
"$",
"this",
"->",
"output",
".",
"'/'",
".",
"$",
"outfile",
",",
"$",
"sql",
")",
";",
"$",
"generated",
".=",
"\"- $outfile\\n\"",
";",
"}",
"$",
"this",
"->",
"log",
".=",
"\"Files generated:\\n$generated\"",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"vendor",
"===",
"false",
")",
"{",
"return",
";",
"}",
"$",
"vendors",
"=",
"array_merge_recursive",
"(",
"array_fill_keys",
"(",
"$",
"vendors",
"??",
"[",
"]",
",",
"null",
")",
",",
"$",
"config",
"[",
"'vendors'",
"]",
"??",
"[",
"]",
")",
";",
"foreach",
"(",
"$",
"vendors",
"as",
"$",
"vendor",
"=>",
"$",
"vendor_configs",
")",
"{",
"$",
"this",
"->",
"log",
".=",
"\"\\nSwitch to vendor $vendor\\n\\n\"",
";",
"if",
"(",
"$",
"vendor_configs",
"===",
"null",
")",
"{",
"$",
"vendor_configs",
"=",
"[",
"null",
"]",
";",
"}",
"foreach",
"(",
"(",
"array",
")",
"$",
"vendor_configs",
"as",
"$",
"vendor_config",
")",
"{",
"$",
"this",
"->",
"build",
"(",
"\"$this->vendor/$vendor/\"",
".",
"(",
"$",
"vendor_config",
"??",
"'config/databases.yml'",
")",
")",
";",
"}",
"}",
"}"
]
| Builds databases in a config file
@param string $config Path to YAML with build configurations
@param array $vendors List of additional vendors to include
(using the default config file location) | [
"Builds",
"databases",
"in",
"a",
"config",
"file"
]
| train | https://github.com/aryelgois/yasql-php/blob/f428b180d35bfc1ddf1f9b3323f9b085fbc09ac7/src/Builder.php#L86-L184 |
fubhy/graphql-php | src/Language/Parser.php | Parser.parse | public function parse(Source $source)
{
$this->source = $source;
$this->lexer = new Lexer($source);
$this->token = $this->lexer->readToken(0);
$this->cursor = 0;
return $this->parseDocument();
} | php | public function parse(Source $source)
{
$this->source = $source;
$this->lexer = new Lexer($source);
$this->token = $this->lexer->readToken(0);
$this->cursor = 0;
return $this->parseDocument();
} | [
"public",
"function",
"parse",
"(",
"Source",
"$",
"source",
")",
"{",
"$",
"this",
"->",
"source",
"=",
"$",
"source",
";",
"$",
"this",
"->",
"lexer",
"=",
"new",
"Lexer",
"(",
"$",
"source",
")",
";",
"$",
"this",
"->",
"token",
"=",
"$",
"this",
"->",
"lexer",
"->",
"readToken",
"(",
"0",
")",
";",
"$",
"this",
"->",
"cursor",
"=",
"0",
";",
"return",
"$",
"this",
"->",
"parseDocument",
"(",
")",
";",
"}"
]
| @param \Fubhy\GraphQL\Language\Source $source
@return \Fubhy\GraphQL\Language\Node\Document | [
"@param",
"\\",
"Fubhy",
"\\",
"GraphQL",
"\\",
"Language",
"\\",
"Source",
"$source"
]
| train | https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Language/Parser.php#L74-L82 |
fubhy/graphql-php | src/Language/Parser.php | Parser.location | protected function location($start)
{
if (!empty($this->options['noLocation'])) {
return NULL;
}
if (!empty($this->options['noSource'])) {
return new Location($start, $this->cursor);
}
return new Location($start, $this->cursor, $this->source);
} | php | protected function location($start)
{
if (!empty($this->options['noLocation'])) {
return NULL;
}
if (!empty($this->options['noSource'])) {
return new Location($start, $this->cursor);
}
return new Location($start, $this->cursor, $this->source);
} | [
"protected",
"function",
"location",
"(",
"$",
"start",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"options",
"[",
"'noLocation'",
"]",
")",
")",
"{",
"return",
"NULL",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"options",
"[",
"'noSource'",
"]",
")",
")",
"{",
"return",
"new",
"Location",
"(",
"$",
"start",
",",
"$",
"this",
"->",
"cursor",
")",
";",
"}",
"return",
"new",
"Location",
"(",
"$",
"start",
",",
"$",
"this",
"->",
"cursor",
",",
"$",
"this",
"->",
"source",
")",
";",
"}"
]
| Returns a location object, used to identify the place in the source that
created a given parsed object.
@param int $start
@return \Fubhy\GraphQL\Language\Location|null | [
"Returns",
"a",
"location",
"object",
"used",
"to",
"identify",
"the",
"place",
"in",
"the",
"source",
"that",
"created",
"a",
"given",
"parsed",
"object",
"."
]
| train | https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Language/Parser.php#L92-L103 |
fubhy/graphql-php | src/Language/Parser.php | Parser.advance | protected function advance()
{
$this->cursor = $this->token->getEnd();
return $this->token = $this->lexer->readToken($this->cursor);
} | php | protected function advance()
{
$this->cursor = $this->token->getEnd();
return $this->token = $this->lexer->readToken($this->cursor);
} | [
"protected",
"function",
"advance",
"(",
")",
"{",
"$",
"this",
"->",
"cursor",
"=",
"$",
"this",
"->",
"token",
"->",
"getEnd",
"(",
")",
";",
"return",
"$",
"this",
"->",
"token",
"=",
"$",
"this",
"->",
"lexer",
"->",
"readToken",
"(",
"$",
"this",
"->",
"cursor",
")",
";",
"}"
]
| Moves the internal parser object to the next lexed token. | [
"Moves",
"the",
"internal",
"parser",
"object",
"to",
"the",
"next",
"lexed",
"token",
"."
]
| train | https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Language/Parser.php#L109-L113 |
fubhy/graphql-php | src/Language/Parser.php | Parser.skip | protected function skip($type)
{
if ($match = ($this->token->getType() === $type)) {
$this->advance();
}
return $match;
} | php | protected function skip($type)
{
if ($match = ($this->token->getType() === $type)) {
$this->advance();
}
return $match;
} | [
"protected",
"function",
"skip",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"$",
"match",
"=",
"(",
"$",
"this",
"->",
"token",
"->",
"getType",
"(",
")",
"===",
"$",
"type",
")",
")",
"{",
"$",
"this",
"->",
"advance",
"(",
")",
";",
"}",
"return",
"$",
"match",
";",
"}"
]
| If the next token is of the given kind, return true after advancing the
parser. Otherwise, do not change the parser state and return false.
@param int $type
@return bool | [
"If",
"the",
"next",
"token",
"is",
"of",
"the",
"given",
"kind",
"return",
"true",
"after",
"advancing",
"the",
"parser",
".",
"Otherwise",
"do",
"not",
"change",
"the",
"parser",
"state",
"and",
"return",
"false",
"."
]
| train | https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Language/Parser.php#L135-L142 |
fubhy/graphql-php | src/Language/Parser.php | Parser.expect | protected function expect($type)
{
if ($this->token->getType() !== $type) {
throw new \Exception(sprintf('Expected %s, found %s', Token::typeToString($type), (string) $this->token));
}
$token = $this->token;
$this->advance();
return $token;
} | php | protected function expect($type)
{
if ($this->token->getType() !== $type) {
throw new \Exception(sprintf('Expected %s, found %s', Token::typeToString($type), (string) $this->token));
}
$token = $this->token;
$this->advance();
return $token;
} | [
"protected",
"function",
"expect",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"token",
"->",
"getType",
"(",
")",
"!==",
"$",
"type",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"'Expected %s, found %s'",
",",
"Token",
"::",
"typeToString",
"(",
"$",
"type",
")",
",",
"(",
"string",
")",
"$",
"this",
"->",
"token",
")",
")",
";",
"}",
"$",
"token",
"=",
"$",
"this",
"->",
"token",
";",
"$",
"this",
"->",
"advance",
"(",
")",
";",
"return",
"$",
"token",
";",
"}"
]
| If the next token is of the given kind, return that token after advancing
the parser. Otherwise, do not change the parser state and return false.
@param int $type
@return \Fubhy\GraphQL\Language\Token
@throws \Exception | [
"If",
"the",
"next",
"token",
"is",
"of",
"the",
"given",
"kind",
"return",
"that",
"token",
"after",
"advancing",
"the",
"parser",
".",
"Otherwise",
"do",
"not",
"change",
"the",
"parser",
"state",
"and",
"return",
"false",
"."
]
| train | https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Language/Parser.php#L154-L163 |
fubhy/graphql-php | src/Language/Parser.php | Parser.expectKeyword | protected function expectKeyword($value)
{
if ($this->token->getType() !== Token::NAME_TYPE || $this->token->getValue() !== $value) {
throw new \Exception(sprintf('Expected %s, found %s', $value, $this->token->getDescription()));
}
return $this->advance();
} | php | protected function expectKeyword($value)
{
if ($this->token->getType() !== Token::NAME_TYPE || $this->token->getValue() !== $value) {
throw new \Exception(sprintf('Expected %s, found %s', $value, $this->token->getDescription()));
}
return $this->advance();
} | [
"protected",
"function",
"expectKeyword",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"token",
"->",
"getType",
"(",
")",
"!==",
"Token",
"::",
"NAME_TYPE",
"||",
"$",
"this",
"->",
"token",
"->",
"getValue",
"(",
")",
"!==",
"$",
"value",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"'Expected %s, found %s'",
",",
"$",
"value",
",",
"$",
"this",
"->",
"token",
"->",
"getDescription",
"(",
")",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"advance",
"(",
")",
";",
"}"
]
| If the next token is a keyword with the given value, return that token
after advancing the parser. Otherwise, do not change the parser state and
return false.
@param string $value
@return \Fubhy\GraphQL\Language\Token
@throws \Exception | [
"If",
"the",
"next",
"token",
"is",
"a",
"keyword",
"with",
"the",
"given",
"value",
"return",
"that",
"token",
"after",
"advancing",
"the",
"parser",
".",
"Otherwise",
"do",
"not",
"change",
"the",
"parser",
"state",
"and",
"return",
"false",
"."
]
| train | https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Language/Parser.php#L176-L183 |
fubhy/graphql-php | src/Language/Parser.php | Parser.unexpected | protected function unexpected(Token $atToken = NULL)
{
$token = $atToken ?: $this->token;
return new \Exception(sprintf('Unexpected %s', $token->getDescription()));
} | php | protected function unexpected(Token $atToken = NULL)
{
$token = $atToken ?: $this->token;
return new \Exception(sprintf('Unexpected %s', $token->getDescription()));
} | [
"protected",
"function",
"unexpected",
"(",
"Token",
"$",
"atToken",
"=",
"NULL",
")",
"{",
"$",
"token",
"=",
"$",
"atToken",
"?",
":",
"$",
"this",
"->",
"token",
";",
"return",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"'Unexpected %s'",
",",
"$",
"token",
"->",
"getDescription",
"(",
")",
")",
")",
";",
"}"
]
| Helper protected function for creating an error when an unexpected lexed token is
encountered.
@param \Fubhy\GraphQL\Language\Token|null $atToken
@return \Exception | [
"Helper",
"protected",
"function",
"for",
"creating",
"an",
"error",
"when",
"an",
"unexpected",
"lexed",
"token",
"is",
"encountered",
"."
]
| train | https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Language/Parser.php#L193-L198 |
fubhy/graphql-php | src/Language/Parser.php | Parser.many | protected function many($openKind, $parseFn, $closeKind)
{
$this->expect($openKind);
$nodes = [$parseFn($this)];
while (!$this->skip($closeKind)) {
array_push($nodes, $parseFn($this));
}
return $nodes;
} | php | protected function many($openKind, $parseFn, $closeKind)
{
$this->expect($openKind);
$nodes = [$parseFn($this)];
while (!$this->skip($closeKind)) {
array_push($nodes, $parseFn($this));
}
return $nodes;
} | [
"protected",
"function",
"many",
"(",
"$",
"openKind",
",",
"$",
"parseFn",
",",
"$",
"closeKind",
")",
"{",
"$",
"this",
"->",
"expect",
"(",
"$",
"openKind",
")",
";",
"$",
"nodes",
"=",
"[",
"$",
"parseFn",
"(",
"$",
"this",
")",
"]",
";",
"while",
"(",
"!",
"$",
"this",
"->",
"skip",
"(",
"$",
"closeKind",
")",
")",
"{",
"array_push",
"(",
"$",
"nodes",
",",
"$",
"parseFn",
"(",
"$",
"this",
")",
")",
";",
"}",
"return",
"$",
"nodes",
";",
"}"
]
| Returns a non-empty list of parse nodes, determined by the parseFn.
This list begins with a lex token of openKind and ends with a lex token
of closeKind. Advances the parser to the next lex token after the closing
token.
@param int $openKind
@param callable $parseFn
@param int $closeKind
@return array | [
"Returns",
"a",
"non",
"-",
"empty",
"list",
"of",
"parse",
"nodes",
"determined",
"by",
"the",
"parseFn",
"."
]
| train | https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Language/Parser.php#L238-L248 |
fubhy/graphql-php | src/Language/Parser.php | Parser.parseName | protected function parseName()
{
$start = $this->token->getStart();
$token = $this->expect(Token::NAME_TYPE);
return new Name($token->getValue(), $this->location($start));
} | php | protected function parseName()
{
$start = $this->token->getStart();
$token = $this->expect(Token::NAME_TYPE);
return new Name($token->getValue(), $this->location($start));
} | [
"protected",
"function",
"parseName",
"(",
")",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"token",
"->",
"getStart",
"(",
")",
";",
"$",
"token",
"=",
"$",
"this",
"->",
"expect",
"(",
"Token",
"::",
"NAME_TYPE",
")",
";",
"return",
"new",
"Name",
"(",
"$",
"token",
"->",
"getValue",
"(",
")",
",",
"$",
"this",
"->",
"location",
"(",
"$",
"start",
")",
")",
";",
"}"
]
| Converts a name lex token into a name parse node.
@return \Fubhy\GraphQL\Language\Node\Name | [
"Converts",
"a",
"name",
"lex",
"token",
"into",
"a",
"name",
"parse",
"node",
"."
]
| train | https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Language/Parser.php#L255-L261 |
fubhy/graphql-php | src/Language/Parser.php | Parser.parseDocument | protected function parseDocument()
{
$start = $this->token->getStart();
$definitions = [];
do {
if ($this->peek(Token::BRACE_L_TYPE)) {
$definitions[] = $this->parseOperationDefinition();
} else if ($this->peek(Token::NAME_TYPE)) {
$value = $this->token->getValue();
if ($value === 'query' || $value === 'mutation') {
$definitions[] = $this->parseOperationDefinition();
} else if ($value === 'fragment') {
$definitions[] = $this->parseFragmentDefinition();
} else {
throw $this->unexpected();
}
} else {
throw $this->unexpected();
}
} while (!$this->skip(Token::EOF_TYPE));
return new Document($definitions, $this->location($start));
} | php | protected function parseDocument()
{
$start = $this->token->getStart();
$definitions = [];
do {
if ($this->peek(Token::BRACE_L_TYPE)) {
$definitions[] = $this->parseOperationDefinition();
} else if ($this->peek(Token::NAME_TYPE)) {
$value = $this->token->getValue();
if ($value === 'query' || $value === 'mutation') {
$definitions[] = $this->parseOperationDefinition();
} else if ($value === 'fragment') {
$definitions[] = $this->parseFragmentDefinition();
} else {
throw $this->unexpected();
}
} else {
throw $this->unexpected();
}
} while (!$this->skip(Token::EOF_TYPE));
return new Document($definitions, $this->location($start));
} | [
"protected",
"function",
"parseDocument",
"(",
")",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"token",
"->",
"getStart",
"(",
")",
";",
"$",
"definitions",
"=",
"[",
"]",
";",
"do",
"{",
"if",
"(",
"$",
"this",
"->",
"peek",
"(",
"Token",
"::",
"BRACE_L_TYPE",
")",
")",
"{",
"$",
"definitions",
"[",
"]",
"=",
"$",
"this",
"->",
"parseOperationDefinition",
"(",
")",
";",
"}",
"else",
"if",
"(",
"$",
"this",
"->",
"peek",
"(",
"Token",
"::",
"NAME_TYPE",
")",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"token",
"->",
"getValue",
"(",
")",
";",
"if",
"(",
"$",
"value",
"===",
"'query'",
"||",
"$",
"value",
"===",
"'mutation'",
")",
"{",
"$",
"definitions",
"[",
"]",
"=",
"$",
"this",
"->",
"parseOperationDefinition",
"(",
")",
";",
"}",
"else",
"if",
"(",
"$",
"value",
"===",
"'fragment'",
")",
"{",
"$",
"definitions",
"[",
"]",
"=",
"$",
"this",
"->",
"parseFragmentDefinition",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"$",
"this",
"->",
"unexpected",
"(",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"$",
"this",
"->",
"unexpected",
"(",
")",
";",
"}",
"}",
"while",
"(",
"!",
"$",
"this",
"->",
"skip",
"(",
"Token",
"::",
"EOF_TYPE",
")",
")",
";",
"return",
"new",
"Document",
"(",
"$",
"definitions",
",",
"$",
"this",
"->",
"location",
"(",
"$",
"start",
")",
")",
";",
"}"
]
| @return \Fubhy\GraphQL\Language\Node\Document
@throws \Exception | [
"@return",
"\\",
"Fubhy",
"\\",
"GraphQL",
"\\",
"Language",
"\\",
"Node",
"\\",
"Document"
]
| train | https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Language/Parser.php#L283-L306 |
fubhy/graphql-php | src/Language/Parser.php | Parser.parseFragment | protected function parseFragment()
{
$start = $this->token->getStart();
$this->expect(Token::SPREAD_TYPE);
if ($this->token->getValue() === 'on') {
$this->advance();
return new InlineFragment(
$this->parseNamedType(),
$this->parseDirectives(),
$this->parseSelectionSet(),
$this->location($start)
);
}
return new FragmentSpread(
$this->parseFragmentName(),
$this->parseDirectives(),
$this->location($start)
);
} | php | protected function parseFragment()
{
$start = $this->token->getStart();
$this->expect(Token::SPREAD_TYPE);
if ($this->token->getValue() === 'on') {
$this->advance();
return new InlineFragment(
$this->parseNamedType(),
$this->parseDirectives(),
$this->parseSelectionSet(),
$this->location($start)
);
}
return new FragmentSpread(
$this->parseFragmentName(),
$this->parseDirectives(),
$this->location($start)
);
} | [
"protected",
"function",
"parseFragment",
"(",
")",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"token",
"->",
"getStart",
"(",
")",
";",
"$",
"this",
"->",
"expect",
"(",
"Token",
"::",
"SPREAD_TYPE",
")",
";",
"if",
"(",
"$",
"this",
"->",
"token",
"->",
"getValue",
"(",
")",
"===",
"'on'",
")",
"{",
"$",
"this",
"->",
"advance",
"(",
")",
";",
"return",
"new",
"InlineFragment",
"(",
"$",
"this",
"->",
"parseNamedType",
"(",
")",
",",
"$",
"this",
"->",
"parseDirectives",
"(",
")",
",",
"$",
"this",
"->",
"parseSelectionSet",
"(",
")",
",",
"$",
"this",
"->",
"location",
"(",
"$",
"start",
")",
")",
";",
"}",
"return",
"new",
"FragmentSpread",
"(",
"$",
"this",
"->",
"parseFragmentName",
"(",
")",
",",
"$",
"this",
"->",
"parseDirectives",
"(",
")",
",",
"$",
"this",
"->",
"location",
"(",
"$",
"start",
")",
")",
";",
"}"
]
| Corresponds to both FragmentSpread and InlineFragment in the spec.
@return \Fubhy\GraphQL\Language\Node\FragmentSpread|\Fubhy\GraphQL\Language\Node\InlineFragment | [
"Corresponds",
"to",
"both",
"FragmentSpread",
"and",
"InlineFragment",
"in",
"the",
"spec",
"."
]
| train | https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Language/Parser.php#L439-L460 |
fubhy/graphql-php | src/Language/Parser.php | Parser.parseValue | protected function parseValue($isConst)
{
$start = $this->token->getStart();
$token = $this->token;
switch ($this->token->getType()) {
case Token::BRACKET_L_TYPE:
return $this->parseArray($isConst);
case Token::BRACE_L_TYPE:
return $this->parseObject($isConst);
case Token::INT_TYPE:
$this->advance();
return new IntValue($token->getValue(), $this->location($start));
case Token::FLOAT_TYPE:
$this->advance();
return new FloatValue($token->getValue(), $this->location($start));
case Token::STRING_TYPE:
$this->advance();
return new StringValue($token->getValue(), $this->location($start));
case Token::NAME_TYPE:
$this->advance();
switch ($value = $token->getValue()) {
case 'true':
case 'false':
return new BooleanValue($value === 'true', $this->location($start));
}
return new EnumValue($value, $this->location($start));
case Token::DOLLAR_TYPE:
if (!$isConst) {
return $this->parseVariable();
}
break;
}
throw $this->unexpected();
} | php | protected function parseValue($isConst)
{
$start = $this->token->getStart();
$token = $this->token;
switch ($this->token->getType()) {
case Token::BRACKET_L_TYPE:
return $this->parseArray($isConst);
case Token::BRACE_L_TYPE:
return $this->parseObject($isConst);
case Token::INT_TYPE:
$this->advance();
return new IntValue($token->getValue(), $this->location($start));
case Token::FLOAT_TYPE:
$this->advance();
return new FloatValue($token->getValue(), $this->location($start));
case Token::STRING_TYPE:
$this->advance();
return new StringValue($token->getValue(), $this->location($start));
case Token::NAME_TYPE:
$this->advance();
switch ($value = $token->getValue()) {
case 'true':
case 'false':
return new BooleanValue($value === 'true', $this->location($start));
}
return new EnumValue($value, $this->location($start));
case Token::DOLLAR_TYPE:
if (!$isConst) {
return $this->parseVariable();
}
break;
}
throw $this->unexpected();
} | [
"protected",
"function",
"parseValue",
"(",
"$",
"isConst",
")",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"token",
"->",
"getStart",
"(",
")",
";",
"$",
"token",
"=",
"$",
"this",
"->",
"token",
";",
"switch",
"(",
"$",
"this",
"->",
"token",
"->",
"getType",
"(",
")",
")",
"{",
"case",
"Token",
"::",
"BRACKET_L_TYPE",
":",
"return",
"$",
"this",
"->",
"parseArray",
"(",
"$",
"isConst",
")",
";",
"case",
"Token",
"::",
"BRACE_L_TYPE",
":",
"return",
"$",
"this",
"->",
"parseObject",
"(",
"$",
"isConst",
")",
";",
"case",
"Token",
"::",
"INT_TYPE",
":",
"$",
"this",
"->",
"advance",
"(",
")",
";",
"return",
"new",
"IntValue",
"(",
"$",
"token",
"->",
"getValue",
"(",
")",
",",
"$",
"this",
"->",
"location",
"(",
"$",
"start",
")",
")",
";",
"case",
"Token",
"::",
"FLOAT_TYPE",
":",
"$",
"this",
"->",
"advance",
"(",
")",
";",
"return",
"new",
"FloatValue",
"(",
"$",
"token",
"->",
"getValue",
"(",
")",
",",
"$",
"this",
"->",
"location",
"(",
"$",
"start",
")",
")",
";",
"case",
"Token",
"::",
"STRING_TYPE",
":",
"$",
"this",
"->",
"advance",
"(",
")",
";",
"return",
"new",
"StringValue",
"(",
"$",
"token",
"->",
"getValue",
"(",
")",
",",
"$",
"this",
"->",
"location",
"(",
"$",
"start",
")",
")",
";",
"case",
"Token",
"::",
"NAME_TYPE",
":",
"$",
"this",
"->",
"advance",
"(",
")",
";",
"switch",
"(",
"$",
"value",
"=",
"$",
"token",
"->",
"getValue",
"(",
")",
")",
"{",
"case",
"'true'",
":",
"case",
"'false'",
":",
"return",
"new",
"BooleanValue",
"(",
"$",
"value",
"===",
"'true'",
",",
"$",
"this",
"->",
"location",
"(",
"$",
"start",
")",
")",
";",
"}",
"return",
"new",
"EnumValue",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"location",
"(",
"$",
"start",
")",
")",
";",
"case",
"Token",
"::",
"DOLLAR_TYPE",
":",
"if",
"(",
"!",
"$",
"isConst",
")",
"{",
"return",
"$",
"this",
"->",
"parseVariable",
"(",
")",
";",
"}",
"break",
";",
"}",
"throw",
"$",
"this",
"->",
"unexpected",
"(",
")",
";",
"}"
]
| @param bool $isConst
@return \Fubhy\GraphQL\Language\Node\ValueInterface
@throws \Exception | [
"@param",
"bool",
"$isConst"
]
| train | https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Language/Parser.php#L505-L540 |
fubhy/graphql-php | src/Language/Parser.php | Parser.parseArray | protected function parseArray($isConst)
{
$start = $this->token->getStart();
$item = $isConst ? 'parseConstValue' : 'parseVariableValue';
return new ArrayValue(
$this->any(Token::BRACKET_L_TYPE, [$this, $item], Token::BRACKET_R_TYPE),
$this->location($start)
);
} | php | protected function parseArray($isConst)
{
$start = $this->token->getStart();
$item = $isConst ? 'parseConstValue' : 'parseVariableValue';
return new ArrayValue(
$this->any(Token::BRACKET_L_TYPE, [$this, $item], Token::BRACKET_R_TYPE),
$this->location($start)
);
} | [
"protected",
"function",
"parseArray",
"(",
"$",
"isConst",
")",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"token",
"->",
"getStart",
"(",
")",
";",
"$",
"item",
"=",
"$",
"isConst",
"?",
"'parseConstValue'",
":",
"'parseVariableValue'",
";",
"return",
"new",
"ArrayValue",
"(",
"$",
"this",
"->",
"any",
"(",
"Token",
"::",
"BRACKET_L_TYPE",
",",
"[",
"$",
"this",
",",
"$",
"item",
"]",
",",
"Token",
"::",
"BRACKET_R_TYPE",
")",
",",
"$",
"this",
"->",
"location",
"(",
"$",
"start",
")",
")",
";",
"}"
]
| @param bool $isConst
@return \Fubhy\GraphQL\Language\Node\ArrayValue | [
"@param",
"bool",
"$isConst"
]
| train | https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Language/Parser.php#L547-L556 |
fubhy/graphql-php | src/Language/Parser.php | Parser.parseObject | protected function parseObject($isConst)
{
$start = $this->token->getStart();
$this->expect(Token::BRACE_L_TYPE);
$fieldNames = [];
$fields = [];
while (!$this->skip(Token::BRACE_R_TYPE)) {
array_push($fields, $this->parseObjectField($isConst, $fieldNames));
}
return new ObjectValue($fields, $this->location($start));
} | php | protected function parseObject($isConst)
{
$start = $this->token->getStart();
$this->expect(Token::BRACE_L_TYPE);
$fieldNames = [];
$fields = [];
while (!$this->skip(Token::BRACE_R_TYPE)) {
array_push($fields, $this->parseObjectField($isConst, $fieldNames));
}
return new ObjectValue($fields, $this->location($start));
} | [
"protected",
"function",
"parseObject",
"(",
"$",
"isConst",
")",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"token",
"->",
"getStart",
"(",
")",
";",
"$",
"this",
"->",
"expect",
"(",
"Token",
"::",
"BRACE_L_TYPE",
")",
";",
"$",
"fieldNames",
"=",
"[",
"]",
";",
"$",
"fields",
"=",
"[",
"]",
";",
"while",
"(",
"!",
"$",
"this",
"->",
"skip",
"(",
"Token",
"::",
"BRACE_R_TYPE",
")",
")",
"{",
"array_push",
"(",
"$",
"fields",
",",
"$",
"this",
"->",
"parseObjectField",
"(",
"$",
"isConst",
",",
"$",
"fieldNames",
")",
")",
";",
"}",
"return",
"new",
"ObjectValue",
"(",
"$",
"fields",
",",
"$",
"this",
"->",
"location",
"(",
"$",
"start",
")",
")",
";",
"}"
]
| @param bool $isConst
@return \Fubhy\GraphQL\Language\Node\ObjectValue | [
"@param",
"bool",
"$isConst"
]
| train | https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Language/Parser.php#L563-L575 |
fubhy/graphql-php | src/Language/Parser.php | Parser.parseObjectField | protected function parseObjectField($isConst, &$fieldNames)
{
$start = $this->token->getStart();
$name = $this->parseName();
$value = $name->get('value');
if (array_key_exists($value, $fieldNames)) {
throw new \Exception(sprintf('Duplicate input object field %s.', $value));
}
$fieldNames[$value] = TRUE;
$this->expect(Token::COLON_TYPE);
return new ObjectField($name, $this->parseValue($isConst), $this->location($start));
} | php | protected function parseObjectField($isConst, &$fieldNames)
{
$start = $this->token->getStart();
$name = $this->parseName();
$value = $name->get('value');
if (array_key_exists($value, $fieldNames)) {
throw new \Exception(sprintf('Duplicate input object field %s.', $value));
}
$fieldNames[$value] = TRUE;
$this->expect(Token::COLON_TYPE);
return new ObjectField($name, $this->parseValue($isConst), $this->location($start));
} | [
"protected",
"function",
"parseObjectField",
"(",
"$",
"isConst",
",",
"&",
"$",
"fieldNames",
")",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"token",
"->",
"getStart",
"(",
")",
";",
"$",
"name",
"=",
"$",
"this",
"->",
"parseName",
"(",
")",
";",
"$",
"value",
"=",
"$",
"name",
"->",
"get",
"(",
"'value'",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"value",
",",
"$",
"fieldNames",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"'Duplicate input object field %s.'",
",",
"$",
"value",
")",
")",
";",
"}",
"$",
"fieldNames",
"[",
"$",
"value",
"]",
"=",
"TRUE",
";",
"$",
"this",
"->",
"expect",
"(",
"Token",
"::",
"COLON_TYPE",
")",
";",
"return",
"new",
"ObjectField",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"parseValue",
"(",
"$",
"isConst",
")",
",",
"$",
"this",
"->",
"location",
"(",
"$",
"start",
")",
")",
";",
"}"
]
| @param bool $isConst
@param array $fieldNames
@return \Fubhy\GraphQL\Language\Node\ObjectField
@throws \Exception | [
"@param",
"bool",
"$isConst",
"@param",
"array",
"$fieldNames"
]
| train | https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Language/Parser.php#L585-L599 |
fubhy/graphql-php | src/Language/Parser.php | Parser.parseDirective | protected function parseDirective()
{
$start = $this->token->getStart();
$this->expect(Token::AT_TYPE);
return new Directive(
$this->parseName(),
$this->parseArguments(),
$this->location($start)
);
} | php | protected function parseDirective()
{
$start = $this->token->getStart();
$this->expect(Token::AT_TYPE);
return new Directive(
$this->parseName(),
$this->parseArguments(),
$this->location($start)
);
} | [
"protected",
"function",
"parseDirective",
"(",
")",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"token",
"->",
"getStart",
"(",
")",
";",
"$",
"this",
"->",
"expect",
"(",
"Token",
"::",
"AT_TYPE",
")",
";",
"return",
"new",
"Directive",
"(",
"$",
"this",
"->",
"parseName",
"(",
")",
",",
"$",
"this",
"->",
"parseArguments",
"(",
")",
",",
"$",
"this",
"->",
"location",
"(",
"$",
"start",
")",
")",
";",
"}"
]
| @return \Fubhy\GraphQL\Language\Node\Directive
@throws \Exception | [
"@return",
"\\",
"Fubhy",
"\\",
"GraphQL",
"\\",
"Language",
"\\",
"Node",
"\\",
"Directive"
]
| train | https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Language/Parser.php#L619-L629 |
fubhy/graphql-php | src/Language/Parser.php | Parser.parseType | protected function parseType()
{
$start = $this->token->getStart();
if ($this->skip(Token::BRACKET_L_TYPE)) {
$type = $this->parseType();
$this->expect(Token::BRACKET_R_TYPE);
$type = new ListType($type, $this->location($start));
} else {
$type = $this->parseNamedType();
}
if ($this->skip(Token::BANG_TYPE)) {
return new NonNullType($type, $this->location($start));
}
return $type;
} | php | protected function parseType()
{
$start = $this->token->getStart();
if ($this->skip(Token::BRACKET_L_TYPE)) {
$type = $this->parseType();
$this->expect(Token::BRACKET_R_TYPE);
$type = new ListType($type, $this->location($start));
} else {
$type = $this->parseNamedType();
}
if ($this->skip(Token::BANG_TYPE)) {
return new NonNullType($type, $this->location($start));
}
return $type;
} | [
"protected",
"function",
"parseType",
"(",
")",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"token",
"->",
"getStart",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"skip",
"(",
"Token",
"::",
"BRACKET_L_TYPE",
")",
")",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"parseType",
"(",
")",
";",
"$",
"this",
"->",
"expect",
"(",
"Token",
"::",
"BRACKET_R_TYPE",
")",
";",
"$",
"type",
"=",
"new",
"ListType",
"(",
"$",
"type",
",",
"$",
"this",
"->",
"location",
"(",
"$",
"start",
")",
")",
";",
"}",
"else",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"parseNamedType",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"skip",
"(",
"Token",
"::",
"BANG_TYPE",
")",
")",
"{",
"return",
"new",
"NonNullType",
"(",
"$",
"type",
",",
"$",
"this",
"->",
"location",
"(",
"$",
"start",
")",
")",
";",
"}",
"return",
"$",
"type",
";",
"}"
]
| Handles the type: TypeName, ListType, and NonNullType parsing rules.
@return \Fubhy\GraphQL\Language\Node\TypeInterface
@throws \Exception | [
"Handles",
"the",
"type",
":",
"TypeName",
"ListType",
"and",
"NonNullType",
"parsing",
"rules",
"."
]
| train | https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Language/Parser.php#L638-L655 |
phpmob/changmin | src/PhpMob/CmsBundle/Doctrine/ORM/TemplateRepository.php | TemplateRepository.findNoneAbstractTemplates | public function findNoneAbstractTemplates()
{
$queryBuilder = $this->createQueryBuilder('o');
return $queryBuilder
->where($queryBuilder->expr()->neq('o.type', ':type'))
->orderBy('o.name', 'ASC')
->setParameter(':type', TemplateInterface::TYPE_ABSTRACT)
->getQuery()->getResult();
} | php | public function findNoneAbstractTemplates()
{
$queryBuilder = $this->createQueryBuilder('o');
return $queryBuilder
->where($queryBuilder->expr()->neq('o.type', ':type'))
->orderBy('o.name', 'ASC')
->setParameter(':type', TemplateInterface::TYPE_ABSTRACT)
->getQuery()->getResult();
} | [
"public",
"function",
"findNoneAbstractTemplates",
"(",
")",
"{",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'o'",
")",
";",
"return",
"$",
"queryBuilder",
"->",
"where",
"(",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"neq",
"(",
"'o.type'",
",",
"':type'",
")",
")",
"->",
"orderBy",
"(",
"'o.name'",
",",
"'ASC'",
")",
"->",
"setParameter",
"(",
"':type'",
",",
"TemplateInterface",
"::",
"TYPE_ABSTRACT",
")",
"->",
"getQuery",
"(",
")",
"->",
"getResult",
"(",
")",
";",
"}"
]
| {@inheritdoc} | [
"{"
]
| train | https://github.com/phpmob/changmin/blob/bfebb1561229094d1c138574abab75f2f1d17d66/src/PhpMob/CmsBundle/Doctrine/ORM/TemplateRepository.php#L34-L43 |
ARCANEDEV/Sanitizer | src/Sanitizer.php | Sanitizer.setFilters | public function setFilters(array $filters)
{
if (empty($this->filters)) {
$this->filters = $this->getDefaultFilters();
}
$this->filters = array_merge(
$this->filters, $filters
);
return $this;
} | php | public function setFilters(array $filters)
{
if (empty($this->filters)) {
$this->filters = $this->getDefaultFilters();
}
$this->filters = array_merge(
$this->filters, $filters
);
return $this;
} | [
"public",
"function",
"setFilters",
"(",
"array",
"$",
"filters",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"filters",
")",
")",
"{",
"$",
"this",
"->",
"filters",
"=",
"$",
"this",
"->",
"getDefaultFilters",
"(",
")",
";",
"}",
"$",
"this",
"->",
"filters",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"filters",
",",
"$",
"filters",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Set filters.
@param array $filters
@return self | [
"Set",
"filters",
"."
]
| train | https://github.com/ARCANEDEV/Sanitizer/blob/e21990ce6d881366d52a7f4e5040b07cc3ecca96/src/Sanitizer.php#L59-L70 |
ARCANEDEV/Sanitizer | src/Sanitizer.php | Sanitizer.sanitize | public function sanitize(array $data, array $rules = [], array $filters = [])
{
$this->setRules($rules);
$this->setFilters($filters);
foreach ($data as $name => $value) {
$data[$name] = $this->sanitizeAttribute($name, $value);
}
return $data;
} | php | public function sanitize(array $data, array $rules = [], array $filters = [])
{
$this->setRules($rules);
$this->setFilters($filters);
foreach ($data as $name => $value) {
$data[$name] = $this->sanitizeAttribute($name, $value);
}
return $data;
} | [
"public",
"function",
"sanitize",
"(",
"array",
"$",
"data",
",",
"array",
"$",
"rules",
"=",
"[",
"]",
",",
"array",
"$",
"filters",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"setRules",
"(",
"$",
"rules",
")",
";",
"$",
"this",
"->",
"setFilters",
"(",
"$",
"filters",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"data",
"[",
"$",
"name",
"]",
"=",
"$",
"this",
"->",
"sanitizeAttribute",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
]
| Sanitize the given data.
@param array $data
@param array $rules
@param array $filters
@return array | [
"Sanitize",
"the",
"given",
"data",
"."
]
| train | https://github.com/ARCANEDEV/Sanitizer/blob/e21990ce6d881366d52a7f4e5040b07cc3ecca96/src/Sanitizer.php#L99-L109 |
ARCANEDEV/Sanitizer | src/Sanitizer.php | Sanitizer.sanitizeAttribute | protected function sanitizeAttribute($attribute, $value)
{
foreach ($this->rules->get($attribute) as $rule) {
$value = $this->applyFilter($rule['name'], $value, $rule['options']);
}
return $value;
} | php | protected function sanitizeAttribute($attribute, $value)
{
foreach ($this->rules->get($attribute) as $rule) {
$value = $this->applyFilter($rule['name'], $value, $rule['options']);
}
return $value;
} | [
"protected",
"function",
"sanitizeAttribute",
"(",
"$",
"attribute",
",",
"$",
"value",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"rules",
"->",
"get",
"(",
"$",
"attribute",
")",
"as",
"$",
"rule",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"applyFilter",
"(",
"$",
"rule",
"[",
"'name'",
"]",
",",
"$",
"value",
",",
"$",
"rule",
"[",
"'options'",
"]",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
]
| Sanitize the given attribute
@param string $attribute
@param mixed $value
@return mixed | [
"Sanitize",
"the",
"given",
"attribute"
]
| train | https://github.com/ARCANEDEV/Sanitizer/blob/e21990ce6d881366d52a7f4e5040b07cc3ecca96/src/Sanitizer.php#L119-L126 |
ARCANEDEV/Sanitizer | src/Sanitizer.php | Sanitizer.applyFilter | protected function applyFilter($name, $value, $options = [])
{
$this->hasFilter($name);
if (empty($value)) return $value;
$filter = $this->filters[$name];
if ($filter instanceof Closure) {
return call_user_func_array($filter, compact('value', 'options'));
}
/** @var Filterable $filterable */
$filterable = new $filter;
return $filterable->filter($value, $options);
} | php | protected function applyFilter($name, $value, $options = [])
{
$this->hasFilter($name);
if (empty($value)) return $value;
$filter = $this->filters[$name];
if ($filter instanceof Closure) {
return call_user_func_array($filter, compact('value', 'options'));
}
/** @var Filterable $filterable */
$filterable = new $filter;
return $filterable->filter($value, $options);
} | [
"protected",
"function",
"applyFilter",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"hasFilter",
"(",
"$",
"name",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"value",
")",
")",
"return",
"$",
"value",
";",
"$",
"filter",
"=",
"$",
"this",
"->",
"filters",
"[",
"$",
"name",
"]",
";",
"if",
"(",
"$",
"filter",
"instanceof",
"Closure",
")",
"{",
"return",
"call_user_func_array",
"(",
"$",
"filter",
",",
"compact",
"(",
"'value'",
",",
"'options'",
")",
")",
";",
"}",
"/** @var Filterable $filterable */",
"$",
"filterable",
"=",
"new",
"$",
"filter",
";",
"return",
"$",
"filterable",
"->",
"filter",
"(",
"$",
"value",
",",
"$",
"options",
")",
";",
"}"
]
| Apply the given filter by its name.
@param string $name
@param mixed $value
@param array $options
@return mixed | [
"Apply",
"the",
"given",
"filter",
"by",
"its",
"name",
"."
]
| train | https://github.com/ARCANEDEV/Sanitizer/blob/e21990ce6d881366d52a7f4e5040b07cc3ecca96/src/Sanitizer.php#L137-L153 |
ARCANEDEV/Sanitizer | src/Sanitizer.php | Sanitizer.getDefaultFilters | private function getDefaultFilters()
{
return [
'capitalize' => Filters\CapitalizeFilter::class,
'email' => Filters\EmailFilter::class,
'escape' => Filters\EscapeFilter::class,
'format_date' => Filters\FormatDateFilter::class,
'lowercase' => Filters\LowercaseFilter::class,
'slug' => Filters\SlugFilter::class,
'trim' => Filters\TrimFilter::class,
'uppercase' => Filters\UppercaseFilter::class,
'url' => Filters\UrlFilter::class,
];
} | php | private function getDefaultFilters()
{
return [
'capitalize' => Filters\CapitalizeFilter::class,
'email' => Filters\EmailFilter::class,
'escape' => Filters\EscapeFilter::class,
'format_date' => Filters\FormatDateFilter::class,
'lowercase' => Filters\LowercaseFilter::class,
'slug' => Filters\SlugFilter::class,
'trim' => Filters\TrimFilter::class,
'uppercase' => Filters\UppercaseFilter::class,
'url' => Filters\UrlFilter::class,
];
} | [
"private",
"function",
"getDefaultFilters",
"(",
")",
"{",
"return",
"[",
"'capitalize'",
"=>",
"Filters",
"\\",
"CapitalizeFilter",
"::",
"class",
",",
"'email'",
"=>",
"Filters",
"\\",
"EmailFilter",
"::",
"class",
",",
"'escape'",
"=>",
"Filters",
"\\",
"EscapeFilter",
"::",
"class",
",",
"'format_date'",
"=>",
"Filters",
"\\",
"FormatDateFilter",
"::",
"class",
",",
"'lowercase'",
"=>",
"Filters",
"\\",
"LowercaseFilter",
"::",
"class",
",",
"'slug'",
"=>",
"Filters",
"\\",
"SlugFilter",
"::",
"class",
",",
"'trim'",
"=>",
"Filters",
"\\",
"TrimFilter",
"::",
"class",
",",
"'uppercase'",
"=>",
"Filters",
"\\",
"UppercaseFilter",
"::",
"class",
",",
"'url'",
"=>",
"Filters",
"\\",
"UrlFilter",
"::",
"class",
",",
"]",
";",
"}"
]
| Get default filters.
@return array | [
"Get",
"default",
"filters",
"."
]
| train | https://github.com/ARCANEDEV/Sanitizer/blob/e21990ce6d881366d52a7f4e5040b07cc3ecca96/src/Sanitizer.php#L184-L197 |
webforge-labs/psc-cms | lib/Psc/URL/Helper.php | Helper.absolute | protected static function absolute($relativeURL) {
$protocol = 'http';
$url = $protocol.'://'.rtrim($_SERVER['HTTP_HOST'],'/');
$url .= $relativeURL;
return $url;
} | php | protected static function absolute($relativeURL) {
$protocol = 'http';
$url = $protocol.'://'.rtrim($_SERVER['HTTP_HOST'],'/');
$url .= $relativeURL;
return $url;
} | [
"protected",
"static",
"function",
"absolute",
"(",
"$",
"relativeURL",
")",
"{",
"$",
"protocol",
"=",
"'http'",
";",
"$",
"url",
"=",
"$",
"protocol",
".",
"'://'",
".",
"rtrim",
"(",
"$",
"_SERVER",
"[",
"'HTTP_HOST'",
"]",
",",
"'/'",
")",
";",
"$",
"url",
".=",
"$",
"relativeURL",
";",
"return",
"$",
"url",
";",
"}"
]
| Wandelt eine Relative in eine absolute URL um (hängt den Host davor)
@param string $section sollte immer mit / anfangen | [
"Wandelt",
"eine",
"Relative",
"in",
"eine",
"absolute",
"URL",
"um",
"(",
"hängt",
"den",
"Host",
"davor",
")"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/URL/Helper.php#L18-L25 |
webforge-labs/psc-cms | lib/Psc/URL/Helper.php | Helper.getRelative | public static function getRelative($flags = 0x000000, Array $queryVars = array()) {
$flags |= self::RELATIVE;
return self::getURL(NULL,$flags, $queryVars);
} | php | public static function getRelative($flags = 0x000000, Array $queryVars = array()) {
$flags |= self::RELATIVE;
return self::getURL(NULL,$flags, $queryVars);
} | [
"public",
"static",
"function",
"getRelative",
"(",
"$",
"flags",
"=",
"0x000000",
",",
"Array",
"$",
"queryVars",
"=",
"array",
"(",
")",
")",
"{",
"$",
"flags",
"|=",
"self",
"::",
"RELATIVE",
";",
"return",
"self",
"::",
"getURL",
"(",
"NULL",
",",
"$",
"flags",
",",
"$",
"queryVars",
")",
";",
"}"
]
| Gibt die aktuelle relative URL zurück
@param bitmap $flags
@param Array $queryVars | [
"Gibt",
"die",
"aktuelle",
"relative",
"URL",
"zurück"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/URL/Helper.php#L33-L36 |
webforge-labs/psc-cms | lib/Psc/URL/Helper.php | Helper.getAbsolute | public static function getAbsolute($flags = 0x000000, Array $queryVars = array()) {
$flags |= self::ABSOLUTE;
return self::getURL(NULL,$flags,$queryVars);
} | php | public static function getAbsolute($flags = 0x000000, Array $queryVars = array()) {
$flags |= self::ABSOLUTE;
return self::getURL(NULL,$flags,$queryVars);
} | [
"public",
"static",
"function",
"getAbsolute",
"(",
"$",
"flags",
"=",
"0x000000",
",",
"Array",
"$",
"queryVars",
"=",
"array",
"(",
")",
")",
"{",
"$",
"flags",
"|=",
"self",
"::",
"ABSOLUTE",
";",
"return",
"self",
"::",
"getURL",
"(",
"NULL",
",",
"$",
"flags",
",",
"$",
"queryVars",
")",
";",
"}"
]
| /*
Gibt die aktuelle absolute URL zurück
Die Parameter verhalten sich so wie bei getRelative und getURL() außer, dass die zurückgegebene URL
eine Absolute ist | [
"/",
"*",
"Gibt",
"die",
"aktuelle",
"absolute",
"URL",
"zurück"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/URL/Helper.php#L44-L47 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.