Skip to content

Commit

Permalink
Fix up TypeError cases found by PHPStan level 7/8
Browse files Browse the repository at this point in the history
  • Loading branch information
dereuromark committed Jan 7, 2023
1 parent 7d4a153 commit f84144d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Driver.php
Expand Up @@ -753,7 +753,7 @@ public function schema(): string
*/
public function lastInsertId(?string $table = null): string
{
return $this->getPdo()->lastInsertId($table);
return (string)$this->getPdo()->lastInsertId($table);
}

/**
Expand Down
1 change: 1 addition & 0 deletions Type/BinaryUuidType.php
Expand Up @@ -118,6 +118,7 @@ protected function convertBinaryUuidToString(mixed $binary): string
$string = unpack('H*', $binary);
assert($string !== false, 'Could not unpack uuid');

/** @var array<string> $string */
$string = preg_replace(
'/([0-9a-f]{8})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{12})/',
'$1-$2-$3-$4-$5',
Expand Down
10 changes: 6 additions & 4 deletions Type/DateTimeType.php
Expand Up @@ -211,8 +211,9 @@ public function toPHP(mixed $value, Driver $driver): DateTime|DateTimeImmutable|
}

if (
!$this->keepDatabaseTimezone &&
$instance->getTimezone()->getName() !== $this->defaultTimezone->getName()
!$this->keepDatabaseTimezone
&& $instance->getTimezone()
&& $instance->getTimezone()->getName() !== $this->defaultTimezone->getName()
) {
$instance = $instance->setTimezone($this->defaultTimezone);
}
Expand Down Expand Up @@ -265,8 +266,9 @@ public function manyToPHP(array $values, array $fields, Driver $driver): array
}

if (
!$this->keepDatabaseTimezone &&
$instance->getTimezone()->getName() !== $this->defaultTimezone->getName()
!$this->keepDatabaseTimezone
&& $instance->getTimezone()
&& $instance->getTimezone()->getName() !== $this->defaultTimezone->getName()
) {
$instance = $instance->setTimezone($this->defaultTimezone);
}
Expand Down
2 changes: 1 addition & 1 deletion Type/EnumType.php
Expand Up @@ -179,7 +179,7 @@ public function marshal(mixed $value): ?BackedEnum
* $this->getSchema()->setColumnType('status', EnumType::from(StatusEnum::class));
* ```
*
* @param string $enumClassName The enum class name
* @param class-string<\BackedEnum> $enumClassName The enum class name
* @return string
*/
public static function from(string $enumClassName): string
Expand Down

0 comments on commit f84144d

Please sign in to comment.