Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add processing binary binding type #11734

Open
wants to merge 16 commits into
base: 3.3.x
Choose a base branch
from
Open
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
9 changes: 8 additions & 1 deletion src/Persisters/Entity/BasicEntityPersister.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php

Check failure on line 1 in src/Persisters/Entity/BasicEntityPersister.php

View workflow job for this annotation

GitHub Actions / Static Analysis with PHPStan (default, phpstan.neon)

Ignored error pattern ~^Match expression does not handle remaining values:~ in path /home/runner/work/orm/orm/src/Persisters/Entity/BasicEntityPersister.php was not matched in reported errors.

Check failure on line 1 in src/Persisters/Entity/BasicEntityPersister.php

View workflow job for this annotation

GitHub Actions / Static Analysis with PHPStan (3.8.2, phpstan-dbal3.neon)

Ignored error pattern ~^Match expression does not handle remaining values:~ in path /home/runner/work/orm/orm/src/Persisters/Entity/BasicEntityPersister.php was not matched in reported errors.

declare(strict_types=1);

Expand All @@ -10,6 +10,7 @@
use Doctrine\Common\Collections\Order;
use Doctrine\DBAL\ArrayParameterType;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\LockMode;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\AbstractPlatform;
Expand Down Expand Up @@ -1929,7 +1930,11 @@
return $types;
}

/** @psalm-return ArrayParameterType::* */
/** @psalm-return ArrayParameterType::*
greg0ire marked this conversation as resolved.
Show resolved Hide resolved
*
* @throws QueryException
* @throws Exception
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In what situations is this method raising these exception? Is the caller supposed to handle it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doctrine\DBAL\Types\Type::getType method throws Exception
Screenshot 2024-12-10 at 11 54 45

Copy link
Member

@derrabus derrabus Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This answers neither the first nor the second of my questions. 😉

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method doesn't handle these exceptions directly. I included them to show which ones the method can raise. If you think this is unnecessary, I’ll remove them.

Copy link
Author

@rabikor rabikor Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exception removed. QueryException throws by this method

*/
private function getArrayBindingType(ParameterType|int|string $type): ArrayParameterType|int
{
if (! $type instanceof ParameterType) {
Expand All @@ -1940,6 +1945,8 @@
ParameterType::STRING => ArrayParameterType::STRING,
ParameterType::INTEGER => ArrayParameterType::INTEGER,
ParameterType::ASCII => ArrayParameterType::ASCII,
ParameterType::BINARY => ArrayParameterType::BINARY,
default => throw new QueryException('Unsupported type for array parameter'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need the default branch here?

Copy link
Author

@rabikor rabikor Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default is necessary because not all ParameterType cases, such as BOOLEAN, LARGE_OBJECT, or NULL, are supported by ArrayParameterType. The default branch ensures these unsupported types are handled gracefully by throwing a clear exception, preventing unexpected behavior or runtime errors.

};
}

Expand Down
Loading