Skip to content

Commit c199db1

Browse files
authored
do not use mix of newline and inline formatting (#54967)
fully newline or fully inline are both okay options for formatting, but this mix of both is very hard to read, especially when you're throwing ternary statements in there. this commit switches these into purely newline format.
1 parent 0dd71ef commit c199db1

File tree

1 file changed

+98
-30
lines changed

1 file changed

+98
-30
lines changed

src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php

Lines changed: 98 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,13 @@ public function hasOneThrough($related, $through, $firstKey = null, $secondKey =
153153
$secondKey = $secondKey ?: $through->getForeignKey();
154154

155155
return $this->newHasOneThrough(
156-
$this->newRelatedInstance($related)->newQuery(), $this, $through,
157-
$firstKey, $secondKey, $localKey ?: $this->getKeyName(),
158-
$secondLocalKey ?: $through->getKeyName()
156+
$this->newRelatedInstance($related)->newQuery(),
157+
$this,
158+
$through,
159+
$firstKey,
160+
$secondKey,
161+
$localKey ?: $this->getKeyName(),
162+
$secondLocalKey ?: $through->getKeyName(),
159163
);
160164
}
161165

@@ -562,9 +566,15 @@ protected function newMorphMany(Builder $query, Model $parent, $type, $id, $loca
562566
* @param string|null $relation
563567
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<TRelatedModel, $this>
564568
*/
565-
public function belongsToMany($related, $table = null, $foreignPivotKey = null, $relatedPivotKey = null,
566-
$parentKey = null, $relatedKey = null, $relation = null)
567-
{
569+
public function belongsToMany(
570+
$related,
571+
$table = null,
572+
$foreignPivotKey = null,
573+
$relatedPivotKey = null,
574+
$parentKey = null,
575+
$relatedKey = null,
576+
$relation = null,
577+
) {
568578
// If no relationship name was passed, we will pull backtraces to get the
569579
// name of the calling function. We will use that function name as the
570580
// title of this relation since that is a great convention to apply.
@@ -589,9 +599,14 @@ public function belongsToMany($related, $table = null, $foreignPivotKey = null,
589599
}
590600

591601
return $this->newBelongsToMany(
592-
$instance->newQuery(), $this, $table, $foreignPivotKey,
593-
$relatedPivotKey, $parentKey ?: $this->getKeyName(),
594-
$relatedKey ?: $instance->getKeyName(), $relation
602+
$instance->newQuery(),
603+
$this,
604+
$table,
605+
$foreignPivotKey,
606+
$relatedPivotKey,
607+
$parentKey ?: $this->getKeyName(),
608+
$relatedKey ?: $instance->getKeyName(),
609+
$relation,
595610
);
596611
}
597612

@@ -611,9 +626,16 @@ public function belongsToMany($related, $table = null, $foreignPivotKey = null,
611626
* @param string|null $relationName
612627
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<TRelatedModel, TDeclaringModel>
613628
*/
614-
protected function newBelongsToMany(Builder $query, Model $parent, $table, $foreignPivotKey, $relatedPivotKey,
615-
$parentKey, $relatedKey, $relationName = null)
616-
{
629+
protected function newBelongsToMany(
630+
Builder $query,
631+
Model $parent,
632+
$table,
633+
$foreignPivotKey,
634+
$relatedPivotKey,
635+
$parentKey,
636+
$relatedKey,
637+
$relationName = null,
638+
) {
617639
return new BelongsToMany($query, $parent, $table, $foreignPivotKey, $relatedPivotKey, $parentKey, $relatedKey, $relationName);
618640
}
619641

@@ -633,10 +655,17 @@ protected function newBelongsToMany(Builder $query, Model $parent, $table, $fore
633655
* @param bool $inverse
634656
* @return \Illuminate\Database\Eloquent\Relations\MorphToMany<TRelatedModel, $this>
635657
*/
636-
public function morphToMany($related, $name, $table = null, $foreignPivotKey = null,
637-
$relatedPivotKey = null, $parentKey = null,
638-
$relatedKey = null, $relation = null, $inverse = false)
639-
{
658+
public function morphToMany(
659+
$related,
660+
$name,
661+
$table = null,
662+
$foreignPivotKey = null,
663+
$relatedPivotKey = null,
664+
$parentKey = null,
665+
$relatedKey = null,
666+
$relation = null,
667+
$inverse = false,
668+
) {
640669
$relation = $relation ?: $this->guessBelongsToManyRelation();
641670

642671
// First, we will need to determine the foreign key and "other key" for the
@@ -660,9 +689,16 @@ public function morphToMany($related, $name, $table = null, $foreignPivotKey = n
660689
}
661690

662691
return $this->newMorphToMany(
663-
$instance->newQuery(), $this, $name, $table,
664-
$foreignPivotKey, $relatedPivotKey, $parentKey ?: $this->getKeyName(),
665-
$relatedKey ?: $instance->getKeyName(), $relation, $inverse
692+
$instance->newQuery(),
693+
$this,
694+
$name,
695+
$table,
696+
$foreignPivotKey,
697+
$relatedPivotKey,
698+
$parentKey ?: $this->getKeyName(),
699+
$relatedKey ?: $instance->getKeyName(),
700+
$relation,
701+
$inverse,
666702
);
667703
}
668704

@@ -684,12 +720,30 @@ public function morphToMany($related, $name, $table = null, $foreignPivotKey = n
684720
* @param bool $inverse
685721
* @return \Illuminate\Database\Eloquent\Relations\MorphToMany<TRelatedModel, TDeclaringModel>
686722
*/
687-
protected function newMorphToMany(Builder $query, Model $parent, $name, $table, $foreignPivotKey,
688-
$relatedPivotKey, $parentKey, $relatedKey,
689-
$relationName = null, $inverse = false)
690-
{
691-
return new MorphToMany($query, $parent, $name, $table, $foreignPivotKey, $relatedPivotKey, $parentKey, $relatedKey,
692-
$relationName, $inverse);
723+
protected function newMorphToMany(
724+
Builder $query,
725+
Model $parent,
726+
$name,
727+
$table,
728+
$foreignPivotKey,
729+
$relatedPivotKey,
730+
$parentKey,
731+
$relatedKey,
732+
$relationName = null,
733+
$inverse = false,
734+
) {
735+
return new MorphToMany(
736+
$query,
737+
$parent,
738+
$name,
739+
$table,
740+
$foreignPivotKey,
741+
$relatedPivotKey,
742+
$parentKey,
743+
$relatedKey,
744+
$relationName,
745+
$inverse,
746+
);
693747
}
694748

695749
/**
@@ -707,9 +761,16 @@ protected function newMorphToMany(Builder $query, Model $parent, $name, $table,
707761
* @param string|null $relation
708762
* @return \Illuminate\Database\Eloquent\Relations\MorphToMany<TRelatedModel, $this>
709763
*/
710-
public function morphedByMany($related, $name, $table = null, $foreignPivotKey = null,
711-
$relatedPivotKey = null, $parentKey = null, $relatedKey = null, $relation = null)
712-
{
764+
public function morphedByMany(
765+
$related,
766+
$name,
767+
$table = null,
768+
$foreignPivotKey = null,
769+
$relatedPivotKey = null,
770+
$parentKey = null,
771+
$relatedKey = null,
772+
$relation = null,
773+
) {
713774
$foreignPivotKey = $foreignPivotKey ?: $this->getForeignKey();
714775

715776
// For the inverse of the polymorphic many-to-many relations, we will change
@@ -718,8 +779,15 @@ public function morphedByMany($related, $name, $table = null, $foreignPivotKey =
718779
$relatedPivotKey = $relatedPivotKey ?: $name.'_id';
719780

720781
return $this->morphToMany(
721-
$related, $name, $table, $foreignPivotKey,
722-
$relatedPivotKey, $parentKey, $relatedKey, $relation, true
782+
$related,
783+
$name,
784+
$table,
785+
$foreignPivotKey,
786+
$relatedPivotKey,
787+
$parentKey,
788+
$relatedKey,
789+
$relation,
790+
true,
723791
);
724792
}
725793

0 commit comments

Comments
 (0)