├── LICENSE ├── README.md ├── SECURITY.md ├── UPGRADE.md ├── composer.json ├── doctrine-mapping.xsd ├── phpstan-dbal3.neon └── src ├── AbstractQuery.php ├── Cache.php ├── Cache ├── AssociationCacheEntry.php ├── CacheConfiguration.php ├── CacheEntry.php ├── CacheException.php ├── CacheFactory.php ├── CacheKey.php ├── CollectionCacheEntry.php ├── CollectionCacheKey.php ├── CollectionHydrator.php ├── ConcurrentRegion.php ├── DefaultCache.php ├── DefaultCacheFactory.php ├── DefaultCollectionHydrator.php ├── DefaultEntityHydrator.php ├── DefaultQueryCache.php ├── EntityCacheEntry.php ├── EntityCacheKey.php ├── EntityHydrator.php ├── Exception │ ├── CacheException.php │ ├── CannotUpdateReadOnlyCollection.php │ ├── CannotUpdateReadOnlyEntity.php │ ├── FeatureNotImplemented.php │ ├── NonCacheableEntity.php │ └── NonCacheableEntityAssociation.php ├── Lock.php ├── LockException.php ├── Logging │ ├── CacheLogger.php │ ├── CacheLoggerChain.php │ └── StatisticsCacheLogger.php ├── Persister │ ├── CachedPersister.php │ ├── Collection │ │ ├── AbstractCollectionPersister.php │ │ ├── CachedCollectionPersister.php │ │ ├── NonStrictReadWriteCachedCollectionPersister.php │ │ ├── ReadOnlyCachedCollectionPersister.php │ │ └── ReadWriteCachedCollectionPersister.php │ └── Entity │ │ ├── AbstractEntityPersister.php │ │ ├── CachedEntityPersister.php │ │ ├── NonStrictReadWriteCachedEntityPersister.php │ │ ├── ReadOnlyCachedEntityPersister.php │ │ └── ReadWriteCachedEntityPersister.php ├── QueryCache.php ├── QueryCacheEntry.php ├── QueryCacheKey.php ├── QueryCacheValidator.php ├── Region.php ├── Region │ ├── DefaultRegion.php │ ├── FileLockRegion.php │ └── UpdateTimestampCache.php ├── RegionsConfiguration.php ├── TimestampCacheEntry.php ├── TimestampCacheKey.php ├── TimestampQueryCacheValidator.php └── TimestampRegion.php ├── Configuration.php ├── Decorator └── EntityManagerDecorator.php ├── EntityManager.php ├── EntityManagerInterface.php ├── EntityNotFoundException.php ├── EntityRepository.php ├── Event ├── ListenersInvoker.php ├── LoadClassMetadataEventArgs.php ├── OnClassMetadataNotFoundEventArgs.php ├── OnClearEventArgs.php ├── OnFlushEventArgs.php ├── PostFlushEventArgs.php ├── PostLoadEventArgs.php ├── PostPersistEventArgs.php ├── PostRemoveEventArgs.php ├── PostUpdateEventArgs.php ├── PreFlushEventArgs.php ├── PrePersistEventArgs.php ├── PreRemoveEventArgs.php └── PreUpdateEventArgs.php ├── Events.php ├── Exception ├── ConfigurationException.php ├── DuplicateFieldException.php ├── EntityIdentityCollisionException.php ├── EntityManagerClosed.php ├── EntityMissingAssignedId.php ├── InvalidEntityRepository.php ├── InvalidHydrationMode.php ├── ManagerException.php ├── MissingIdentifierField.php ├── MissingMappingDriverImplementation.php ├── MultipleSelectorsFoundException.php ├── NoMatchingPropertyException.php ├── NotSupported.php ├── ORMException.php ├── PersisterException.php ├── RepositoryException.php ├── SchemaToolException.php ├── UnexpectedAssociationValue.php └── UnrecognizedIdentifierFields.php ├── Id ├── AbstractIdGenerator.php ├── AssignedGenerator.php ├── BigIntegerIdentityGenerator.php ├── IdentityGenerator.php └── SequenceGenerator.php ├── Internal ├── Hydration │ ├── AbstractHydrator.php │ ├── ArrayHydrator.php │ ├── HydrationException.php │ ├── ObjectHydrator.php │ ├── ScalarColumnHydrator.php │ ├── ScalarHydrator.php │ ├── SimpleObjectHydrator.php │ └── SingleScalarHydrator.php ├── HydrationCompleteHandler.php ├── NoUnknownNamedArguments.php ├── QueryType.php ├── SQLResultCasing.php ├── StronglyConnectedComponents.php ├── TopologicalSort.php └── TopologicalSort │ └── CycleDetectedException.php ├── LazyCriteriaCollection.php ├── Mapping ├── AnsiQuoteStrategy.php ├── ArrayAccessImplementation.php ├── AssociationMapping.php ├── AssociationOverride.php ├── AssociationOverrides.php ├── AttributeOverride.php ├── AttributeOverrides.php ├── Builder │ ├── AssociationBuilder.php │ ├── ClassMetadataBuilder.php │ ├── EmbeddedBuilder.php │ ├── EntityListenerBuilder.php │ ├── FieldBuilder.php │ ├── ManyToManyAssociationBuilder.php │ └── OneToManyAssociationBuilder.php ├── Cache.php ├── ChainTypedFieldMapper.php ├── ChangeTrackingPolicy.php ├── ClassMetadata.php ├── ClassMetadataFactory.php ├── Column.php ├── CustomIdGenerator.php ├── DefaultEntityListenerResolver.php ├── DefaultNamingStrategy.php ├── DefaultQuoteStrategy.php ├── DefaultTypedFieldMapper.php ├── DiscriminatorColumn.php ├── DiscriminatorColumnMapping.php ├── DiscriminatorMap.php ├── Driver │ ├── AttributeDriver.php │ ├── AttributeReader.php │ ├── DatabaseDriver.php │ ├── LoadMappingFileImplementation.php │ ├── ReflectionBasedDriver.php │ ├── RepeatableAttributeCollection.php │ ├── SimplifiedXmlDriver.php │ └── XmlDriver.php ├── Embeddable.php ├── Embedded.php ├── EmbeddedClassMapping.php ├── Entity.php ├── EntityListenerResolver.php ├── EntityListeners.php ├── Exception │ ├── InvalidCustomGenerator.php │ └── UnknownGeneratorType.php ├── FieldMapping.php ├── GeneratedValue.php ├── GetReflectionClassImplementation.php ├── HasLifecycleCallbacks.php ├── Id.php ├── Index.php ├── InheritanceType.php ├── InverseJoinColumn.php ├── InverseSideMapping.php ├── JoinColumn.php ├── JoinColumnMapping.php ├── JoinColumnProperties.php ├── JoinColumns.php ├── JoinTable.php ├── JoinTableMapping.php ├── ManyToMany.php ├── ManyToManyAssociationMapping.php ├── ManyToManyInverseSideMapping.php ├── ManyToManyOwningSideMapping.php ├── ManyToOne.php ├── ManyToOneAssociationMapping.php ├── MappedSuperclass.php ├── MappingAttribute.php ├── MappingException.php ├── NamingStrategy.php ├── OneToMany.php ├── OneToManyAssociationMapping.php ├── OneToOne.php ├── OneToOneAssociationMapping.php ├── OneToOneInverseSideMapping.php ├── OneToOneOwningSideMapping.php ├── OrderBy.php ├── OwningSideMapping.php ├── PostLoad.php ├── PostPersist.php ├── PostRemove.php ├── PostUpdate.php ├── PreFlush.php ├── PrePersist.php ├── PreRemove.php ├── PreUpdate.php ├── QuoteStrategy.php ├── ReflectionEmbeddedProperty.php ├── ReflectionEnumProperty.php ├── ReflectionReadonlyProperty.php ├── SequenceGenerator.php ├── Table.php ├── ToManyAssociationMapping.php ├── ToManyAssociationMappingImplementation.php ├── ToManyInverseSideMapping.php ├── ToManyOwningSideMapping.php ├── ToOneAssociationMapping.php ├── ToOneInverseSideMapping.php ├── ToOneOwningSideMapping.php ├── TypedFieldMapper.php ├── UnderscoreNamingStrategy.php ├── UniqueConstraint.php └── Version.php ├── NativeQuery.php ├── NoResultException.php ├── NonUniqueResultException.php ├── ORMInvalidArgumentException.php ├── ORMSetup.php ├── OptimisticLockException.php ├── PersistentCollection.php ├── Persisters ├── Collection │ ├── AbstractCollectionPersister.php │ ├── CollectionPersister.php │ ├── ManyToManyPersister.php │ └── OneToManyPersister.php ├── Entity │ ├── AbstractEntityInheritancePersister.php │ ├── BasicEntityPersister.php │ ├── CachedPersisterContext.php │ ├── EntityPersister.php │ ├── JoinedSubclassPersister.php │ └── SingleTablePersister.php ├── Exception │ ├── CantUseInOperatorOnCompositeKeys.php │ ├── InvalidOrientation.php │ └── UnrecognizedField.php ├── MatchingAssociationFieldRequiresObject.php ├── PersisterException.php ├── SqlExpressionVisitor.php └── SqlValueVisitor.php ├── PessimisticLockException.php ├── Proxy ├── Autoloader.php ├── DefaultProxyClassNameResolver.php ├── InternalProxy.php ├── NotAProxyClass.php └── ProxyFactory.php ├── Query.php ├── Query ├── AST │ ├── ASTException.php │ ├── AggregateExpression.php │ ├── ArithmeticExpression.php │ ├── ArithmeticFactor.php │ ├── ArithmeticTerm.php │ ├── BetweenExpression.php │ ├── CoalesceExpression.php │ ├── CollectionMemberExpression.php │ ├── ComparisonExpression.php │ ├── ConditionalExpression.php │ ├── ConditionalFactor.php │ ├── ConditionalPrimary.php │ ├── ConditionalTerm.php │ ├── DeleteClause.php │ ├── DeleteStatement.php │ ├── EmptyCollectionComparisonExpression.php │ ├── ExistsExpression.php │ ├── FromClause.php │ ├── Functions │ │ ├── AbsFunction.php │ │ ├── AvgFunction.php │ │ ├── BitAndFunction.php │ │ ├── BitOrFunction.php │ │ ├── ConcatFunction.php │ │ ├── CountFunction.php │ │ ├── CurrentDateFunction.php │ │ ├── CurrentTimeFunction.php │ │ ├── CurrentTimestampFunction.php │ │ ├── DateAddFunction.php │ │ ├── DateDiffFunction.php │ │ ├── DateSubFunction.php │ │ ├── FunctionNode.php │ │ ├── IdentityFunction.php │ │ ├── LengthFunction.php │ │ ├── LocateFunction.php │ │ ├── LowerFunction.php │ │ ├── MaxFunction.php │ │ ├── MinFunction.php │ │ ├── ModFunction.php │ │ ├── SizeFunction.php │ │ ├── SqrtFunction.php │ │ ├── SubstringFunction.php │ │ ├── SumFunction.php │ │ ├── TrimFunction.php │ │ └── UpperFunction.php │ ├── GeneralCaseExpression.php │ ├── GroupByClause.php │ ├── HavingClause.php │ ├── IdentificationVariableDeclaration.php │ ├── InListExpression.php │ ├── InSubselectExpression.php │ ├── IndexBy.php │ ├── InputParameter.php │ ├── InstanceOfExpression.php │ ├── Join.php │ ├── JoinAssociationDeclaration.php │ ├── JoinAssociationPathExpression.php │ ├── JoinClassPathExpression.php │ ├── JoinVariableDeclaration.php │ ├── LikeExpression.php │ ├── Literal.php │ ├── NewObjectExpression.php │ ├── Node.php │ ├── NullComparisonExpression.php │ ├── NullIfExpression.php │ ├── OrderByClause.php │ ├── OrderByItem.php │ ├── ParenthesisExpression.php │ ├── PartialObjectExpression.php │ ├── PathExpression.php │ ├── Phase2OptimizableConditional.php │ ├── QuantifiedExpression.php │ ├── RangeVariableDeclaration.php │ ├── SelectClause.php │ ├── SelectExpression.php │ ├── SelectStatement.php │ ├── SimpleArithmeticExpression.php │ ├── SimpleCaseExpression.php │ ├── SimpleSelectClause.php │ ├── SimpleSelectExpression.php │ ├── SimpleWhenClause.php │ ├── Subselect.php │ ├── SubselectFromClause.php │ ├── SubselectIdentificationVariableDeclaration.php │ ├── TypedExpression.php │ ├── UpdateClause.php │ ├── UpdateItem.php │ ├── UpdateStatement.php │ ├── WhenClause.php │ └── WhereClause.php ├── Exec │ ├── AbstractSqlExecutor.php │ ├── FinalizedSelectExecutor.php │ ├── MultiTableDeleteExecutor.php │ ├── MultiTableUpdateExecutor.php │ ├── PreparedExecutorFinalizer.php │ ├── SingleSelectExecutor.php │ ├── SingleSelectSqlFinalizer.php │ ├── SingleTableDeleteUpdateExecutor.php │ └── SqlFinalizer.php ├── Expr.php ├── Expr │ ├── Andx.php │ ├── Base.php │ ├── Comparison.php │ ├── Composite.php │ ├── From.php │ ├── Func.php │ ├── GroupBy.php │ ├── Join.php │ ├── Literal.php │ ├── Math.php │ ├── OrderBy.php │ ├── Orx.php │ └── Select.php ├── Filter │ ├── FilterException.php │ └── SQLFilter.php ├── FilterCollection.php ├── Lexer.php ├── OutputWalker.php ├── Parameter.php ├── ParameterTypeInferer.php ├── Parser.php ├── ParserResult.php ├── Printer.php ├── QueryException.php ├── QueryExpressionVisitor.php ├── ResultSetMapping.php ├── ResultSetMappingBuilder.php ├── SqlOutputWalker.php ├── SqlWalker.php ├── TokenType.php ├── TreeWalker.php ├── TreeWalkerAdapter.php └── TreeWalkerChain.php ├── QueryBuilder.php ├── Repository ├── DefaultRepositoryFactory.php ├── Exception │ ├── InvalidFindByCall.php │ └── InvalidMagicMethodCall.php └── RepositoryFactory.php ├── Tools ├── AttachEntityListenersListener.php ├── Console │ ├── Command │ │ ├── AbstractEntityManagerCommand.php │ │ ├── ClearCache │ │ │ ├── CollectionRegionCommand.php │ │ │ ├── EntityRegionCommand.php │ │ │ ├── MetadataCommand.php │ │ │ ├── QueryCommand.php │ │ │ ├── QueryRegionCommand.php │ │ │ └── ResultCommand.php │ │ ├── GenerateProxiesCommand.php │ │ ├── InfoCommand.php │ │ ├── MappingDescribeCommand.php │ │ ├── RunDqlCommand.php │ │ ├── SchemaTool │ │ │ ├── AbstractCommand.php │ │ │ ├── CreateCommand.php │ │ │ ├── DropCommand.php │ │ │ └── UpdateCommand.php │ │ └── ValidateSchemaCommand.php │ ├── ConsoleRunner.php │ ├── EntityManagerProvider.php │ ├── EntityManagerProvider │ │ ├── ConnectionFromManagerProvider.php │ │ ├── SingleManagerProvider.php │ │ └── UnknownManagerException.php │ └── MetadataFilter.php ├── Debug.php ├── DebugUnitOfWorkListener.php ├── Event │ ├── GenerateSchemaEventArgs.php │ └── GenerateSchemaTableEventArgs.php ├── Exception │ ├── MissingColumnException.php │ └── NotSupported.php ├── Pagination │ ├── CountOutputWalker.php │ ├── CountWalker.php │ ├── Exception │ │ └── RowNumberOverFunctionNotEnabled.php │ ├── LimitSubqueryOutputWalker.php │ ├── LimitSubqueryWalker.php │ ├── Paginator.php │ ├── RootTypeWalker.php │ ├── RowNumberOverFunction.php │ └── WhereInWalker.php ├── ResolveTargetEntityListener.php ├── SchemaTool.php ├── SchemaValidator.php ├── ToolEvents.php └── ToolsException.php ├── TransactionRequiredException.php ├── UnexpectedResultException.php ├── UnitOfWork.php └── Utility ├── HierarchyDiscriminatorResolver.php ├── IdentifierFlattener.php ├── LockSqlHelper.php └── PersisterHelper.php /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) Doctrine Project 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | Security 2 | ======== 3 | 4 | The Doctrine library is operating very close to your database and as such needs 5 | to handle and make assumptions about SQL injection vulnerabilities. 6 | 7 | It is vital that you understand how Doctrine approaches security, because 8 | we cannot protect you from SQL injection. 9 | 10 | Please read the documentation chapter on Security in Doctrine DBAL and ORM to 11 | understand the assumptions we make. 12 | 13 | - [DBAL Security Page](https://www.doctrine-project.org/projects/doctrine-dbal/en/stable/reference/security.html) 14 | - [ORM Security Page](https://www.doctrine-project.org/projects/doctrine-orm/en/stable/reference/security.html) 15 | 16 | If you find a Security bug in Doctrine, please follow our 17 | [Security reporting guidelines](https://www.doctrine-project.org/policies/security.html#reporting). 18 | -------------------------------------------------------------------------------- /src/Cache/AssociationCacheEntry.php: -------------------------------------------------------------------------------- 1 | $identifier The entity identifier. 11 | * @param class-string $class The entity class name 12 | */ 13 | public function __construct( 14 | public readonly string $class, 15 | public readonly array $identifier, 16 | ) { 17 | } 18 | 19 | /** 20 | * Creates a new AssociationCacheEntry 21 | * 22 | * This method allow Doctrine\Common\Cache\PhpFileCache compatibility 23 | * 24 | * @param array $values array containing property values 25 | */ 26 | public static function __set_state(array $values): self 27 | { 28 | return new self($values['class'], $values['identifier']); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Cache/CacheEntry.php: -------------------------------------------------------------------------------- 1 | IMPORTANT NOTE: 11 | * 12 | * Fields of classes that implement CacheEntry are public for performance reason. 13 | */ 14 | interface CacheEntry 15 | { 16 | } 17 | -------------------------------------------------------------------------------- /src/Cache/CacheException.php: -------------------------------------------------------------------------------- 1 | $values array containing property values 20 | */ 21 | public static function __set_state(array $values): CollectionCacheEntry 22 | { 23 | return new self($values['identifiers']); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Cache/CollectionCacheKey.php: -------------------------------------------------------------------------------- 1 | 21 | */ 22 | public readonly array $ownerIdentifier; 23 | 24 | /** 25 | * @param class-string $entityClass The owner entity class. 26 | * @param array $ownerIdentifier The identifier of the owning entity. 27 | */ 28 | public function __construct( 29 | public readonly string $entityClass, 30 | public readonly string $association, 31 | array $ownerIdentifier, 32 | string $filterHash = '', 33 | ) { 34 | ksort($ownerIdentifier); 35 | 36 | $this->ownerIdentifier = $ownerIdentifier; 37 | 38 | $filterHash = $filterHash === '' ? '' : '_' . $filterHash; 39 | 40 | parent::__construct(str_replace('\\', '.', strtolower($entityClass)) . '_' . implode(' ', $ownerIdentifier) . '__' . $association . $filterHash); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/Cache/CollectionHydrator.php: -------------------------------------------------------------------------------- 1 | $data The entity map data 16 | */ 17 | public function __construct( 18 | public readonly string $class, 19 | public readonly array $data, 20 | ) { 21 | } 22 | 23 | /** 24 | * Creates a new EntityCacheEntry 25 | * 26 | * This method allows Doctrine\Common\Cache\PhpFileCache compatibility 27 | * 28 | * @param array $values array containing property values 29 | */ 30 | public static function __set_state(array $values): self 31 | { 32 | return new self($values['class'], $values['data']); 33 | } 34 | 35 | /** 36 | * Retrieves the entity data resolving cache entries 37 | * 38 | * @return array 39 | */ 40 | public function resolveAssociationEntries(EntityManagerInterface $em): array 41 | { 42 | return array_map(static function ($value) use ($em) { 43 | if (! ($value instanceof AssociationCacheEntry)) { 44 | return $value; 45 | } 46 | 47 | return $em->getReference($value->class, $value->identifier); 48 | }, $this->data); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/Cache/EntityCacheKey.php: -------------------------------------------------------------------------------- 1 | 21 | */ 22 | public readonly array $identifier; 23 | 24 | /** 25 | * @param class-string $entityClass The entity class name. In a inheritance hierarchy it should always be the root entity class. 26 | * @param array $identifier The entity identifier 27 | */ 28 | public function __construct( 29 | public readonly string $entityClass, 30 | array $identifier, 31 | ) { 32 | ksort($identifier); 33 | 34 | $this->identifier = $identifier; 35 | 36 | parent::__construct(str_replace('\\', '.', strtolower($entityClass) . '_' . implode(' ', $identifier))); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Cache/EntityHydrator.php: -------------------------------------------------------------------------------- 1 | time = $time ?? time(); 19 | } 20 | 21 | public static function createLockRead(): Lock 22 | { 23 | return new self(uniqid((string) time(), true)); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Cache/LockException.php: -------------------------------------------------------------------------------- 1 | isDirty() && $collection->getSnapshot()) { 16 | throw CannotUpdateReadOnlyCollection::fromEntityAndField( 17 | DefaultProxyClassNameResolver::getClass($collection->getOwner()), 18 | $this->association->fieldName, 19 | ); 20 | } 21 | 22 | parent::update($collection); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Cache/Persister/Entity/CachedEntityPersister.php: -------------------------------------------------------------------------------- 1 | $result List of entity identifiers */ 17 | public function __construct( 18 | public readonly array $result, 19 | float|null $time = null, 20 | ) { 21 | $this->time = $time ?: microtime(true); 22 | } 23 | 24 | /** @param array $values */ 25 | public static function __set_state(array $values): self 26 | { 27 | return new self($values['result'], $values['time']); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Cache/QueryCacheKey.php: -------------------------------------------------------------------------------- 1 | put($key, new TimestampCacheEntry()); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Cache/TimestampCacheEntry.php: -------------------------------------------------------------------------------- 1 | time = $time ?? microtime(true); 16 | } 17 | 18 | /** 19 | * Creates a new TimestampCacheEntry 20 | * 21 | * This method allow Doctrine\Common\Cache\PhpFileCache compatibility 22 | * 23 | * @param array $values array containing property values 24 | */ 25 | public static function __set_state(array $values): TimestampCacheEntry 26 | { 27 | return new self($values['time']); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Cache/TimestampCacheKey.php: -------------------------------------------------------------------------------- 1 | regionUpdated($key, $entry)) { 18 | return false; 19 | } 20 | 21 | if ($key->lifetime === 0) { 22 | return true; 23 | } 24 | 25 | return $entry->time + $key->lifetime > microtime(true); 26 | } 27 | 28 | private function regionUpdated(QueryCacheKey $key, QueryCacheEntry $entry): bool 29 | { 30 | if ($key->timestampKey === null) { 31 | return false; 32 | } 33 | 34 | $timestamp = $this->timestampRegion->get($key->timestampKey); 35 | 36 | return $timestamp && $timestamp->time > $entry->time; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Cache/TimestampRegion.php: -------------------------------------------------------------------------------- 1 | $value) { 28 | $ids[] = $key . '(' . $value . ')'; 29 | } 30 | 31 | return new self( 32 | 'Entity of type \'' . $className . '\'' . ($ids ? ' for IDs ' . implode(', ', $ids) : '') . ' was not found', 33 | ); 34 | } 35 | 36 | /** 37 | * Instance for which no identifier can be found 38 | */ 39 | public static function noIdentifierFound(string $className): self 40 | { 41 | return new self(sprintf( 42 | 'Unable to find "%s" entity identifier associated with the UnitOfWork', 43 | $className, 44 | )); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Event/LoadClassMetadataEventArgs.php: -------------------------------------------------------------------------------- 1 | , EntityManagerInterface> 15 | */ 16 | class LoadClassMetadataEventArgs extends BaseLoadClassMetadataEventArgs 17 | { 18 | /** 19 | * Retrieve associated EntityManager. 20 | */ 21 | public function getEntityManager(): EntityManagerInterface 22 | { 23 | return $this->getObjectManager(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Event/OnClearEventArgs.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class OnClearEventArgs extends BaseOnClearEventArgs 18 | { 19 | } 20 | -------------------------------------------------------------------------------- /src/Event/OnFlushEventArgs.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class OnFlushEventArgs extends ManagerEventArgs 18 | { 19 | } 20 | -------------------------------------------------------------------------------- /src/Event/PostFlushEventArgs.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class PostFlushEventArgs extends ManagerEventArgs 18 | { 19 | } 20 | -------------------------------------------------------------------------------- /src/Event/PostLoadEventArgs.php: -------------------------------------------------------------------------------- 1 | */ 11 | final class PostLoadEventArgs extends LifecycleEventArgs 12 | { 13 | } 14 | -------------------------------------------------------------------------------- /src/Event/PostPersistEventArgs.php: -------------------------------------------------------------------------------- 1 | */ 11 | final class PostPersistEventArgs extends LifecycleEventArgs 12 | { 13 | } 14 | -------------------------------------------------------------------------------- /src/Event/PostRemoveEventArgs.php: -------------------------------------------------------------------------------- 1 | */ 11 | final class PostRemoveEventArgs extends LifecycleEventArgs 12 | { 13 | } 14 | -------------------------------------------------------------------------------- /src/Event/PostUpdateEventArgs.php: -------------------------------------------------------------------------------- 1 | */ 11 | final class PostUpdateEventArgs extends LifecycleEventArgs 12 | { 13 | } 14 | -------------------------------------------------------------------------------- /src/Event/PreFlushEventArgs.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class PreFlushEventArgs extends ManagerEventArgs 18 | { 19 | } 20 | -------------------------------------------------------------------------------- /src/Event/PrePersistEventArgs.php: -------------------------------------------------------------------------------- 1 | */ 11 | final class PrePersistEventArgs extends LifecycleEventArgs 12 | { 13 | } 14 | -------------------------------------------------------------------------------- /src/Event/PreRemoveEventArgs.php: -------------------------------------------------------------------------------- 1 | */ 11 | final class PreRemoveEventArgs extends LifecycleEventArgs 12 | { 13 | } 14 | -------------------------------------------------------------------------------- /src/Exception/ConfigurationException.php: -------------------------------------------------------------------------------- 1 | getClassMetadata($entity::class); 25 | $idFields = $class->getIdentifierFieldNames(); 26 | $identifier = []; 27 | 28 | foreach ($idFields as $idField) { 29 | $value = $class->getFieldValue($entity, $idField); 30 | 31 | if (! isset($value)) { 32 | throw EntityMissingAssignedId::forField($entity, $idField); 33 | } 34 | 35 | if (isset($class->associationMappings[$idField])) { 36 | // NOTE: Single Columns as associated identifiers only allowed - this constraint it is enforced. 37 | $value = $em->getUnitOfWork()->getSingleIdentifierValue($value); 38 | } 39 | 40 | $identifier[$idField] = $value; 41 | } 42 | 43 | return $identifier; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Id/BigIntegerIdentityGenerator.php: -------------------------------------------------------------------------------- 1 | getConnection()->lastInsertId(); 19 | } 20 | 21 | public function isPostInsertGenerator(): bool 22 | { 23 | return true; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Id/IdentityGenerator.php: -------------------------------------------------------------------------------- 1 | getConnection()->lastInsertId(); 19 | } 20 | 21 | public function isPostInsertGenerator(): bool 22 | { 23 | return true; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Internal/Hydration/ScalarColumnHydrator.php: -------------------------------------------------------------------------------- 1 | resultSetMapping()->fieldMappings) > 1) { 27 | throw MultipleSelectorsFoundException::create($this->resultSetMapping()->fieldMappings); 28 | } 29 | 30 | $result = $this->statement()->fetchAllNumeric(); 31 | 32 | return array_column($result, 0); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Internal/Hydration/ScalarHydrator.php: -------------------------------------------------------------------------------- 1 | statement()->fetchAssociative()) { 22 | $this->hydrateRowData($data, $result); 23 | } 24 | 25 | return $result; 26 | } 27 | 28 | /** 29 | * {@inheritDoc} 30 | */ 31 | protected function hydrateRowData(array $row, array &$result): void 32 | { 33 | $result[] = $this->gatherScalarRowData($row); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Internal/Hydration/SingleScalarHydrator.php: -------------------------------------------------------------------------------- 1 | statement()->fetchAllAssociative(); 22 | $numRows = count($data); 23 | 24 | if ($numRows === 0) { 25 | throw new NoResultException(); 26 | } 27 | 28 | if ($numRows > 1) { 29 | throw new NonUniqueResultException('The query returned multiple rows. Change the query or use a different result function like getScalarResult().'); 30 | } 31 | 32 | $result = $this->gatherScalarRowData($data[key($data)]); 33 | 34 | if (count($result) > 1) { 35 | throw new NonUniqueResultException('The query returned a row containing multiple columns. Change the query or use a different result function like getScalarResult().'); 36 | } 37 | 38 | return array_shift($result); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Internal/QueryType.php: -------------------------------------------------------------------------------- 1 | */ 14 | private array $cycle; 15 | 16 | /** 17 | * Do we have the complete cycle collected? 18 | */ 19 | private bool $cycleCollected = false; 20 | 21 | public function __construct(private readonly object $startNode) 22 | { 23 | parent::__construct('A cycle has been detected, so a topological sort is not possible. The getCycle() method provides the list of nodes that form the cycle.'); 24 | 25 | $this->cycle = [$startNode]; 26 | } 27 | 28 | /** @return list */ 29 | public function getCycle(): array 30 | { 31 | return $this->cycle; 32 | } 33 | 34 | public function addToCycle(object $node): void 35 | { 36 | array_unshift($this->cycle, $node); 37 | 38 | if ($node === $this->startNode) { 39 | $this->cycleCollected = true; 40 | } 41 | } 42 | 43 | public function isCycleCollected(): bool 44 | { 45 | return $this->cycleCollected; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Mapping/AssociationOverrides.php: -------------------------------------------------------------------------------- 1 | 20 | */ 21 | public readonly array $overrides; 22 | 23 | /** @param array|AssociationOverride $overrides */ 24 | public function __construct(array|AssociationOverride $overrides) 25 | { 26 | if (! is_array($overrides)) { 27 | $overrides = [$overrides]; 28 | } 29 | 30 | foreach ($overrides as $override) { 31 | if (! ($override instanceof AssociationOverride)) { 32 | throw MappingException::invalidOverrideType('AssociationOverride', $override); 33 | } 34 | } 35 | 36 | $this->overrides = array_values($overrides); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Mapping/AttributeOverride.php: -------------------------------------------------------------------------------- 1 | 20 | */ 21 | public readonly array $overrides; 22 | 23 | /** @param array|AttributeOverride $overrides */ 24 | public function __construct(array|AttributeOverride $overrides) 25 | { 26 | if (! is_array($overrides)) { 27 | $overrides = [$overrides]; 28 | } 29 | 30 | foreach ($overrides as $override) { 31 | if (! ($override instanceof AttributeOverride)) { 32 | throw MappingException::invalidOverrideType('AttributeOverride', $override); 33 | } 34 | } 35 | 36 | $this->overrides = array_values($overrides); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Mapping/Builder/EmbeddedBuilder.php: -------------------------------------------------------------------------------- 1 | mapping['columnPrefix'] = $columnPrefix; 29 | 30 | return $this; 31 | } 32 | 33 | /** 34 | * Finalizes this embeddable and attach it to the ClassMetadata. 35 | * 36 | * Without this call an EmbeddedBuilder has no effect on the ClassMetadata. 37 | */ 38 | public function build(): ClassMetadataBuilder 39 | { 40 | $cm = $this->builder->getClassMetadata(); 41 | 42 | $cm->mapEmbedded($this->mapping); 43 | 44 | return $this->builder; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Mapping/Builder/OneToManyAssociationBuilder.php: -------------------------------------------------------------------------------- 1 | $fieldNames 16 | * 17 | * @return $this 18 | */ 19 | public function setOrderBy(array $fieldNames): static 20 | { 21 | $this->mapping['orderBy'] = $fieldNames; 22 | 23 | return $this; 24 | } 25 | 26 | /** @return $this */ 27 | public function setIndexBy(string $fieldName): static 28 | { 29 | $this->mapping['indexBy'] = $fieldName; 30 | 31 | return $this; 32 | } 33 | 34 | public function build(): ClassMetadataBuilder 35 | { 36 | $mapping = $this->mapping; 37 | if ($this->joinColumns) { 38 | $mapping['joinColumns'] = $this->joinColumns; 39 | } 40 | 41 | $cm = $this->builder->getClassMetadata(); 42 | $cm->mapOneToMany($mapping); 43 | 44 | return $this->builder; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Mapping/Cache.php: -------------------------------------------------------------------------------- 1 | $typedFieldMappers */ 15 | private readonly array $typedFieldMappers; 16 | 17 | public function __construct(TypedFieldMapper ...$typedFieldMappers) 18 | { 19 | self::validateVariadicParameter($typedFieldMappers); 20 | 21 | $this->typedFieldMappers = $typedFieldMappers; 22 | } 23 | 24 | /** 25 | * {@inheritDoc} 26 | */ 27 | public function validateAndComplete(array $mapping, ReflectionProperty $field): array 28 | { 29 | foreach ($this->typedFieldMappers as $typedFieldMapper) { 30 | $mapping = $typedFieldMapper->validateAndComplete($mapping, $field); 31 | } 32 | 33 | return $mapping; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Mapping/ChangeTrackingPolicy.php: -------------------------------------------------------------------------------- 1 | |null $enumType 17 | * @param array $options 18 | * @phpstan-param 'NEVER'|'INSERT'|'ALWAYS'|null $generated 19 | */ 20 | public function __construct( 21 | public readonly string|null $name = null, 22 | public readonly string|null $type = null, 23 | public readonly int|null $length = null, 24 | public readonly int|null $precision = null, 25 | public readonly int|null $scale = null, 26 | public readonly bool $unique = false, 27 | public readonly bool $nullable = false, 28 | public readonly bool $insertable = true, 29 | public readonly bool $updatable = true, 30 | public readonly string|null $enumType = null, 31 | public readonly array $options = [], 32 | public readonly string|null $columnDefinition = null, 33 | public readonly string|null $generated = null, 34 | ) { 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Mapping/CustomIdGenerator.php: -------------------------------------------------------------------------------- 1 | Map to store entity listener instances. */ 15 | private array $instances = []; 16 | 17 | public function clear(string|null $className = null): void 18 | { 19 | if ($className === null) { 20 | $this->instances = []; 21 | 22 | return; 23 | } 24 | 25 | $className = trim($className, '\\'); 26 | unset($this->instances[$className]); 27 | } 28 | 29 | public function register(object $object): void 30 | { 31 | $this->instances[$object::class] = $object; 32 | } 33 | 34 | public function resolve(string $className): object 35 | { 36 | $className = trim($className, '\\'); 37 | 38 | return $this->instances[$className] ??= new $className(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Mapping/DiscriminatorColumn.php: -------------------------------------------------------------------------------- 1 | |null */ 19 | public readonly string|null $enumType = null, 20 | /** @var array */ 21 | public readonly array $options = [], 22 | ) { 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Mapping/DiscriminatorMap.php: -------------------------------------------------------------------------------- 1 | $value */ 13 | public function __construct( 14 | public readonly array $value, 15 | ) { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Mapping/Driver/LoadMappingFileImplementation.php: -------------------------------------------------------------------------------- 1 | doLoadMappingFile($file); 21 | } 22 | } 23 | } else { 24 | /** @internal */ 25 | trait LoadMappingFileImplementation 26 | { 27 | /** 28 | * {@inheritDoc} 29 | */ 30 | protected function loadMappingFile($file) 31 | { 32 | return $this->doLoadMappingFile($file); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Mapping/Driver/RepeatableAttributeCollection.php: -------------------------------------------------------------------------------- 1 | 12 | * @template T of MappingAttribute 13 | */ 14 | final class RepeatableAttributeCollection extends ArrayObject 15 | { 16 | } 17 | -------------------------------------------------------------------------------- /src/Mapping/Driver/SimplifiedXmlDriver.php: -------------------------------------------------------------------------------- 1 | >|null $repositoryClass */ 15 | public function __construct( 16 | public readonly string|null $repositoryClass = null, 17 | public readonly bool $readOnly = false, 18 | ) { 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Mapping/EntityListenerResolver.php: -------------------------------------------------------------------------------- 1 | $value */ 17 | public function __construct( 18 | public readonly array $value = [], 19 | ) { 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Mapping/Exception/InvalidCustomGenerator.php: -------------------------------------------------------------------------------- 1 | reflClass; 18 | } 19 | } 20 | } else { 21 | trait GetReflectionClassImplementation 22 | { 23 | /** 24 | * {@inheritDoc} 25 | * 26 | * Can return null when using static reflection, in violation of the LSP 27 | */ 28 | public function getReflectionClass(): ReflectionClass|null 29 | { 30 | return $this->reflClass; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Mapping/HasLifecycleCallbacks.php: -------------------------------------------------------------------------------- 1 | |null $columns 14 | * @param array|null $fields 15 | * @param array|null $flags 16 | * @param array|null $options 17 | */ 18 | public function __construct( 19 | public readonly string|null $name = null, 20 | public readonly array|null $columns = null, 21 | public readonly array|null $fields = null, 22 | public readonly array|null $flags = null, 23 | public readonly array|null $options = null, 24 | ) { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Mapping/InheritanceType.php: -------------------------------------------------------------------------------- 1 | mappedBy; 20 | } 21 | 22 | /** @return list */ 23 | public function __sleep(): array 24 | { 25 | return [ 26 | ...parent::__sleep(), 27 | 'mappedBy', 28 | ]; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Mapping/JoinColumn.php: -------------------------------------------------------------------------------- 1 | $options */ 10 | public function __construct( 11 | public readonly string|null $name = null, 12 | public readonly string $referencedColumnName = 'id', 13 | public readonly bool $unique = false, 14 | public readonly bool $nullable = true, 15 | public readonly mixed $onDelete = null, 16 | public readonly string|null $columnDefinition = null, 17 | public readonly string|null $fieldName = null, 18 | public readonly array $options = [], 19 | ) { 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Mapping/JoinColumns.php: -------------------------------------------------------------------------------- 1 | $value */ 10 | public function __construct( 11 | public readonly array $value, 12 | ) { 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/Mapping/JoinTable.php: -------------------------------------------------------------------------------- 1 | */ 13 | public readonly array $joinColumns; 14 | 15 | /** @var array */ 16 | public readonly array $inverseJoinColumns; 17 | 18 | /** 19 | * @param array|JoinColumn $joinColumns 20 | * @param array|JoinColumn $inverseJoinColumns 21 | * @param array $options 22 | */ 23 | public function __construct( 24 | public readonly string|null $name = null, 25 | public readonly string|null $schema = null, 26 | array|JoinColumn $joinColumns = [], 27 | array|JoinColumn $inverseJoinColumns = [], 28 | public readonly array $options = [], 29 | ) { 30 | $this->joinColumns = $joinColumns instanceof JoinColumn ? [$joinColumns] : $joinColumns; 31 | $this->inverseJoinColumns = $inverseJoinColumns instanceof JoinColumn 32 | ? [$inverseJoinColumns] 33 | : $inverseJoinColumns; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Mapping/ManyToMany.php: -------------------------------------------------------------------------------- 1 | |null $repositoryClass */ 14 | public function __construct( 15 | public readonly string|null $repositoryClass = null, 16 | ) { 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/Mapping/MappingAttribute.php: -------------------------------------------------------------------------------- 1 | |null $cascade 15 | * @phpstan-param 'LAZY'|'EAGER'|'EXTRA_LAZY' $fetch 16 | */ 17 | public function __construct( 18 | public readonly string|null $targetEntity = null, 19 | public readonly string|null $mappedBy = null, 20 | public readonly string|null $inversedBy = null, 21 | public readonly array|null $cascade = null, 22 | public readonly string $fetch = 'LAZY', 23 | public readonly bool $orphanRemoval = false, 24 | ) { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Mapping/OneToOneAssociationMapping.php: -------------------------------------------------------------------------------- 1 | $value */ 13 | public function __construct( 14 | public readonly array $value, 15 | ) { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Mapping/OwningSideMapping.php: -------------------------------------------------------------------------------- 1 | */ 18 | public function __sleep(): array 19 | { 20 | $serialized = parent::__sleep(); 21 | 22 | if ($this->inversedBy !== null) { 23 | $serialized[] = 'inversedBy'; 24 | } 25 | 26 | return $serialized; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Mapping/PostLoad.php: -------------------------------------------------------------------------------- 1 | indexBy() */ 10 | public function isIndexed(): bool; 11 | 12 | public function indexBy(): string; 13 | 14 | /** @return array */ 15 | public function orderBy(): array; 16 | } 17 | -------------------------------------------------------------------------------- /src/Mapping/ToManyInverseSideMapping.php: -------------------------------------------------------------------------------- 1 | , type?: string} $mapping The field mapping to validate & complete. 16 | * 17 | * @return array{fieldName: string, enumType?: class-string, type?: string} The updated mapping. 18 | */ 19 | public function validateAndComplete(array $mapping, ReflectionProperty $field): array; 20 | } 21 | -------------------------------------------------------------------------------- /src/Mapping/UniqueConstraint.php: -------------------------------------------------------------------------------- 1 | |null $columns 14 | * @param array|null $fields 15 | * @param array|null $options 16 | */ 17 | public function __construct( 18 | public readonly string|null $name = null, 19 | public readonly array|null $columns = null, 20 | public readonly array|null $fields = null, 21 | public readonly array|null $options = null, 22 | ) { 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Mapping/Version.php: -------------------------------------------------------------------------------- 1 | resolveClassName($object::class); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Proxy/InternalProxy.php: -------------------------------------------------------------------------------- 1 | 14 | */ 15 | interface InternalProxy extends Proxy 16 | { 17 | public function __setInitialized(bool $initialized): void; 18 | } 19 | -------------------------------------------------------------------------------- /src/Proxy/NotAProxyClass.php: -------------------------------------------------------------------------------- 1 | walkAggregateExpression($this); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Query/AST/ArithmeticExpression.php: -------------------------------------------------------------------------------- 1 | simpleArithmeticExpression; 23 | } 24 | 25 | public function isSubselect(): bool 26 | { 27 | return (bool) $this->subselect; 28 | } 29 | 30 | public function dispatch(SqlWalker $walker): string 31 | { 32 | return $walker->walkArithmeticExpression($this); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Query/AST/ArithmeticFactor.php: -------------------------------------------------------------------------------- 1 | sign === true; 25 | } 26 | 27 | public function isNegativeSigned(): bool 28 | { 29 | return $this->sign === false; 30 | } 31 | 32 | public function dispatch(SqlWalker $walker): string 33 | { 34 | return $walker->walkArithmeticFactor($this); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Query/AST/ArithmeticTerm.php: -------------------------------------------------------------------------------- 1 | walkArithmeticTerm($this); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Query/AST/BetweenExpression.php: -------------------------------------------------------------------------------- 1 | walkBetweenExpression($this); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Query/AST/CoalesceExpression.php: -------------------------------------------------------------------------------- 1 | walkCoalesceExpression($this); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Query/AST/CollectionMemberExpression.php: -------------------------------------------------------------------------------- 1 | walkCollectionMemberExpression($this); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Query/AST/ComparisonExpression.php: -------------------------------------------------------------------------------- 1 | " | "!=") (BooleanExpression | QuantifiedExpression) | 13 | * EnumExpression ("=" | "<>" | "!=") (EnumExpression | QuantifiedExpression) | 14 | * DatetimeExpression ComparisonOperator (DatetimeExpression | QuantifiedExpression) | 15 | * EntityExpression ("=" | "<>") (EntityExpression | QuantifiedExpression) 16 | * 17 | * @link www.doctrine-project.org 18 | */ 19 | class ComparisonExpression extends Node 20 | { 21 | public function __construct( 22 | public Node|string $leftExpression, 23 | public string $operator, 24 | public Node|string $rightExpression, 25 | ) { 26 | } 27 | 28 | public function dispatch(SqlWalker $walker): string 29 | { 30 | return $walker->walkComparisonExpression($this); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Query/AST/ConditionalExpression.php: -------------------------------------------------------------------------------- 1 | walkConditionalExpression($this); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Query/AST/ConditionalFactor.php: -------------------------------------------------------------------------------- 1 | walkConditionalFactor($this); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Query/AST/ConditionalPrimary.php: -------------------------------------------------------------------------------- 1 | simpleConditionalExpression; 23 | } 24 | 25 | public function isConditionalExpression(): bool 26 | { 27 | return (bool) $this->conditionalExpression; 28 | } 29 | 30 | public function dispatch(SqlWalker $walker): string 31 | { 32 | return $walker->walkConditionalPrimary($this); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Query/AST/ConditionalTerm.php: -------------------------------------------------------------------------------- 1 | walkConditionalTerm($this); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Query/AST/DeleteClause.php: -------------------------------------------------------------------------------- 1 | walkDeleteClause($this); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Query/AST/DeleteStatement.php: -------------------------------------------------------------------------------- 1 | walkDeleteStatement($this); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Query/AST/EmptyCollectionComparisonExpression.php: -------------------------------------------------------------------------------- 1 | walkEmptyCollectionComparisonExpression($this); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Query/AST/ExistsExpression.php: -------------------------------------------------------------------------------- 1 | walkExistsExpression($this); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Query/AST/FromClause.php: -------------------------------------------------------------------------------- 1 | walkFromClause($this); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Query/AST/Functions/AbsFunction.php: -------------------------------------------------------------------------------- 1 | walkSimpleArithmeticExpression( 24 | $this->simpleArithmeticExpression, 25 | ) . ')'; 26 | } 27 | 28 | public function parse(Parser $parser): void 29 | { 30 | $parser->match(TokenType::T_IDENTIFIER); 31 | $parser->match(TokenType::T_OPEN_PARENTHESIS); 32 | 33 | $this->simpleArithmeticExpression = $parser->SimpleArithmeticExpression(); 34 | 35 | $parser->match(TokenType::T_CLOSE_PARENTHESIS); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Query/AST/Functions/AvgFunction.php: -------------------------------------------------------------------------------- 1 | aggregateExpression->dispatch($sqlWalker); 21 | } 22 | 23 | public function parse(Parser $parser): void 24 | { 25 | $this->aggregateExpression = $parser->AggregateExpression(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Query/AST/Functions/BitAndFunction.php: -------------------------------------------------------------------------------- 1 | getConnection()->getDatabasePlatform(); 25 | 26 | return $platform->getBitAndComparisonExpression( 27 | $this->firstArithmetic->dispatch($sqlWalker), 28 | $this->secondArithmetic->dispatch($sqlWalker), 29 | ); 30 | } 31 | 32 | public function parse(Parser $parser): void 33 | { 34 | $parser->match(TokenType::T_IDENTIFIER); 35 | $parser->match(TokenType::T_OPEN_PARENTHESIS); 36 | 37 | $this->firstArithmetic = $parser->ArithmeticPrimary(); 38 | $parser->match(TokenType::T_COMMA); 39 | $this->secondArithmetic = $parser->ArithmeticPrimary(); 40 | 41 | $parser->match(TokenType::T_CLOSE_PARENTHESIS); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Query/AST/Functions/BitOrFunction.php: -------------------------------------------------------------------------------- 1 | getConnection()->getDatabasePlatform(); 25 | 26 | return $platform->getBitOrComparisonExpression( 27 | $this->firstArithmetic->dispatch($sqlWalker), 28 | $this->secondArithmetic->dispatch($sqlWalker), 29 | ); 30 | } 31 | 32 | public function parse(Parser $parser): void 33 | { 34 | $parser->match(TokenType::T_IDENTIFIER); 35 | $parser->match(TokenType::T_OPEN_PARENTHESIS); 36 | 37 | $this->firstArithmetic = $parser->ArithmeticPrimary(); 38 | $parser->match(TokenType::T_COMMA); 39 | $this->secondArithmetic = $parser->ArithmeticPrimary(); 40 | 41 | $parser->match(TokenType::T_CLOSE_PARENTHESIS); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Query/AST/Functions/CountFunction.php: -------------------------------------------------------------------------------- 1 | aggregateExpression->dispatch($sqlWalker); 24 | } 25 | 26 | public function parse(Parser $parser): void 27 | { 28 | $this->aggregateExpression = $parser->AggregateExpression(); 29 | } 30 | 31 | public function getReturnType(): Type 32 | { 33 | return Type::getType(Types::INTEGER); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Query/AST/Functions/CurrentDateFunction.php: -------------------------------------------------------------------------------- 1 | getConnection()->getDatabasePlatform()->getCurrentDateSQL(); 21 | } 22 | 23 | public function parse(Parser $parser): void 24 | { 25 | $parser->match(TokenType::T_IDENTIFIER); 26 | $parser->match(TokenType::T_OPEN_PARENTHESIS); 27 | $parser->match(TokenType::T_CLOSE_PARENTHESIS); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Query/AST/Functions/CurrentTimeFunction.php: -------------------------------------------------------------------------------- 1 | getConnection()->getDatabasePlatform()->getCurrentTimeSQL(); 21 | } 22 | 23 | public function parse(Parser $parser): void 24 | { 25 | $parser->match(TokenType::T_IDENTIFIER); 26 | $parser->match(TokenType::T_OPEN_PARENTHESIS); 27 | $parser->match(TokenType::T_CLOSE_PARENTHESIS); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Query/AST/Functions/CurrentTimestampFunction.php: -------------------------------------------------------------------------------- 1 | getConnection()->getDatabasePlatform()->getCurrentTimestampSQL(); 21 | } 22 | 23 | public function parse(Parser $parser): void 24 | { 25 | $parser->match(TokenType::T_IDENTIFIER); 26 | $parser->match(TokenType::T_OPEN_PARENTHESIS); 27 | $parser->match(TokenType::T_CLOSE_PARENTHESIS); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Query/AST/Functions/DateDiffFunction.php: -------------------------------------------------------------------------------- 1 | getConnection()->getDatabasePlatform()->getDateDiffExpression( 25 | $this->date1->dispatch($sqlWalker), 26 | $this->date2->dispatch($sqlWalker), 27 | ); 28 | } 29 | 30 | public function parse(Parser $parser): void 31 | { 32 | $parser->match(TokenType::T_IDENTIFIER); 33 | $parser->match(TokenType::T_OPEN_PARENTHESIS); 34 | 35 | $this->date1 = $parser->ArithmeticPrimary(); 36 | $parser->match(TokenType::T_COMMA); 37 | $this->date2 = $parser->ArithmeticPrimary(); 38 | 39 | $parser->match(TokenType::T_CLOSE_PARENTHESIS); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Query/AST/Functions/FunctionNode.php: -------------------------------------------------------------------------------- 1 | walkFunction($this); 29 | } 30 | 31 | abstract public function parse(Parser $parser): void; 32 | } 33 | -------------------------------------------------------------------------------- /src/Query/AST/Functions/LengthFunction.php: -------------------------------------------------------------------------------- 1 | getConnection()->getDatabasePlatform()->getLengthExpression( 27 | $sqlWalker->walkSimpleArithmeticExpression($this->stringPrimary), 28 | ); 29 | } 30 | 31 | public function parse(Parser $parser): void 32 | { 33 | $parser->match(TokenType::T_IDENTIFIER); 34 | $parser->match(TokenType::T_OPEN_PARENTHESIS); 35 | 36 | $this->stringPrimary = $parser->StringPrimary(); 37 | 38 | $parser->match(TokenType::T_CLOSE_PARENTHESIS); 39 | } 40 | 41 | public function getReturnType(): Type 42 | { 43 | return Type::getType(Types::INTEGER); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Query/AST/Functions/LowerFunction.php: -------------------------------------------------------------------------------- 1 | walkSimpleArithmeticExpression($this->stringPrimary), 28 | ); 29 | } 30 | 31 | public function parse(Parser $parser): void 32 | { 33 | $parser->match(TokenType::T_IDENTIFIER); 34 | $parser->match(TokenType::T_OPEN_PARENTHESIS); 35 | 36 | $this->stringPrimary = $parser->StringPrimary(); 37 | 38 | $parser->match(TokenType::T_CLOSE_PARENTHESIS); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Query/AST/Functions/MaxFunction.php: -------------------------------------------------------------------------------- 1 | aggregateExpression->dispatch($sqlWalker); 21 | } 22 | 23 | public function parse(Parser $parser): void 24 | { 25 | $this->aggregateExpression = $parser->AggregateExpression(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Query/AST/Functions/MinFunction.php: -------------------------------------------------------------------------------- 1 | aggregateExpression->dispatch($sqlWalker); 21 | } 22 | 23 | public function parse(Parser $parser): void 24 | { 25 | $this->aggregateExpression = $parser->AggregateExpression(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Query/AST/Functions/ModFunction.php: -------------------------------------------------------------------------------- 1 | getConnection()->getDatabasePlatform()->getModExpression( 25 | $sqlWalker->walkSimpleArithmeticExpression($this->firstSimpleArithmeticExpression), 26 | $sqlWalker->walkSimpleArithmeticExpression($this->secondSimpleArithmeticExpression), 27 | ); 28 | } 29 | 30 | public function parse(Parser $parser): void 31 | { 32 | $parser->match(TokenType::T_IDENTIFIER); 33 | $parser->match(TokenType::T_OPEN_PARENTHESIS); 34 | 35 | $this->firstSimpleArithmeticExpression = $parser->SimpleArithmeticExpression(); 36 | 37 | $parser->match(TokenType::T_COMMA); 38 | 39 | $this->secondSimpleArithmeticExpression = $parser->SimpleArithmeticExpression(); 40 | 41 | $parser->match(TokenType::T_CLOSE_PARENTHESIS); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Query/AST/Functions/SqrtFunction.php: -------------------------------------------------------------------------------- 1 | walkSimpleArithmeticExpression($this->simpleArithmeticExpression), 28 | ); 29 | } 30 | 31 | public function parse(Parser $parser): void 32 | { 33 | $parser->match(TokenType::T_IDENTIFIER); 34 | $parser->match(TokenType::T_OPEN_PARENTHESIS); 35 | 36 | $this->simpleArithmeticExpression = $parser->SimpleArithmeticExpression(); 37 | 38 | $parser->match(TokenType::T_CLOSE_PARENTHESIS); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Query/AST/Functions/SumFunction.php: -------------------------------------------------------------------------------- 1 | aggregateExpression->dispatch($sqlWalker); 21 | } 22 | 23 | public function parse(Parser $parser): void 24 | { 25 | $this->aggregateExpression = $parser->AggregateExpression(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Query/AST/Functions/UpperFunction.php: -------------------------------------------------------------------------------- 1 | walkSimpleArithmeticExpression($this->stringPrimary), 28 | ); 29 | } 30 | 31 | public function parse(Parser $parser): void 32 | { 33 | $parser->match(TokenType::T_IDENTIFIER); 34 | $parser->match(TokenType::T_OPEN_PARENTHESIS); 35 | 36 | $this->stringPrimary = $parser->StringPrimary(); 37 | 38 | $parser->match(TokenType::T_CLOSE_PARENTHESIS); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Query/AST/GeneralCaseExpression.php: -------------------------------------------------------------------------------- 1 | walkGeneralCaseExpression($this); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Query/AST/GroupByClause.php: -------------------------------------------------------------------------------- 1 | walkGroupByClause($this); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Query/AST/HavingClause.php: -------------------------------------------------------------------------------- 1 | walkHavingClause($this); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/Query/AST/IdentificationVariableDeclaration.php: -------------------------------------------------------------------------------- 1 | walkIdentificationVariableDeclaration($this); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Query/AST/InListExpression.php: -------------------------------------------------------------------------------- 1 | $literals */ 12 | public function __construct( 13 | public ArithmeticExpression $expression, 14 | public array $literals, 15 | public bool $not = false, 16 | ) { 17 | } 18 | 19 | public function dispatch(SqlWalker $walker): string 20 | { 21 | return $walker->walkInListExpression($this); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Query/AST/InSubselectExpression.php: -------------------------------------------------------------------------------- 1 | walkInSubselectExpression($this); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Query/AST/IndexBy.php: -------------------------------------------------------------------------------- 1 | walkIndexBy($this); 23 | 24 | return ''; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Query/AST/InputParameter.php: -------------------------------------------------------------------------------- 1 | isNamed = ! is_numeric($param); 28 | $this->name = $param; 29 | } 30 | 31 | public function dispatch(SqlWalker $walker): string 32 | { 33 | return $walker->walkInputParameter($this); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Query/AST/InstanceOfExpression.php: -------------------------------------------------------------------------------- 1 | $value */ 18 | public function __construct( 19 | public string $identificationVariable, 20 | public array $value, 21 | public bool $not = false, 22 | ) { 23 | } 24 | 25 | public function dispatch(SqlWalker $walker): string 26 | { 27 | return $walker->walkInstanceOfExpression($this); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Query/AST/Join.php: -------------------------------------------------------------------------------- 1 | walkJoin($this); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Query/AST/JoinAssociationDeclaration.php: -------------------------------------------------------------------------------- 1 | walkJoinAssociationDeclaration($this); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Query/AST/JoinAssociationPathExpression.php: -------------------------------------------------------------------------------- 1 | walkJoinPathExpression($this); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Query/AST/JoinVariableDeclaration.php: -------------------------------------------------------------------------------- 1 | walkJoinVariableDeclaration($this); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Query/AST/LikeExpression.php: -------------------------------------------------------------------------------- 1 | walkLikeExpression($this); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Query/AST/Literal.php: -------------------------------------------------------------------------------- 1 | walkLiteral($this); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Query/AST/NewObjectExpression.php: -------------------------------------------------------------------------------- 1 | 1 ? func_get_arg(1) : null; 30 | 31 | return $walker->walkNewObject($this, $parentAlias); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Query/AST/NullComparisonExpression.php: -------------------------------------------------------------------------------- 1 | walkNullComparisonExpression($this); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Query/AST/NullIfExpression.php: -------------------------------------------------------------------------------- 1 | walkNullIfExpression($this); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Query/AST/OrderByClause.php: -------------------------------------------------------------------------------- 1 | walkOrderByClause($this); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Query/AST/OrderByItem.php: -------------------------------------------------------------------------------- 1 | type) === 'ASC'; 27 | } 28 | 29 | public function isDesc(): bool 30 | { 31 | return strtoupper($this->type) === 'DESC'; 32 | } 33 | 34 | public function dispatch(SqlWalker $walker): string 35 | { 36 | return $walker->walkOrderByItem($this); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Query/AST/ParenthesisExpression.php: -------------------------------------------------------------------------------- 1 | walkParenthesisExpression($this); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Query/AST/PartialObjectExpression.php: -------------------------------------------------------------------------------- 1 | type) === 'ALL'; 27 | } 28 | 29 | public function isAny(): bool 30 | { 31 | return strtoupper($this->type) === 'ANY'; 32 | } 33 | 34 | public function isSome(): bool 35 | { 36 | return strtoupper($this->type) === 'SOME'; 37 | } 38 | 39 | public function dispatch(SqlWalker $walker): string 40 | { 41 | return $walker->walkQuantifiedExpression($this); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Query/AST/RangeVariableDeclaration.php: -------------------------------------------------------------------------------- 1 | walkRangeVariableDeclaration($this); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Query/AST/SelectClause.php: -------------------------------------------------------------------------------- 1 | walkSelectClause($this); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Query/AST/SelectExpression.php: -------------------------------------------------------------------------------- 1 | walkSelectExpression($this); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Query/AST/SelectStatement.php: -------------------------------------------------------------------------------- 1 | walkSelectStatement($this); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Query/AST/SimpleArithmeticExpression.php: -------------------------------------------------------------------------------- 1 | walkSimpleArithmeticExpression($this); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Query/AST/SimpleCaseExpression.php: -------------------------------------------------------------------------------- 1 | walkSimpleCaseExpression($this); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Query/AST/SimpleSelectClause.php: -------------------------------------------------------------------------------- 1 | walkSimpleSelectClause($this); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Query/AST/SimpleSelectExpression.php: -------------------------------------------------------------------------------- 1 | walkSimpleSelectExpression($this); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Query/AST/SimpleWhenClause.php: -------------------------------------------------------------------------------- 1 | walkWhenClauseExpression($this); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Query/AST/Subselect.php: -------------------------------------------------------------------------------- 1 | walkSubselect($this); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Query/AST/SubselectFromClause.php: -------------------------------------------------------------------------------- 1 | walkSubselectFromClause($this); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Query/AST/SubselectIdentificationVariableDeclaration.php: -------------------------------------------------------------------------------- 1 | walkUpdateClause($this); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Query/AST/UpdateItem.php: -------------------------------------------------------------------------------- 1 | walkUpdateItem($this); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Query/AST/UpdateStatement.php: -------------------------------------------------------------------------------- 1 | walkUpdateStatement($this); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Query/AST/WhenClause.php: -------------------------------------------------------------------------------- 1 | walkWhenClauseExpression($this); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Query/AST/WhereClause.php: -------------------------------------------------------------------------------- 1 | walkWhereClause($this); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Query/Exec/FinalizedSelectExecutor.php: -------------------------------------------------------------------------------- 1 | sqlStatements = $sql; 20 | } 21 | 22 | /** 23 | * {@inheritDoc} 24 | */ 25 | public function execute(Connection $conn, array $params, array $types): Result 26 | { 27 | return $conn->executeQuery($this->getSqlStatements(), $params, $types, $this->queryCacheProfile); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Query/Exec/PreparedExecutorFinalizer.php: -------------------------------------------------------------------------------- 1 | executor = $exeutor; 21 | } 22 | 23 | public function createExecutor(Query $query): AbstractSqlExecutor 24 | { 25 | return $this->executor; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Query/Exec/SingleSelectExecutor.php: -------------------------------------------------------------------------------- 1 | sqlStatements = $sqlWalker->walkSelectStatement($AST); 22 | } 23 | 24 | /** 25 | * {@inheritDoc} 26 | */ 27 | public function execute(Connection $conn, array $params, array $types): Result 28 | { 29 | return $conn->executeQuery($this->sqlStatements, $params, $types, $this->queryCacheProfile); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Query/Exec/SingleTableDeleteUpdateExecutor.php: -------------------------------------------------------------------------------- 1 | sqlStatements = $sqlWalker->walkUpdateStatement($AST); 24 | } elseif ($AST instanceof AST\DeleteStatement) { 25 | $this->sqlStatements = $sqlWalker->walkDeleteStatement($AST); 26 | } 27 | } 28 | 29 | /** 30 | * {@inheritDoc} 31 | */ 32 | public function execute(Connection $conn, array $params, array $types): int 33 | { 34 | if ($conn instanceof PrimaryReadReplicaConnection) { 35 | $conn->ensureConnectedToPrimary(); 36 | } 37 | 38 | return $conn->executeStatement($this->sqlStatements, $params, $types); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Query/Exec/SqlFinalizer.php: -------------------------------------------------------------------------------- 1 | */ 25 | protected array $parts = []; 26 | 27 | /** @phpstan-return list */ 28 | public function getParts(): array 29 | { 30 | return $this->parts; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Query/Expr/Comparison.php: -------------------------------------------------------------------------------- 1 | '; 18 | final public const LT = '<'; 19 | final public const LTE = '<='; 20 | final public const GT = '>'; 21 | final public const GTE = '>='; 22 | 23 | /** Creates a comparison expression with the given arguments. */ 24 | public function __construct(protected mixed $leftExpr, protected string $operator, protected mixed $rightExpr) 25 | { 26 | } 27 | 28 | public function getLeftExpr(): mixed 29 | { 30 | return $this->leftExpr; 31 | } 32 | 33 | public function getOperator(): string 34 | { 35 | return $this->operator; 36 | } 37 | 38 | public function getRightExpr(): mixed 39 | { 40 | return $this->rightExpr; 41 | } 42 | 43 | public function __toString(): string 44 | { 45 | return $this->leftExpr . ' ' . $this->operator . ' ' . $this->rightExpr; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Query/Expr/Composite.php: -------------------------------------------------------------------------------- 1 | count() === 1) { 23 | return (string) $this->parts[0]; 24 | } 25 | 26 | $components = []; 27 | 28 | foreach ($this->parts as $part) { 29 | $components[] = $this->processQueryPart($part); 30 | } 31 | 32 | return implode($this->separator, $components); 33 | } 34 | 35 | private function processQueryPart(string|Stringable $part): string 36 | { 37 | $queryPart = (string) $part; 38 | 39 | if (is_object($part) && $part instanceof self && $part->count() > 1) { 40 | return $this->preSeparator . $queryPart . $this->postSeparator; 41 | } 42 | 43 | // Fixes DDC-1237: User may have added a where item containing nested expression (with "OR" or "AND") 44 | if (preg_match('/\s(OR|AND)\s/i', $queryPart)) { 45 | return $this->preSeparator . $queryPart . $this->postSeparator; 46 | } 47 | 48 | return $queryPart; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/Query/Expr/From.php: -------------------------------------------------------------------------------- 1 | from; 31 | } 32 | 33 | public function getAlias(): string 34 | { 35 | return $this->alias; 36 | } 37 | 38 | public function getIndexBy(): string|null 39 | { 40 | return $this->indexBy; 41 | } 42 | 43 | public function __toString(): string 44 | { 45 | return $this->from . ' ' . $this->alias . 46 | ($this->indexBy ? ' INDEX BY ' . $this->indexBy : ''); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/Query/Expr/Func.php: -------------------------------------------------------------------------------- 1 | |mixed $arguments 25 | */ 26 | public function __construct( 27 | protected string $name, 28 | mixed $arguments, 29 | ) { 30 | $this->arguments = (array) $arguments; 31 | } 32 | 33 | public function getName(): string 34 | { 35 | return $this->name; 36 | } 37 | 38 | /** @phpstan-return list */ 39 | public function getArguments(): array 40 | { 41 | return $this->arguments; 42 | } 43 | 44 | public function __toString(): string 45 | { 46 | return $this->name . '(' . implode(', ', $this->arguments) . ')'; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/Query/Expr/GroupBy.php: -------------------------------------------------------------------------------- 1 | */ 18 | protected array $parts = []; 19 | 20 | /** @phpstan-return list */ 21 | public function getParts(): array 22 | { 23 | return $this->parts; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Query/Expr/Literal.php: -------------------------------------------------------------------------------- 1 | */ 18 | protected array $parts = []; 19 | 20 | /** @phpstan-return list */ 21 | public function getParts(): array 22 | { 23 | return $this->parts; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Query/Expr/Math.php: -------------------------------------------------------------------------------- 1 | leftExpr; 29 | } 30 | 31 | public function getOperator(): string 32 | { 33 | return $this->operator; 34 | } 35 | 36 | public function getRightExpr(): mixed 37 | { 38 | return $this->rightExpr; 39 | } 40 | 41 | public function __toString(): string 42 | { 43 | // Adjusting Left Expression 44 | $leftExpr = (string) $this->leftExpr; 45 | 46 | if ($this->leftExpr instanceof Math) { 47 | $leftExpr = '(' . $leftExpr . ')'; 48 | } 49 | 50 | // Adjusting Right Expression 51 | $rightExpr = (string) $this->rightExpr; 52 | 53 | if ($this->rightExpr instanceof Math) { 54 | $rightExpr = '(' . $rightExpr . ')'; 55 | } 56 | 57 | return $leftExpr . ' ' . $this->operator . ' ' . $rightExpr; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/Query/Expr/Orx.php: -------------------------------------------------------------------------------- 1 | */ 25 | protected array $parts = []; 26 | 27 | /** @phpstan-return list */ 28 | public function getParts(): array 29 | { 30 | return $this->parts; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Query/Expr/Select.php: -------------------------------------------------------------------------------- 1 | */ 21 | protected array $parts = []; 22 | 23 | /** @phpstan-return list */ 24 | public function getParts(): array 25 | { 26 | return $this->parts; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Query/Filter/FilterException.php: -------------------------------------------------------------------------------- 1 | createSqlForFinalizer($AST)); 19 | 20 | case $AST instanceof AST\UpdateStatement: 21 | return new PreparedExecutorFinalizer($this->createUpdateStatementExecutor($AST)); 22 | 23 | case $AST instanceof AST\DeleteStatement: 24 | return new PreparedExecutorFinalizer($this->createDeleteStatementExecutor($AST)); 25 | } 26 | 27 | throw new LogicException('Unexpected AST node type'); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Query/TreeWalker.php: -------------------------------------------------------------------------------- 1 | $queryComponents The query components (symbol table). 20 | */ 21 | public function __construct(AbstractQuery $query, ParserResult $parserResult, array $queryComponents); 22 | 23 | /** 24 | * Returns internal queryComponents array. 25 | * 26 | * @phpstan-return array 27 | */ 28 | public function getQueryComponents(): array; 29 | 30 | /** 31 | * Walks down a SelectStatement AST node. 32 | */ 33 | public function walkSelectStatement(AST\SelectStatement $selectStatement): void; 34 | 35 | /** 36 | * Walks down an UpdateStatement AST node. 37 | */ 38 | public function walkUpdateStatement(AST\UpdateStatement $updateStatement): void; 39 | 40 | /** 41 | * Walks down a DeleteStatement AST node. 42 | */ 43 | public function walkDeleteStatement(AST\DeleteStatement $deleteStatement): void; 44 | } 45 | -------------------------------------------------------------------------------- /src/Repository/Exception/InvalidFindByCall.php: -------------------------------------------------------------------------------- 1 | $entityName The name of the entity. 20 | * 21 | * @return EntityRepository 22 | * 23 | * @template T of object 24 | */ 25 | public function getRepository(EntityManagerInterface $entityManager, string $entityName): EntityRepository; 26 | } 27 | -------------------------------------------------------------------------------- /src/Tools/Console/Command/AbstractEntityManagerCommand.php: -------------------------------------------------------------------------------- 1 | getOption('em') === null 22 | ? $this->entityManagerProvider->getDefaultManager() 23 | : $this->entityManagerProvider->getManager($input->getOption('em')); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Tools/Console/Command/SchemaTool/AbstractCommand.php: -------------------------------------------------------------------------------- 1 | getEntityManager($input); 28 | 29 | $metadatas = $em->getMetadataFactory()->getAllMetadata(); 30 | 31 | if (empty($metadatas)) { 32 | $ui->getErrorStyle()->success('No Metadata Classes to process.'); 33 | 34 | return 0; 35 | } 36 | 37 | return $this->executeSchemaCommand($input, $output, new SchemaTool($em), $metadatas, $ui); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Tools/Console/EntityManagerProvider.php: -------------------------------------------------------------------------------- 1 | entityManagerProvider->getDefaultManager()->getConnection(); 20 | } 21 | 22 | public function getConnection(string $name): Connection 23 | { 24 | return $this->entityManagerProvider->getManager($name)->getConnection(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Tools/Console/EntityManagerProvider/SingleManagerProvider.php: -------------------------------------------------------------------------------- 1 | entityManager; 21 | } 22 | 23 | public function getManager(string $name): EntityManagerInterface 24 | { 25 | if ($name !== $this->defaultManagerName) { 26 | throw UnknownManagerException::unknownManager($name, [$this->defaultManagerName]); 27 | } 28 | 29 | return $this->entityManager; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Tools/Console/EntityManagerProvider/UnknownManagerException.php: -------------------------------------------------------------------------------- 1 | $knownManagers */ 15 | public static function unknownManager(string $unknownManager, array $knownManagers = []): self 16 | { 17 | return new self(sprintf( 18 | 'Requested unknown entity manager: %s, known managers: %s', 19 | $unknownManager, 20 | implode(', ', $knownManagers), 21 | )); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Tools/Event/GenerateSchemaEventArgs.php: -------------------------------------------------------------------------------- 1 | em; 27 | } 28 | 29 | public function getSchema(): Schema 30 | { 31 | return $this->schema; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Tools/Event/GenerateSchemaTableEventArgs.php: -------------------------------------------------------------------------------- 1 | classMetadata; 29 | } 30 | 31 | public function getSchema(): Schema 32 | { 33 | return $this->schema; 34 | } 35 | 36 | public function getClassTable(): Table 37 | { 38 | return $this->classTable; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Tools/Exception/MissingColumnException.php: -------------------------------------------------------------------------------- 1 | walkOrderByClause( 27 | $this->orderByClause, 28 | )) . ')'; 29 | } 30 | 31 | /** 32 | * @throws RowNumberOverFunctionNotEnabled 33 | * 34 | * @inheritdoc 35 | */ 36 | public function parse(Parser $parser): void 37 | { 38 | throw RowNumberOverFunctionNotEnabled::create(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Tools/ToolEvents.php: -------------------------------------------------------------------------------- 1 | getMessage() . "' while executing DDL: " . $sql, 20 | 0, 21 | $e, 22 | ); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/TransactionRequiredException.php: -------------------------------------------------------------------------------- 1 | 'LOCK IN SHARE MODE', 21 | $platform instanceof PostgreSQLPlatform => 'FOR SHARE', 22 | default => $this->getWriteLockSQL($platform), 23 | }; 24 | } 25 | 26 | private function getWriteLockSQL(AbstractPlatform $platform): string 27 | { 28 | return match (true) { 29 | $platform instanceof DB2Platform => 'WITH RR USE AND KEEP UPDATE LOCKS', 30 | $platform instanceof SQLitePlatform, 31 | $platform instanceof SQLServerPlatform => '', 32 | default => 'FOR UPDATE', 33 | }; 34 | } 35 | } 36 | --------------------------------------------------------------------------------