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

SchemaValidator: Adapting to new DBAL mapping of bigint #11396

Closed
wants to merge 1 commit into from

Conversation

ThomasLandauer
Copy link
Contributor

Closes #11377

@greg0ire
Copy link
Member

Have you tried that on a real project?

@ThomasLandauer
Copy link
Contributor Author

  • With the current BigIntType::class => 'string', I'm getting the mapping error with:
    private ?int $foo = null;
    But not with:
    private string|array|null $foo = null; // i.e. `string` doesn't have to be the only type
  • With the new BigIntType::class => 'string|int', I'm still getting it with:
    private ?int $foo = null;
    But not with any of these:
    private string|int|null $foo = null;
    private int|string|null $foo = null; // i.e. order doesn't matter
    private string|int|array|null $foo = null; // i.e. some "bogus" alternative like `array` is still allowed

=> So this does indeed look like a step forward to me.

@@ -53,7 +53,7 @@ class SchemaValidator
*/
private const BUILTIN_TYPES_MAP = [
AsciiStringType::class => 'string',
BigIntType::class => 'string',
BigIntType::class => 'string|int',
Copy link
Member

Choose a reason for hiding this comment

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

We still support DBAL 3 though… maybe we should keep string when DBAL 3 is installed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, but how can the version of DBAL be detected here?

Copy link
Member

Choose a reason for hiding this comment

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

You could test for the existence of BigIntType::getName() with a call to method_exists(). That method does not exist with DBAL 4.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, but how can I do this inside this const?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think you can, you'd probably have to convert the const to a property.

Copy link
Member

@derrabus derrabus left a comment

Choose a reason for hiding this comment

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

No tests. 🤷🏻‍♂️

@ThomasLandauer
Copy link
Contributor Author

In #11399 I started over (using git CLI ;-) so I'm closing here.

@ThomasLandauer ThomasLandauer deleted the patch-10 branch March 22, 2024 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SchemaValidator is complaining about BIGINT with PHP typehint int
3 participants