@@ -81,10 +81,10 @@ public function __construct(Query $query)
8181 */
8282 public function getRelations (Model $ model )
8383 {
84- if (! $ this ->relations ->contains ($ model )) {
84+ if (! $ this ->relations ->offsetExists ($ model )) {
8585 $ relations = new Relations ();
8686 $ model ->createRelations ($ relations );
87- $ this ->relations ->attach ($ model , $ relations );
87+ $ this ->relations ->offsetSet ($ model , $ relations );
8888 }
8989
9090 return $ this ->relations [$ model ];
@@ -99,10 +99,10 @@ public function getRelations(Model $model)
9999 */
100100 public function getBehaviors (Model $ model )
101101 {
102- if (! $ this ->behaviors ->contains ($ model )) {
102+ if (! $ this ->behaviors ->offsetExists ($ model )) {
103103 $ behaviors = new Behaviors ();
104104 $ model ->createBehaviors ($ behaviors );
105- $ this ->behaviors ->attach ($ model , $ behaviors );
105+ $ this ->behaviors ->offsetSet ($ model , $ behaviors );
106106
107107 foreach ($ behaviors as $ behavior ) {
108108 if ($ behavior instanceof QueryAwareBehavior) {
@@ -123,10 +123,10 @@ public function getBehaviors(Model $model)
123123 */
124124 public function getDefaults (Model $ model ): Defaults
125125 {
126- if (! $ this ->defaults ->contains ($ model )) {
126+ if (! $ this ->defaults ->offsetExists ($ model )) {
127127 $ defaults = new Defaults ();
128128 $ model ->createDefaults ($ defaults );
129- $ this ->defaults ->attach ($ model , $ defaults );
129+ $ this ->defaults ->offsetSet ($ model , $ defaults );
130130 }
131131
132132 return $ this ->defaults [$ model ];
@@ -143,7 +143,7 @@ public function getDefaults(Model $model): Defaults
143143 */
144144 public function getAlias (Model $ model )
145145 {
146- if (! $ this ->aliases ->contains ($ model )) {
146+ if (! $ this ->aliases ->offsetExists ($ model )) {
147147 throw new OutOfBoundsException (sprintf (
148148 "Can't get alias for model '%s'. Alias does not exist " ,
149149 get_class ($ model )
@@ -202,7 +202,7 @@ public function setAliasPrefix($alias)
202202 */
203203 public function hasSelectableColumn (Model $ subject , $ column )
204204 {
205- if (! $ this ->selectableColumns ->contains ($ subject )) {
205+ if (! $ this ->selectableColumns ->offsetExists ($ subject )) {
206206 $ this ->collectColumns ($ subject );
207207 }
208208
@@ -223,7 +223,7 @@ public function hasSelectableColumn(Model $subject, $column)
223223 */
224224 public function getSelectableColumns (Model $ subject )
225225 {
226- if (! $ this ->selectableColumns ->contains ($ subject )) {
226+ if (! $ this ->selectableColumns ->offsetExists ($ subject )) {
227227 $ this ->collectColumns ($ subject );
228228 }
229229
@@ -239,7 +239,7 @@ public function getSelectableColumns(Model $subject)
239239 */
240240 public function getSelectColumns (Model $ subject )
241241 {
242- if (! $ this ->selectColumns ->contains ($ subject )) {
242+ if (! $ this ->selectColumns ->offsetExists ($ subject )) {
243243 $ this ->collectColumns ($ subject );
244244 }
245245
@@ -255,8 +255,8 @@ public function getSelectColumns(Model $subject)
255255 */
256256 public function getColumnDefinitions (Model $ subject )
257257 {
258- if (! $ this ->metaData ->contains ($ subject )) {
259- $ this ->metaData ->attach ($ subject , $ this ->collectMetaData ($ subject ));
258+ if (! $ this ->metaData ->offsetExists ($ subject )) {
259+ $ this ->metaData ->offsetSet ($ subject , $ this ->collectMetaData ($ subject ));
260260 }
261261
262262 return $ this ->metaData [$ subject ];
@@ -329,14 +329,14 @@ public function qualifyColumn($column, $tableName)
329329 * Qualify the given columns by the specified model
330330 *
331331 * @param iterable $columns
332- * @param Model $model Leave null in case $columns is {@see Resolver::requireAndResolveColumns()}
332+ * @param ? Model $model Leave null in case $columns is {@see Resolver::requireAndResolveColumns()}
333333 *
334334 * @return array
335335 *
336336 * @throws InvalidArgumentException If $columns is not iterable
337337 * @throws InvalidArgumentException If $model is not passed and $columns is not a generator
338338 */
339- public function qualifyColumns ($ columns , Model $ model = null )
339+ public function qualifyColumns ($ columns , ? Model $ model = null )
340340 {
341341 $ target = $ model ?: $ this ->query ->getModel ();
342342 $ targetAlias = $ this ->getAlias ($ target );
@@ -382,15 +382,15 @@ public function qualifyColumns($columns, Model $model = null)
382382 * Qualify the given columns and aliases by the specified model
383383 *
384384 * @param iterable $columns
385- * @param Model $model Leave null in case $columns is {@see Resolver::requireAndResolveColumns()}
385+ * @param ? Model $model Leave null in case $columns is {@see Resolver::requireAndResolveColumns()}
386386 * @param bool $autoAlias Set an alias for columns which have none
387387 *
388388 * @return array
389389 *
390390 * @throws InvalidArgumentException If $columns is not iterable
391391 * @throws InvalidArgumentException If $model is not passed and $columns is not a generator
392392 */
393- public function qualifyColumnsAndAliases ($ columns , Model $ model = null , $ autoAlias = true )
393+ public function qualifyColumnsAndAliases ($ columns , ? Model $ model = null , $ autoAlias = true )
394394 {
395395 $ target = $ model ?: $ this ->query ->getModel ();
396396 $ targetAlias = $ this ->getAlias ($ target );
@@ -492,14 +492,14 @@ public function isDistinctRelation($path)
492492 * Also resolves all other relations.
493493 *
494494 * @param string $path
495- * @param Model $subject
495+ * @param ? Model $subject
496496 *
497497 * @return Relation
498498 */
499- public function resolveRelation ($ path , Model $ subject = null )
499+ public function resolveRelation ($ path , ? Model $ subject = null )
500500 {
501501 $ subject = $ subject ?: $ this ->query ->getModel ();
502- if (! $ this ->resolvedRelations ->contains ($ subject ) || ! isset ($ this ->resolvedRelations [$ subject ][$ path ])) {
502+ if (! $ this ->resolvedRelations ->offsetExists ($ subject ) || ! isset ($ this ->resolvedRelations [$ subject ][$ path ])) {
503503 foreach ($ this ->resolveRelations ($ path , $ subject ) as $ _ ) {
504504 // run and exhaust generator
505505 }
@@ -514,13 +514,13 @@ public function resolveRelation($path, Model $subject = null)
514514 * Traverses the entire path and yields the path travelled so far as key and the relation as value.
515515 *
516516 * @param string $path
517- * @param Model $subject
517+ * @param ? Model $subject
518518 *
519519 * @return Generator
520520 * @throws InvalidArgumentException In case $path is not fully qualified
521521 * @throws InvalidRelationException In case a relation is unknown
522522 */
523- public function resolveRelations ($ path , Model $ subject = null )
523+ public function resolveRelations ($ path , ? Model $ subject = null )
524524 {
525525 $ relations = explode ('. ' , $ path );
526526 $ subject = $ subject ?: $ this ->query ->getModel ();
@@ -533,7 +533,7 @@ public function resolveRelations($path, Model $subject = null)
533533 }
534534
535535 $ resolvedRelations = [];
536- if ($ this ->resolvedRelations ->contains ($ subject )) {
536+ if ($ this ->resolvedRelations ->offsetExists ($ subject )) {
537537 $ resolvedRelations = $ this ->resolvedRelations [$ subject ];
538538 }
539539
@@ -585,22 +585,22 @@ public function resolveRelations($path, Model $subject = null)
585585 $ resolvedRelations [$ pathBeingResolved ] = $ relation ;
586586 }
587587
588- $ this ->resolvedRelations ->attach ($ subject , $ resolvedRelations );
588+ $ this ->resolvedRelations ->offsetSet ($ subject , $ resolvedRelations );
589589 }
590590
591591 /**
592592 * Require and resolve columns
593593 *
594594 * Related models will be automatically added for eager-loading.
595595 *
596- * @param array $columns
597- * @param Model $model
596+ * @param array $columns
597+ * @param ? Model $model
598598 *
599599 * @return Generator
600600 *
601601 * @throws InvalidColumnException If a column does not exist
602602 */
603- public function requireAndResolveColumns (array $ columns , Model $ model = null )
603+ public function requireAndResolveColumns (array $ columns , ? Model $ model = null )
604604 {
605605 $ model = $ model ?: $ this ->query ->getModel ();
606606 $ tableName = $ model ->getTableAlias ();
@@ -745,7 +745,7 @@ protected function collectColumns(Model $subject)
745745 // Don't fail if Model::getColumns() also contains the primary key columns
746746 $ columns = array_merge ((array ) $ subject ->getKeyName (), (array ) $ subject ->getColumns ());
747747
748- $ this ->selectColumns ->attach ($ subject , $ columns );
748+ $ this ->selectColumns ->offsetSet ($ subject , $ columns );
749749
750750 $ selectable = [];
751751
@@ -759,7 +759,7 @@ protected function collectColumns(Model $subject)
759759 }
760760 }
761761
762- $ this ->selectableColumns ->attach ($ subject , $ selectable );
762+ $ this ->selectableColumns ->offsetSet ($ subject , $ selectable );
763763 }
764764
765765 /**
0 commit comments