Skip to content

Conversation

@IonBazan
Copy link
Member

@IonBazan IonBazan commented Dec 1, 2025

Q A
Type improvement
BC Break yes
Fixed issues -

Summary

Add types to Types namespace and some leftovers in other places.

@IonBazan IonBazan added this to the 3.0.0 milestone Dec 1, 2025
@IonBazan IonBazan self-assigned this Dec 1, 2025
Copilot finished reviewing on behalf of IonBazan December 1, 2025 07:42
Copy link

Copilot AI left a 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 mixed parameter types and specific return types to type conversion methods across all Type classes
  • Typed class constants as string in Type class and BaseBench
  • Migrated PHPBench benchmarks from annotation-based to attribute-based configuration
  • Added Stringable interface implementation to the base Type class

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.

@IonBazan IonBazan changed the title [3.x] Make Types strongly typed, update benchmarks [3.x] Make Types strongly typed Dec 1, 2025
@IonBazan IonBazan enabled auto-merge (squash) December 1, 2025 11:33
->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']];
Copy link
Member

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]>
@alcaeus alcaeus requested review from GromNaN and removed request for alcaeus December 2, 2025 12:21
@IonBazan IonBazan merged commit 29dda5d into doctrine:3.0.x Dec 4, 2025
15 checks passed
@IonBazan IonBazan deleted the types-stage-2 branch December 4, 2025 08:08
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.

2 participants