diff --git a/src/Database/Attach/File.php b/src/Database/Attach/File.php index ce2d168d7..56abc28df 100644 --- a/src/Database/Attach/File.php +++ b/src/Database/Attach/File.php @@ -6,6 +6,7 @@ use Storage; use Response; use File as FileHelper; +use Illuminate\Support\Arr; use October\Rain\Database\Model; use October\Rain\Resize\Resizer; use Symfony\Component\HttpFoundation\File\UploadedFile; @@ -327,7 +328,7 @@ public function output($disposition = 'inline', $returnResponse = true) */ public function outputThumb($width, $height, $options = [], $returnResponse = true) { - $disposition = array_get($options, 'disposition', 'inline'); + $disposition = Arr::get($options, 'disposition', 'inline'); $options = $this->getDefaultThumbOptions($options); // Generate thumb if not existing already diff --git a/src/Database/Models/DeferredBinding.php b/src/Database/Models/DeferredBinding.php index 1fbc2500b..c7c600aa5 100644 --- a/src/Database/Models/DeferredBinding.php +++ b/src/Database/Models/DeferredBinding.php @@ -2,6 +2,7 @@ use Event; use Carbon\Carbon; +use Illuminate\Support\Arr; use October\Rain\Database\Model; use Throwable; @@ -209,12 +210,12 @@ protected function deleteSlaveRecord() } $options = $masterObject->getRelationDefinition($this->master_field); - if (!array_get($options, 'delete', false)) { + if (!Arr::get($options, 'delete', false)) { return; } // Only delete it if the relationship is null - $foreignKey = array_get($options, 'key', $masterObject->getForeignKey()); + $foreignKey = Arr::get($options, 'key', $masterObject->getForeignKey()); if ($foreignKey && !$relatedObj->$foreignKey) { $relatedObj->delete(); } diff --git a/src/Database/Relations/AttachOneOrMany.php b/src/Database/Relations/AttachOneOrMany.php index f8338c2e2..e5f953816 100644 --- a/src/Database/Relations/AttachOneOrMany.php +++ b/src/Database/Relations/AttachOneOrMany.php @@ -2,6 +2,7 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Builder; +use Illuminate\Support\Arr; use October\Rain\Database\Attach\File as FileModel; use Symfony\Component\HttpFoundation\File\UploadedFile; @@ -368,7 +369,7 @@ public function remove(Model $model, $sessionKey = null) $options = $this->parent->getRelationDefinition($this->relationName); - if (array_get($options, 'delete', false)) { + if (Arr::get($options, 'delete', false)) { $model->delete(); } else { @@ -477,7 +478,7 @@ protected function ensureRelationIsEmpty() { $options = $this->parent->getRelationDefinition($this->relationName); - if (array_get($options, 'delete', false)) { + if (Arr::get($options, 'delete', false)) { $this->delete(); } else { diff --git a/src/Database/Relations/DefinedConstraints.php b/src/Database/Relations/DefinedConstraints.php index 9aae1171e..a03c7897f 100644 --- a/src/Database/Relations/DefinedConstraints.php +++ b/src/Database/Relations/DefinedConstraints.php @@ -1,6 +1,7 @@ withDefault($defaultData); } // Pivot data (belongsToMany, morphToMany, morphByMany) - if ($pivotData = array_get($args, 'pivot')) { + if ($pivotData = Arr::get($args, 'pivot')) { $relation->withPivot($pivotData); } // Pivot incrementing key (belongsToMany, morphToMany, morphByMany) - if ($pivotKey = array_get($args, 'pivotKey')) { + if ($pivotKey = Arr::get($args, 'pivotKey')) { $relation->withPivot($pivotKey); } // Pivot timestamps (belongsToMany, morphToMany, morphByMany) - if (array_get($args, 'timestamps')) { + if (Arr::get($args, 'timestamps')) { $relation->withTimestamps(); } // Count "helper" relation // @deprecated use Laravel withCount() method instead - if (array_get($args, 'count')) { + if (Arr::get($args, 'count')) { if ($relation instanceof BelongsToManyBase) { $relation->countMode = true; $keyName = $relation->getQualifiedForeignPivotKeyName(); @@ -79,14 +80,14 @@ public function addDefinedConstraintsToQuery($query, ?array $args = null) } // Conditions - if ($conditions = array_get($args, 'conditions')) { + if ($conditions = Arr::get($args, 'conditions')) { $query->whereRaw($conditions); } // Sort order // @deprecated count is deprecated - $hasCountArg = array_get($args, 'count') !== null; - if (($orderBy = array_get($args, 'order')) && !$hasCountArg) { + $hasCountArg = Arr::get($args, 'count') !== null; + if (($orderBy = Arr::get($args, 'order')) && !$hasCountArg) { if (!is_array($orderBy)) { $orderBy = [$orderBy]; } @@ -105,7 +106,7 @@ public function addDefinedConstraintsToQuery($query, ?array $args = null) } // Scope - if ($scope = array_get($args, 'scope')) { + if ($scope = Arr::get($args, 'scope')) { if (is_string($scope)) { $query->$scope($this->parent); } diff --git a/src/Database/Relations/HasOneOrMany.php b/src/Database/Relations/HasOneOrMany.php index 6415fd539..eaed01905 100644 --- a/src/Database/Relations/HasOneOrMany.php +++ b/src/Database/Relations/HasOneOrMany.php @@ -1,6 +1,7 @@ parent->getRelationDefinition($this->relationName); // Delete or orphan the model - if (array_get($options, 'delete', false)) { + if (Arr::get($options, 'delete', false)) { $model->delete(); } else { @@ -304,7 +305,7 @@ protected function ensureRelationIsEmpty() { $options = $this->parent->getRelationDefinition($this->relationName); - if (array_get($options, 'delete', false)) { + if (Arr::get($options, 'delete', false)) { $this->delete(); } else { diff --git a/src/Database/Relations/MorphOneOrMany.php b/src/Database/Relations/MorphOneOrMany.php index 0fada3094..f52f599c9 100644 --- a/src/Database/Relations/MorphOneOrMany.php +++ b/src/Database/Relations/MorphOneOrMany.php @@ -1,6 +1,7 @@ parent->getRelationDefinition($this->relationName); // Delete or orphan the model - if (array_get($options, 'delete', false)) { + if (Arr::get($options, 'delete', false)) { $model->delete(); } else { @@ -298,7 +299,7 @@ protected function ensureRelationIsEmpty() { $options = $this->parent->getRelationDefinition($this->relationName); - if (array_get($options, 'delete', false)) { + if (Arr::get($options, 'delete', false)) { $this->delete(); } else { diff --git a/src/Database/Traits/Encryptable.php b/src/Database/Traits/Encryptable.php index b30495699..098be36d4 100644 --- a/src/Database/Traits/Encryptable.php +++ b/src/Database/Traits/Encryptable.php @@ -2,6 +2,7 @@ use Crypt; use Exception; +use Illuminate\Support\Arr; /** * Encryptable database trait @@ -49,8 +50,8 @@ public function initializeEncryptable() $this->bindEvent('model.beforeGetAttribute', function ($key) { if ( in_array($key, $this->getEncryptableAttributes()) && - array_get($this->attributes, $key) !== null && - array_get($this->attributes, $key) !== '' + Arr::get($this->attributes, $key) !== null && + Arr::get($this->attributes, $key) !== '' ) { return $this->getEncryptableValue($key); } diff --git a/src/Database/Traits/Multisite.php b/src/Database/Traits/Multisite.php index 1fb31edb5..e5500c886 100644 --- a/src/Database/Traits/Multisite.php +++ b/src/Database/Traits/Multisite.php @@ -1,5 +1,6 @@ propagatableSync, $key, $default); + return Arr::get($this->propagatableSync, $key, $default); } /** diff --git a/src/Database/Traits/Revisionable.php b/src/Database/Traits/Revisionable.php index e7bda43db..be457928a 100644 --- a/src/Database/Traits/Revisionable.php +++ b/src/Database/Traits/Revisionable.php @@ -4,6 +4,7 @@ use Exception; use DateTime; use Illuminate\Database\Eloquent\Model as EloquentModel; +use Illuminate\Support\Arr; /** * Revisionable trait tracks changes to specific attributes @@ -79,7 +80,7 @@ public function revisionableAfterUpdate() $toSave[] = [ 'field' => $attribute, - 'old_value' => array_get($this->original, $attribute), + 'old_value' => Arr::get($this->original, $attribute), 'new_value' => $value, 'revisionable_type' => $relationObject->getMorphClass(), 'revisionable_id' => $this->getKey(), diff --git a/src/Database/Traits/SimpleTree.php b/src/Database/Traits/SimpleTree.php index e3a0aaf60..5fe45aeb8 100644 --- a/src/Database/Traits/SimpleTree.php +++ b/src/Database/Traits/SimpleTree.php @@ -1,5 +1,6 @@ {$idName}, []); + $childItems = Arr::get($map, $item->{$idName}, []); if (count($childItems) > 0) { $result = $result + $buildCollection($childItems, $map, $depth + 1); } diff --git a/src/Database/Traits/SoftDelete.php b/src/Database/Traits/SoftDelete.php index 19b6fef59..1a1e3d2d4 100644 --- a/src/Database/Traits/SoftDelete.php +++ b/src/Database/Traits/SoftDelete.php @@ -2,6 +2,7 @@ use Illuminate\Database\Eloquent\Model as EloquentModel; use Illuminate\Database\Eloquent\Collection as CollectionBase; +use Illuminate\Support\Arr; use October\Rain\Database\Scopes\SoftDeleteScope; /** @@ -129,7 +130,7 @@ protected function performSoftDeleteOnRelations() $definitions = $this->getRelationDefinitions(); foreach ($definitions as $type => $relations) { foreach ($relations as $name => $options) { - if (!array_get($options, 'softDelete', false)) { + if (!Arr::get($options, 'softDelete', false)) { continue; } @@ -213,7 +214,7 @@ protected function performRestoreOnRelations() $definitions = $this->getRelationDefinitions(); foreach ($definitions as $type => $relations) { foreach ($relations as $name => $options) { - if (!array_get($options, 'softDelete', false)) { + if (!Arr::get($options, 'softDelete', false)) { continue; } diff --git a/src/Halcyon/Builder.php b/src/Halcyon/Builder.php index 2a8a85d54..045cd3037 100644 --- a/src/Halcyon/Builder.php +++ b/src/Halcyon/Builder.php @@ -1,6 +1,7 @@ selectSingle; diff --git a/src/Halcyon/Datasource/AutoDatasource.php b/src/Halcyon/Datasource/AutoDatasource.php index 7677a740b..c16e59824 100644 --- a/src/Halcyon/Datasource/AutoDatasource.php +++ b/src/Halcyon/Datasource/AutoDatasource.php @@ -1,5 +1,6 @@ datasources = $datasources; - $this->primaryDatasource = array_first($datasources); + $this->primaryDatasource = Arr::first($datasources); $this->postProcessor = new Processor; } diff --git a/src/Halcyon/Processors/Processor.php b/src/Halcyon/Processors/Processor.php index 1d9ef4269..84ee792a0 100644 --- a/src/Halcyon/Processors/Processor.php +++ b/src/Halcyon/Processors/Processor.php @@ -1,5 +1,6 @@ $this->parseTemplateContent($query, $result, $fileName)]; } @@ -45,7 +46,7 @@ public function processSelect(Builder $query, $results) $items = []; foreach ($results as $result) { - $fileName = array_get($result, 'fileName'); + $fileName = Arr::get($result, 'fileName'); $items[$fileName] = $this->parseTemplateContent($query, $result, $fileName); } @@ -64,14 +65,14 @@ protected function parseTemplateContent($query, $result, $fileName) 'isCompoundObject' => $query->getModel()->isCompoundObject() ]; - $content = array_get($result, 'content'); + $content = Arr::get($result, 'content'); $processed = SectionParser::parse($content, $options); return [ 'fileName' => $fileName, 'content' => $content, - 'mtime' => array_get($result, 'mtime'), + 'mtime' => Arr::get($result, 'mtime'), 'markup' => $processed['markup'], 'code' => $processed['code'] ] + $processed['settings']; diff --git a/src/Halcyon/Traits/Validation.php b/src/Halcyon/Traits/Validation.php index 7a0c6dfef..b074e9488 100644 --- a/src/Halcyon/Traits/Validation.php +++ b/src/Halcyon/Traits/Validation.php @@ -1,9 +1,10 @@ validate([], []); } diff --git a/src/Html/FormBuilder.php b/src/Html/FormBuilder.php index 8a8bbcd2f..a92fdcdc5 100644 --- a/src/Html/FormBuilder.php +++ b/src/Html/FormBuilder.php @@ -2,6 +2,7 @@ use Illuminate\Session\Store as Session; use Illuminate\Routing\UrlGenerator as UrlGeneratorBase; +use Illuminate\Support\Arr; /** * FormBuilder @@ -114,9 +115,9 @@ public function __construct(HtmlBuilder $html, UrlGeneratorBase $url, $csrfToken */ public function open(array $options = []) { - $method = strtoupper(array_get($options, 'method', 'post')); - $request = array_get($options, 'request'); - $model = array_get($options, 'model'); + $method = strtoupper(Arr::get($options, 'method', 'post')); + $request = Arr::get($options, 'request'); + $model = Arr::get($options, 'model'); if ($model) { $this->model = $model; @@ -125,7 +126,7 @@ public function open(array $options = []) $append = $this->requestHandler($request); if ($method !== 'GET') { - $append .= $this->sessionKey(array_get($options, 'sessionKey')); + $append .= $this->sessionKey(Arr::get($options, 'sessionKey')); } $attributes = []; @@ -153,7 +154,7 @@ public function open(array $options = []) // is used to spoof requests for this PUT, PATCH, etc. methods on forms. $attributes = array_merge( $attributes, - array_except($options, $this->reserved) + Arr::except($options, $this->reserved) ); // Finally, we will concatenate all of the attributes into a single string so @@ -178,7 +179,7 @@ public function ajax($handler, array $options = []) $attributes = array_merge([ 'data-request' => $handler - ], array_except($options, $this->reservedAjax)); + ], Arr::except($options, $this->reservedAjax)); $ajaxAttributes = array_diff_key($options, $attributes); foreach ($ajaxAttributes as $property => $value) { @@ -436,9 +437,9 @@ protected function setTextAreaSize($options) // If the "size" attribute was not specified, we will just look for the regular // columns and rows attributes, using sane defaults if these do not exist on // the attributes array. We'll then return this entire options array back. - $cols = array_get($options, 'cols', 50); + $cols = Arr::get($options, 'cols', 50); - $rows = array_get($options, 'rows', 10); + $rows = Arr::get($options, 'rows', 10); return array_merge($options, compact('cols', 'rows')); } @@ -978,7 +979,7 @@ protected function getModelValueAttribute($name) return object_get($this->model, $this->transformKey($name)); } elseif (is_array($this->model)) { - return array_get($this->model, $this->transformKey($name)); + return Arr::get($this->model, $this->transformKey($name)); } } diff --git a/src/Mail/Mailer.php b/src/Mail/Mailer.php index 8dba37d5e..1a2c56aae 100644 --- a/src/Mail/Mailer.php +++ b/src/Mail/Mailer.php @@ -7,6 +7,7 @@ use Illuminate\Mail\Mailer as MailerBase; use Illuminate\Mail\SentMessage; use Illuminate\Contracts\Mail\Mailable as MailableContract; +use Illuminate\Support\Arr; use Illuminate\Support\Collection; /** @@ -386,11 +387,11 @@ protected function processRecipients($recipients) $result[$address] = $name; } elseif (is_array($person)) { - if (!$address = array_get($person, 'email', array_get($person, 'address'))) { + if (!$address = Arr::get($person, 'email', Arr::get($person, 'address'))) { continue; } - $result[$address] = array_get($person, 'name'); + $result[$address] = Arr::get($person, 'name'); } } } @@ -457,7 +458,7 @@ protected function addContent($message, $view, $plain, $raw, $data) $customSubject = $message->getSymfonyMessage()->getSubject(); if ( empty($customSubject) && - ($subject = array_get($result['settings'], 'subject')) + ($subject = Arr::get($result['settings'], 'subject')) ) { $message->subject($subject); } diff --git a/src/Network/Http.php b/src/Network/Http.php index 155de48fa..d64569920 100644 --- a/src/Network/Http.php +++ b/src/Network/Http.php @@ -1,5 +1,6 @@ redirectCount = $this->maxRedirects; } if (in_array($this->code, [301, 302])) { - $this->url = array_get($this->info, 'redirect_url'); + $this->url = Arr::get($this->info, 'redirect_url'); if (!empty($this->url) && $this->redirectCount > 0) { $this->redirectCount -= 1; return $this->send(); diff --git a/src/Parse/Syntax/FieldParser.php b/src/Parse/Syntax/FieldParser.php index 47ecb3c4b..840a1d60a 100644 --- a/src/Parse/Syntax/FieldParser.php +++ b/src/Parse/Syntax/FieldParser.php @@ -1,6 +1,7 @@ tagPrefix = array_get($options, 'tagPrefix', ''); + $this->tagPrefix = Arr::get($options, 'tagPrefix', ''); $this->template = $template; $this->processTemplate($template); } @@ -170,7 +171,7 @@ public function getDefaultParams($fields = null) if ($params['type'] === 'repeater') { $defaults[$field] = []; - $defaults[$field][] = $this->getDefaultParams(array_get($params, 'fields', [])); + $defaults[$field][] = $this->getDefaultParams(Arr::get($params, 'fields', [])); } else { $defaults[$field] = $params['default'] ?? null; @@ -253,7 +254,7 @@ protected function processTags($template, $usingTags = null) if ($tagName === 'variable') { $params['X_OCTOBER_IS_VARIABLE'] = true; - $tagName = array_get($params, 'type', 'text'); + $tagName = Arr::get($params, 'type', 'text'); } $params['type'] = $tagName; diff --git a/src/Parse/Syntax/Parser.php b/src/Parse/Syntax/Parser.php index 59942edf5..0636a8c99 100644 --- a/src/Parse/Syntax/Parser.php +++ b/src/Parse/Syntax/Parser.php @@ -1,5 +1,6 @@ template = $template; - $this->varPrefix = array_get($options, 'varPrefix', ''); + $this->varPrefix = Arr::get($options, 'varPrefix', ''); $this->fieldParser = new FieldParser($template, $options); $textFilters = [ @@ -145,7 +146,7 @@ protected function processRepeatingTag($engine, $template, $field, $tagDetails) { $prefixField = $this->varPrefix.$field; $params = $this->fieldParser->getFieldParams($field); - $innerFields = array_get($params, 'fields', []); + $innerFields = Arr::get($params, 'fields', []); $innerTags = $tagDetails['tags']; $innerTemplate = $tagDetails['template']; @@ -153,7 +154,7 @@ protected function processRepeatingTag($engine, $template, $field, $tagDetails) * Replace all the inner tags */ foreach ($innerTags as $innerField => $tagString) { - $innerParams = array_get($innerFields, $innerField, []); + $innerParams = Arr::get($innerFields, $innerField, []); $tagReplacement = $this->{'eval'.$engine.'ViewField'}($innerField, $innerParams, 'fields'); $innerTemplate = str_replace($tagString, $tagReplacement, $innerTemplate); } @@ -161,7 +162,7 @@ protected function processRepeatingTag($engine, $template, $field, $tagDetails) /* * Replace the opening tag */ - $openTag = array_get($tagDetails, 'open', '{repeater}'); + $openTag = Arr::get($tagDetails, 'open', '{repeater}'); $openReplacement = $engine === 'Twig' ? '{% for fields in '.$prefixField.' %}' : '{'.$prefixField.'}'; $openReplacement = $openReplacement . PHP_EOL; $innerTemplate = str_replace($openTag, $openReplacement, $innerTemplate); @@ -169,7 +170,7 @@ protected function processRepeatingTag($engine, $template, $field, $tagDetails) /* * Replace the closing tag */ - $closeTag = array_get($tagDetails, 'close', '{/repeater}'); + $closeTag = Arr::get($tagDetails, 'close', '{/repeater}'); $closeReplacement = $engine === 'Twig' ? '{% endfor %}' : '{/'.$prefixField.'}'; $closeReplacement = PHP_EOL . $closeReplacement; $innerTemplate = str_replace($closeTag, $closeReplacement, $innerTemplate); diff --git a/src/Parse/Syntax/SyntaxModelTrait.php b/src/Parse/Syntax/SyntaxModelTrait.php index c48e3cf0b..e59765691 100644 --- a/src/Parse/Syntax/SyntaxModelTrait.php +++ b/src/Parse/Syntax/SyntaxModelTrait.php @@ -1,5 +1,6 @@ getThumb($imageWidth, $imageHeight, ['mode' => 'crop']); } @@ -136,7 +137,7 @@ public function getFormSyntaxFields() } if ($params['type'] === 'repeater') { - $params['form']['fields'] = array_get($params, 'fields', []); + $params['form']['fields'] = Arr::get($params, 'fields', []); unset($params['fields']); }