forked from doctrine/dbal
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 4.3.x: Enable platformOptions to be considered for ColumnDiff (PostgreSQL jsonb support) (doctrine#6693) Ignore new PHPStan errors Cleanup obsolete PHPStan ignore rules (doctrine#6697) Add a `NumberType` that maps to the `BcMath\Number` value object (doctrine#6686) PHPStan 2.1.1 (doctrine#6690) PHPUnit 10.5.39 (doctrine#6692) PHPUnit 9.6.22 (doctrine#6691) Bump doctrine/.github from 6.0.0 to 7.1.0 (doctrine#6649) Bump doctrine/.github from 5.3.0 to 6.0.0 (doctrine#6642)
- Loading branch information
Showing
22 changed files
with
652 additions
and
267 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
parameters: | ||
ignoreErrors: | ||
- | ||
message: '#^Method Doctrine\\DBAL\\Driver\\IBMDB2\\Connection\:\:exec\(\) never returns numeric\-string so it can be removed from the return type\.$#' | ||
identifier: return.unusedType | ||
count: 1 | ||
path: src/Driver/IBMDB2/Connection.php | ||
|
||
- | ||
message: '#^Method Doctrine\\DBAL\\Driver\\OCI8\\Connection\:\:exec\(\) never returns numeric\-string so it can be removed from the return type\.$#' | ||
identifier: return.unusedType | ||
count: 1 | ||
path: src/Driver/OCI8/Connection.php | ||
|
||
- | ||
message: '#^Method Doctrine\\DBAL\\Driver\\OCI8\\Result\:\:fetchAllAssociative\(\) should return list\<array\<string, mixed\>\> but returns array\<mixed\>\.$#' | ||
identifier: return.type | ||
count: 1 | ||
path: src/Driver/OCI8/Result.php | ||
|
||
- | ||
message: '#^Method Doctrine\\DBAL\\Driver\\OCI8\\Result\:\:fetchAllNumeric\(\) should return list\<list\<mixed\>\> but returns array\<mixed\>\.$#' | ||
identifier: return.type | ||
count: 1 | ||
path: src/Driver/OCI8/Result.php | ||
|
||
- | ||
message: '#^Method Doctrine\\DBAL\\Driver\\PDO\\Result\:\:fetchAll\(\) should return list\<mixed\> but returns array\.$#' | ||
identifier: return.type | ||
count: 1 | ||
path: src/Driver/PDO/Result.php | ||
|
||
- | ||
message: '#^Method Doctrine\\DBAL\\Driver\\PgSQL\\Result\:\:fetchAllAssociative\(\) should return list\<array\<string, mixed\>\> but returns array\<int, array\<string, mixed\>\>\.$#' | ||
identifier: return.type | ||
count: 1 | ||
path: src/Driver/PgSQL/Result.php | ||
|
||
- | ||
message: '#^Method Doctrine\\DBAL\\Driver\\PgSQL\\Result\:\:fetchAllNumeric\(\) should return list\<list\<mixed\>\> but returns array\<int, list\<mixed\>\>\.$#' | ||
identifier: return.type | ||
count: 1 | ||
path: src/Driver/PgSQL/Result.php | ||
|
||
- | ||
message: '#^Method Doctrine\\DBAL\\Driver\\PgSQL\\Result\:\:fetchFirstColumn\(\) should return list\<mixed\> but returns array\<int, bool\|float\|int\|string\|null\>\.$#' | ||
identifier: return.type | ||
count: 1 | ||
path: src/Driver/PgSQL/Result.php | ||
|
||
- | ||
message: '#^Method Doctrine\\DBAL\\Driver\\SQLite3\\Result\:\:fetchNumeric\(\) should return list\<mixed\>\|false but returns array\|false\.$#' | ||
identifier: return.type | ||
count: 1 | ||
path: src/Driver/SQLite3/Result.php | ||
|
||
- | ||
message: '#^Template type T is declared as covariant, but occurs in invariant position in property Doctrine\\DBAL\\Schema\\AbstractSchemaManager\:\:\$platform\.$#' | ||
identifier: generics.variance | ||
count: 1 | ||
path: src/Schema/AbstractSchemaManager.php | ||
|
||
- | ||
message: '#^Loose comparison via "\!\=" is not allowed\.$#' | ||
identifier: notEqual.notAllowed | ||
count: 1 | ||
path: src/Schema/ColumnDiff.php | ||
|
||
- | ||
message: '#^Method Doctrine\\DBAL\\Schema\\SQLiteSchemaManager\:\:addDetailsToTableForeignKeyColumns\(\) should return list\<array\<string, mixed\>\> but returns array\<int\<0, max\>, array\<string, mixed\>\>\.$#' | ||
identifier: return.type | ||
count: 1 | ||
path: src/Schema/SQLiteSchemaManager.php | ||
|
||
- | ||
message: '#^Offset string might not exist on array\{application_name\?\: string, charset\?\: string, dbname\?\: string, defaultTableOptions\?\: array\<string, mixed\>, driver\?\: ''ibm_db2''\|''mysqli''\|''oci8''\|''pdo_mysql''\|''pdo_oci''\|''pdo_pgsql''\|''pdo_sqlite''\|''pdo_sqlsrv''\|''pgsql''\|''sqlite3''\|''sqlsrv'', driverClass\?\: class\-string\<Doctrine\\DBAL\\Driver\>, driverOptions\?\: array\<mixed\>, host\?\: string, \.\.\.\}\.$#' | ||
identifier: offsetAccess.notFound | ||
count: 1 | ||
path: tests/DriverManagerTest.php | ||
|
||
- | ||
message: '#^Call to new Doctrine\\DBAL\\Driver\\PgSQL\\Result\(\) on a separate line has no effect\.$#' | ||
identifier: new.resultUnused | ||
count: 1 | ||
path: tests/Functional/Driver/PgSQL/ResultTest.php | ||
|
||
- | ||
message: '#^Call to function array_filter\(\) requires parameter \#2 to be passed to avoid loose comparison semantics\.$#' | ||
identifier: arrayFilter.strict | ||
count: 1 | ||
path: tests/Functional/Schema/MySQL/JsonCollationTest.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\DBAL\Types; | ||
|
||
use BcMath\Number; | ||
use Doctrine\DBAL\Platforms\AbstractPlatform; | ||
use Doctrine\DBAL\Types\Exception\InvalidType; | ||
use Doctrine\DBAL\Types\Exception\ValueNotConvertible; | ||
use TypeError; | ||
use ValueError; | ||
|
||
use function is_float; | ||
|
||
final class NumberType extends Type | ||
{ | ||
/** {@inheritDoc} */ | ||
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string | ||
{ | ||
return $platform->getDecimalTypeDeclarationSQL($column); | ||
} | ||
|
||
public function convertToDatabaseValue(mixed $value, AbstractPlatform $platform): ?string | ||
{ | ||
if ($value === null) { | ||
return null; | ||
} | ||
|
||
if (! $value instanceof Number) { | ||
throw InvalidType::new($value, static::class, ['null', Number::class]); | ||
} | ||
|
||
return (string) $value; | ||
} | ||
|
||
public function convertToPHPValue(mixed $value, AbstractPlatform $platform): ?Number | ||
{ | ||
if ($value === null) { | ||
return null; | ||
} | ||
|
||
// SQLite might return a decimal as float. | ||
if (is_float($value)) { | ||
$value = (string) $value; | ||
} | ||
|
||
try { | ||
return new Number($value); | ||
} catch (TypeError | ValueError $e) { | ||
throw ValueNotConvertible::new($value, static::class, previous: $e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.