-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector; | ||
use Rector\Config\RectorConfig; | ||
use Rector\Set\ValueObject\LevelSetList; | ||
|
||
return static function (RectorConfig $rectorConfig): void { | ||
$rectorConfig->paths([ | ||
__DIR__ . '/src', | ||
__DIR__ . '/tests', | ||
]); | ||
|
||
// register a single rule | ||
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class); | ||
|
||
// define sets of rules | ||
$rectorConfig->sets([ | ||
LevelSetList::UP_TO_PHP_80 | ||
]); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,16 +7,13 @@ | |
|
||
abstract class EntityCollection implements \Iterator, \Countable | ||
{ | ||
private $iteratorPosition = 0; | ||
private int $iteratorPosition = 0; | ||
|
||
/** | ||
* @var \stdClass | ||
* @param \stdClass $data | ||
*/ | ||
protected $rawData; | ||
|
||
final public function __construct($data) | ||
final public function __construct(protected $rawData) | ||
Check failure on line 15 in src/Entity/Collection/EntityCollection.php
|
||
{ | ||
$this->rawData = $data; | ||
} | ||
|
||
/** | ||
|
@@ -30,7 +27,7 @@ final public function __construct($data) | |
*/ | ||
public static function fromResponse(ResponseInterface $response) | ||
{ | ||
return new static(json_decode((string) $response->getBody())); | ||
return new static(json_decode((string) $response->getBody(), null, 512, JSON_THROW_ON_ERROR)); | ||
} | ||
|
||
public function getSelfLink() | ||
|
@@ -132,6 +129,6 @@ public function rewind() | |
*/ | ||
public function count() | ||
Check failure on line 130 in src/Entity/Collection/EntityCollection.php
|
||
{ | ||
return count($this->rawData->list); | ||
return is_countable($this->rawData->list) ? count($this->rawData->list) : 0; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,16 +9,13 @@ abstract class Entity | |
/** | ||
* @var mixed | ||
*/ | ||
protected $rawData; | ||
protected $data; | ||
|
||
/** | ||
* @var mixed | ||
* @param mixed $raw_data | ||
*/ | ||
protected $data; | ||
|
||
final public function __construct($raw_data) | ||
final public function __construct(protected $rawData) | ||
Check failure on line 17 in src/Entity/Entity.php
|
||
{ | ||
$this->rawData = $raw_data; | ||
} | ||
|
||
/** | ||
|
@@ -61,7 +58,7 @@ public function getData() | |
*/ | ||
public function __get($name) | ||
{ | ||
return isset($this->rawData->$name) ? $this->rawData->$name : null; | ||
return $this->rawData->$name ?? null; | ||
} | ||
|
||
/** | ||
|
@@ -72,7 +69,7 @@ public function __get($name) | |
* @param mixed $value | ||
* Value | ||
*/ | ||
public function __set($name, $value): void | ||
public function __set($name, mixed $value): void | ||
{ | ||
$this->rawData->$name = $value; | ||
} | ||
|
@@ -129,6 +126,6 @@ abstract protected function getIntegerFields(): array; | |
*/ | ||
public static function fromResponse(ResponseInterface $response): self | ||
{ | ||
return new static(json_decode((string) $response->getBody())); | ||
return new static(json_decode((string) $response->getBody(), null, 512, JSON_THROW_ON_ERROR)); | ||
} | ||
} |