Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ci/phpstan/baselines/lexer-constants.neon
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ parameters:
- '#Fetching deprecated class constant T_ORDER of class Doctrine\\ORM\\Query\\Lexer#'
- '#Fetching deprecated class constant T_AS of class Doctrine\\ORM\\Query\\Lexer#'
- '#Fetching deprecated class constant T_DISTINCT of class Doctrine\\ORM\\Query\\Lexer#'
- '#Parameter \#1 \$token of method Doctrine\\ORM\\Query\\Parser::match\(\) expects Doctrine\\ORM\\Query\\TokenType, mixed given.#'
- '#Parameter \#1 \$type of method Doctrine\\Common\\Lexer\\AbstractLexer<Doctrine\\ORM\\Query\\TokenType,string>::isNextToken\(\) expects Doctrine\\ORM\\Query\\TokenType, mixed given.#'
1 change: 1 addition & 0 deletions ci/phpstan/config.neon
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ parameters:

errorFormat: table
reportUnmatchedIgnoredErrors: false
treatPhpDocTypesAsCertain: false
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@
"require-dev": {
"deptrac/deptrac": "^3.0",
"doctrine/orm": "~2.14||~3.0",
"ekino/phpstan-banned-code": "^1.0",
"ekino/phpstan-banned-code": "^3.0",
"friendsofphp/php-cs-fixer": "^3.72.0",
"phpstan/phpstan": "^1.12.21",
"phpstan/phpstan-deprecation-rules": "^1.2.1",
"phpstan/phpstan-doctrine": "^1.5.7",
"phpstan/phpstan-phpunit": "^1.4.2",
"phpstan/phpstan": "^2.1",
"phpstan/phpstan-deprecation-rules": "^2.0",
"phpstan/phpstan-doctrine": "^2.0",
"phpstan/phpstan-phpunit": "^2.0",
"phpunit/phpunit": "^10.5.45",
"rector/rector": "^1.2.10",
"rector/rector": "^2.0",
"symfony/cache": "^6.4||^7.0"
},
"suggest": {
Expand Down
7 changes: 5 additions & 2 deletions src/MartinGeorgiev/Doctrine/DBAL/Types/BaseType.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
*/
abstract class BaseType extends Type
{
protected const TYPE_NAME = null;
/**
* @var string
*/
protected const TYPE_NAME = '';

public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform): string
{
Expand All @@ -42,7 +45,7 @@ public function requiresSQLCommentHint(AbstractPlatform $platform): bool

private function throwExceptionIfTypeNameNotConfigured(): void
{
if (null === static::TYPE_NAME) {
if (static::TYPE_NAME === '') {
throw new \LogicException(\sprintf('Doctrine type defined in class %s has no meaningful value for TYPE_NAME constant', self::class));
}
}
Expand Down
4 changes: 0 additions & 4 deletions src/MartinGeorgiev/Doctrine/DBAL/Types/TextArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform): ?str

protected function transformToPostgresTextArray(array $phpTextArray): string
{
if (!\is_array($phpTextArray)) {
throw new \InvalidArgumentException(\sprintf('Value %s is not an array', \var_export($phpTextArray, true)));
}

if ($phpTextArray === []) {
return '{}';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ protected function feedParserWithNodes(Parser $parser): void
$lastNode = $nodesMappingCount - 1;
for ($i = 0; $i < $nodesMappingCount; $i++) {
$parserMethod = $this->nodesMapping[$i];
// @phpstan-ignore-next-line
$this->nodes[$i] = $parser->{$parserMethod}();
if ($i < $lastNode) {
$parser->match(\class_exists(TokenType::class) ? TokenType::T_COMMA : Lexer::T_COMMA);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ protected function feedParserWithNodes(Parser $parser): void
$lexer = $parser->getLexer();

try {
// @phpstan-ignore-next-line
$this->nodes[] = $parser->{$this->commonNodeMapping}();
if ($lexer->lookahead?->type === null) {
throw ParserException::missingLookaheadType();
Expand All @@ -42,6 +43,7 @@ protected function feedParserWithNodes(Parser $parser): void
while (($shouldUseLexer ? Lexer::T_CLOSE_PARENTHESIS : TokenType::T_CLOSE_PARENTHESIS) !== $aheadType) {
if (($shouldUseLexer ? Lexer::T_COMMA : TokenType::T_COMMA) === $aheadType) {
$parser->match($shouldUseLexer ? Lexer::T_COMMA : TokenType::T_COMMA);
// @phpstan-ignore-next-line
$this->nodes[] = $parser->{$this->commonNodeMapping}();
}

Expand Down
14 changes: 7 additions & 7 deletions src/MartinGeorgiev/Utils/DataStructure.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@ public static function transformPostgresTextArrayToPHPArray(string $postgresArra
continue;
}

if (!\is_string($text)) {
$exceptionMessage = 'Unsupported data type encountered. Expected null, integer, float or string value. Instead it is "%s".';

throw new \InvalidArgumentException(\sprintf($exceptionMessage, \gettype($text)));
}

$phpArray[$i] = \stripslashes(\str_replace('\"', '"', $text));
}

Expand All @@ -78,7 +72,13 @@ public static function transformPHPArrayToPostgresTextArray(array $phpArray): st
throw new \InvalidArgumentException('Only single-dimensioned arrays are supported');
}

$escapedText = \is_numeric($text) || \ctype_digit($text) ? $text : \sprintf('"%s"', \addcslashes($text, '"\\'));
if (\is_numeric($text) || \ctype_digit($text)) {
$escapedText = $text;
} else {
\assert(\is_string($text));
$escapedText = \sprintf('"%s"', \addcslashes($text, '"\\'));
}

$result[] = $escapedText;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

abstract class TestCase extends BaseTestCase
{
/**
* @var string
*/
protected const FIXTURES_DIRECTORY = __DIR__.'/../../../../../../fixtures/MartinGeorgiev/Doctrine/Entity';

private Configuration $configuration;
Expand All @@ -34,6 +37,7 @@
private function setConfigurationCache(Configuration $configuration): void
{
$symfonyArrayAdapterClass = '\\'.ArrayAdapter::class;
// @phpstan-ignore-next-line
$useDbalV3 = \class_exists($symfonyArrayAdapterClass) && \method_exists($configuration, 'setMetadataCache') && \method_exists($configuration, 'setQueryCache');
if ($useDbalV3) {
// @phpstan-ignore-next-line
Expand All @@ -45,7 +49,7 @@
}

$doctrineArrayCacheClass = '\Doctrine\Common\Cache\ArrayCache';
$useDbalV2 = \class_exists($doctrineArrayCacheClass) && \method_exists($configuration, 'setMetadataCacheImpl') && \method_exists($configuration, 'setQueryCacheImpl');

Check failure on line 52 in tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/TestCase.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 + Doctrine ORM 2.14

Call to function method_exists() with Doctrine\ORM\Configuration and 'setQueryCacheImpl' will always evaluate to true.

Check failure on line 52 in tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/TestCase.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 + Doctrine ORM 2.14

Call to function method_exists() with Doctrine\ORM\Configuration and 'setMetadataCacheImpl' will always evaluate to true.

Check failure on line 52 in tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/TestCase.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 + Doctrine ORM 2.14

Call to function method_exists() with Doctrine\ORM\Configuration and 'setQueryCacheImpl' will always evaluate to true.

Check failure on line 52 in tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/TestCase.php

View workflow job for this annotation

GitHub Actions / PHP 8.1 + Doctrine ORM 2.14

Call to function method_exists() with Doctrine\ORM\Configuration and 'setMetadataCacheImpl' will always evaluate to true.

Check failure on line 52 in tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/TestCase.php

View workflow job for this annotation

GitHub Actions / PHP 8.4 + Doctrine ORM 2.14

Call to function method_exists() with Doctrine\ORM\Configuration and 'setQueryCacheImpl' will always evaluate to true.

Check failure on line 52 in tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/TestCase.php

View workflow job for this annotation

GitHub Actions / PHP 8.4 + Doctrine ORM 2.14

Call to function method_exists() with Doctrine\ORM\Configuration and 'setMetadataCacheImpl' will always evaluate to true.

Check failure on line 52 in tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/TestCase.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 + Doctrine ORM 2.14

Call to function method_exists() with Doctrine\ORM\Configuration and 'setQueryCacheImpl' will always evaluate to true.

Check failure on line 52 in tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/TestCase.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 + Doctrine ORM 2.14

Call to function method_exists() with Doctrine\ORM\Configuration and 'setMetadataCacheImpl' will always evaluate to true.
if ($useDbalV2) {
// @phpstan-ignore-next-line
$configuration->setMetadataCacheImpl(new $doctrineArrayCacheClass());
Expand Down
Loading