@@ -234,7 +234,7 @@ |
||
234 | 234 | $segments = explode('.', $this->{$item}); |
235 | 235 | $carry[] = end($segments); |
236 | 236 | |
237 | - } |
|
237 | + } |
|
238 | 238 | return $carry; |
239 | 239 | }; |
240 | 240 | return call_user_func($getter->bindTo($relation, Relation::class)); |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $stub->setBaseType(get_class(self::getParent($relation))); |
70 | 70 | $stub->setRelationName($name); |
71 | 71 | $stub->setThroughFieldChain($keyChain); |
72 | - $stub->setKeyField($keyChain[0] ?: $relation->getRelated()->getKeyName() ); |
|
72 | + $stub->setKeyField($keyChain[0] ?: $relation->getRelated()->getKeyName()); |
|
73 | 73 | $stub->setForeignField($keyChain[0]); |
74 | 74 | $stub->setMultiplicity(AssociationStubRelationType::ONE()); |
75 | 75 | $stub->setTargType(null); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @return AssociationStubBase |
103 | 103 | */ |
104 | 104 | protected static function handleHasManyThrough(string $name, Relation $relation, $cacheKey = 'HasManyThrough'):AssociationStubBase{ |
105 | - $farParentGetter = function(){ |
|
105 | + $farParentGetter = function () { |
|
106 | 106 | return $this->farParent; |
107 | 107 | }; |
108 | 108 | $farParent = call_user_func($farParentGetter->bindTo($relation, HasManyThrough::class)); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @return AssociationStubBase |
127 | 127 | */ |
128 | 128 | protected static function handleMorphToMany(string $name, Relation $relation, $cacheKey = 'BelongsToMany'): AssociationStubBase{ |
129 | - $inverseGetter = function(){ |
|
129 | + $inverseGetter = function () { |
|
130 | 130 | return $this->inverse; |
131 | 131 | }; |
132 | 132 | $inverse = call_user_func($inverseGetter->bindTo($relation, MorphToMany::class)); |
@@ -214,8 +214,8 @@ discard block |
||
214 | 214 | return $stub; |
215 | 215 | } |
216 | 216 | |
217 | - private static function getParent(Relation $relation){ |
|
218 | - $getter = function(){ |
|
217 | + private static function getParent(Relation $relation) { |
|
218 | + $getter = function () { |
|
219 | 219 | return $this->parent; |
220 | 220 | }; |
221 | 221 | return call_user_func($getter->bindTo($relation, Relation::class)); |
@@ -223,11 +223,11 @@ discard block |
||
223 | 223 | |
224 | 224 | private static function getKeyChain(Relation $relation, string $cacheKey) : array { |
225 | 225 | $fields = self::$fieldOrderCache[$cacheKey]; |
226 | - $getter = function() use ($fields){ |
|
226 | + $getter = function () use ($fields){ |
|
227 | 227 | $carry = []; |
228 | - foreach($fields as $item){ |
|
228 | + foreach ($fields as $item) { |
|
229 | 229 | $v = $this->{$item}; |
230 | - if($v == null && $item == 'ownerKey'){ |
|
230 | + if ($v == null && $item == 'ownerKey') { |
|
231 | 231 | $carry[] = null; |
232 | 232 | continue; |
233 | 233 | } |
@@ -242,8 +242,8 @@ discard block |
||
242 | 242 | |
243 | 243 | private static $fieldOrderCache = [ |
244 | 244 | 'BelongsTo' => ['ownerKey', 'foreignKey'], |
245 | - 'BelongsToMany' => ['parentKey','foreignPivotKey','relatedPivotKey','relatedKey'], |
|
246 | - 'HasOneOrMany' => ['localKey', 'foreignKey' ], |
|
245 | + 'BelongsToMany' => ['parentKey', 'foreignPivotKey', 'relatedPivotKey', 'relatedKey'], |
|
246 | + 'HasOneOrMany' => ['localKey', 'foreignKey'], |
|
247 | 247 | 'HasManyThrough' => ['localKey', 'firstKey', 'secondLocalKey', 'secondKey'], |
248 | 248 | |
249 | 249 | ]; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @return AssociationStubBase |
103 | 103 | */ |
104 | 104 | protected static function handleHasManyThrough(string $name, Relation $relation, $cacheKey = 'HasManyThrough'):AssociationStubBase{ |
105 | - $farParentGetter = function(){ |
|
105 | + $farParentGetter = function() { |
|
106 | 106 | return $this->farParent; |
107 | 107 | }; |
108 | 108 | $farParent = call_user_func($farParentGetter->bindTo($relation, HasManyThrough::class)); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @return AssociationStubBase |
127 | 127 | */ |
128 | 128 | protected static function handleMorphToMany(string $name, Relation $relation, $cacheKey = 'BelongsToMany'): AssociationStubBase{ |
129 | - $inverseGetter = function(){ |
|
129 | + $inverseGetter = function() { |
|
130 | 130 | return $this->inverse; |
131 | 131 | }; |
132 | 132 | $inverse = call_user_func($inverseGetter->bindTo($relation, MorphToMany::class)); |
@@ -214,8 +214,9 @@ discard block |
||
214 | 214 | return $stub; |
215 | 215 | } |
216 | 216 | |
217 | - private static function getParent(Relation $relation){ |
|
218 | - $getter = function(){ |
|
217 | + private static function getParent(Relation $relation) |
|
218 | + { |
|
219 | + $getter = function() { |
|
219 | 220 | return $this->parent; |
220 | 221 | }; |
221 | 222 | return call_user_func($getter->bindTo($relation, Relation::class)); |
@@ -223,11 +224,11 @@ discard block |
||
223 | 224 | |
224 | 225 | private static function getKeyChain(Relation $relation, string $cacheKey) : array { |
225 | 226 | $fields = self::$fieldOrderCache[$cacheKey]; |
226 | - $getter = function() use ($fields){ |
|
227 | + $getter = function() use ($fields) { |
|
227 | 228 | $carry = []; |
228 | - foreach($fields as $item){ |
|
229 | + foreach($fields as $item) { |
|
229 | 230 | $v = $this->{$item}; |
230 | - if($v == null && $item == 'ownerKey'){ |
|
231 | + if($v == null && $item == 'ownerKey') { |
|
231 | 232 | $carry[] = null; |
232 | 233 | continue; |
233 | 234 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public function getRelationships($temping = false) |
35 | 35 | { |
36 | - if($temping) { |
|
36 | + if ($temping) { |
|
37 | 37 | $rels = $this->getRelationshipsFromMethods(true); |
38 | 38 | return array_unique(array_merge( |
39 | 39 | array_keys($rels['UnknownPolyMorphSide']), |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | $fileName = $method->getFileName(); |
99 | 99 | |
100 | 100 | $file = new \SplFileObject($fileName); |
101 | - $file->seek($method->getStartLine() - 1); |
|
101 | + $file->seek($method->getStartLine()-1); |
|
102 | 102 | $code = ''; |
103 | 103 | while ($file->key() < $method->getEndLine()) { |
104 | 104 | $code .= $file->current(); |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | throw new InvalidOperationException($msg); |
112 | 112 | } |
113 | 113 | $begin = strpos($code, 'function('); |
114 | - $code = substr($code, $begin, strrpos($code, '}') - $begin + 1); |
|
115 | - $lastCode = $code[strlen($code) - 1]; |
|
114 | + $code = substr($code, $begin, strrpos($code, '}')-$begin+1); |
|
115 | + $lastCode = $code[strlen($code)-1]; |
|
116 | 116 | if ('}' != $lastCode) { |
117 | 117 | $msg = 'Final character of function definition must be closing brace'; |
118 | 118 | throw new InvalidOperationException($msg); |
@@ -157,11 +157,10 @@ discard block |
||
157 | 157 | continue; |
158 | 158 | } |
159 | 159 | $targetClass = $relation == 'morphTo' ? |
160 | - '\Illuminate\Database\Eloquent\Model|\Eloquent' : |
|
161 | - '\\' . get_class($relObject); |
|
160 | + '\Illuminate\Database\Eloquent\Model|\Eloquent' : '\\' . get_class($relObject); |
|
162 | 161 | $targObject = $biDir ? $relationObj : $targetClass; |
163 | 162 | $relToKeyMap = [ |
164 | - 'morphedByMany' => ['UnknownPolyMorphSide','HasMany'], |
|
163 | + 'morphedByMany' => ['UnknownPolyMorphSide', 'HasMany'], |
|
165 | 164 | 'morphToMany' => ['KnownPolyMorphSide', 'HasMany'], |
166 | 165 | 'morphMany' => ['KnownPolyMorphSide', 'HasMany'], |
167 | 166 | 'hasMany' => ['HasMany'], |
@@ -200,8 +199,7 @@ discard block |
||
200 | 199 | $keyName = $this->polyglotFkKey($relation); |
201 | 200 | $localName = $this->polyglotRkKey($relation); |
202 | 201 | $thruName = $relation instanceof HasManyThrough ? |
203 | - $this->polyglotThroughKey($relation) : |
|
204 | - null; |
|
202 | + $this->polyglotThroughKey($relation) : null; |
|
205 | 203 | |
206 | 204 | $first = $keyName; |
207 | 205 | $last = $localName; |