Skip to content

Commit

Permalink
fix: incorrect return types
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Sep 27, 2023
1 parent 8e3dd0e commit c9b0e58
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
5 changes: 0 additions & 5 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@
'count' => 1,
'path' => __DIR__ . '/system/BaseModel.php',
];
$ignoreErrors[] = [
'message' => '#^Only booleans are allowed in an if condition, array\\|null given\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/BaseModel.php',
];
$ignoreErrors[] = [
'message' => '#^Only booleans are allowed in an if condition, int given\\.$#',
'count' => 1,
Expand Down
7 changes: 4 additions & 3 deletions system/BaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -1657,7 +1657,7 @@ protected function objectToArray($data, bool $onlyChanged = true, bool $recursiv
$properties = $this->objectToRawArray($data, $onlyChanged, $recursive);

// Convert any Time instances to appropriate $dateFormat
if ($properties) {
if ($properties !== []) {
$properties = array_map(function ($value) {
if ($value instanceof Time) {
return $this->timeToDate($value);
Expand All @@ -1678,12 +1678,13 @@ protected function objectToArray($data, bool $onlyChanged = true, bool $recursiv
* @param bool $onlyChanged Only Changed Property
* @param bool $recursive If true, inner entities will be casted as array as well
*
* @return array|null Array
* @return array Array with raw values.
*
* @throws ReflectionException
*/
protected function objectToRawArray($data, bool $onlyChanged = true, bool $recursive = false): ?array
protected function objectToRawArray($data, bool $onlyChanged = true, bool $recursive = false): array
{
// @TODO Should define Interface or Class. Entity has toRawArray() now.
if (method_exists($data, 'toRawArray')) {
$properties = $data->toRawArray($onlyChanged, $recursive);
} else {
Expand Down
4 changes: 2 additions & 2 deletions system/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -783,11 +783,11 @@ public function update($id = null, $data = null): bool
* @param object|string $data
* @param bool $recursive If true, inner entities will be cast as array as well
*
* @return array|null Array
* @return array Array with raw values.
*
* @throws ReflectionException
*/
protected function objectToRawArray($data, bool $onlyChanged = true, bool $recursive = false): ?array
protected function objectToRawArray($data, bool $onlyChanged = true, bool $recursive = false): array
{
$properties = parent::objectToRawArray($data, $onlyChanged);

Expand Down

0 comments on commit c9b0e58

Please sign in to comment.