Skip to content

Commit

Permalink
Merge pull request #120 from nextras/php8
Browse files Browse the repository at this point in the history
gactions: run with PHP 8.0
  • Loading branch information
hrach committed Nov 1, 2020
2 parents 951524a + 2db8dc1 commit 1817fa6
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
- v*.*

env:
php-extensions: mbstring, intl, mysqli, pgsql, sqlsrv
php-extensions: mbstring, intl, mysqli, pgsql, sqlsrv-5.9.0preview1
php-extensions-key: v1
php-tools: "composer:v2, pecl"

Expand All @@ -25,7 +25,7 @@ jobs:

strategy:
matrix:
php-version: [ '7.4' ]
php-version: [ '7.4', '8.0' ]

steps:
- name: Checkout
Expand Down Expand Up @@ -59,7 +59,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version: [ '7.1', '7.2', '7.3', '7.4' ]
php-version: [ '7.1', '7.2', '7.3', '7.4', '8.0' ]

runs-on: ubuntu-latest

Expand Down
2 changes: 2 additions & 0 deletions .phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ parameters:
Nextras\Dbal\Drivers\Sqlsrv\SqlsrvDriver:
- throwErrors

reportUnmatchedIgnoredErrors: false

ignoreErrors:
-
message: '~Call to an undefined method .+::children\(\)\.~'
Expand Down
7 changes: 4 additions & 3 deletions src/Drivers/Mysqli/MysqliDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ public function connect(array $params, ILogger $logger): void
throw $this->createException(
$this->connection->connect_error ?? $this->connection->error, // @phpstan-ignore-line
$this->connection->connect_errno,
// @phpstan-ignore-next-line - Property access is not allowed yet
@$this->connection->sqlstate ?: 'HY000'
'HY000'
);
}

Expand Down Expand Up @@ -376,8 +375,10 @@ public function convertIdentifierToSql(string $value): string

public function convertDateTimeToSql(DateTimeInterface $value): string
{
$valueTimezone = $value->getTimezone();
assert($value instanceof DateTime || $value instanceof DateTimeImmutable);
if ($value->getTimezone()->getName() !== $this->connectionTz->getName()) {
assert($valueTimezone !== false); // @phpstan-ignore-line
if ($valueTimezone->getName() !== $this->connectionTz->getName()) {
if ($value instanceof DateTimeImmutable) {
$value = $value->setTimezone($this->connectionTz);
} else {
Expand Down
6 changes: 4 additions & 2 deletions src/Drivers/Pgsql/PgsqlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function getResourceHandle()
public function query(string $query): Result
{
assert($this->connection !== null);
if (!pg_send_query($this->connection, $query)) {
if (pg_send_query($this->connection, $query) === false) {
throw $this->createException(pg_last_error($this->connection), 0, null);
}

Expand Down Expand Up @@ -344,8 +344,10 @@ public function convertIdentifierToSql(string $value): string

public function convertDateTimeToSql(DateTimeInterface $value): string
{
$valueTimezone = $value->getTimezone();
assert($value instanceof DateTime || $value instanceof DateTimeImmutable);
if ($value->getTimezone()->getName() !== $this->connectionTz->getName()) {
assert($valueTimezone !== false); // @phpstan-ignore-line
if ($valueTimezone->getName() !== $this->connectionTz->getName()) {
if ($value instanceof DateTimeImmutable) {
$value = $value->setTimezone($this->connectionTz);
} else {
Expand Down
3 changes: 3 additions & 0 deletions src/Utils/DateTimeImmutable.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public function setTimestamp($timestamp): self
{
$zone = $this->getTimezone();
$datetime = new static('@' . (string) $timestamp);
if ($zone === false) { // @phpstan-ignore-line
return $datetime;
}
return $datetime->setTimezone($zone);
}
}

0 comments on commit 1817fa6

Please sign in to comment.