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 |
|---|---|---|---|---|---|---|---|---|---|---|
la-haute-societe/yii2-save-relations-behavior | src/SaveRelationsBehavior.php | SaveRelationsBehavior.setMultipleRelation | protected function setMultipleRelation($relationName, $value)
{
/** @var BaseActiveRecord $owner */
$owner = $this->owner;
/** @var ActiveQuery $relation */
$relation = $owner->getRelation($relationName);
$newRelations = [];
if (!is_array($value)) {
if (!e... | php | protected function setMultipleRelation($relationName, $value)
{
/** @var BaseActiveRecord $owner */
$owner = $this->owner;
/** @var ActiveQuery $relation */
$relation = $owner->getRelation($relationName);
$newRelations = [];
if (!is_array($value)) {
if (!e... | [
"protected",
"function",
"setMultipleRelation",
"(",
"$",
"relationName",
",",
"$",
"value",
")",
"{",
"/** @var BaseActiveRecord $owner */",
"$",
"owner",
"=",
"$",
"this",
"->",
"owner",
";",
"/** @var ActiveQuery $relation */",
"$",
"relation",
"=",
"$",
"owner",... | Set the named multiple relation with the given value
@param string $relationName
@param $value
@throws \yii\base\InvalidArgumentException | [
"Set",
"the",
"named",
"multiple",
"relation",
"with",
"the",
"given",
"value"
] | train | https://github.com/la-haute-societe/yii2-save-relations-behavior/blob/1afd088dbf20fa110389b14986c7ac777fcbbd60/src/SaveRelationsBehavior.php#L177-L201 |
la-haute-societe/yii2-save-relations-behavior | src/SaveRelationsBehavior.php | SaveRelationsBehavior.processModelAsArray | protected function processModelAsArray($data, $relation, $name)
{
/** @var BaseActiveRecord $modelClass */
$modelClass = $relation->modelClass;
$fks = $this->_getRelatedFks($data, $relation, $modelClass);
return $this->_loadOrCreateRelationModel($data, $fks, $modelClass, $name);
... | php | protected function processModelAsArray($data, $relation, $name)
{
/** @var BaseActiveRecord $modelClass */
$modelClass = $relation->modelClass;
$fks = $this->_getRelatedFks($data, $relation, $modelClass);
return $this->_loadOrCreateRelationModel($data, $fks, $modelClass, $name);
... | [
"protected",
"function",
"processModelAsArray",
"(",
"$",
"data",
",",
"$",
"relation",
",",
"$",
"name",
")",
"{",
"/** @var BaseActiveRecord $modelClass */",
"$",
"modelClass",
"=",
"$",
"relation",
"->",
"modelClass",
";",
"$",
"fks",
"=",
"$",
"this",
"->"... | Get a BaseActiveRecord model using the given $data parameter.
$data could either be a model ID or an associative array representing model attributes => values
@param mixed $data
@param \yii\db\ActiveQuery $relation
@return BaseActiveRecord | [
"Get",
"a",
"BaseActiveRecord",
"model",
"using",
"the",
"given",
"$data",
"parameter",
".",
"$data",
"could",
"either",
"be",
"a",
"model",
"ID",
"or",
"an",
"associative",
"array",
"representing",
"model",
"attributes",
"=",
">",
"values"
] | train | https://github.com/la-haute-societe/yii2-save-relations-behavior/blob/1afd088dbf20fa110389b14986c7ac777fcbbd60/src/SaveRelationsBehavior.php#L210-L216 |
la-haute-societe/yii2-save-relations-behavior | src/SaveRelationsBehavior.php | SaveRelationsBehavior._getRelatedFks | private function _getRelatedFks($data, $relation, $modelClass)
{
$fks = [];
if (is_array($data)) {
// Get the right link definition
if ($relation->via instanceof BaseActiveRecord) {
$link = $relation->via->link;
} elseif (is_array($relation->via)) ... | php | private function _getRelatedFks($data, $relation, $modelClass)
{
$fks = [];
if (is_array($data)) {
// Get the right link definition
if ($relation->via instanceof BaseActiveRecord) {
$link = $relation->via->link;
} elseif (is_array($relation->via)) ... | [
"private",
"function",
"_getRelatedFks",
"(",
"$",
"data",
",",
"$",
"relation",
",",
"$",
"modelClass",
")",
"{",
"$",
"fks",
"=",
"[",
"]",
";",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"// Get the right link definition",
"if",
"(",
"$... | Get the related model foreign keys
@param $data
@param $relation
@param BaseActiveRecord $modelClass
@return array | [
"Get",
"the",
"related",
"model",
"foreign",
"keys"
] | train | https://github.com/la-haute-societe/yii2-save-relations-behavior/blob/1afd088dbf20fa110389b14986c7ac777fcbbd60/src/SaveRelationsBehavior.php#L225-L264 |
la-haute-societe/yii2-save-relations-behavior | src/SaveRelationsBehavior.php | SaveRelationsBehavior._loadOrCreateRelationModel | private function _loadOrCreateRelationModel($data, $fks, $modelClass, $relationName)
{
/** @var BaseActiveRecord $relationModel */
$relationModel = null;
if (!empty($fks)) {
$relationModel = $modelClass::findOne($fks);
}
if (!($relationModel instanceof BaseActive... | php | private function _loadOrCreateRelationModel($data, $fks, $modelClass, $relationName)
{
/** @var BaseActiveRecord $relationModel */
$relationModel = null;
if (!empty($fks)) {
$relationModel = $modelClass::findOne($fks);
}
if (!($relationModel instanceof BaseActive... | [
"private",
"function",
"_loadOrCreateRelationModel",
"(",
"$",
"data",
",",
"$",
"fks",
",",
"$",
"modelClass",
",",
"$",
"relationName",
")",
"{",
"/** @var BaseActiveRecord $relationModel */",
"$",
"relationModel",
"=",
"null",
";",
"if",
"(",
"!",
"empty",
"(... | Load existing model or create one if no key was provided and data is not empty
@param $data
@param $fks
@param $modelClass
@param $relationName
@return BaseActiveRecord | [
"Load",
"existing",
"model",
"or",
"create",
"one",
"if",
"no",
"key",
"was",
"provided",
"and",
"data",
"is",
"not",
"empty"
] | train | https://github.com/la-haute-societe/yii2-save-relations-behavior/blob/1afd088dbf20fa110389b14986c7ac777fcbbd60/src/SaveRelationsBehavior.php#L274-L297 |
la-haute-societe/yii2-save-relations-behavior | src/SaveRelationsBehavior.php | SaveRelationsBehavior.beforeValidate | public function beforeValidate(ModelEvent $event)
{
if ($this->_relationsSaveStarted === false && !empty($this->_oldRelationValue)) {
/* @var $model BaseActiveRecord */
$model = $this->owner;
if ($this->saveRelatedRecords($model, $event)) {
// If relation ... | php | public function beforeValidate(ModelEvent $event)
{
if ($this->_relationsSaveStarted === false && !empty($this->_oldRelationValue)) {
/* @var $model BaseActiveRecord */
$model = $this->owner;
if ($this->saveRelatedRecords($model, $event)) {
// If relation ... | [
"public",
"function",
"beforeValidate",
"(",
"ModelEvent",
"$",
"event",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_relationsSaveStarted",
"===",
"false",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"_oldRelationValue",
")",
")",
"{",
"/* @var $model BaseActive... | Before the owner model validation, save related models.
For `hasOne()` relations, set the according foreign keys of the owner model to be able to validate it
@param ModelEvent $event
@throws DbException
@throws \yii\base\InvalidConfigException | [
"Before",
"the",
"owner",
"model",
"validation",
"save",
"related",
"models",
".",
"For",
"hasOne",
"()",
"relations",
"set",
"the",
"according",
"foreign",
"keys",
"of",
"the",
"owner",
"model",
"to",
"be",
"able",
"to",
"validate",
"it"
] | train | https://github.com/la-haute-societe/yii2-save-relations-behavior/blob/1afd088dbf20fa110389b14986c7ac777fcbbd60/src/SaveRelationsBehavior.php#L306-L320 |
la-haute-societe/yii2-save-relations-behavior | src/SaveRelationsBehavior.php | SaveRelationsBehavior.saveRelatedRecords | protected function saveRelatedRecords(BaseActiveRecord $model, ModelEvent $event)
{
try {
foreach ($this->_relations as $relationName) {
if (array_key_exists($relationName, $this->_oldRelationValue)) { // Relation was not set, do nothing...
/** @var ActiveQuer... | php | protected function saveRelatedRecords(BaseActiveRecord $model, ModelEvent $event)
{
try {
foreach ($this->_relations as $relationName) {
if (array_key_exists($relationName, $this->_oldRelationValue)) { // Relation was not set, do nothing...
/** @var ActiveQuer... | [
"protected",
"function",
"saveRelatedRecords",
"(",
"BaseActiveRecord",
"$",
"model",
",",
"ModelEvent",
"$",
"event",
")",
"{",
"try",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_relations",
"as",
"$",
"relationName",
")",
"{",
"if",
"(",
"array_key_exists",
... | Prepare each related model (validate or save if needed).
This is done during the before validation process to be able
to set the related foreign keys for newly created has one records.
@param BaseActiveRecord $model
@param ModelEvent $event
@return bool
@throws DbException
@throws \yii\base\InvalidConfigException | [
"Prepare",
"each",
"related",
"model",
"(",
"validate",
"or",
"save",
"if",
"needed",
")",
".",
"This",
"is",
"done",
"during",
"the",
"before",
"validation",
"process",
"to",
"be",
"able",
"to",
"set",
"the",
"related",
"foreign",
"keys",
"for",
"newly",
... | train | https://github.com/la-haute-societe/yii2-save-relations-behavior/blob/1afd088dbf20fa110389b14986c7ac777fcbbd60/src/SaveRelationsBehavior.php#L332-L359 |
la-haute-societe/yii2-save-relations-behavior | src/SaveRelationsBehavior.php | SaveRelationsBehavior.validateRelationModel | protected function validateRelationModel($prettyRelationName, $relationName, BaseActiveRecord $relationModel)
{
/** @var BaseActiveRecord $model */
$model = $this->owner;
if (!is_null($relationModel) && ($relationModel->isNewRecord || count($relationModel->getDirtyAttributes()))) {
... | php | protected function validateRelationModel($prettyRelationName, $relationName, BaseActiveRecord $relationModel)
{
/** @var BaseActiveRecord $model */
$model = $this->owner;
if (!is_null($relationModel) && ($relationModel->isNewRecord || count($relationModel->getDirtyAttributes()))) {
... | [
"protected",
"function",
"validateRelationModel",
"(",
"$",
"prettyRelationName",
",",
"$",
"relationName",
",",
"BaseActiveRecord",
"$",
"relationModel",
")",
"{",
"/** @var BaseActiveRecord $model */",
"$",
"model",
"=",
"$",
"this",
"->",
"owner",
";",
"if",
"(",... | Validate a relation model and add an error message to owner model attribute if needed
@param string $prettyRelationName
@param string $relationName
@param BaseActiveRecord $relationModel | [
"Validate",
"a",
"relation",
"model",
"and",
"add",
"an",
"error",
"message",
"to",
"owner",
"model",
"attribute",
"if",
"needed"
] | train | https://github.com/la-haute-societe/yii2-save-relations-behavior/blob/1afd088dbf20fa110389b14986c7ac777fcbbd60/src/SaveRelationsBehavior.php#L391-L402 |
la-haute-societe/yii2-save-relations-behavior | src/SaveRelationsBehavior.php | SaveRelationsBehavior._addError | private function _addError($relationModel, $owner, $relationName, $prettyRelationName)
{
foreach ($relationModel->errors as $attribute => $attributeErrors) {
foreach ($attributeErrors as $error) {
$owner->addError($relationName, "{$prettyRelationName}: {$error}");
}
... | php | private function _addError($relationModel, $owner, $relationName, $prettyRelationName)
{
foreach ($relationModel->errors as $attribute => $attributeErrors) {
foreach ($attributeErrors as $error) {
$owner->addError($relationName, "{$prettyRelationName}: {$error}");
}
... | [
"private",
"function",
"_addError",
"(",
"$",
"relationModel",
",",
"$",
"owner",
",",
"$",
"relationName",
",",
"$",
"prettyRelationName",
")",
"{",
"foreach",
"(",
"$",
"relationModel",
"->",
"errors",
"as",
"$",
"attribute",
"=>",
"$",
"attributeErrors",
... | Attach errors to owner relational attributes
@param BaseActiveRecord $relationModel
@param BaseActiveRecord $owner
@param string $relationName
@param string $prettyRelationName | [
"Attach",
"errors",
"to",
"owner",
"relational",
"attributes"
] | train | https://github.com/la-haute-societe/yii2-save-relations-behavior/blob/1afd088dbf20fa110389b14986c7ac777fcbbd60/src/SaveRelationsBehavior.php#L411-L418 |
la-haute-societe/yii2-save-relations-behavior | src/SaveRelationsBehavior.php | SaveRelationsBehavior._setRelationForeignKeys | protected function _setRelationForeignKeys($relationName)
{
/** @var BaseActiveRecord $owner */
$owner = $this->owner;
/** @var ActiveQuery $relation */
$relation = $owner->getRelation($relationName);
if ($relation->multiple === false && !empty($owner->{$relationName})) {
... | php | protected function _setRelationForeignKeys($relationName)
{
/** @var BaseActiveRecord $owner */
$owner = $this->owner;
/** @var ActiveQuery $relation */
$relation = $owner->getRelation($relationName);
if ($relation->multiple === false && !empty($owner->{$relationName})) {
... | [
"protected",
"function",
"_setRelationForeignKeys",
"(",
"$",
"relationName",
")",
"{",
"/** @var BaseActiveRecord $owner */",
"$",
"owner",
"=",
"$",
"this",
"->",
"owner",
";",
"/** @var ActiveQuery $relation */",
"$",
"relation",
"=",
"$",
"owner",
"->",
"getRelati... | Set relation foreign keys that point to owner primary key
@param $relationName | [
"Set",
"relation",
"foreign",
"keys",
"that",
"point",
"to",
"owner",
"primary",
"key"
] | train | https://github.com/la-haute-societe/yii2-save-relations-behavior/blob/1afd088dbf20fa110389b14986c7ac777fcbbd60/src/SaveRelationsBehavior.php#L458-L475 |
la-haute-societe/yii2-save-relations-behavior | src/SaveRelationsBehavior.php | SaveRelationsBehavior.afterSave | public function afterSave()
{
if ($this->_relationsSaveStarted === false) {
/** @var BaseActiveRecord $owner */
$owner = $this->owner;
$this->_relationsSaveStarted = true;
// Populate relations with updated values
foreach ($this->_newRelationValue ... | php | public function afterSave()
{
if ($this->_relationsSaveStarted === false) {
/** @var BaseActiveRecord $owner */
$owner = $this->owner;
$this->_relationsSaveStarted = true;
// Populate relations with updated values
foreach ($this->_newRelationValue ... | [
"public",
"function",
"afterSave",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_relationsSaveStarted",
"===",
"false",
")",
"{",
"/** @var BaseActiveRecord $owner */",
"$",
"owner",
"=",
"$",
"this",
"->",
"owner",
";",
"$",
"this",
"->",
"_relationsSaveStar... | Link the related models.
If the models have not been changed, nothing will be done.
Related records will be linked to the owner model using the BaseActiveRecord `link()` method.
@throws Exception | [
"Link",
"the",
"related",
"models",
".",
"If",
"the",
"models",
"have",
"not",
"been",
"changed",
"nothing",
"will",
"be",
"done",
".",
"Related",
"records",
"will",
"be",
"linked",
"to",
"the",
"owner",
"model",
"using",
"the",
"BaseActiveRecord",
"link",
... | train | https://github.com/la-haute-societe/yii2-save-relations-behavior/blob/1afd088dbf20fa110389b14986c7ac777fcbbd60/src/SaveRelationsBehavior.php#L483-L519 |
la-haute-societe/yii2-save-relations-behavior | src/SaveRelationsBehavior.php | SaveRelationsBehavior._getJunctionTableColumns | private function _getJunctionTableColumns($relationName, $model)
{
$junctionTableColumns = [];
if (array_key_exists($relationName, $this->_relationsExtraColumns)) {
if (is_callable($this->_relationsExtraColumns[$relationName])) {
$junctionTableColumns = $this->_relationsE... | php | private function _getJunctionTableColumns($relationName, $model)
{
$junctionTableColumns = [];
if (array_key_exists($relationName, $this->_relationsExtraColumns)) {
if (is_callable($this->_relationsExtraColumns[$relationName])) {
$junctionTableColumns = $this->_relationsE... | [
"private",
"function",
"_getJunctionTableColumns",
"(",
"$",
"relationName",
",",
"$",
"model",
")",
"{",
"$",
"junctionTableColumns",
"=",
"[",
"]",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"relationName",
",",
"$",
"this",
"->",
"_relationsExtraColumns",
... | Return array of columns to save to the junction table for a related model having a many-to-many relation.
@param string $relationName
@param BaseActiveRecord $model
@return array
@throws \RuntimeException | [
"Return",
"array",
"of",
"columns",
"to",
"save",
"to",
"the",
"junction",
"table",
"for",
"a",
"related",
"model",
"having",
"a",
"many",
"-",
"to",
"-",
"many",
"relation",
"."
] | train | https://github.com/la-haute-societe/yii2-save-relations-behavior/blob/1afd088dbf20fa110389b14986c7ac777fcbbd60/src/SaveRelationsBehavior.php#L597-L613 |
la-haute-societe/yii2-save-relations-behavior | src/SaveRelationsBehavior.php | SaveRelationsBehavior._computePkDiff | private function _computePkDiff($initialRelations, $updatedRelations, $forceSave = false)
{
// Compute differences between initial relations and the current ones
$oldPks = ArrayHelper::getColumn($initialRelations, function (BaseActiveRecord $model) {
return implode('-', $model->getPrimar... | php | private function _computePkDiff($initialRelations, $updatedRelations, $forceSave = false)
{
// Compute differences between initial relations and the current ones
$oldPks = ArrayHelper::getColumn($initialRelations, function (BaseActiveRecord $model) {
return implode('-', $model->getPrimar... | [
"private",
"function",
"_computePkDiff",
"(",
"$",
"initialRelations",
",",
"$",
"updatedRelations",
",",
"$",
"forceSave",
"=",
"false",
")",
"{",
"// Compute differences between initial relations and the current ones",
"$",
"oldPks",
"=",
"ArrayHelper",
"::",
"getColumn... | Compute the difference between two set of records using primary keys "tokens"
If third parameter is set to true all initial related records will be marked for removal even if their
properties did not change. This can be handy in a many-to-many relation_ involving a junction table.
@param BaseActiveRecord[] $initialRela... | [
"Compute",
"the",
"difference",
"between",
"two",
"set",
"of",
"records",
"using",
"primary",
"keys",
"tokens",
"If",
"third",
"parameter",
"is",
"set",
"to",
"true",
"all",
"initial",
"related",
"records",
"will",
"be",
"marked",
"for",
"removal",
"even",
"... | train | https://github.com/la-haute-societe/yii2-save-relations-behavior/blob/1afd088dbf20fa110389b14986c7ac777fcbbd60/src/SaveRelationsBehavior.php#L624-L642 |
la-haute-societe/yii2-save-relations-behavior | src/SaveRelationsBehavior.php | SaveRelationsBehavior.beforeDelete | public function beforeDelete()
{
/** @var BaseActiveRecord $owner */
$owner = $this->owner;
foreach ($this->_relationsCascadeDelete as $relationName => $params) {
if ($params === true) {
/** @var ActiveQuery $relation */
$relation = $owner->getRela... | php | public function beforeDelete()
{
/** @var BaseActiveRecord $owner */
$owner = $this->owner;
foreach ($this->_relationsCascadeDelete as $relationName => $params) {
if ($params === true) {
/** @var ActiveQuery $relation */
$relation = $owner->getRela... | [
"public",
"function",
"beforeDelete",
"(",
")",
"{",
"/** @var BaseActiveRecord $owner */",
"$",
"owner",
"=",
"$",
"this",
"->",
"owner",
";",
"foreach",
"(",
"$",
"this",
"->",
"_relationsCascadeDelete",
"as",
"$",
"relationName",
"=>",
"$",
"params",
")",
"... | Get the list of owner model relations in order to be able to delete them after its deletion | [
"Get",
"the",
"list",
"of",
"owner",
"model",
"relations",
"in",
"order",
"to",
"be",
"able",
"to",
"delete",
"them",
"after",
"its",
"deletion"
] | train | https://github.com/la-haute-societe/yii2-save-relations-behavior/blob/1afd088dbf20fa110389b14986c7ac777fcbbd60/src/SaveRelationsBehavior.php#L669-L686 |
la-haute-societe/yii2-save-relations-behavior | src/SaveRelationsBehavior.php | SaveRelationsBehavior.afterDelete | public function afterDelete()
{
/** @var BaseActiveRecord $modelToDelete */
foreach ($this->_relationsToDelete as $modelToDelete) {
try {
if (!$modelToDelete->delete()) {
throw new DbException('Could not delete the related record: ' . $modelToDelete::c... | php | public function afterDelete()
{
/** @var BaseActiveRecord $modelToDelete */
foreach ($this->_relationsToDelete as $modelToDelete) {
try {
if (!$modelToDelete->delete()) {
throw new DbException('Could not delete the related record: ' . $modelToDelete::c... | [
"public",
"function",
"afterDelete",
"(",
")",
"{",
"/** @var BaseActiveRecord $modelToDelete */",
"foreach",
"(",
"$",
"this",
"->",
"_relationsToDelete",
"as",
"$",
"modelToDelete",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"$",
"modelToDelete",
"->",
"delete",
"(... | Delete related models marked as to be deleted
@throws Exception | [
"Delete",
"related",
"models",
"marked",
"as",
"to",
"be",
"deleted"
] | train | https://github.com/la-haute-societe/yii2-save-relations-behavior/blob/1afd088dbf20fa110389b14986c7ac777fcbbd60/src/SaveRelationsBehavior.php#L692-L706 |
la-haute-societe/yii2-save-relations-behavior | src/SaveRelationsBehavior.php | SaveRelationsBehavior.loadRelations | public function loadRelations($data)
{
/** @var BaseActiveRecord $owner */
$owner = $this->owner;
foreach ($this->_relations as $relationName) {
$keyName = $this->_getRelationKeyName($relationName);
if (array_key_exists($keyName, $data)) {
$owner->{$re... | php | public function loadRelations($data)
{
/** @var BaseActiveRecord $owner */
$owner = $this->owner;
foreach ($this->_relations as $relationName) {
$keyName = $this->_getRelationKeyName($relationName);
if (array_key_exists($keyName, $data)) {
$owner->{$re... | [
"public",
"function",
"loadRelations",
"(",
"$",
"data",
")",
"{",
"/** @var BaseActiveRecord $owner */",
"$",
"owner",
"=",
"$",
"this",
"->",
"owner",
";",
"foreach",
"(",
"$",
"this",
"->",
"_relations",
"as",
"$",
"relationName",
")",
"{",
"$",
"keyName"... | Populates relations with input data
@param array $data
@throws InvalidConfigException | [
"Populates",
"relations",
"with",
"input",
"data"
] | train | https://github.com/la-haute-societe/yii2-save-relations-behavior/blob/1afd088dbf20fa110389b14986c7ac777fcbbd60/src/SaveRelationsBehavior.php#L713-L723 |
la-haute-societe/yii2-save-relations-behavior | src/SaveRelationsBehavior.php | SaveRelationsBehavior.setRelationScenario | public function setRelationScenario($relationName, $scenario)
{
/** @var BaseActiveRecord $owner */
$owner = $this->owner;
$relation = $owner->getRelation($relationName, false);
if (in_array($relationName, $this->_relations) && !is_null($relation)) {
$this->_relationsScen... | php | public function setRelationScenario($relationName, $scenario)
{
/** @var BaseActiveRecord $owner */
$owner = $this->owner;
$relation = $owner->getRelation($relationName, false);
if (in_array($relationName, $this->_relations) && !is_null($relation)) {
$this->_relationsScen... | [
"public",
"function",
"setRelationScenario",
"(",
"$",
"relationName",
",",
"$",
"scenario",
")",
"{",
"/** @var BaseActiveRecord $owner */",
"$",
"owner",
"=",
"$",
"this",
"->",
"owner",
";",
"$",
"relation",
"=",
"$",
"owner",
"->",
"getRelation",
"(",
"$",... | Set the scenario for a given relation
@param $relationName
@param $scenario
@throws InvalidArgumentException | [
"Set",
"the",
"scenario",
"for",
"a",
"given",
"relation"
] | train | https://github.com/la-haute-societe/yii2-save-relations-behavior/blob/1afd088dbf20fa110389b14986c7ac777fcbbd60/src/SaveRelationsBehavior.php#L731-L742 |
la-haute-societe/yii2-save-relations-behavior | src/SaveRelationsBehavior.php | SaveRelationsBehavior.getOldRelations | public function getOldRelations()
{
$oldRelations = [];
foreach ($this->_relations as $relationName) {
$oldRelations[$relationName] = $this->getOldRelation($relationName);
}
return $oldRelations;
} | php | public function getOldRelations()
{
$oldRelations = [];
foreach ($this->_relations as $relationName) {
$oldRelations[$relationName] = $this->getOldRelation($relationName);
}
return $oldRelations;
} | [
"public",
"function",
"getOldRelations",
"(",
")",
"{",
"$",
"oldRelations",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"_relations",
"as",
"$",
"relationName",
")",
"{",
"$",
"oldRelations",
"[",
"$",
"relationName",
"]",
"=",
"$",
"this",
... | Return the old relations values.
@return array The old relations (name-value pairs) | [
"Return",
"the",
"old",
"relations",
"values",
"."
] | train | https://github.com/la-haute-societe/yii2-save-relations-behavior/blob/1afd088dbf20fa110389b14986c7ac777fcbbd60/src/SaveRelationsBehavior.php#L775-L782 |
la-haute-societe/yii2-save-relations-behavior | src/SaveRelationsBehavior.php | SaveRelationsBehavior.getOldRelation | public function getOldRelation($relationName)
{
return array_key_exists($relationName, $this->_oldRelationValue) ? $this->_oldRelationValue[$relationName] : $this->owner->{$relationName};
} | php | public function getOldRelation($relationName)
{
return array_key_exists($relationName, $this->_oldRelationValue) ? $this->_oldRelationValue[$relationName] : $this->owner->{$relationName};
} | [
"public",
"function",
"getOldRelation",
"(",
"$",
"relationName",
")",
"{",
"return",
"array_key_exists",
"(",
"$",
"relationName",
",",
"$",
"this",
"->",
"_oldRelationValue",
")",
"?",
"$",
"this",
"->",
"_oldRelationValue",
"[",
"$",
"relationName",
"]",
":... | Returns the old value of the named relation.
@param $relationName string The relations name as defined in the behavior `relations` parameter
@return mixed | [
"Returns",
"the",
"old",
"value",
"of",
"the",
"named",
"relation",
"."
] | train | https://github.com/la-haute-societe/yii2-save-relations-behavior/blob/1afd088dbf20fa110389b14986c7ac777fcbbd60/src/SaveRelationsBehavior.php#L789-L792 |
la-haute-societe/yii2-save-relations-behavior | src/SaveRelationsBehavior.php | SaveRelationsBehavior.getDirtyRelations | public function getDirtyRelations()
{
$dirtyRelations = [];
foreach ($this->_relations as $relationName) {
if (array_key_exists($relationName, $this->_oldRelationValue)) {
$dirtyRelations[$relationName] = $this->owner->{$relationName};
}
}
retu... | php | public function getDirtyRelations()
{
$dirtyRelations = [];
foreach ($this->_relations as $relationName) {
if (array_key_exists($relationName, $this->_oldRelationValue)) {
$dirtyRelations[$relationName] = $this->owner->{$relationName};
}
}
retu... | [
"public",
"function",
"getDirtyRelations",
"(",
")",
"{",
"$",
"dirtyRelations",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"_relations",
"as",
"$",
"relationName",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"relationName",
",",
"$",
... | Returns the relations that have been modified since they are loaded.
@return array The changed relations (name-value pairs) | [
"Returns",
"the",
"relations",
"that",
"have",
"been",
"modified",
"since",
"they",
"are",
"loaded",
"."
] | train | https://github.com/la-haute-societe/yii2-save-relations-behavior/blob/1afd088dbf20fa110389b14986c7ac777fcbbd60/src/SaveRelationsBehavior.php#L798-L807 |
la-haute-societe/yii2-save-relations-behavior | src/SaveRelationsBehavior.php | SaveRelationsBehavior.markRelationDirty | public function markRelationDirty($relationName)
{
if (in_array($relationName, $this->_relations) && !array_key_exists($relationName, $this->_oldRelationValue)) {
$this->_oldRelationValue[$relationName] = $this->owner->{$relationName};
return true;
}
return false;
... | php | public function markRelationDirty($relationName)
{
if (in_array($relationName, $this->_relations) && !array_key_exists($relationName, $this->_oldRelationValue)) {
$this->_oldRelationValue[$relationName] = $this->owner->{$relationName};
return true;
}
return false;
... | [
"public",
"function",
"markRelationDirty",
"(",
"$",
"relationName",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"relationName",
",",
"$",
"this",
"->",
"_relations",
")",
"&&",
"!",
"array_key_exists",
"(",
"$",
"relationName",
",",
"$",
"this",
"->",
"_ol... | Mark a relation as dirty
@param $relationName string
@return bool Whether the operation succeeded. | [
"Mark",
"a",
"relation",
"as",
"dirty"
] | train | https://github.com/la-haute-societe/yii2-save-relations-behavior/blob/1afd088dbf20fa110389b14986c7ac777fcbbd60/src/SaveRelationsBehavior.php#L814-L821 |
silexphp/Silex | src/Silex/Provider/Validator/ConstraintValidatorFactory.php | ConstraintValidatorFactory.getInstance | public function getInstance(Constraint $constraint)
{
$name = $constraint->validatedBy();
if (isset($this->serviceNames[$name])) {
return $this->container[$this->serviceNames[$name]];
}
return parent::getInstance($constraint);
} | php | public function getInstance(Constraint $constraint)
{
$name = $constraint->validatedBy();
if (isset($this->serviceNames[$name])) {
return $this->container[$this->serviceNames[$name]];
}
return parent::getInstance($constraint);
} | [
"public",
"function",
"getInstance",
"(",
"Constraint",
"$",
"constraint",
")",
"{",
"$",
"name",
"=",
"$",
"constraint",
"->",
"validatedBy",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"serviceNames",
"[",
"$",
"name",
"]",
")",
")",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/silexphp/Silex/blob/2065bd6dcae0f6d11dc6680c1219343493b76087/src/Silex/Provider/Validator/ConstraintValidatorFactory.php#L53-L62 |
silexphp/Silex | src/Silex/AppArgumentValueResolver.php | AppArgumentValueResolver.supports | public function supports(Request $request, ArgumentMetadata $argument)
{
return null !== $argument->getType() && (Application::class === $argument->getType() || is_subclass_of($argument->getType(), Application::class));
} | php | public function supports(Request $request, ArgumentMetadata $argument)
{
return null !== $argument->getType() && (Application::class === $argument->getType() || is_subclass_of($argument->getType(), Application::class));
} | [
"public",
"function",
"supports",
"(",
"Request",
"$",
"request",
",",
"ArgumentMetadata",
"$",
"argument",
")",
"{",
"return",
"null",
"!==",
"$",
"argument",
"->",
"getType",
"(",
")",
"&&",
"(",
"Application",
"::",
"class",
"===",
"$",
"argument",
"->"... | {@inheritdoc} | [
"{"
] | train | https://github.com/silexphp/Silex/blob/2065bd6dcae0f6d11dc6680c1219343493b76087/src/Silex/AppArgumentValueResolver.php#L35-L38 |
silexphp/Silex | src/Silex/Application.php | Application.register | public function register(ServiceProviderInterface $provider, array $values = [])
{
$this->providers[] = $provider;
parent::register($provider, $values);
return $this;
} | php | public function register(ServiceProviderInterface $provider, array $values = [])
{
$this->providers[] = $provider;
parent::register($provider, $values);
return $this;
} | [
"public",
"function",
"register",
"(",
"ServiceProviderInterface",
"$",
"provider",
",",
"array",
"$",
"values",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"providers",
"[",
"]",
"=",
"$",
"provider",
";",
"parent",
"::",
"register",
"(",
"$",
"provider... | Registers a service provider.
@param ServiceProviderInterface $provider A ServiceProviderInterface instance
@param array $values An array of values that customizes the provider
@return Application | [
"Registers",
"a",
"service",
"provider",
"."
] | train | https://github.com/silexphp/Silex/blob/2065bd6dcae0f6d11dc6680c1219343493b76087/src/Silex/Application.php#L86-L93 |
silexphp/Silex | src/Silex/Application.php | Application.boot | public function boot()
{
if ($this->booted) {
return;
}
$this->booted = true;
foreach ($this->providers as $provider) {
if ($provider instanceof EventListenerProviderInterface) {
$provider->subscribe($this, $this['dispatcher']);
}... | php | public function boot()
{
if ($this->booted) {
return;
}
$this->booted = true;
foreach ($this->providers as $provider) {
if ($provider instanceof EventListenerProviderInterface) {
$provider->subscribe($this, $this['dispatcher']);
}... | [
"public",
"function",
"boot",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"booted",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"booted",
"=",
"true",
";",
"foreach",
"(",
"$",
"this",
"->",
"providers",
"as",
"$",
"provider",
")",
"{",
"if... | Boots all service providers.
This method is automatically called by handle(), but you can use it
to boot all service providers when not handling a request. | [
"Boots",
"all",
"service",
"providers",
"."
] | train | https://github.com/silexphp/Silex/blob/2065bd6dcae0f6d11dc6680c1219343493b76087/src/Silex/Application.php#L101-L118 |
silexphp/Silex | src/Silex/Application.php | Application.on | public function on($eventName, $callback, $priority = 0)
{
if ($this->booted) {
$this['dispatcher']->addListener($eventName, $this['callback_resolver']->resolveCallback($callback), $priority);
return;
}
$this->extend('dispatcher', function (EventDispatcherInterface ... | php | public function on($eventName, $callback, $priority = 0)
{
if ($this->booted) {
$this['dispatcher']->addListener($eventName, $this['callback_resolver']->resolveCallback($callback), $priority);
return;
}
$this->extend('dispatcher', function (EventDispatcherInterface ... | [
"public",
"function",
"on",
"(",
"$",
"eventName",
",",
"$",
"callback",
",",
"$",
"priority",
"=",
"0",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"booted",
")",
"{",
"$",
"this",
"[",
"'dispatcher'",
"]",
"->",
"addListener",
"(",
"$",
"eventName",
... | Adds an event listener that listens on the specified events.
@param string $eventName The event to listen on
@param callable $callback The listener
@param int $priority The higher this value, the earlier an event
listener will be triggered in the chain (defaults to 0) | [
"Adds",
"an",
"event",
"listener",
"that",
"listens",
"on",
"the",
"specified",
"events",
"."
] | train | https://github.com/silexphp/Silex/blob/2065bd6dcae0f6d11dc6680c1219343493b76087/src/Silex/Application.php#L221-L234 |
silexphp/Silex | src/Silex/Application.php | Application.before | public function before($callback, $priority = 0)
{
$app = $this;
$this->on(KernelEvents::REQUEST, function (GetResponseEvent $event) use ($callback, $app) {
if (!$event->isMasterRequest()) {
return;
}
$ret = call_user_func($app['callback_resolver... | php | public function before($callback, $priority = 0)
{
$app = $this;
$this->on(KernelEvents::REQUEST, function (GetResponseEvent $event) use ($callback, $app) {
if (!$event->isMasterRequest()) {
return;
}
$ret = call_user_func($app['callback_resolver... | [
"public",
"function",
"before",
"(",
"$",
"callback",
",",
"$",
"priority",
"=",
"0",
")",
"{",
"$",
"app",
"=",
"$",
"this",
";",
"$",
"this",
"->",
"on",
"(",
"KernelEvents",
"::",
"REQUEST",
",",
"function",
"(",
"GetResponseEvent",
"$",
"event",
... | Registers a before filter.
Before filters are run before any route has been matched.
@param mixed $callback Before filter callback
@param int $priority The higher this value, the earlier an event
listener will be triggered in the chain (defaults to 0) | [
"Registers",
"a",
"before",
"filter",
"."
] | train | https://github.com/silexphp/Silex/blob/2065bd6dcae0f6d11dc6680c1219343493b76087/src/Silex/Application.php#L245-L260 |
silexphp/Silex | src/Silex/Application.php | Application.after | public function after($callback, $priority = 0)
{
$app = $this;
$this->on(KernelEvents::RESPONSE, function (FilterResponseEvent $event) use ($callback, $app) {
if (!$event->isMasterRequest()) {
return;
}
$response = call_user_func($app['callback_... | php | public function after($callback, $priority = 0)
{
$app = $this;
$this->on(KernelEvents::RESPONSE, function (FilterResponseEvent $event) use ($callback, $app) {
if (!$event->isMasterRequest()) {
return;
}
$response = call_user_func($app['callback_... | [
"public",
"function",
"after",
"(",
"$",
"callback",
",",
"$",
"priority",
"=",
"0",
")",
"{",
"$",
"app",
"=",
"$",
"this",
";",
"$",
"this",
"->",
"on",
"(",
"KernelEvents",
"::",
"RESPONSE",
",",
"function",
"(",
"FilterResponseEvent",
"$",
"event",... | Registers an after filter.
After filters are run after the controller has been executed.
@param mixed $callback After filter callback
@param int $priority The higher this value, the earlier an event
listener will be triggered in the chain (defaults to 0) | [
"Registers",
"an",
"after",
"filter",
"."
] | train | https://github.com/silexphp/Silex/blob/2065bd6dcae0f6d11dc6680c1219343493b76087/src/Silex/Application.php#L271-L287 |
silexphp/Silex | src/Silex/Application.php | Application.finish | public function finish($callback, $priority = 0)
{
$app = $this;
$this->on(KernelEvents::TERMINATE, function (PostResponseEvent $event) use ($callback, $app) {
call_user_func($app['callback_resolver']->resolveCallback($callback), $event->getRequest(), $event->getResponse(), $app);
... | php | public function finish($callback, $priority = 0)
{
$app = $this;
$this->on(KernelEvents::TERMINATE, function (PostResponseEvent $event) use ($callback, $app) {
call_user_func($app['callback_resolver']->resolveCallback($callback), $event->getRequest(), $event->getResponse(), $app);
... | [
"public",
"function",
"finish",
"(",
"$",
"callback",
",",
"$",
"priority",
"=",
"0",
")",
"{",
"$",
"app",
"=",
"$",
"this",
";",
"$",
"this",
"->",
"on",
"(",
"KernelEvents",
"::",
"TERMINATE",
",",
"function",
"(",
"PostResponseEvent",
"$",
"event",... | Registers a finish filter.
Finish filters are run after the response has been sent.
@param mixed $callback Finish filter callback
@param int $priority The higher this value, the earlier an event
listener will be triggered in the chain (defaults to 0) | [
"Registers",
"a",
"finish",
"filter",
"."
] | train | https://github.com/silexphp/Silex/blob/2065bd6dcae0f6d11dc6680c1219343493b76087/src/Silex/Application.php#L298-L305 |
silexphp/Silex | src/Silex/Application.php | Application.view | public function view($callback, $priority = 0)
{
$this->on(KernelEvents::VIEW, new ViewListenerWrapper($this, $callback), $priority);
} | php | public function view($callback, $priority = 0)
{
$this->on(KernelEvents::VIEW, new ViewListenerWrapper($this, $callback), $priority);
} | [
"public",
"function",
"view",
"(",
"$",
"callback",
",",
"$",
"priority",
"=",
"0",
")",
"{",
"$",
"this",
"->",
"on",
"(",
"KernelEvents",
"::",
"VIEW",
",",
"new",
"ViewListenerWrapper",
"(",
"$",
"this",
",",
"$",
"callback",
")",
",",
"$",
"prior... | Registers a view handler.
View handlers are simple callables which take a controller result and the
request as arguments, whenever a controller returns a value that is not
an instance of Response. When this occurs, all suitable handlers will be
called, until one returns a Response object.
@param mixed $callback View ... | [
"Registers",
"a",
"view",
"handler",
"."
] | train | https://github.com/silexphp/Silex/blob/2065bd6dcae0f6d11dc6680c1219343493b76087/src/Silex/Application.php#L353-L356 |
silexphp/Silex | src/Silex/Application.php | Application.escape | public function escape($text, $flags = ENT_COMPAT, $charset = null, $doubleEncode = true)
{
return htmlspecialchars($text, $flags, $charset ?: $this['charset'], $doubleEncode);
} | php | public function escape($text, $flags = ENT_COMPAT, $charset = null, $doubleEncode = true)
{
return htmlspecialchars($text, $flags, $charset ?: $this['charset'], $doubleEncode);
} | [
"public",
"function",
"escape",
"(",
"$",
"text",
",",
"$",
"flags",
"=",
"ENT_COMPAT",
",",
"$",
"charset",
"=",
"null",
",",
"$",
"doubleEncode",
"=",
"true",
")",
"{",
"return",
"htmlspecialchars",
"(",
"$",
"text",
",",
"$",
"flags",
",",
"$",
"c... | Escapes a text for HTML.
@param string $text The input text to be escaped
@param int $flags The flags (@see htmlspecialchars)
@param string $charset The charset
@param bool $doubleEncode Whether to try to avoid double escaping or not
@return string Escaped text | [
"Escapes",
"a",
"text",
"for",
"HTML",
"."
] | train | https://github.com/silexphp/Silex/blob/2065bd6dcae0f6d11dc6680c1219343493b76087/src/Silex/Application.php#L403-L406 |
silexphp/Silex | src/Silex/Application.php | Application.sendFile | public function sendFile($file, $status = 200, array $headers = [], $contentDisposition = null)
{
return new BinaryFileResponse($file, $status, $headers, true, $contentDisposition);
} | php | public function sendFile($file, $status = 200, array $headers = [], $contentDisposition = null)
{
return new BinaryFileResponse($file, $status, $headers, true, $contentDisposition);
} | [
"public",
"function",
"sendFile",
"(",
"$",
"file",
",",
"$",
"status",
"=",
"200",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
",",
"$",
"contentDisposition",
"=",
"null",
")",
"{",
"return",
"new",
"BinaryFileResponse",
"(",
"$",
"file",
",",
"$",
... | Sends a file.
@param \SplFileInfo|string $file The file to stream
@param int $status The response status code
@param array $headers An array of response headers
@param null|string $contentDisposition The type of Content-Disposition to set autom... | [
"Sends",
"a",
"file",
"."
] | train | https://github.com/silexphp/Silex/blob/2065bd6dcae0f6d11dc6680c1219343493b76087/src/Silex/Application.php#L432-L435 |
silexphp/Silex | src/Silex/Application.php | Application.mount | public function mount($prefix, $controllers)
{
if ($controllers instanceof ControllerProviderInterface) {
$connectedControllers = $controllers->connect($this);
if (!$connectedControllers instanceof ControllerCollection) {
throw new \LogicException(sprintf('The method... | php | public function mount($prefix, $controllers)
{
if ($controllers instanceof ControllerProviderInterface) {
$connectedControllers = $controllers->connect($this);
if (!$connectedControllers instanceof ControllerCollection) {
throw new \LogicException(sprintf('The method... | [
"public",
"function",
"mount",
"(",
"$",
"prefix",
",",
"$",
"controllers",
")",
"{",
"if",
"(",
"$",
"controllers",
"instanceof",
"ControllerProviderInterface",
")",
"{",
"$",
"connectedControllers",
"=",
"$",
"controllers",
"->",
"connect",
"(",
"$",
"this",... | Mounts controllers under the given route prefix.
@param string $prefix The route prefix
@param ControllerCollection|callable|ControllerProviderInterface $controllers A ControllerCollection, a callable, or a ControllerProviderInterface instance
@return Applicatio... | [
"Mounts",
"controllers",
"under",
"the",
"given",
"route",
"prefix",
"."
] | train | https://github.com/silexphp/Silex/blob/2065bd6dcae0f6d11dc6680c1219343493b76087/src/Silex/Application.php#L447-L464 |
silexphp/Silex | src/Silex/Application.php | Application.handle | public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
if (!$this->booted) {
$this->boot();
}
$this->flush();
return $this['kernel']->handle($request, $type, $catch);
} | php | public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
if (!$this->booted) {
$this->boot();
}
$this->flush();
return $this['kernel']->handle($request, $type, $catch);
} | [
"public",
"function",
"handle",
"(",
"Request",
"$",
"request",
",",
"$",
"type",
"=",
"HttpKernelInterface",
"::",
"MASTER_REQUEST",
",",
"$",
"catch",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"booted",
")",
"{",
"$",
"this",
"->",
... | {@inheritdoc}
If you call this method directly instead of run(), you must call the
terminate() method yourself if you want the finish filters to be run. | [
"{",
"@inheritdoc",
"}"
] | train | https://github.com/silexphp/Silex/blob/2065bd6dcae0f6d11dc6680c1219343493b76087/src/Silex/Application.php#L488-L497 |
silexphp/Silex | src/Silex/Route.php | Route.convert | public function convert($variable, $callback)
{
$converters = $this->getOption('_converters');
$converters[$variable] = $callback;
$this->setOption('_converters', $converters);
return $this;
} | php | public function convert($variable, $callback)
{
$converters = $this->getOption('_converters');
$converters[$variable] = $callback;
$this->setOption('_converters', $converters);
return $this;
} | [
"public",
"function",
"convert",
"(",
"$",
"variable",
",",
"$",
"callback",
")",
"{",
"$",
"converters",
"=",
"$",
"this",
"->",
"getOption",
"(",
"'_converters'",
")",
";",
"$",
"converters",
"[",
"$",
"variable",
"]",
"=",
"$",
"callback",
";",
"$",... | Sets a converter for a route variable.
@param string $variable The variable name
@param mixed $callback A PHP callback that converts the original value
@return Route $this The current Route instance | [
"Sets",
"a",
"converter",
"for",
"a",
"route",
"variable",
"."
] | train | https://github.com/silexphp/Silex/blob/2065bd6dcae0f6d11dc6680c1219343493b76087/src/Silex/Route.php#L96-L103 |
silexphp/Silex | src/Silex/Route.php | Route.before | public function before($callback)
{
$callbacks = $this->getOption('_before_middlewares');
$callbacks[] = $callback;
$this->setOption('_before_middlewares', $callbacks);
return $this;
} | php | public function before($callback)
{
$callbacks = $this->getOption('_before_middlewares');
$callbacks[] = $callback;
$this->setOption('_before_middlewares', $callbacks);
return $this;
} | [
"public",
"function",
"before",
"(",
"$",
"callback",
")",
"{",
"$",
"callbacks",
"=",
"$",
"this",
"->",
"getOption",
"(",
"'_before_middlewares'",
")",
";",
"$",
"callbacks",
"[",
"]",
"=",
"$",
"callback",
";",
"$",
"this",
"->",
"setOption",
"(",
"... | Sets a callback to handle before triggering the route callback.
@param mixed $callback A PHP callback to be triggered when the Route is matched, just before the route callback
@return Route $this The current Route instance | [
"Sets",
"a",
"callback",
"to",
"handle",
"before",
"triggering",
"the",
"route",
"callback",
"."
] | train | https://github.com/silexphp/Silex/blob/2065bd6dcae0f6d11dc6680c1219343493b76087/src/Silex/Route.php#L164-L171 |
silexphp/Silex | src/Silex/Route.php | Route.after | public function after($callback)
{
$callbacks = $this->getOption('_after_middlewares');
$callbacks[] = $callback;
$this->setOption('_after_middlewares', $callbacks);
return $this;
} | php | public function after($callback)
{
$callbacks = $this->getOption('_after_middlewares');
$callbacks[] = $callback;
$this->setOption('_after_middlewares', $callbacks);
return $this;
} | [
"public",
"function",
"after",
"(",
"$",
"callback",
")",
"{",
"$",
"callbacks",
"=",
"$",
"this",
"->",
"getOption",
"(",
"'_after_middlewares'",
")",
";",
"$",
"callbacks",
"[",
"]",
"=",
"$",
"callback",
";",
"$",
"this",
"->",
"setOption",
"(",
"'_... | Sets a callback to handle after the route callback.
@param mixed $callback A PHP callback to be triggered after the route callback
@return Route $this The current Route instance | [
"Sets",
"a",
"callback",
"to",
"handle",
"after",
"the",
"route",
"callback",
"."
] | train | https://github.com/silexphp/Silex/blob/2065bd6dcae0f6d11dc6680c1219343493b76087/src/Silex/Route.php#L180-L187 |
silexphp/Silex | src/Silex/EventListener/LogListener.php | LogListener.logRequest | protected function logRequest(Request $request)
{
$this->logger->log(LogLevel::DEBUG, '> '.$request->getMethod().' '.$request->getRequestUri());
} | php | protected function logRequest(Request $request)
{
$this->logger->log(LogLevel::DEBUG, '> '.$request->getMethod().' '.$request->getRequestUri());
} | [
"protected",
"function",
"logRequest",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"log",
"(",
"LogLevel",
"::",
"DEBUG",
",",
"'> '",
".",
"$",
"request",
"->",
"getMethod",
"(",
")",
".",
"' '",
".",
"$",
"request",
... | Logs a request.
@param Request $request | [
"Logs",
"a",
"request",
"."
] | train | https://github.com/silexphp/Silex/blob/2065bd6dcae0f6d11dc6680c1219343493b76087/src/Silex/EventListener/LogListener.php#L93-L96 |
silexphp/Silex | src/Silex/EventListener/LogListener.php | LogListener.logResponse | protected function logResponse(Response $response)
{
$message = '< '.$response->getStatusCode();
if ($response instanceof RedirectResponse) {
$message .= ' '.$response->getTargetUrl();
}
$this->logger->log(LogLevel::DEBUG, $message);
} | php | protected function logResponse(Response $response)
{
$message = '< '.$response->getStatusCode();
if ($response instanceof RedirectResponse) {
$message .= ' '.$response->getTargetUrl();
}
$this->logger->log(LogLevel::DEBUG, $message);
} | [
"protected",
"function",
"logResponse",
"(",
"Response",
"$",
"response",
")",
"{",
"$",
"message",
"=",
"'< '",
".",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
";",
"if",
"(",
"$",
"response",
"instanceof",
"RedirectResponse",
")",
"{",
"$",
"messa... | Logs a response.
@param Response $response | [
"Logs",
"a",
"response",
"."
] | train | https://github.com/silexphp/Silex/blob/2065bd6dcae0f6d11dc6680c1219343493b76087/src/Silex/EventListener/LogListener.php#L103-L112 |
silexphp/Silex | src/Silex/EventListener/LogListener.php | LogListener.logException | protected function logException(\Exception $e)
{
$this->logger->log(call_user_func($this->exceptionLogFilter, $e), sprintf('%s: %s (uncaught exception) at %s line %s', get_class($e), $e->getMessage(), $e->getFile(), $e->getLine()), ['exception' => $e]);
} | php | protected function logException(\Exception $e)
{
$this->logger->log(call_user_func($this->exceptionLogFilter, $e), sprintf('%s: %s (uncaught exception) at %s line %s', get_class($e), $e->getMessage(), $e->getFile(), $e->getLine()), ['exception' => $e]);
} | [
"protected",
"function",
"logException",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"log",
"(",
"call_user_func",
"(",
"$",
"this",
"->",
"exceptionLogFilter",
",",
"$",
"e",
")",
",",
"sprintf",
"(",
"'%s: %s (uncaught ... | Logs an exception. | [
"Logs",
"an",
"exception",
"."
] | train | https://github.com/silexphp/Silex/blob/2065bd6dcae0f6d11dc6680c1219343493b76087/src/Silex/EventListener/LogListener.php#L117-L120 |
silexphp/Silex | src/Silex/CallbackResolver.php | CallbackResolver.isValid | public function isValid($name)
{
return is_string($name) && (preg_match(static::SERVICE_PATTERN, $name) || isset($this->app[$name]));
} | php | public function isValid($name)
{
return is_string($name) && (preg_match(static::SERVICE_PATTERN, $name) || isset($this->app[$name]));
} | [
"public",
"function",
"isValid",
"(",
"$",
"name",
")",
"{",
"return",
"is_string",
"(",
"$",
"name",
")",
"&&",
"(",
"preg_match",
"(",
"static",
"::",
"SERVICE_PATTERN",
",",
"$",
"name",
")",
"||",
"isset",
"(",
"$",
"this",
"->",
"app",
"[",
"$",... | Returns true if the string is a valid service method representation.
@param string $name
@return bool | [
"Returns",
"true",
"if",
"the",
"string",
"is",
"a",
"valid",
"service",
"method",
"representation",
"."
] | train | https://github.com/silexphp/Silex/blob/2065bd6dcae0f6d11dc6680c1219343493b76087/src/Silex/CallbackResolver.php#L34-L37 |
silexphp/Silex | src/Silex/Provider/HttpKernelServiceProvider.php | HttpKernelServiceProvider.register | public function register(Container $app)
{
$app['resolver'] = function ($app) {
return new ControllerResolver($app['logger']);
};
$app['argument_metadata_factory'] = function ($app) {
return new ArgumentMetadataFactory();
};
$app['argument_value_resol... | php | public function register(Container $app)
{
$app['resolver'] = function ($app) {
return new ControllerResolver($app['logger']);
};
$app['argument_metadata_factory'] = function ($app) {
return new ArgumentMetadataFactory();
};
$app['argument_value_resol... | [
"public",
"function",
"register",
"(",
"Container",
"$",
"app",
")",
"{",
"$",
"app",
"[",
"'resolver'",
"]",
"=",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"ControllerResolver",
"(",
"$",
"app",
"[",
"'logger'",
"]",
")",
";",
"}",
";"... | {@inheritdoc} | [
"{"
] | train | https://github.com/silexphp/Silex/blob/2065bd6dcae0f6d11dc6680c1219343493b76087/src/Silex/Provider/HttpKernelServiceProvider.php#L29-L61 |
silexphp/Silex | src/Silex/Provider/HttpKernelServiceProvider.php | HttpKernelServiceProvider.subscribe | public function subscribe(Container $app, EventDispatcherInterface $dispatcher)
{
$dispatcher->addSubscriber(new ResponseListener($app['charset']));
$dispatcher->addSubscriber(new MiddlewareListener($app));
$dispatcher->addSubscriber(new ConverterListener($app['routes'], $app['callback_resol... | php | public function subscribe(Container $app, EventDispatcherInterface $dispatcher)
{
$dispatcher->addSubscriber(new ResponseListener($app['charset']));
$dispatcher->addSubscriber(new MiddlewareListener($app));
$dispatcher->addSubscriber(new ConverterListener($app['routes'], $app['callback_resol... | [
"public",
"function",
"subscribe",
"(",
"Container",
"$",
"app",
",",
"EventDispatcherInterface",
"$",
"dispatcher",
")",
"{",
"$",
"dispatcher",
"->",
"addSubscriber",
"(",
"new",
"ResponseListener",
"(",
"$",
"app",
"[",
"'charset'",
"]",
")",
")",
";",
"$... | {@inheritdoc} | [
"{"
] | train | https://github.com/silexphp/Silex/blob/2065bd6dcae0f6d11dc6680c1219343493b76087/src/Silex/Provider/HttpKernelServiceProvider.php#L66-L76 |
silexphp/Silex | src/Silex/Application/SecurityTrait.php | SecurityTrait.encodePassword | public function encodePassword(UserInterface $user, $password)
{
return $this['security.encoder_factory']->getEncoder($user)->encodePassword($password, $user->getSalt());
} | php | public function encodePassword(UserInterface $user, $password)
{
return $this['security.encoder_factory']->getEncoder($user)->encodePassword($password, $user->getSalt());
} | [
"public",
"function",
"encodePassword",
"(",
"UserInterface",
"$",
"user",
",",
"$",
"password",
")",
"{",
"return",
"$",
"this",
"[",
"'security.encoder_factory'",
"]",
"->",
"getEncoder",
"(",
"$",
"user",
")",
"->",
"encodePassword",
"(",
"$",
"password",
... | Encodes the raw password.
@param UserInterface $user A UserInterface instance
@param string $password The password to encode
@return string The encoded password
@throws \RuntimeException when no password encoder could be found for the user | [
"Encodes",
"the",
"raw",
"password",
"."
] | train | https://github.com/silexphp/Silex/blob/2065bd6dcae0f6d11dc6680c1219343493b76087/src/Silex/Application/SecurityTrait.php#L34-L37 |
silexphp/Silex | src/Silex/EventListener/ConverterListener.php | ConverterListener.onKernelController | public function onKernelController(FilterControllerEvent $event)
{
$request = $event->getRequest();
$route = $this->routes->get($request->attributes->get('_route'));
if ($route && $converters = $route->getOption('_converters')) {
foreach ($converters as $name => $callback) {
... | php | public function onKernelController(FilterControllerEvent $event)
{
$request = $event->getRequest();
$route = $this->routes->get($request->attributes->get('_route'));
if ($route && $converters = $route->getOption('_converters')) {
foreach ($converters as $name => $callback) {
... | [
"public",
"function",
"onKernelController",
"(",
"FilterControllerEvent",
"$",
"event",
")",
"{",
"$",
"request",
"=",
"$",
"event",
"->",
"getRequest",
"(",
")",
";",
"$",
"route",
"=",
"$",
"this",
"->",
"routes",
"->",
"get",
"(",
"$",
"request",
"->"... | Handles converters.
@param FilterControllerEvent $event The event to handle | [
"Handles",
"converters",
"."
] | train | https://github.com/silexphp/Silex/blob/2065bd6dcae0f6d11dc6680c1219343493b76087/src/Silex/EventListener/ConverterListener.php#L47-L58 |
silexphp/Silex | src/Silex/ServiceControllerResolver.php | ServiceControllerResolver.getController | public function getController(Request $request)
{
$controller = $request->attributes->get('_controller', null);
if (!$this->callbackResolver->isValid($controller)) {
return $this->controllerResolver->getController($request);
}
return $this->callbackResolver->convertCall... | php | public function getController(Request $request)
{
$controller = $request->attributes->get('_controller', null);
if (!$this->callbackResolver->isValid($controller)) {
return $this->controllerResolver->getController($request);
}
return $this->callbackResolver->convertCall... | [
"public",
"function",
"getController",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"controller",
"=",
"$",
"request",
"->",
"attributes",
"->",
"get",
"(",
"'_controller'",
",",
"null",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"callbackResolver",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/silexphp/Silex/blob/2065bd6dcae0f6d11dc6680c1219343493b76087/src/Silex/ServiceControllerResolver.php#L42-L51 |
silexphp/Silex | src/Silex/EventListener/StringToResponseListener.php | StringToResponseListener.onKernelView | public function onKernelView(GetResponseForControllerResultEvent $event)
{
$response = $event->getControllerResult();
if (!(
null === $response
|| is_array($response)
|| $response instanceof Response
|| (is_object($response) && !method_exists($respons... | php | public function onKernelView(GetResponseForControllerResultEvent $event)
{
$response = $event->getControllerResult();
if (!(
null === $response
|| is_array($response)
|| $response instanceof Response
|| (is_object($response) && !method_exists($respons... | [
"public",
"function",
"onKernelView",
"(",
"GetResponseForControllerResultEvent",
"$",
"event",
")",
"{",
"$",
"response",
"=",
"$",
"event",
"->",
"getControllerResult",
"(",
")",
";",
"if",
"(",
"!",
"(",
"null",
"===",
"$",
"response",
"||",
"is_array",
"... | Handles string responses.
@param GetResponseForControllerResultEvent $event The event to handle | [
"Handles",
"string",
"responses",
"."
] | train | https://github.com/silexphp/Silex/blob/2065bd6dcae0f6d11dc6680c1219343493b76087/src/Silex/EventListener/StringToResponseListener.php#L31-L43 |
silexphp/Silex | src/Silex/EventListener/MiddlewareListener.php | MiddlewareListener.onKernelRequest | public function onKernelRequest(GetResponseEvent $event)
{
$request = $event->getRequest();
$routeName = $request->attributes->get('_route');
if (!$route = $this->app['routes']->get($routeName)) {
return;
}
foreach ((array) $route->getOption('_before_middlewares'... | php | public function onKernelRequest(GetResponseEvent $event)
{
$request = $event->getRequest();
$routeName = $request->attributes->get('_route');
if (!$route = $this->app['routes']->get($routeName)) {
return;
}
foreach ((array) $route->getOption('_before_middlewares'... | [
"public",
"function",
"onKernelRequest",
"(",
"GetResponseEvent",
"$",
"event",
")",
"{",
"$",
"request",
"=",
"$",
"event",
"->",
"getRequest",
"(",
")",
";",
"$",
"routeName",
"=",
"$",
"request",
"->",
"attributes",
"->",
"get",
"(",
"'_route'",
")",
... | Runs before filters.
@param GetResponseEvent $event The event to handle | [
"Runs",
"before",
"filters",
"."
] | train | https://github.com/silexphp/Silex/blob/2065bd6dcae0f6d11dc6680c1219343493b76087/src/Silex/EventListener/MiddlewareListener.php#L45-L63 |
silexphp/Silex | src/Silex/EventListener/MiddlewareListener.php | MiddlewareListener.onKernelResponse | public function onKernelResponse(FilterResponseEvent $event)
{
$request = $event->getRequest();
$routeName = $request->attributes->get('_route');
if (!$route = $this->app['routes']->get($routeName)) {
return;
}
foreach ((array) $route->getOption('_after_middlewar... | php | public function onKernelResponse(FilterResponseEvent $event)
{
$request = $event->getRequest();
$routeName = $request->attributes->get('_route');
if (!$route = $this->app['routes']->get($routeName)) {
return;
}
foreach ((array) $route->getOption('_after_middlewar... | [
"public",
"function",
"onKernelResponse",
"(",
"FilterResponseEvent",
"$",
"event",
")",
"{",
"$",
"request",
"=",
"$",
"event",
"->",
"getRequest",
"(",
")",
";",
"$",
"routeName",
"=",
"$",
"request",
"->",
"attributes",
"->",
"get",
"(",
"'_route'",
")"... | Runs after filters.
@param FilterResponseEvent $event The event to handle | [
"Runs",
"after",
"filters",
"."
] | train | https://github.com/silexphp/Silex/blob/2065bd6dcae0f6d11dc6680c1219343493b76087/src/Silex/EventListener/MiddlewareListener.php#L70-L86 |
silexphp/Silex | src/Silex/ControllerCollection.php | ControllerCollection.mount | public function mount($prefix, $controllers)
{
if (is_callable($controllers)) {
$collection = $this->controllersFactory ? call_user_func($this->controllersFactory) : new static(new Route(), new RouteCollection());
$collection->defaultRoute = clone $this->defaultRoute;
cal... | php | public function mount($prefix, $controllers)
{
if (is_callable($controllers)) {
$collection = $this->controllersFactory ? call_user_func($this->controllersFactory) : new static(new Route(), new RouteCollection());
$collection->defaultRoute = clone $this->defaultRoute;
cal... | [
"public",
"function",
"mount",
"(",
"$",
"prefix",
",",
"$",
"controllers",
")",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"controllers",
")",
")",
"{",
"$",
"collection",
"=",
"$",
"this",
"->",
"controllersFactory",
"?",
"call_user_func",
"(",
"$",
"thi... | Mounts controllers under the given route prefix.
@param string $prefix The route prefix
@param ControllerCollection|callable $controllers A ControllerCollection instance or a callable for defining routes
@throws \LogicException | [
"Mounts",
"controllers",
"under",
"the",
"given",
"route",
"prefix",
"."
] | train | https://github.com/silexphp/Silex/blob/2065bd6dcae0f6d11dc6680c1219343493b76087/src/Silex/ControllerCollection.php#L67-L81 |
silexphp/Silex | src/Silex/ControllerCollection.php | ControllerCollection.match | public function match($pattern, $to = null)
{
$route = clone $this->defaultRoute;
$route->setPath($pattern);
$this->controllers[] = $controller = new Controller($route);
$route->setDefault('_controller', null === $to ? $this->defaultController : $to);
return $controller;
... | php | public function match($pattern, $to = null)
{
$route = clone $this->defaultRoute;
$route->setPath($pattern);
$this->controllers[] = $controller = new Controller($route);
$route->setDefault('_controller', null === $to ? $this->defaultController : $to);
return $controller;
... | [
"public",
"function",
"match",
"(",
"$",
"pattern",
",",
"$",
"to",
"=",
"null",
")",
"{",
"$",
"route",
"=",
"clone",
"$",
"this",
"->",
"defaultRoute",
";",
"$",
"route",
"->",
"setPath",
"(",
"$",
"pattern",
")",
";",
"$",
"this",
"->",
"control... | Maps a pattern to a callable.
You can optionally specify HTTP methods that should be matched.
@param string $pattern Matched route pattern
@param mixed $to Callback that returns the response when matched
@return Controller | [
"Maps",
"a",
"pattern",
"to",
"a",
"callable",
"."
] | train | https://github.com/silexphp/Silex/blob/2065bd6dcae0f6d11dc6680c1219343493b76087/src/Silex/ControllerCollection.php#L93-L101 |
silexphp/Silex | src/Silex/ControllerCollection.php | ControllerCollection.flush | public function flush()
{
if (null === $this->routesFactory) {
$routes = new RouteCollection();
} else {
$routes = $this->routesFactory;
}
return $this->doFlush('', $routes);
} | php | public function flush()
{
if (null === $this->routesFactory) {
$routes = new RouteCollection();
} else {
$routes = $this->routesFactory;
}
return $this->doFlush('', $routes);
} | [
"public",
"function",
"flush",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"routesFactory",
")",
"{",
"$",
"routes",
"=",
"new",
"RouteCollection",
"(",
")",
";",
"}",
"else",
"{",
"$",
"routes",
"=",
"$",
"this",
"->",
"routesFactory... | Persists and freezes staged controllers.
@return RouteCollection A RouteCollection instance | [
"Persists",
"and",
"freezes",
"staged",
"controllers",
"."
] | train | https://github.com/silexphp/Silex/blob/2065bd6dcae0f6d11dc6680c1219343493b76087/src/Silex/ControllerCollection.php#L201-L210 |
silexphp/Silex | src/Silex/Controller.php | Controller.bind | public function bind($routeName)
{
if ($this->isFrozen) {
throw new ControllerFrozenException(sprintf('Calling %s on frozen %s instance.', __METHOD__, __CLASS__));
}
$this->routeName = $routeName;
return $this;
} | php | public function bind($routeName)
{
if ($this->isFrozen) {
throw new ControllerFrozenException(sprintf('Calling %s on frozen %s instance.', __METHOD__, __CLASS__));
}
$this->routeName = $routeName;
return $this;
} | [
"public",
"function",
"bind",
"(",
"$",
"routeName",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isFrozen",
")",
"{",
"throw",
"new",
"ControllerFrozenException",
"(",
"sprintf",
"(",
"'Calling %s on frozen %s instance.'",
",",
"__METHOD__",
",",
"__CLASS__",
")",
... | Sets the controller's route.
@param string $routeName
@return Controller $this The current Controller instance | [
"Sets",
"the",
"controller",
"s",
"route",
"."
] | train | https://github.com/silexphp/Silex/blob/2065bd6dcae0f6d11dc6680c1219343493b76087/src/Silex/Controller.php#L77-L86 |
aaronlord/laroute | src/LarouteServiceProvider.php | LarouteServiceProvider.register | public function register()
{
$source = $this->getConfigPath();
$this->mergeConfigFrom($source, 'laroute');
$this->registerGenerator();
$this->registerCompiler();
$this->registerCommand();
} | php | public function register()
{
$source = $this->getConfigPath();
$this->mergeConfigFrom($source, 'laroute');
$this->registerGenerator();
$this->registerCompiler();
$this->registerCommand();
} | [
"public",
"function",
"register",
"(",
")",
"{",
"$",
"source",
"=",
"$",
"this",
"->",
"getConfigPath",
"(",
")",
";",
"$",
"this",
"->",
"mergeConfigFrom",
"(",
"$",
"source",
",",
"'laroute'",
")",
";",
"$",
"this",
"->",
"registerGenerator",
"(",
"... | Register the service provider.
@return void | [
"Register",
"the",
"service",
"provider",
"."
] | train | https://github.com/aaronlord/laroute/blob/7242310f02ebc3f3d6a94b00db95ad0978b1802b/src/LarouteServiceProvider.php#L27-L37 |
aaronlord/laroute | src/LarouteServiceProvider.php | LarouteServiceProvider.registerCommand | protected function registerCommand()
{
$this->app->singleton(
'command.laroute.generate',
function ($app) {
$config = $app['config'];
$routes = new Routes($app['router']->getRoutes(), $config->get('laroute.filter', 'all'), $config->get('laroute... | php | protected function registerCommand()
{
$this->app->singleton(
'command.laroute.generate',
function ($app) {
$config = $app['config'];
$routes = new Routes($app['router']->getRoutes(), $config->get('laroute.filter', 'all'), $config->get('laroute... | [
"protected",
"function",
"registerCommand",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'command.laroute.generate'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"config",
"=",
"$",
"app",
"[",
"'config'",
"]",
";",
"$",
"routes... | Register the command
@return void | [
"Register",
"the",
"command"
] | train | https://github.com/aaronlord/laroute/blob/7242310f02ebc3f3d6a94b00db95ad0978b1802b/src/LarouteServiceProvider.php#L80-L94 |
aaronlord/laroute | src/Generators/TemplateGenerator.php | TemplateGenerator.compile | public function compile($templatePath, Array $templateData, $filePath)
{
$template = $this->filesystem->get($templatePath);
$compiled = $this->compiler->compile($template, $templateData);
$this->makeDirectory(dirname($filePath));
$this->filesystem->put($filePath, $compiled);
... | php | public function compile($templatePath, Array $templateData, $filePath)
{
$template = $this->filesystem->get($templatePath);
$compiled = $this->compiler->compile($template, $templateData);
$this->makeDirectory(dirname($filePath));
$this->filesystem->put($filePath, $compiled);
... | [
"public",
"function",
"compile",
"(",
"$",
"templatePath",
",",
"Array",
"$",
"templateData",
",",
"$",
"filePath",
")",
"{",
"$",
"template",
"=",
"$",
"this",
"->",
"filesystem",
"->",
"get",
"(",
"$",
"templatePath",
")",
";",
"$",
"compiled",
"=",
... | Compile the template.
@param $templatePath
@param $templateData
@param $filePath
@return string | [
"Compile",
"the",
"template",
"."
] | train | https://github.com/aaronlord/laroute/blob/7242310f02ebc3f3d6a94b00db95ad0978b1802b/src/Generators/TemplateGenerator.php#L47-L58 |
aaronlord/laroute | src/Console/Commands/LarouteGeneratorCommand.php | LarouteGeneratorCommand.handle | public function handle()
{
try {
$filePath = $this->generator->compile(
$this->getTemplatePath(),
$this->getTemplateData(),
$this->getFileGenerationPath()
);
$this->info("Created: {$filePath}");
} catch (\Exception ... | php | public function handle()
{
try {
$filePath = $this->generator->compile(
$this->getTemplatePath(),
$this->getTemplateData(),
$this->getFileGenerationPath()
);
$this->info("Created: {$filePath}");
} catch (\Exception ... | [
"public",
"function",
"handle",
"(",
")",
"{",
"try",
"{",
"$",
"filePath",
"=",
"$",
"this",
"->",
"generator",
"->",
"compile",
"(",
"$",
"this",
"->",
"getTemplatePath",
"(",
")",
",",
"$",
"this",
"->",
"getTemplateData",
"(",
")",
",",
"$",
"thi... | Execute the console command.
@return void | [
"Execute",
"the",
"console",
"command",
"."
] | train | https://github.com/aaronlord/laroute/blob/7242310f02ebc3f3d6a94b00db95ad0978b1802b/src/Console/Commands/LarouteGeneratorCommand.php#L71-L84 |
aaronlord/laroute | src/Console/Commands/LarouteGeneratorCommand.php | LarouteGeneratorCommand.getTemplateData | protected function getTemplateData()
{
$namespace = $this->getOptionOrConfig('namespace');
$routes = $this->routes->toJSON();
$absolute = $this->config->get('laroute.absolute', false);
$rootUrl = $this->config->get('app.url', '');
$prefix = $this->config->get('laro... | php | protected function getTemplateData()
{
$namespace = $this->getOptionOrConfig('namespace');
$routes = $this->routes->toJSON();
$absolute = $this->config->get('laroute.absolute', false);
$rootUrl = $this->config->get('app.url', '');
$prefix = $this->config->get('laro... | [
"protected",
"function",
"getTemplateData",
"(",
")",
"{",
"$",
"namespace",
"=",
"$",
"this",
"->",
"getOptionOrConfig",
"(",
"'namespace'",
")",
";",
"$",
"routes",
"=",
"$",
"this",
"->",
"routes",
"->",
"toJSON",
"(",
")",
";",
"$",
"absolute",
"=",
... | Get the data for the template.
@return array | [
"Get",
"the",
"data",
"for",
"the",
"template",
"."
] | train | https://github.com/aaronlord/laroute/blob/7242310f02ebc3f3d6a94b00db95ad0978b1802b/src/Console/Commands/LarouteGeneratorCommand.php#L101-L110 |
aaronlord/laroute | src/Console/Commands/LarouteGeneratorCommand.php | LarouteGeneratorCommand.getOptionOrConfig | protected function getOptionOrConfig($key)
{
if ($option = $this->option($key)) {
return $option;
}
return $this->config->get("laroute.{$key}");
} | php | protected function getOptionOrConfig($key)
{
if ($option = $this->option($key)) {
return $option;
}
return $this->config->get("laroute.{$key}");
} | [
"protected",
"function",
"getOptionOrConfig",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"option",
"=",
"$",
"this",
"->",
"option",
"(",
"$",
"key",
")",
")",
"{",
"return",
"$",
"option",
";",
"}",
"return",
"$",
"this",
"->",
"config",
"->",
"ge... | Get an option value either from console input, or the config files.
@param $key
@return array|mixed|string | [
"Get",
"an",
"option",
"value",
"either",
"from",
"console",
"input",
"or",
"the",
"config",
"files",
"."
] | train | https://github.com/aaronlord/laroute/blob/7242310f02ebc3f3d6a94b00db95ad0978b1802b/src/Console/Commands/LarouteGeneratorCommand.php#L133-L140 |
aaronlord/laroute | src/Console/Commands/LarouteGeneratorCommand.php | LarouteGeneratorCommand.getOptions | protected function getOptions()
{
return [
[
'path',
'p',
InputOption::VALUE_OPTIONAL,
sprintf('Path to the javscript assets directory (default: "%s")', $this->config->get('laroute.path'))
],
[
... | php | protected function getOptions()
{
return [
[
'path',
'p',
InputOption::VALUE_OPTIONAL,
sprintf('Path to the javscript assets directory (default: "%s")', $this->config->get('laroute.path'))
],
[
... | [
"protected",
"function",
"getOptions",
"(",
")",
"{",
"return",
"[",
"[",
"'path'",
",",
"'p'",
",",
"InputOption",
"::",
"VALUE_OPTIONAL",
",",
"sprintf",
"(",
"'Path to the javscript assets directory (default: \"%s\")'",
",",
"$",
"this",
"->",
"config",
"->",
"... | Get the console command options.
@return array | [
"Get",
"the",
"console",
"command",
"options",
"."
] | train | https://github.com/aaronlord/laroute/blob/7242310f02ebc3f3d6a94b00db95ad0978b1802b/src/Console/Commands/LarouteGeneratorCommand.php#L147-L173 |
aaronlord/laroute | src/Routes/Collection.php | Collection.parseRoutes | protected function parseRoutes(RouteCollection $routes, $filter, $namespace)
{
$this->guardAgainstZeroRoutes($routes);
$results = [];
foreach ($routes as $route) {
$results[] = $this->getRouteInformation($route, $filter, $namespace);
}
return array_values(array... | php | protected function parseRoutes(RouteCollection $routes, $filter, $namespace)
{
$this->guardAgainstZeroRoutes($routes);
$results = [];
foreach ($routes as $route) {
$results[] = $this->getRouteInformation($route, $filter, $namespace);
}
return array_values(array... | [
"protected",
"function",
"parseRoutes",
"(",
"RouteCollection",
"$",
"routes",
",",
"$",
"filter",
",",
"$",
"namespace",
")",
"{",
"$",
"this",
"->",
"guardAgainstZeroRoutes",
"(",
"$",
"routes",
")",
";",
"$",
"results",
"=",
"[",
"]",
";",
"foreach",
... | Parse the routes into a jsonable output.
@param RouteCollection $routes
@param string $filter
@param string $namespace
@return array
@throws ZeroRoutesException | [
"Parse",
"the",
"routes",
"into",
"a",
"jsonable",
"output",
"."
] | train | https://github.com/aaronlord/laroute/blob/7242310f02ebc3f3d6a94b00db95ad0978b1802b/src/Routes/Collection.php#L26-L37 |
aaronlord/laroute | src/Routes/Collection.php | Collection.getRouteInformation | protected function getRouteInformation(Route $route, $filter, $namespace)
{
$host = $route->domain();
$methods = $route->methods();
$uri = $route->uri();
$name = $route->getName();
$action = $route->getActionName();
$laroute = array_get($route->getAction(),... | php | protected function getRouteInformation(Route $route, $filter, $namespace)
{
$host = $route->domain();
$methods = $route->methods();
$uri = $route->uri();
$name = $route->getName();
$action = $route->getActionName();
$laroute = array_get($route->getAction(),... | [
"protected",
"function",
"getRouteInformation",
"(",
"Route",
"$",
"route",
",",
"$",
"filter",
",",
"$",
"namespace",
")",
"{",
"$",
"host",
"=",
"$",
"route",
"->",
"domain",
"(",
")",
";",
"$",
"methods",
"=",
"$",
"route",
"->",
"methods",
"(",
"... | Get the route information for a given route.
@param $route \Illuminate\Routing\Route
@param $filter string
@param $namespace string
@return array | [
"Get",
"the",
"route",
"information",
"for",
"a",
"given",
"route",
"."
] | train | https://github.com/aaronlord/laroute/blob/7242310f02ebc3f3d6a94b00db95ad0978b1802b/src/Routes/Collection.php#L62-L89 |
aaronlord/laroute | src/Compilers/TemplateCompiler.php | TemplateCompiler.compile | public function compile($template, $data)
{
foreach ($data as $key => $value) {
$key = strtoupper($key);
if(is_bool($value))
$value = $value ? 'true' : 'false';
$template = preg_replace("#\\$$key\\$#i", $value, $template);
}
return $temp... | php | public function compile($template, $data)
{
foreach ($data as $key => $value) {
$key = strtoupper($key);
if(is_bool($value))
$value = $value ? 'true' : 'false';
$template = preg_replace("#\\$$key\\$#i", $value, $template);
}
return $temp... | [
"public",
"function",
"compile",
"(",
"$",
"template",
",",
"$",
"data",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"key",
"=",
"strtoupper",
"(",
"$",
"key",
")",
";",
"if",
"(",
"is_bool",
"(",
... | Compile a template with given data.
@param $template
@param $data
@return string | [
"Compile",
"a",
"template",
"with",
"given",
"data",
"."
] | train | https://github.com/aaronlord/laroute/blob/7242310f02ebc3f3d6a94b00db95ad0978b1802b/src/Compilers/TemplateCompiler.php#L15-L27 |
PHPCompatibility/PHPCompatibility | PHPCompatibility/Sniffs/Extensions/RemovedExtensionsSniff.php | RemovedExtensionsSniff.process | public function process(File $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();
// Find the next non-empty token.
$openBracket = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
if ($tokens[$openBracket]['code'] !== \T_OPEN_PARENTHESIS) {
... | php | public function process(File $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();
// Find the next non-empty token.
$openBracket = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
if ($tokens[$openBracket]['code'] !== \T_OPEN_PARENTHESIS) {
... | [
"public",
"function",
"process",
"(",
"File",
"$",
"phpcsFile",
",",
"$",
"stackPtr",
")",
"{",
"$",
"tokens",
"=",
"$",
"phpcsFile",
"->",
"getTokens",
"(",
")",
";",
"// Find the next non-empty token.",
"$",
"openBracket",
"=",
"$",
"phpcsFile",
"->",
"fin... | Processes this test, when one of its tokens is encountered.
@param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
@param int $stackPtr The position of the current token in the
stack passed in $tokens.
@return void | [
"Processes",
"this",
"test",
"when",
"one",
"of",
"its",
"tokens",
"is",
"encountered",
"."
] | train | https://github.com/PHPCompatibility/PHPCompatibility/blob/8451ac21d652156e6742bbada166d28503ef67e4/PHPCompatibility/Sniffs/Extensions/RemovedExtensionsSniff.php#L199-L252 |
PHPCompatibility/PHPCompatibility | PHPCompatibility/Sniffs/Extensions/RemovedExtensionsSniff.php | RemovedExtensionsSniff.isWhiteListed | protected function isWhiteListed($content)
{
if (isset($this->functionWhitelist) === false) {
return false;
}
if (\is_string($this->functionWhitelist) === true) {
if (strpos($this->functionWhitelist, ',') !== false) {
$this->functionWhitelist = explod... | php | protected function isWhiteListed($content)
{
if (isset($this->functionWhitelist) === false) {
return false;
}
if (\is_string($this->functionWhitelist) === true) {
if (strpos($this->functionWhitelist, ',') !== false) {
$this->functionWhitelist = explod... | [
"protected",
"function",
"isWhiteListed",
"(",
"$",
"content",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"functionWhitelist",
")",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"\\",
"is_string",
"(",
"$",
"this",
"->",
... | Is the current function being checked whitelisted ?
Parsing the list late as it may be provided as a property, but also inline.
@param string $content Content of the current token.
@return bool | [
"Is",
"the",
"current",
"function",
"being",
"checked",
"whitelisted",
"?"
] | train | https://github.com/PHPCompatibility/PHPCompatibility/blob/8451ac21d652156e6742bbada166d28503ef67e4/PHPCompatibility/Sniffs/Extensions/RemovedExtensionsSniff.php#L264-L284 |
PHPCompatibility/PHPCompatibility | PHPCompatibility/Sniffs/Miscellaneous/ValidIntegersSniff.php | ValidIntegersSniff.process | public function process(File $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();
$token = $tokens[$stackPtr];
if ($this->couldBeBinaryInteger($tokens, $stackPtr) === true) {
if ($this->supportsBelow('5.3')) {
$error = 'Binary integer literals were not pr... | php | public function process(File $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();
$token = $tokens[$stackPtr];
if ($this->couldBeBinaryInteger($tokens, $stackPtr) === true) {
if ($this->supportsBelow('5.3')) {
$error = 'Binary integer literals were not pr... | [
"public",
"function",
"process",
"(",
"File",
"$",
"phpcsFile",
",",
"$",
"stackPtr",
")",
"{",
"$",
"tokens",
"=",
"$",
"phpcsFile",
"->",
"getTokens",
"(",
")",
";",
"$",
"token",
"=",
"$",
"tokens",
"[",
"$",
"stackPtr",
"]",
";",
"if",
"(",
"$"... | Processes this test, when one of its tokens is encountered.
@param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
@param int $stackPtr The position of the current token in
the stack.
@return void | [
"Processes",
"this",
"test",
"when",
"one",
"of",
"its",
"tokens",
"is",
"encountered",
"."
] | train | https://github.com/PHPCompatibility/PHPCompatibility/blob/8451ac21d652156e6742bbada166d28503ef67e4/PHPCompatibility/Sniffs/Miscellaneous/ValidIntegersSniff.php#L57-L107 |
PHPCompatibility/PHPCompatibility | PHPCompatibility/Sniffs/Miscellaneous/ValidIntegersSniff.php | ValidIntegersSniff.couldBeBinaryInteger | private function couldBeBinaryInteger($tokens, $stackPtr)
{
$token = $tokens[$stackPtr];
if ($token['code'] !== \T_LNUMBER) {
return false;
}
if ($this->isLowPHPVersion === false) {
return (preg_match('`^0b[0-1]+$`D', $token['content']) === 1);
}
... | php | private function couldBeBinaryInteger($tokens, $stackPtr)
{
$token = $tokens[$stackPtr];
if ($token['code'] !== \T_LNUMBER) {
return false;
}
if ($this->isLowPHPVersion === false) {
return (preg_match('`^0b[0-1]+$`D', $token['content']) === 1);
}
... | [
"private",
"function",
"couldBeBinaryInteger",
"(",
"$",
"tokens",
",",
"$",
"stackPtr",
")",
"{",
"$",
"token",
"=",
"$",
"tokens",
"[",
"$",
"stackPtr",
"]",
";",
"if",
"(",
"$",
"token",
"[",
"'code'",
"]",
"!==",
"\\",
"T_LNUMBER",
")",
"{",
"ret... | Could the current token an potentially be a binary integer ?
@param array $tokens Token stack.
@param int $stackPtr The current position in the token stack.
@return bool | [
"Could",
"the",
"current",
"token",
"an",
"potentially",
"be",
"a",
"binary",
"integer",
"?"
] | train | https://github.com/PHPCompatibility/PHPCompatibility/blob/8451ac21d652156e6742bbada166d28503ef67e4/PHPCompatibility/Sniffs/Miscellaneous/ValidIntegersSniff.php#L118-L134 |
PHPCompatibility/PHPCompatibility | PHPCompatibility/Sniffs/Miscellaneous/ValidIntegersSniff.php | ValidIntegersSniff.isInvalidBinaryInteger | private function isInvalidBinaryInteger($tokens, $stackPtr)
{
if ($this->couldBeBinaryInteger($tokens, $stackPtr) === false) {
return false;
}
if ($this->isLowPHPVersion === false) {
// If it's an invalid binary int, the token will be split into two T_LNUMBER tokens.... | php | private function isInvalidBinaryInteger($tokens, $stackPtr)
{
if ($this->couldBeBinaryInteger($tokens, $stackPtr) === false) {
return false;
}
if ($this->isLowPHPVersion === false) {
// If it's an invalid binary int, the token will be split into two T_LNUMBER tokens.... | [
"private",
"function",
"isInvalidBinaryInteger",
"(",
"$",
"tokens",
",",
"$",
"stackPtr",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"couldBeBinaryInteger",
"(",
"$",
"tokens",
",",
"$",
"stackPtr",
")",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}... | Is the current token an invalid binary integer ?
@param array $tokens Token stack.
@param int $stackPtr The current position in the token stack.
@return bool | [
"Is",
"the",
"current",
"token",
"an",
"invalid",
"binary",
"integer",
"?"
] | train | https://github.com/PHPCompatibility/PHPCompatibility/blob/8451ac21d652156e6742bbada166d28503ef67e4/PHPCompatibility/Sniffs/Miscellaneous/ValidIntegersSniff.php#L144-L156 |
PHPCompatibility/PHPCompatibility | PHPCompatibility/Sniffs/Miscellaneous/ValidIntegersSniff.php | ValidIntegersSniff.getBinaryInteger | private function getBinaryInteger(File $phpcsFile, $tokens, $stackPtr)
{
$length = 2; // PHP < 5.4 T_LNUMBER + T_STRING.
if ($this->isLowPHPVersion === false) {
$i = $stackPtr;
while ($tokens[$i]['code'] === \T_LNUMBER) {
$i++;
}
$leng... | php | private function getBinaryInteger(File $phpcsFile, $tokens, $stackPtr)
{
$length = 2; // PHP < 5.4 T_LNUMBER + T_STRING.
if ($this->isLowPHPVersion === false) {
$i = $stackPtr;
while ($tokens[$i]['code'] === \T_LNUMBER) {
$i++;
}
$leng... | [
"private",
"function",
"getBinaryInteger",
"(",
"File",
"$",
"phpcsFile",
",",
"$",
"tokens",
",",
"$",
"stackPtr",
")",
"{",
"$",
"length",
"=",
"2",
";",
"// PHP < 5.4 T_LNUMBER + T_STRING.",
"if",
"(",
"$",
"this",
"->",
"isLowPHPVersion",
"===",
"false",
... | Retrieve the content of the tokens which together look like a binary integer.
@param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
@param array $tokens Token stack.
@param int $stackPtr The position of the current token in
the stack.
@return string | [
"Retrieve",
"the",
"content",
"of",
"the",
"tokens",
"which",
"together",
"look",
"like",
"a",
"binary",
"integer",
"."
] | train | https://github.com/PHPCompatibility/PHPCompatibility/blob/8451ac21d652156e6742bbada166d28503ef67e4/PHPCompatibility/Sniffs/Miscellaneous/ValidIntegersSniff.php#L168-L181 |
PHPCompatibility/PHPCompatibility | PHPCompatibility/Sniffs/Miscellaneous/ValidIntegersSniff.php | ValidIntegersSniff.isInvalidOctalInteger | private function isInvalidOctalInteger($tokens, $stackPtr)
{
$token = $tokens[$stackPtr];
if ($token['code'] === \T_LNUMBER && preg_match('`^0[0-7]*[8-9]+[0-9]*$`D', $token['content']) === 1) {
return true;
}
return false;
} | php | private function isInvalidOctalInteger($tokens, $stackPtr)
{
$token = $tokens[$stackPtr];
if ($token['code'] === \T_LNUMBER && preg_match('`^0[0-7]*[8-9]+[0-9]*$`D', $token['content']) === 1) {
return true;
}
return false;
} | [
"private",
"function",
"isInvalidOctalInteger",
"(",
"$",
"tokens",
",",
"$",
"stackPtr",
")",
"{",
"$",
"token",
"=",
"$",
"tokens",
"[",
"$",
"stackPtr",
"]",
";",
"if",
"(",
"$",
"token",
"[",
"'code'",
"]",
"===",
"\\",
"T_LNUMBER",
"&&",
"preg_mat... | Is the current token an invalid octal integer ?
@param array $tokens Token stack.
@param int $stackPtr The current position in the token stack.
@return bool | [
"Is",
"the",
"current",
"token",
"an",
"invalid",
"octal",
"integer",
"?"
] | train | https://github.com/PHPCompatibility/PHPCompatibility/blob/8451ac21d652156e6742bbada166d28503ef67e4/PHPCompatibility/Sniffs/Miscellaneous/ValidIntegersSniff.php#L191-L200 |
PHPCompatibility/PHPCompatibility | PHPCompatibility/Sniffs/Miscellaneous/ValidIntegersSniff.php | ValidIntegersSniff.isHexidecimalNumericString | private function isHexidecimalNumericString($tokens, $stackPtr)
{
$token = $tokens[$stackPtr];
if ($token['code'] === \T_CONSTANT_ENCAPSED_STRING && preg_match('`^0x[a-f0-9]+$`iD', $this->stripQuotes($token['content'])) === 1) {
return true;
}
return false;
} | php | private function isHexidecimalNumericString($tokens, $stackPtr)
{
$token = $tokens[$stackPtr];
if ($token['code'] === \T_CONSTANT_ENCAPSED_STRING && preg_match('`^0x[a-f0-9]+$`iD', $this->stripQuotes($token['content'])) === 1) {
return true;
}
return false;
} | [
"private",
"function",
"isHexidecimalNumericString",
"(",
"$",
"tokens",
",",
"$",
"stackPtr",
")",
"{",
"$",
"token",
"=",
"$",
"tokens",
"[",
"$",
"stackPtr",
"]",
";",
"if",
"(",
"$",
"token",
"[",
"'code'",
"]",
"===",
"\\",
"T_CONSTANT_ENCAPSED_STRING... | Is the current token a hexidecimal numeric string ?
@param array $tokens Token stack.
@param int $stackPtr The current position in the token stack.
@return bool | [
"Is",
"the",
"current",
"token",
"a",
"hexidecimal",
"numeric",
"string",
"?"
] | train | https://github.com/PHPCompatibility/PHPCompatibility/blob/8451ac21d652156e6742bbada166d28503ef67e4/PHPCompatibility/Sniffs/Miscellaneous/ValidIntegersSniff.php#L210-L219 |
PHPCompatibility/PHPCompatibility | PHPCompatibility/Sniffs/FunctionDeclarations/NewParamTypeDeclarationsSniff.php | NewParamTypeDeclarationsSniff.process | public function process(File $phpcsFile, $stackPtr)
{
// Get all parameters from method signature.
$paramNames = PHPCSHelper::getMethodParameters($phpcsFile, $stackPtr);
if (empty($paramNames)) {
return;
}
$supportsPHP4 = $this->supportsBelow('4.4');
for... | php | public function process(File $phpcsFile, $stackPtr)
{
// Get all parameters from method signature.
$paramNames = PHPCSHelper::getMethodParameters($phpcsFile, $stackPtr);
if (empty($paramNames)) {
return;
}
$supportsPHP4 = $this->supportsBelow('4.4');
for... | [
"public",
"function",
"process",
"(",
"File",
"$",
"phpcsFile",
",",
"$",
"stackPtr",
")",
"{",
"// Get all parameters from method signature.",
"$",
"paramNames",
"=",
"PHPCSHelper",
"::",
"getMethodParameters",
"(",
"$",
"phpcsFile",
",",
"$",
"stackPtr",
")",
";... | Processes this test, when one of its tokens is encountered.
@param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
@param int $stackPtr The position of the current token in
the stack passed in $tokens.
@return void | [
"Processes",
"this",
"test",
"when",
"one",
"of",
"its",
"tokens",
"is",
"encountered",
"."
] | train | https://github.com/PHPCompatibility/PHPCompatibility/blob/8451ac21d652156e6742bbada166d28503ef67e4/PHPCompatibility/Sniffs/FunctionDeclarations/NewParamTypeDeclarationsSniff.php#L115-L170 |
PHPCompatibility/PHPCompatibility | PHPCompatibility/Sniffs/FunctionDeclarations/NewReturnTypeDeclarationsSniff.php | NewReturnTypeDeclarationsSniff.process | public function process(File $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();
// Deal with older PHPCS version which don't recognize return type hints
// as well as newer PHPCS versions (3.3.0+) where the tokenization has changed.
if ($tokens[$stackPtr]['code'] === \T_FUN... | php | public function process(File $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();
// Deal with older PHPCS version which don't recognize return type hints
// as well as newer PHPCS versions (3.3.0+) where the tokenization has changed.
if ($tokens[$stackPtr]['code'] === \T_FUN... | [
"public",
"function",
"process",
"(",
"File",
"$",
"phpcsFile",
",",
"$",
"stackPtr",
")",
"{",
"$",
"tokens",
"=",
"$",
"phpcsFile",
"->",
"getTokens",
"(",
")",
";",
"// Deal with older PHPCS version which don't recognize return type hints",
"// as well as newer PHPCS... | Processes this test, when one of its tokens is encountered.
@param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
@param int $stackPtr The position of the current token in
the stack passed in $tokens.
@return void | [
"Processes",
"this",
"test",
"when",
"one",
"of",
"its",
"tokens",
"is",
"encountered",
"."
] | train | https://github.com/PHPCompatibility/PHPCompatibility/blob/8451ac21d652156e6742bbada166d28503ef67e4/PHPCompatibility/Sniffs/FunctionDeclarations/NewReturnTypeDeclarationsSniff.php#L120-L148 |
PHPCompatibility/PHPCompatibility | PHPCompatibility/Sniffs/Constants/NewMagicClassConstantSniff.php | NewMagicClassConstantSniff.process | public function process(File $phpcsFile, $stackPtr)
{
if ($this->supportsBelow('5.4') === false) {
return;
}
$tokens = $phpcsFile->getTokens();
if (strtolower($tokens[$stackPtr]['content']) !== 'class') {
return;
}
$prevToken = $phpcsFile->f... | php | public function process(File $phpcsFile, $stackPtr)
{
if ($this->supportsBelow('5.4') === false) {
return;
}
$tokens = $phpcsFile->getTokens();
if (strtolower($tokens[$stackPtr]['content']) !== 'class') {
return;
}
$prevToken = $phpcsFile->f... | [
"public",
"function",
"process",
"(",
"File",
"$",
"phpcsFile",
",",
"$",
"stackPtr",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"supportsBelow",
"(",
"'5.4'",
")",
"===",
"false",
")",
"{",
"return",
";",
"}",
"$",
"tokens",
"=",
"$",
"phpcsFile",
"->"... | Processes this test, when one of its tokens is encountered.
@param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
@param int $stackPtr The position of the current token in the
stack passed in $tokens.
@return void | [
"Processes",
"this",
"test",
"when",
"one",
"of",
"its",
"tokens",
"is",
"encountered",
"."
] | train | https://github.com/PHPCompatibility/PHPCompatibility/blob/8451ac21d652156e6742bbada166d28503ef67e4/PHPCompatibility/Sniffs/Constants/NewMagicClassConstantSniff.php#L52-L74 |
PHPCompatibility/PHPCompatibility | PHPCompatibility/Sniffs/Classes/NewAnonymousClassesSniff.php | NewAnonymousClassesSniff.process | public function process(File $phpcsFile, $stackPtr)
{
if ($this->supportsBelow('5.6') === false) {
return;
}
$tokens = $phpcsFile->getTokens();
$nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
if ($nextNonEm... | php | public function process(File $phpcsFile, $stackPtr)
{
if ($this->supportsBelow('5.6') === false) {
return;
}
$tokens = $phpcsFile->getTokens();
$nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
if ($nextNonEm... | [
"public",
"function",
"process",
"(",
"File",
"$",
"phpcsFile",
",",
"$",
"stackPtr",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"supportsBelow",
"(",
"'5.6'",
")",
"===",
"false",
")",
"{",
"return",
";",
"}",
"$",
"tokens",
"=",
"$",
"phpcsFile",
"->"... | Processes this test, when one of its tokens is encountered.
@param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
@param int $stackPtr The position of the current token in the
stack passed in $tokens.
@return void | [
"Processes",
"this",
"test",
"when",
"one",
"of",
"its",
"tokens",
"is",
"encountered",
"."
] | train | https://github.com/PHPCompatibility/PHPCompatibility/blob/8451ac21d652156e6742bbada166d28503ef67e4/PHPCompatibility/Sniffs/Classes/NewAnonymousClassesSniff.php#L68-L86 |
PHPCompatibility/PHPCompatibility | PHPCompatibility/Sniffs/ControlStructures/DiscouragedSwitchContinueSniff.php | DiscouragedSwitchContinueSniff.register | public function register()
{
$this->acceptedLevelTokens += Tokens::$arithmeticTokens;
$this->acceptedLevelTokens += Tokens::$emptyTokens;
return array(\T_SWITCH);
} | php | public function register()
{
$this->acceptedLevelTokens += Tokens::$arithmeticTokens;
$this->acceptedLevelTokens += Tokens::$emptyTokens;
return array(\T_SWITCH);
} | [
"public",
"function",
"register",
"(",
")",
"{",
"$",
"this",
"->",
"acceptedLevelTokens",
"+=",
"Tokens",
"::",
"$",
"arithmeticTokens",
";",
"$",
"this",
"->",
"acceptedLevelTokens",
"+=",
"Tokens",
"::",
"$",
"emptyTokens",
";",
"return",
"array",
"(",
"\... | Returns an array of tokens this test wants to listen for.
@return array | [
"Returns",
"an",
"array",
"of",
"tokens",
"this",
"test",
"wants",
"to",
"listen",
"for",
"."
] | train | https://github.com/PHPCompatibility/PHPCompatibility/blob/8451ac21d652156e6742bbada166d28503ef67e4/PHPCompatibility/Sniffs/ControlStructures/DiscouragedSwitchContinueSniff.php#L74-L80 |
PHPCompatibility/PHPCompatibility | PHPCompatibility/Sniffs/ControlStructures/DiscouragedSwitchContinueSniff.php | DiscouragedSwitchContinueSniff.process | public function process(File $phpcsFile, $stackPtr)
{
if ($this->supportsAbove('7.3') === false) {
return;
}
$tokens = $phpcsFile->getTokens();
if (isset($tokens[$stackPtr]['scope_opener'], $tokens[$stackPtr]['scope_closer']) === false) {
return;
}
... | php | public function process(File $phpcsFile, $stackPtr)
{
if ($this->supportsAbove('7.3') === false) {
return;
}
$tokens = $phpcsFile->getTokens();
if (isset($tokens[$stackPtr]['scope_opener'], $tokens[$stackPtr]['scope_closer']) === false) {
return;
}
... | [
"public",
"function",
"process",
"(",
"File",
"$",
"phpcsFile",
",",
"$",
"stackPtr",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"supportsAbove",
"(",
"'7.3'",
")",
"===",
"false",
")",
"{",
"return",
";",
"}",
"$",
"tokens",
"=",
"$",
"phpcsFile",
"->"... | Processes this test, when one of its tokens is encountered.
@param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
@param int $stackPtr The position of the current token in the
stack passed in $tokens.
@return void | [
"Processes",
"this",
"test",
"when",
"one",
"of",
"its",
"tokens",
"is",
"encountered",
"."
] | train | https://github.com/PHPCompatibility/PHPCompatibility/blob/8451ac21d652156e6742bbada166d28503ef67e4/PHPCompatibility/Sniffs/ControlStructures/DiscouragedSwitchContinueSniff.php#L91-L222 |
PHPCompatibility/PHPCompatibility | PHPCompatibility/Sniffs/ParameterValues/RemovedNonCryptoHashSniff.php | RemovedNonCryptoHashSniff.processParameters | public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
{
if (isset($parameters[1]) === false) {
return;
}
$targetParam = $parameters[1];
if (isset($this->disabledCryptos[$this->stripQuotes($targetParam['raw'])]) === false) {
... | php | public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
{
if (isset($parameters[1]) === false) {
return;
}
$targetParam = $parameters[1];
if (isset($this->disabledCryptos[$this->stripQuotes($targetParam['raw'])]) === false) {
... | [
"public",
"function",
"processParameters",
"(",
"File",
"$",
"phpcsFile",
",",
"$",
"stackPtr",
",",
"$",
"functionName",
",",
"$",
"parameters",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"parameters",
"[",
"1",
"]",
")",
"===",
"false",
")",
"{",
"retur... | Process the parameters of a matched function.
@param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
@param int $stackPtr The position of the current token in the stack.
@param string $functionName The token content (function name) which was matched.
@param array ... | [
"Process",
"the",
"parameters",
"of",
"a",
"matched",
"function",
"."
] | train | https://github.com/PHPCompatibility/PHPCompatibility/blob/8451ac21d652156e6742bbada166d28503ef67e4/PHPCompatibility/Sniffs/ParameterValues/RemovedNonCryptoHashSniff.php#L83-L113 |
PHPCompatibility/PHPCompatibility | PHPCompatibility/Sniffs/Variables/NewUniformVariableSyntaxSniff.php | NewUniformVariableSyntaxSniff.process | public function process(File $phpcsFile, $stackPtr)
{
if ($this->supportsAbove('7.0') === false) {
return;
}
$tokens = $phpcsFile->getTokens();
// Verify that the next token is a square open bracket. If not, bow out.
$nextToken = $phpcsFile->findNext(Tokens::$em... | php | public function process(File $phpcsFile, $stackPtr)
{
if ($this->supportsAbove('7.0') === false) {
return;
}
$tokens = $phpcsFile->getTokens();
// Verify that the next token is a square open bracket. If not, bow out.
$nextToken = $phpcsFile->findNext(Tokens::$em... | [
"public",
"function",
"process",
"(",
"File",
"$",
"phpcsFile",
",",
"$",
"stackPtr",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"supportsAbove",
"(",
"'7.0'",
")",
"===",
"false",
")",
"{",
"return",
";",
"}",
"$",
"tokens",
"=",
"$",
"phpcsFile",
"->"... | Processes this test, when one of its tokens is encountered.
@param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
@param int $stackPtr The position of the current token
in the stack passed in $tokens.
@return void | [
"Processes",
"this",
"test",
"when",
"one",
"of",
"its",
"tokens",
"is",
"encountered",
"."
] | train | https://github.com/PHPCompatibility/PHPCompatibility/blob/8451ac21d652156e6742bbada166d28503ef67e4/PHPCompatibility/Sniffs/Variables/NewUniformVariableSyntaxSniff.php#L50-L110 |
PHPCompatibility/PHPCompatibility | PHPCompatibility/Sniffs/Variables/RemovedPredefinedGlobalVariablesSniff.php | RemovedPredefinedGlobalVariablesSniff.process | public function process(File $phpcsFile, $stackPtr)
{
if ($this->supportsAbove('5.3') === false) {
return;
}
$tokens = $phpcsFile->getTokens();
$varName = substr($tokens[$stackPtr]['content'], 1);
if (isset($this->removedGlobalVariables[$varName]) === false) {
... | php | public function process(File $phpcsFile, $stackPtr)
{
if ($this->supportsAbove('5.3') === false) {
return;
}
$tokens = $phpcsFile->getTokens();
$varName = substr($tokens[$stackPtr]['content'], 1);
if (isset($this->removedGlobalVariables[$varName]) === false) {
... | [
"public",
"function",
"process",
"(",
"File",
"$",
"phpcsFile",
",",
"$",
"stackPtr",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"supportsAbove",
"(",
"'5.3'",
")",
"===",
"false",
")",
"{",
"return",
";",
"}",
"$",
"tokens",
"=",
"$",
"phpcsFile",
"->"... | Processes this test, when one of its tokens is encountered.
@param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
@param int $stackPtr The position of the current token in the
stack passed in $tokens.
@return void | [
"Processes",
"this",
"test",
"when",
"one",
"of",
"its",
"tokens",
"is",
"encountered",
"."
] | train | https://github.com/PHPCompatibility/PHPCompatibility/blob/8451ac21d652156e6742bbada166d28503ef67e4/PHPCompatibility/Sniffs/Variables/RemovedPredefinedGlobalVariablesSniff.php#L107-L145 |
PHPCompatibility/PHPCompatibility | PHPCompatibility/Sniffs/Variables/RemovedPredefinedGlobalVariablesSniff.php | RemovedPredefinedGlobalVariablesSniff.isTargetPHPErrormsgVar | private function isTargetPHPErrormsgVar(File $phpcsFile, $stackPtr, array $tokens)
{
$scopeStart = 0;
/*
* If the variable is detected within the scope of a function/closure, limit the checking.
*/
$function = $phpcsFile->getCondition($stackPtr, \T_CLOSURE);
if ($f... | php | private function isTargetPHPErrormsgVar(File $phpcsFile, $stackPtr, array $tokens)
{
$scopeStart = 0;
/*
* If the variable is detected within the scope of a function/closure, limit the checking.
*/
$function = $phpcsFile->getCondition($stackPtr, \T_CLOSURE);
if ($f... | [
"private",
"function",
"isTargetPHPErrormsgVar",
"(",
"File",
"$",
"phpcsFile",
",",
"$",
"stackPtr",
",",
"array",
"$",
"tokens",
")",
"{",
"$",
"scopeStart",
"=",
"0",
";",
"/*\n * If the variable is detected within the scope of a function/closure, limit the check... | Run some additional checks for the `$php_errormsg` variable.
@param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
@param int $stackPtr The position of the current token in the
stack passed in $tokens.
@param array $tokens Token array of the current file.
@return bool | [
"Run",
"some",
"additional",
"checks",
"for",
"the",
"$php_errormsg",
"variable",
"."
] | train | https://github.com/PHPCompatibility/PHPCompatibility/blob/8451ac21d652156e6742bbada166d28503ef67e4/PHPCompatibility/Sniffs/Variables/RemovedPredefinedGlobalVariablesSniff.php#L199-L292 |
PHPCompatibility/PHPCompatibility | PHPCompatibility/Sniffs/IniDirectives/NewIniDirectivesSniff.php | NewIniDirectivesSniff.process | public function process(File $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();
$ignore = array(
\T_DOUBLE_COLON => true,
\T_OBJECT_OPERATOR => true,
\T_FUNCTION => true,
\T_CONST => true,
);
$prevToken = ... | php | public function process(File $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();
$ignore = array(
\T_DOUBLE_COLON => true,
\T_OBJECT_OPERATOR => true,
\T_FUNCTION => true,
\T_CONST => true,
);
$prevToken = ... | [
"public",
"function",
"process",
"(",
"File",
"$",
"phpcsFile",
",",
"$",
"stackPtr",
")",
"{",
"$",
"tokens",
"=",
"$",
"phpcsFile",
"->",
"getTokens",
"(",
")",
";",
"$",
"ignore",
"=",
"array",
"(",
"\\",
"T_DOUBLE_COLON",
"=>",
"true",
",",
"\\",
... | Processes this test, when one of its tokens is encountered.
@param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
@param int $stackPtr The position of the current token in the
stack passed in $tokens.
@return void | [
"Processes",
"this",
"test",
"when",
"one",
"of",
"its",
"tokens",
"is",
"encountered",
"."
] | train | https://github.com/PHPCompatibility/PHPCompatibility/blob/8451ac21d652156e6742bbada166d28503ef67e4/PHPCompatibility/Sniffs/IniDirectives/NewIniDirectivesSniff.php#L526-L563 |
PHPCompatibility/PHPCompatibility | PHPCompatibility/Sniffs/IniDirectives/NewIniDirectivesSniff.php | NewIniDirectivesSniff.getErrorInfo | public function getErrorInfo(array $itemArray, array $itemInfo)
{
$errorInfo = parent::getErrorInfo($itemArray, $itemInfo);
$errorInfo['alternative'] = '';
if (isset($itemArray['alternative']) === true) {
$errorInfo['alternative'] = $itemArray['alternative'];
... | php | public function getErrorInfo(array $itemArray, array $itemInfo)
{
$errorInfo = parent::getErrorInfo($itemArray, $itemInfo);
$errorInfo['alternative'] = '';
if (isset($itemArray['alternative']) === true) {
$errorInfo['alternative'] = $itemArray['alternative'];
... | [
"public",
"function",
"getErrorInfo",
"(",
"array",
"$",
"itemArray",
",",
"array",
"$",
"itemInfo",
")",
"{",
"$",
"errorInfo",
"=",
"parent",
"::",
"getErrorInfo",
"(",
"$",
"itemArray",
",",
"$",
"itemInfo",
")",
";",
"$",
"errorInfo",
"[",
"'alternativ... | Retrieve the relevant detail (version) information for use in an error message.
@param array $itemArray Version and other information about the item.
@param array $itemInfo Base information about the item.
@return array | [
"Retrieve",
"the",
"relevant",
"detail",
"(",
"version",
")",
"information",
"for",
"use",
"in",
"an",
"error",
"message",
"."
] | train | https://github.com/PHPCompatibility/PHPCompatibility/blob/8451ac21d652156e6742bbada166d28503ef67e4/PHPCompatibility/Sniffs/IniDirectives/NewIniDirectivesSniff.php#L598-L613 |
PHPCompatibility/PHPCompatibility | PHPCompatibility/AbstractComplexVersionSniff.php | AbstractComplexVersionSniff.handleFeature | public function handleFeature(File $phpcsFile, $stackPtr, array $itemInfo)
{
$itemArray = $this->getItemArray($itemInfo);
$errorInfo = $this->getErrorInfo($itemArray, $itemInfo);
if ($this->shouldThrowError($errorInfo) === true) {
$this->addError($phpcsFile, $stackPtr, $itemInfo... | php | public function handleFeature(File $phpcsFile, $stackPtr, array $itemInfo)
{
$itemArray = $this->getItemArray($itemInfo);
$errorInfo = $this->getErrorInfo($itemArray, $itemInfo);
if ($this->shouldThrowError($errorInfo) === true) {
$this->addError($phpcsFile, $stackPtr, $itemInfo... | [
"public",
"function",
"handleFeature",
"(",
"File",
"$",
"phpcsFile",
",",
"$",
"stackPtr",
",",
"array",
"$",
"itemInfo",
")",
"{",
"$",
"itemArray",
"=",
"$",
"this",
"->",
"getItemArray",
"(",
"$",
"itemInfo",
")",
";",
"$",
"errorInfo",
"=",
"$",
"... | Handle the retrieval of relevant information and - if necessary - throwing of an
error/warning for an item.
@param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
@param int $stackPtr The position of the relevant token in
the stack.
@param array $itemInfo Base information a... | [
"Handle",
"the",
"retrieval",
"of",
"relevant",
"information",
"and",
"-",
"if",
"necessary",
"-",
"throwing",
"of",
"an",
"error",
"/",
"warning",
"for",
"an",
"item",
"."
] | train | https://github.com/PHPCompatibility/PHPCompatibility/blob/8451ac21d652156e6742bbada166d28503ef67e4/PHPCompatibility/AbstractComplexVersionSniff.php#L36-L44 |
PHPCompatibility/PHPCompatibility | PHPCompatibility/Sniffs/TypeCasts/RemovedTypeCastsSniff.php | RemovedTypeCastsSniff.register | public function register()
{
$tokens = array();
foreach ($this->deprecatedTypeCasts as $token => $versions) {
$tokens[] = constant($token);
}
return $tokens;
} | php | public function register()
{
$tokens = array();
foreach ($this->deprecatedTypeCasts as $token => $versions) {
$tokens[] = constant($token);
}
return $tokens;
} | [
"public",
"function",
"register",
"(",
")",
"{",
"$",
"tokens",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"deprecatedTypeCasts",
"as",
"$",
"token",
"=>",
"$",
"versions",
")",
"{",
"$",
"tokens",
"[",
"]",
"=",
"constant",
"(",... | Returns an array of tokens this test wants to listen for.
@return array | [
"Returns",
"an",
"array",
"of",
"tokens",
"this",
"test",
"wants",
"to",
"listen",
"for",
"."
] | train | https://github.com/PHPCompatibility/PHPCompatibility/blob/8451ac21d652156e6742bbada166d28503ef67e4/PHPCompatibility/Sniffs/TypeCasts/RemovedTypeCastsSniff.php#L46-L54 |
PHPCompatibility/PHPCompatibility | PHPCompatibility/Sniffs/TypeCasts/RemovedTypeCastsSniff.php | RemovedTypeCastsSniff.process | public function process(File $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();
$tokenType = $tokens[$stackPtr]['type'];
$itemInfo = array(
'name' => $tokenType,
'description' => $this->deprecatedTypeCasts[$tokenType]['description'],
);
... | php | public function process(File $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();
$tokenType = $tokens[$stackPtr]['type'];
$itemInfo = array(
'name' => $tokenType,
'description' => $this->deprecatedTypeCasts[$tokenType]['description'],
);
... | [
"public",
"function",
"process",
"(",
"File",
"$",
"phpcsFile",
",",
"$",
"stackPtr",
")",
"{",
"$",
"tokens",
"=",
"$",
"phpcsFile",
"->",
"getTokens",
"(",
")",
";",
"$",
"tokenType",
"=",
"$",
"tokens",
"[",
"$",
"stackPtr",
"]",
"[",
"'type'",
"]... | Processes this test, when one of its tokens is encountered.
@param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
@param int $stackPtr The position of the current token in
the stack passed in $tokens.
@return void | [
"Processes",
"this",
"test",
"when",
"one",
"of",
"its",
"tokens",
"is",
"encountered",
"."
] | train | https://github.com/PHPCompatibility/PHPCompatibility/blob/8451ac21d652156e6742bbada166d28503ef67e4/PHPCompatibility/Sniffs/TypeCasts/RemovedTypeCastsSniff.php#L66-L76 |
PHPCompatibility/PHPCompatibility | PHPCompatibility/Sniffs/Generators/NewGeneratorReturnSniff.php | NewGeneratorReturnSniff.register | public function register()
{
$targets = array(
\T_YIELD,
);
/*
* The `yield` keyword was introduced in PHP 5.5 with the token T_YIELD.
* The `yield from` keyword was introduced in PHP 7.0 and tokenizes as
* "T_YIELD T_WHITESPACE T_STRING".
*
... | php | public function register()
{
$targets = array(
\T_YIELD,
);
/*
* The `yield` keyword was introduced in PHP 5.5 with the token T_YIELD.
* The `yield from` keyword was introduced in PHP 7.0 and tokenizes as
* "T_YIELD T_WHITESPACE T_STRING".
*
... | [
"public",
"function",
"register",
"(",
")",
"{",
"$",
"targets",
"=",
"array",
"(",
"\\",
"T_YIELD",
",",
")",
";",
"/*\n * The `yield` keyword was introduced in PHP 5.5 with the token T_YIELD.\n * The `yield from` keyword was introduced in PHP 7.0 and tokenizes as\n ... | Returns an array of tokens this test wants to listen for.
@return array | [
"Returns",
"an",
"array",
"of",
"tokens",
"this",
"test",
"wants",
"to",
"listen",
"for",
"."
] | train | https://github.com/PHPCompatibility/PHPCompatibility/blob/8451ac21d652156e6742bbada166d28503ef67e4/PHPCompatibility/Sniffs/Generators/NewGeneratorReturnSniff.php#L47-L77 |
PHPCompatibility/PHPCompatibility | PHPCompatibility/Sniffs/Generators/NewGeneratorReturnSniff.php | NewGeneratorReturnSniff.process | public function process(File $phpcsFile, $stackPtr)
{
if ($this->supportsBelow('5.6') !== true) {
return;
}
$tokens = $phpcsFile->getTokens();
if ($tokens[$stackPtr]['code'] === \T_STRING
&& $tokens[$stackPtr]['content'] !== 'yield'
) {
r... | php | public function process(File $phpcsFile, $stackPtr)
{
if ($this->supportsBelow('5.6') !== true) {
return;
}
$tokens = $phpcsFile->getTokens();
if ($tokens[$stackPtr]['code'] === \T_STRING
&& $tokens[$stackPtr]['content'] !== 'yield'
) {
r... | [
"public",
"function",
"process",
"(",
"File",
"$",
"phpcsFile",
",",
"$",
"stackPtr",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"supportsBelow",
"(",
"'5.6'",
")",
"!==",
"true",
")",
"{",
"return",
";",
"}",
"$",
"tokens",
"=",
"$",
"phpcsFile",
"->",... | Processes this test, when one of its tokens is encountered.
@param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
@param int $stackPtr The position of the current token in the
stack passed in $tokens.
@return void|int Void or a stack pointer to skip forward. | [
"Processes",
"this",
"test",
"when",
"one",
"of",
"its",
"tokens",
"is",
"encountered",
"."
] | train | https://github.com/PHPCompatibility/PHPCompatibility/blob/8451ac21d652156e6742bbada166d28503ef67e4/PHPCompatibility/Sniffs/Generators/NewGeneratorReturnSniff.php#L88-L152 |
PHPCompatibility/PHPCompatibility | PHPCompatibility/Sniffs/Syntax/NewDynamicAccessToStaticSniff.php | NewDynamicAccessToStaticSniff.process | public function process(File $phpcsFile, $stackPtr)
{
if ($this->supportsBelow('5.2') === false) {
return;
}
$tokens = $phpcsFile->getTokens();
$prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
// Disregard `stati... | php | public function process(File $phpcsFile, $stackPtr)
{
if ($this->supportsBelow('5.2') === false) {
return;
}
$tokens = $phpcsFile->getTokens();
$prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
// Disregard `stati... | [
"public",
"function",
"process",
"(",
"File",
"$",
"phpcsFile",
",",
"$",
"stackPtr",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"supportsBelow",
"(",
"'5.2'",
")",
"===",
"false",
")",
"{",
"return",
";",
"}",
"$",
"tokens",
"=",
"$",
"phpcsFile",
"->"... | Processes this test, when one of its tokens is encountered.
@param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
@param int $stackPtr The position of the current token in the
stack passed in $tokens.
@return void | [
"Processes",
"this",
"test",
"when",
"one",
"of",
"its",
"tokens",
"is",
"encountered",
"."
] | train | https://github.com/PHPCompatibility/PHPCompatibility/blob/8451ac21d652156e6742bbada166d28503ef67e4/PHPCompatibility/Sniffs/Syntax/NewDynamicAccessToStaticSniff.php#L54-L84 |
PHPCompatibility/PHPCompatibility | PHPCompatibility/Sniffs/ControlStructures/NewMultiCatchSniff.php | NewMultiCatchSniff.process | public function process(File $phpcsFile, $stackPtr)
{
if ($this->supportsBelow('7.0') === false) {
return;
}
$tokens = $phpcsFile->getTokens();
$token = $tokens[$stackPtr];
// Bow out during live coding.
if (isset($token['parenthesis_opener'], $token['p... | php | public function process(File $phpcsFile, $stackPtr)
{
if ($this->supportsBelow('7.0') === false) {
return;
}
$tokens = $phpcsFile->getTokens();
$token = $tokens[$stackPtr];
// Bow out during live coding.
if (isset($token['parenthesis_opener'], $token['p... | [
"public",
"function",
"process",
"(",
"File",
"$",
"phpcsFile",
",",
"$",
"stackPtr",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"supportsBelow",
"(",
"'7.0'",
")",
"===",
"false",
")",
"{",
"return",
";",
"}",
"$",
"tokens",
"=",
"$",
"phpcsFile",
"->"... | Processes this test, when one of its tokens is encountered.
@param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
@param int $stackPtr The position of the current token
in the stack passed in $tokens.
@return void | [
"Processes",
"this",
"test",
"when",
"one",
"of",
"its",
"tokens",
"is",
"encountered",
"."
] | train | https://github.com/PHPCompatibility/PHPCompatibility/blob/8451ac21d652156e6742bbada166d28503ef67e4/PHPCompatibility/Sniffs/ControlStructures/NewMultiCatchSniff.php#L49-L74 |
PHPCompatibility/PHPCompatibility | PHPCompatibility/Sniffs/ControlStructures/NewExecutionDirectivesSniff.php | NewExecutionDirectivesSniff.register | public function register()
{
$this->ignoreTokens = Tokens::$emptyTokens;
$this->ignoreTokens[\T_EQUAL] = \T_EQUAL;
return array(\T_DECLARE);
} | php | public function register()
{
$this->ignoreTokens = Tokens::$emptyTokens;
$this->ignoreTokens[\T_EQUAL] = \T_EQUAL;
return array(\T_DECLARE);
} | [
"public",
"function",
"register",
"(",
")",
"{",
"$",
"this",
"->",
"ignoreTokens",
"=",
"Tokens",
"::",
"$",
"emptyTokens",
";",
"$",
"this",
"->",
"ignoreTokens",
"[",
"\\",
"T_EQUAL",
"]",
"=",
"\\",
"T_EQUAL",
";",
"return",
"array",
"(",
"\\",
"T_... | Returns an array of tokens this test wants to listen for.
@return array | [
"Returns",
"an",
"array",
"of",
"tokens",
"this",
"test",
"wants",
"to",
"listen",
"for",
"."
] | train | https://github.com/PHPCompatibility/PHPCompatibility/blob/8451ac21d652156e6742bbada166d28503ef67e4/PHPCompatibility/Sniffs/ControlStructures/NewExecutionDirectivesSniff.php#L69-L75 |
PHPCompatibility/PHPCompatibility | PHPCompatibility/Sniffs/ControlStructures/NewExecutionDirectivesSniff.php | NewExecutionDirectivesSniff.process | public function process(File $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();
if (isset($tokens[$stackPtr]['parenthesis_opener'], $tokens[$stackPtr]['parenthesis_closer']) === true) {
$openParenthesis = $tokens[$stackPtr]['parenthesis_opener'];
$closeParenthesis ... | php | public function process(File $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();
if (isset($tokens[$stackPtr]['parenthesis_opener'], $tokens[$stackPtr]['parenthesis_closer']) === true) {
$openParenthesis = $tokens[$stackPtr]['parenthesis_opener'];
$closeParenthesis ... | [
"public",
"function",
"process",
"(",
"File",
"$",
"phpcsFile",
",",
"$",
"stackPtr",
")",
"{",
"$",
"tokens",
"=",
"$",
"phpcsFile",
"->",
"getTokens",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"tokens",
"[",
"$",
"stackPtr",
"]",
"[",
"'parenthe... | Processes this test, when one of its tokens is encountered.
@param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
@param int $stackPtr The position of the current token in
the stack passed in $tokens.
@return void | [
"Processes",
"this",
"test",
"when",
"one",
"of",
"its",
"tokens",
"is",
"encountered",
"."
] | train | https://github.com/PHPCompatibility/PHPCompatibility/blob/8451ac21d652156e6742bbada166d28503ef67e4/PHPCompatibility/Sniffs/ControlStructures/NewExecutionDirectivesSniff.php#L87-L138 |
PHPCompatibility/PHPCompatibility | PHPCompatibility/Sniffs/ControlStructures/NewExecutionDirectivesSniff.php | NewExecutionDirectivesSniff.getErrorInfo | public function getErrorInfo(array $itemArray, array $itemInfo)
{
$errorInfo = parent::getErrorInfo($itemArray, $itemInfo);
$errorInfo['conditional_version'] = '';
$errorInfo['condition'] = '';
$versionArray = $this->getVersionArray($itemArray);
if (empty($version... | php | public function getErrorInfo(array $itemArray, array $itemInfo)
{
$errorInfo = parent::getErrorInfo($itemArray, $itemInfo);
$errorInfo['conditional_version'] = '';
$errorInfo['condition'] = '';
$versionArray = $this->getVersionArray($itemArray);
if (empty($version... | [
"public",
"function",
"getErrorInfo",
"(",
"array",
"$",
"itemArray",
",",
"array",
"$",
"itemInfo",
")",
"{",
"$",
"errorInfo",
"=",
"parent",
"::",
"getErrorInfo",
"(",
"$",
"itemArray",
",",
"$",
"itemInfo",
")",
";",
"$",
"errorInfo",
"[",
"'conditiona... | Retrieve the relevant detail (version) information for use in an error message.
@param array $itemArray Version and other information about the item.
@param array $itemInfo Base information about the item.
@return array | [
"Retrieve",
"the",
"relevant",
"detail",
"(",
"version",
")",
"information",
"for",
"use",
"in",
"an",
"error",
"message",
"."
] | train | https://github.com/PHPCompatibility/PHPCompatibility/blob/8451ac21d652156e6742bbada166d28503ef67e4/PHPCompatibility/Sniffs/ControlStructures/NewExecutionDirectivesSniff.php#L189-L208 |
PHPCompatibility/PHPCompatibility | PHPCompatibility/Sniffs/ControlStructures/NewExecutionDirectivesSniff.php | NewExecutionDirectivesSniff.addError | public function addError(File $phpcsFile, $stackPtr, array $itemInfo, array $errorInfo)
{
if ($errorInfo['not_in_version'] !== '') {
parent::addError($phpcsFile, $stackPtr, $itemInfo, $errorInfo);
} elseif ($errorInfo['conditional_version'] !== '') {
$error = 'Directive %... | php | public function addError(File $phpcsFile, $stackPtr, array $itemInfo, array $errorInfo)
{
if ($errorInfo['not_in_version'] !== '') {
parent::addError($phpcsFile, $stackPtr, $itemInfo, $errorInfo);
} elseif ($errorInfo['conditional_version'] !== '') {
$error = 'Directive %... | [
"public",
"function",
"addError",
"(",
"File",
"$",
"phpcsFile",
",",
"$",
"stackPtr",
",",
"array",
"$",
"itemInfo",
",",
"array",
"$",
"errorInfo",
")",
"{",
"if",
"(",
"$",
"errorInfo",
"[",
"'not_in_version'",
"]",
"!==",
"''",
")",
"{",
"parent",
... | Generates the error or warning for this item.
@param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
@param int $stackPtr The position of the relevant token in
the stack.
@param array $itemInfo Base information about the item.
@param array $errorInfo Array w... | [
"Generates",
"the",
"error",
"or",
"warning",
"for",
"this",
"item",
"."
] | train | https://github.com/PHPCompatibility/PHPCompatibility/blob/8451ac21d652156e6742bbada166d28503ef67e4/PHPCompatibility/Sniffs/ControlStructures/NewExecutionDirectivesSniff.php#L234-L249 |
PHPCompatibility/PHPCompatibility | PHPCompatibility/Sniffs/ControlStructures/NewExecutionDirectivesSniff.php | NewExecutionDirectivesSniff.addWarningOnInvalidValue | protected function addWarningOnInvalidValue(File $phpcsFile, $stackPtr, $directive)
{
$tokens = $phpcsFile->getTokens();
$value = $tokens[$stackPtr]['content'];
if (isset(Tokens::$stringTokens[$tokens[$stackPtr]['code']]) === true) {
$value = $this->stripQuotes($value);
... | php | protected function addWarningOnInvalidValue(File $phpcsFile, $stackPtr, $directive)
{
$tokens = $phpcsFile->getTokens();
$value = $tokens[$stackPtr]['content'];
if (isset(Tokens::$stringTokens[$tokens[$stackPtr]['code']]) === true) {
$value = $this->stripQuotes($value);
... | [
"protected",
"function",
"addWarningOnInvalidValue",
"(",
"File",
"$",
"phpcsFile",
",",
"$",
"stackPtr",
",",
"$",
"directive",
")",
"{",
"$",
"tokens",
"=",
"$",
"phpcsFile",
"->",
"getTokens",
"(",
")",
";",
"$",
"value",
"=",
"$",
"tokens",
"[",
"$",... | Generates a error or warning for this sniff.
@param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
@param int $stackPtr The position of the execution directive value
in the token array.
@param string $directive The directive.
@return void | [
"Generates",
"a",
"error",
"or",
"warning",
"for",
"this",
"sniff",
"."
] | train | https://github.com/PHPCompatibility/PHPCompatibility/blob/8451ac21d652156e6742bbada166d28503ef67e4/PHPCompatibility/Sniffs/ControlStructures/NewExecutionDirectivesSniff.php#L262-L293 |
PHPCompatibility/PHPCompatibility | PHPCompatibility/Sniffs/ControlStructures/NewExecutionDirectivesSniff.php | NewExecutionDirectivesSniff.validEncoding | protected function validEncoding($value)
{
static $encodings;
if (isset($encodings) === false && function_exists('mb_list_encodings')) {
$encodings = mb_list_encodings();
}
if (empty($encodings) || \is_array($encodings) === false) {
// If we can't test the en... | php | protected function validEncoding($value)
{
static $encodings;
if (isset($encodings) === false && function_exists('mb_list_encodings')) {
$encodings = mb_list_encodings();
}
if (empty($encodings) || \is_array($encodings) === false) {
// If we can't test the en... | [
"protected",
"function",
"validEncoding",
"(",
"$",
"value",
")",
"{",
"static",
"$",
"encodings",
";",
"if",
"(",
"isset",
"(",
"$",
"encodings",
")",
"===",
"false",
"&&",
"function_exists",
"(",
"'mb_list_encodings'",
")",
")",
"{",
"$",
"encodings",
"=... | Check whether a value is a valid encoding.
Callback function to test whether the value for an execution directive is valid.
@param mixed $value The value to test.
@return bool | [
"Check",
"whether",
"a",
"value",
"is",
"a",
"valid",
"encoding",
"."
] | train | https://github.com/PHPCompatibility/PHPCompatibility/blob/8451ac21d652156e6742bbada166d28503ef67e4/PHPCompatibility/Sniffs/ControlStructures/NewExecutionDirectivesSniff.php#L320-L333 |
PHPCompatibility/PHPCompatibility | PHPCompatibility/Sniffs/Operators/NewShortTernarySniff.php | NewShortTernarySniff.process | public function process(File $phpcsFile, $stackPtr)
{
if ($this->supportsBelow('5.2') === false) {
return;
}
$tokens = $phpcsFile->getTokens();
// Get next non-whitespace token, and check it isn't the related inline else
// symbol, which is not allowed prior to ... | php | public function process(File $phpcsFile, $stackPtr)
{
if ($this->supportsBelow('5.2') === false) {
return;
}
$tokens = $phpcsFile->getTokens();
// Get next non-whitespace token, and check it isn't the related inline else
// symbol, which is not allowed prior to ... | [
"public",
"function",
"process",
"(",
"File",
"$",
"phpcsFile",
",",
"$",
"stackPtr",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"supportsBelow",
"(",
"'5.2'",
")",
"===",
"false",
")",
"{",
"return",
";",
"}",
"$",
"tokens",
"=",
"$",
"phpcsFile",
"->"... | Processes this test, when one of its tokens is encountered.
@param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
@param int $stackPtr The position of the current token in the
stack passed in $tokens.
@return void | [
"Processes",
"this",
"test",
"when",
"one",
"of",
"its",
"tokens",
"is",
"encountered",
"."
] | train | https://github.com/PHPCompatibility/PHPCompatibility/blob/8451ac21d652156e6742bbada166d28503ef67e4/PHPCompatibility/Sniffs/Operators/NewShortTernarySniff.php#L54-L73 |
PHPCompatibility/PHPCompatibility | PHPCompatibility/Sniffs/ParameterValues/RemovedSetlocaleStringSniff.php | RemovedSetlocaleStringSniff.processParameters | public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
{
if (isset($parameters[1]) === false) {
return;
}
$tokens = $phpcsFile->getTokens();
$targetParam = $parameters[1];
for ($i = $targetParam['start']; $i <= $targetPara... | php | public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)
{
if (isset($parameters[1]) === false) {
return;
}
$tokens = $phpcsFile->getTokens();
$targetParam = $parameters[1];
for ($i = $targetParam['start']; $i <= $targetPara... | [
"public",
"function",
"processParameters",
"(",
"File",
"$",
"phpcsFile",
",",
"$",
"stackPtr",
",",
"$",
"functionName",
",",
"$",
"parameters",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"parameters",
"[",
"1",
"]",
")",
"===",
"false",
")",
"{",
"retur... | Process the parameters of a matched function.
@param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
@param int $stackPtr The position of the current token in the stack.
@param string $functionName The token content (function name) which was matched.
@param array ... | [
"Process",
"the",
"parameters",
"of",
"a",
"matched",
"function",
"."
] | train | https://github.com/PHPCompatibility/PHPCompatibility/blob/8451ac21d652156e6742bbada166d28503ef67e4/PHPCompatibility/Sniffs/ParameterValues/RemovedSetlocaleStringSniff.php#L66-L98 |
PHPCompatibility/PHPCompatibility | PHPCompatibility/Sniffs/FunctionNameRestrictions/NewMagicMethodsSniff.php | NewMagicMethodsSniff.process | public function process(File $phpcsFile, $stackPtr)
{
$functionName = $phpcsFile->getDeclarationName($stackPtr);
$functionNameLc = strtolower($functionName);
if (isset($this->newMagicMethods[$functionNameLc]) === false) {
return;
}
if ($this->inClassScope($php... | php | public function process(File $phpcsFile, $stackPtr)
{
$functionName = $phpcsFile->getDeclarationName($stackPtr);
$functionNameLc = strtolower($functionName);
if (isset($this->newMagicMethods[$functionNameLc]) === false) {
return;
}
if ($this->inClassScope($php... | [
"public",
"function",
"process",
"(",
"File",
"$",
"phpcsFile",
",",
"$",
"stackPtr",
")",
"{",
"$",
"functionName",
"=",
"$",
"phpcsFile",
"->",
"getDeclarationName",
"(",
"$",
"stackPtr",
")",
";",
"$",
"functionNameLc",
"=",
"strtolower",
"(",
"$",
"fun... | Processes this test, when one of its tokens is encountered.
@param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
@param int $stackPtr The position of the current token in the
stack passed in $tokens.
@return void | [
"Processes",
"this",
"test",
"when",
"one",
"of",
"its",
"tokens",
"is",
"encountered",
"."
] | train | https://github.com/PHPCompatibility/PHPCompatibility/blob/8451ac21d652156e6742bbada166d28503ef67e4/PHPCompatibility/Sniffs/FunctionNameRestrictions/NewMagicMethodsSniff.php#L99-L117 |
PHPCompatibility/PHPCompatibility | PHPCompatibility/Sniffs/FunctionNameRestrictions/NewMagicMethodsSniff.php | NewMagicMethodsSniff.getErrorInfo | public function getErrorInfo(array $itemArray, array $itemInfo)
{
$errorInfo = parent::getErrorInfo($itemArray, $itemInfo);
$errorInfo['error'] = false; // Warning, not error.
$errorInfo['message'] = '';
if (empty($itemArray['message']) === false) {
$errorIn... | php | public function getErrorInfo(array $itemArray, array $itemInfo)
{
$errorInfo = parent::getErrorInfo($itemArray, $itemInfo);
$errorInfo['error'] = false; // Warning, not error.
$errorInfo['message'] = '';
if (empty($itemArray['message']) === false) {
$errorIn... | [
"public",
"function",
"getErrorInfo",
"(",
"array",
"$",
"itemArray",
",",
"array",
"$",
"itemInfo",
")",
"{",
"$",
"errorInfo",
"=",
"parent",
"::",
"getErrorInfo",
"(",
"$",
"itemArray",
",",
"$",
"itemInfo",
")",
";",
"$",
"errorInfo",
"[",
"'error'",
... | Retrieve the relevant detail (version) information for use in an error message.
@param array $itemArray Version and other information about the item.
@param array $itemInfo Base information about the item.
@return array | [
"Retrieve",
"the",
"relevant",
"detail",
"(",
"version",
")",
"information",
"for",
"use",
"in",
"an",
"error",
"message",
"."
] | train | https://github.com/PHPCompatibility/PHPCompatibility/blob/8451ac21d652156e6742bbada166d28503ef67e4/PHPCompatibility/Sniffs/FunctionNameRestrictions/NewMagicMethodsSniff.php#L152-L163 |
PHPCompatibility/PHPCompatibility | PHPCompatibility/Sniffs/Lists/AssignmentOrderSniff.php | AssignmentOrderSniff.process | public function process(File $phpcsFile, $stackPtr)
{
if ($this->supportsAbove('7.0') === false) {
return;
}
$tokens = $phpcsFile->getTokens();
if ($tokens[$stackPtr]['code'] === \T_OPEN_SHORT_ARRAY
&& $this->isShortList($phpcsFile, $stackPtr) === false
... | php | public function process(File $phpcsFile, $stackPtr)
{
if ($this->supportsAbove('7.0') === false) {
return;
}
$tokens = $phpcsFile->getTokens();
if ($tokens[$stackPtr]['code'] === \T_OPEN_SHORT_ARRAY
&& $this->isShortList($phpcsFile, $stackPtr) === false
... | [
"public",
"function",
"process",
"(",
"File",
"$",
"phpcsFile",
",",
"$",
"stackPtr",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"supportsAbove",
"(",
"'7.0'",
")",
"===",
"false",
")",
"{",
"return",
";",
"}",
"$",
"tokens",
"=",
"$",
"phpcsFile",
"->"... | Processes this test, when one of its tokens is encountered.
@param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
@param int $stackPtr The position of the current token in the
stack passed in $tokens.
@return void|int Void if not a valid list. If a list construct has been
examined, the st... | [
"Processes",
"this",
"test",
"when",
"one",
"of",
"its",
"tokens",
"is",
"encountered",
"."
] | train | https://github.com/PHPCompatibility/PHPCompatibility/blob/8451ac21d652156e6742bbada166d28503ef67e4/PHPCompatibility/Sniffs/Lists/AssignmentOrderSniff.php#L58-L182 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.