Skip to content

Commit 86d47ce

Browse files
authored
move affecting type hints (#47)
Moving the type hint at the end of the function.
1 parent f695c57 commit 86d47ce

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/Http/Response.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,12 @@ public static function makeFromJson(JsonResponse $json)
125125
*/
126126
public function morph($format = 'json')
127127
{
128-
$this->content = $this->getOriginalContent() ?? '';
128+
$content = $this->getOriginalContent() ?? '';
129129

130130
$this->fireMorphingEvent();
131131

132-
if (isset(static::$transformer) && static::$transformer->transformableResponse($this->content)) {
133-
$this->content = static::$transformer->transform($this->content);
132+
if (isset(static::$transformer) && static::$transformer->transformableResponse($content)) {
133+
$content = static::$transformer->transform($content);
134134
}
135135

136136
$formatter = static::getFormatter($format);
@@ -147,20 +147,22 @@ public function morph($format = 'json')
147147

148148
$this->fireMorphedEvent();
149149

150-
if ($this->content instanceof EloquentModel) {
151-
$this->content = $formatter->formatEloquentModel($this->content);
152-
} elseif ($this->content instanceof EloquentCollection) {
153-
$this->content = $formatter->formatEloquentCollection($this->content);
154-
} elseif (is_array($this->content) || $this->content instanceof ArrayObject || $this->content instanceof Arrayable) {
155-
$this->content = $formatter->formatArray($this->content);
156-
} elseif ($this->content instanceof stdClass) {
157-
$this->content = $formatter->formatArray((array) $this->content);
150+
if ($content instanceof EloquentModel) {
151+
$content = $formatter->formatEloquentModel($content);
152+
} elseif ($content instanceof EloquentCollection) {
153+
$content = $formatter->formatEloquentCollection($content);
154+
} elseif (is_array($content) || $content instanceof ArrayObject || $content instanceof Arrayable) {
155+
$content = $formatter->formatArray($content);
156+
} elseif ($content instanceof stdClass) {
157+
$content = $formatter->formatArray((array) $content);
158158
} else {
159159
if (! empty($defaultContentType)) {
160160
$this->headers->set('Content-Type', $defaultContentType);
161161
}
162162
}
163163

164+
$this->content = $content;
165+
164166
return $this;
165167
}
166168

0 commit comments

Comments
 (0)