-
-
Notifications
You must be signed in to change notification settings - Fork 56
feat!: refactor exceptions handling for JsonbArray in the style used for the network types
#311
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
Conversation
…d for the network types
WalkthroughThis pull request introduces a new exception class, Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant JsonbArray
participant ExceptionFactory
Client->>JsonbArray: transformArrayItemForPHP(input)
alt JSON decoding fails
JsonbArray->>ExceptionFactory: forInvalidFormat(value)
ExceptionFactory-->>JsonbArray: Exception instance
JsonbArray->>Client: throw exception
else Decoded value is not an array
JsonbArray->>ExceptionFactory: forInvalidType(value)
ExceptionFactory-->>JsonbArray: Exception instance
JsonbArray->>Client: throw exception
else Valid array obtained
JsonbArray->>Client: return array
end
Poem
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (8)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
src/MartinGeorgiev/Doctrine/DBAL/Types/Exceptions/InvalidJsonbArrayItemForPHPException.php(1 hunks)src/MartinGeorgiev/Doctrine/DBAL/Types/Exceptions/TypeException.php(0 hunks)src/MartinGeorgiev/Doctrine/DBAL/Types/Exceptions/UnexpectedTypeOfTransformedPHPValue.php(0 hunks)src/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArray.php(2 hunks)tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php(2 hunks)
💤 Files with no reviewable changes (2)
- src/MartinGeorgiev/Doctrine/DBAL/Types/Exceptions/TypeException.php
- src/MartinGeorgiev/Doctrine/DBAL/Types/Exceptions/UnexpectedTypeOfTransformedPHPValue.php
🧰 Additional context used
🧬 Code Definitions (1)
src/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArray.php (1)
src/MartinGeorgiev/Doctrine/DBAL/Types/Exceptions/InvalidJsonbArrayItemForPHPException.php (3)
InvalidJsonbArrayItemForPHPException(9-25)forInvalidType(16-19)forInvalidFormat(21-24)
🪛 GitHub Check: PHP 8.1 + Doctrine ORM 2.14 + Doctrine Lexer 1.2
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php
[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.
🪛 GitHub Check: PHP 8.4 + Doctrine ORM 3.0 + Doctrine Lexer 3.0
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php
[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.
🪛 GitHub Check: PHP 8.4 + Doctrine ORM 3.0 + Doctrine Lexer latest
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php
[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.
🪛 GitHub Check: PHP 8.4 + Doctrine ORM 2.14 + Doctrine Lexer latest
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php
[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.
🪛 GitHub Check: PHP 8.3 + Doctrine ORM 2.14 + Doctrine Lexer latest
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php
[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.
🪛 GitHub Check: PHP 8.3 + Doctrine ORM 2.18 + Doctrine Lexer latest
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php
[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.
🪛 GitHub Check: PHP 8.3 + Doctrine ORM latest + Doctrine Lexer latest
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php
[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.
🪛 GitHub Check: PHP 8.3 + Doctrine ORM 3.0 + Doctrine Lexer latest
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php
[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.
🪛 GitHub Check: PHP 8.3 + Doctrine ORM latest + Doctrine Lexer 2.1
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php
[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.
🪛 GitHub Check: PHP 8.4 + Doctrine ORM latest + Doctrine Lexer 2.1
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php
[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.
🪛 GitHub Check: PHP 8.4 + Doctrine ORM latest + Doctrine Lexer 3.0
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php
[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.
🪛 GitHub Check: PHP 8.4 + Doctrine ORM 2.18 + Doctrine Lexer 3.0
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php
[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.
🪛 GitHub Check: PHP 8.4 + Doctrine ORM 2.18 + Doctrine Lexer 2.1
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php
[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.
🪛 GitHub Check: PHP 8.3 + Doctrine ORM 2.14 + Doctrine Lexer 2.1
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php
[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.
🪛 GitHub Check: PHP 8.3 + Doctrine ORM 2.18 + Doctrine Lexer 3.0
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php
[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.
🪛 GitHub Check: PHP 8.2 + Doctrine ORM latest + Doctrine Lexer latest
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php
[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.
🪛 GitHub Check: PHP 8.3 + Doctrine ORM 3.0 + Doctrine Lexer 3.0
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php
[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.
🪛 GitHub Check: PHP 8.2 + Doctrine ORM 3.0 + Doctrine Lexer latest
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php
[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.
🪛 GitHub Check: PHP 8.3 + Doctrine ORM latest + Doctrine Lexer 3.0
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php
[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.
🪛 GitHub Check: PHP 8.2 + Doctrine ORM 2.18 + Doctrine Lexer latest
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php
[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.
🪛 GitHub Check: PHP 8.2 + Doctrine ORM latest + Doctrine Lexer 3.0
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php
[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.
🪛 GitHub Check: PHP 8.1 + Doctrine ORM 2.18 + Doctrine Lexer latest
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php
[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.
🪛 GitHub Check: PHP 8.3 + Doctrine ORM 2.18 + Doctrine Lexer 2.1
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php
[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.
🪛 GitHub Check: PHP 8.2 + Doctrine ORM 2.18 + Doctrine Lexer 3.0
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php
[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.
🪛 GitHub Check: PHP 8.2 + Doctrine ORM latest + Doctrine Lexer 2.1
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php
[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.
🪛 GitHub Check: PHP 8.2 + Doctrine ORM 3.0 + Doctrine Lexer 3.0
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php
[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.
🪛 GitHub Check: PHP 8.2 + Doctrine ORM 2.14 + Doctrine Lexer latest
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php
[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.
🪛 GitHub Check: PHP 8.1 + Doctrine ORM 3.0 + Doctrine Lexer latest
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php
[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.
🪛 GitHub Check: PHP 8.1 + Doctrine ORM 2.14 + Doctrine Lexer latest
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php
[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.
🪛 GitHub Check: PHP 8.1 + Doctrine ORM latest + Doctrine Lexer 2.1
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php
[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.
🪛 GitHub Check: PHP 8.2 + Doctrine ORM 2.18 + Doctrine Lexer 2.1
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php
[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.
🪛 GitHub Check: PHP 8.2 + Doctrine ORM 2.14 + Doctrine Lexer 2.1
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php
[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.
🪛 GitHub Check: PHP 8.1 + Doctrine ORM latest + Doctrine Lexer latest
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php
[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.
🪛 GitHub Check: PHP 8.1 + Doctrine ORM 2.18 + Doctrine Lexer 2.1
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php
[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.
🪛 GitHub Check: PHP 8.1 + Doctrine ORM 2.18 + Doctrine Lexer 3.0
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php
[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.
🪛 GitHub Check: PHP 8.1 + Doctrine ORM 3.0 + Doctrine Lexer 3.0
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php
[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.
🪛 GitHub Check: PHP 8.1 + Doctrine ORM latest + Doctrine Lexer 3.0
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php
[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.
🪛 GitHub Check: PHP 8.1 + Doctrine ORM 2.14 + Doctrine Lexer 2.1
tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php
[failure] 111-111:
Method Tests\MartinGeorgiev\Doctrine\DBAL\Types\JsonbArrayTest::provideInvalidTransformations() should return array<string, array{string, string}> but returns array{non-array json: array{'"a string encoded…'}, invalid json format: array{'{invalid json}'}}.
⏰ Context from checks skipped due to timeout of 90000ms (5)
- GitHub Check: PHP 8.4 + Doctrine ORM latest + Doctrine Lexer latest
- GitHub Check: PHP 8.4 + Doctrine ORM 2.18 + Doctrine Lexer latest
- GitHub Check: PHP 8.4 + Doctrine ORM 2.14 + Doctrine Lexer 2.1
- GitHub Check: PHP 8.4 + Doctrine ORM 2.14 + Doctrine Lexer latest
- GitHub Check: PHP 8.3 + Doctrine ORM 2.18 + Doctrine Lexer latest
🔇 Additional comments (10)
src/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArray.php (4)
7-7: Import statement updated to use the new exception classThe import statement has been properly updated to use the new
InvalidJsonbArrayItemForPHPExceptionclass, which is part of the refactoring to improve exception handling.
50-52: Improved exception handling for invalid typesThe code now uses the specialized
forInvalidTypefactory method from the new exception class, which provides more specific and descriptive error messages when a non-array JSON value is encountered.
54-54: Code simplification by returning directlyThe code has been simplified by removing the unnecessary
$transformedValuevariable and returning the value directly, which reduces cognitive load while maintaining the same functionality.
55-57: Enhanced exception handling for invalid formatsThe catch block now uses the specialized
forInvalidFormatfactory method from the new exception class, providing clearer error messages when JSON parsing fails due to format issues.src/MartinGeorgiev/Doctrine/DBAL/Types/Exceptions/InvalidJsonbArrayItemForPHPException.php (3)
9-14: Well-structured exception class with proper inheritanceThe new exception class properly extends Doctrine's
ConversionExceptionand includes a private factory method for creating exception instances with formatted messages. This approach ensures consistent error message formatting.
16-19: Clear factory method for type validation errorsThe
forInvalidTypemethod provides a clear, specific error message for invalid JSON types, making debugging easier by immediately showing what was actually received versus what was expected.
21-24: Specialized factory method for format validation errorsThe
forInvalidFormatmethod creates exceptions with clear error messages for invalid JSON format issues, improving the debugging experience when malformed JSON is encountered.tests/MartinGeorgiev/Doctrine/DBAL/Types/JsonbArrayTest.php (3)
8-8: Updated import to reference the new exception classThe import statement has been correctly updated to use the new
InvalidJsonbArrayItemForPHPExceptionclass, which aligns with the refactoring changes.
93-98: Test method renamed and updated to use data providerThe test method has been renamed to better reflect its broader purpose and now accepts a parameter from the data provider, allowing for more comprehensive testing of different invalid JSON scenarios.
100-101: Updated exception assertionsThe test now correctly expects the new exception class and message, ensuring proper validation of the error handling behavior.
Summary by CodeRabbit
New Features
Bug Fixes