-
-
Notifications
You must be signed in to change notification settings - Fork 515
[3.x] Make Types strongly typed #2945
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
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.
Pull request overview
This pull request adds strong typing to the Types namespace and updates PHPBench benchmarks to use PHP attributes instead of annotations. The changes improve type safety across type conversion methods and modernize the benchmark infrastructure.
Key Changes:
- Added
mixedparameter types and specific return types to type conversion methods across all Type classes - Typed class constants as
stringin Type class and BaseBench - Migrated PHPBench benchmarks from annotation-based to attribute-based configuration
- Added
Stringableinterface implementation to the baseTypeclass
Reviewed changes
Copilot reviewed 30 out of 30 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Types/Type.php | Added Stringable interface, typed constants, and added method parameter/return types |
| src/Types/Versionable.php | Added mixed parameter and return types to interface method |
| src/Types/Incrementable.php | Added mixed parameter and return types to interface method |
| src/Types/StringType.php | Added parameter and return types to conversion methods |
| src/Types/TimestampType.php | Added parameter and return types with proper union types |
| src/Types/RawType.php | Added parameter and return types to conversion methods |
| src/Types/ObjectIdType.php | Added parameter and return types to conversion and version methods |
| src/Types/KeyType.php | Added parameter and return types with proper union types |
| src/Types/IntType.php | Added parameter and return types to all methods |
| src/Types/Int64Type.php | Added parameter and return types, removed redundant interface declarations |
| src/Types/IdType.php | Added parameter and return types to conversion methods |
| src/Types/HashType.php | Added parameter and return types with PHPDoc annotations |
| src/Types/FloatType.php | Added parameter and return types to all methods |
| src/Types/Decimal128Type.php | Added parameter and return types, removed redundant PHPDoc |
| src/Types/DateType.php | Added parameter and return types to all methods |
| src/Types/DateImmutableType.php | Narrowed return type to DateTimeImmutable, removed redundant PHPDoc |
| src/Types/CustomIdType.php | Added parameter and return types to conversion methods |
| src/Types/CollectionType.php | Added parameter and return types with PHPDoc for array structure |
| src/Types/BooleanType.php | Added parameter and return types to conversion methods |
| src/Types/BinDataType.php | Added parameter and return types to conversion methods |
| src/PersistentCollection/DefaultPersistentCollectionGenerator.php | Added union type for $fileName parameter |
| src/Mapping/ClassMetadataFactory.php | Added string type to parameter |
| src/Mapping/ClassMetadata.php | Added parameter types, removed redundant PHPDoc |
| src/Aggregation/Builder.php | Added readonly properties, union types for parameters, removed redundant property assignments |
| tests/Tests/Functional/DocumentPersisterTest.php | Added parameter and return types to custom type implementation |
| tests/Tests/Functional/CustomTypeTest.php | Added parameter and return types with PHPDoc for array structures |
| benchmark/BaseBench.php | Removed @BeforeMethods annotation, typed constants, added property types |
| benchmark/Document/StoreDocumentBench.php | Migrated to PHP attributes for PHPBench configuration |
| benchmark/Document/LoadDocumentBench.php | Migrated to PHP attributes, added property types |
| benchmark/Document/HydrateDocumentBench.php | Migrated to PHP attributes, added property types |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
93cc8dd to
260a585
Compare
1eddc42 to
2139929
Compare
2139929 to
2923dce
Compare
| ->equals('someValue'); | ||
|
|
||
| $stage = ['near' => [0, 0], 'spherical' => false, 'distanceField' => 'distance', 'query' => ['someField' => 'someValue']]; | ||
| $stage = ['near' => [0.0, 0.0], 'spherical' => false, 'distanceField' => 'distance', 'query' => ['someField' => 'someValue']]; |
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.
Noted we convert the value to float with the arg type.
Co-authored-by: Jérôme Tamarelle <[email protected]>
Summary
Add types to
Typesnamespace and some leftovers in other places.