demos-europe / edt

Enables your PHP application to expose its entities as REST resources using the feature rich JSON:API specification as API. How and to whom your entities are exposed is highly customizable while minimizing boilerplate code.
MIT License
2 stars 1 forks source link

Add compatibility with `doctrine/orm` version 3 #38

Open dresslerdemos opened 1 year ago

dresslerdemos commented 1 year ago

doctrine/orm 3 is not supported out of the box as shown by the phpstan output below. It seems this is mainly due to the removal of ClassMetadataInfo.

Updating to doctrine/orm 3 needs to be coordinated with the development of demosplan-core, so that support is not added too soon or too late. However, the clean approach would be to add the support to EDT via a minor release after the current version (0.26) of this library (e.g. 0.27, 0.28, …). Under this assumption, demosplan-core needs to upgrade to the already released EDT versions 0.25 and 0.26 first, regardless of the exact version in which EDT starts supporting doctrine/orm version 3, as demosplan-core currently uses EDT at version 0.24.

Therefore, feedback from the demosplan-core developers is required to coordinate how and when to approach this issue.

 % composer phpstan     
> phpstan analyse
Note: Using configuration file /home/christian/demos-projects/edt/phpstan.neon.
 355/355 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 ------ -------------------------------------------------------------------------------------------------------------------------- 
  Line   dql/src/PropertyAccessors/ProxyPropertyAccessor.php                                                                       
 ------ -------------------------------------------------------------------------------------------------------------------------- 
  39     Class Doctrine\ORM\Mapping\ClassMetadataInfo not found.                                                                   
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                                                       
  40     Access to property $associationMappings on an unknown class Doctrine\ORM\Mapping\ClassMetadataInfo.                       
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                                                       
  40     Cannot access offset 'type' on mixed.                                                                                     
  40     Cannot access offset non-empty-string on mixed.                                                                           
  42     Access to constant MANY_TO_MANY on an unknown class Doctrine\ORM\Mapping\ClassMetadataInfo.                               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                                                       
  42     Access to constant ONE_TO_MANY on an unknown class Doctrine\ORM\Mapping\ClassMetadataInfo.                                
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                                                       
  69     Class Doctrine\ORM\Mapping\ClassMetadataInfo not found.                                                                   
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                                                       
  73     Access to property $rootEntityName on an unknown class Doctrine\ORM\Mapping\ClassMetadataInfo.                            
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                                                       
  75     Method EDT\DqlQuerying\PropertyAccessors\ProxyPropertyAccessor::getClass() should return class-string but returns mixed.  
 ------ -------------------------------------------------------------------------------------------------------------------------- 

 ------ -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
  Line   dql/src/Utilities/JoinFinder.php                                                                                                                                                      
 ------ -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
  58     Parameter $classMetadata of method EDT\DqlQuerying\Utilities\JoinFinder::findNecessaryJoins() has invalid type Doctrine\ORM\Mapping\ClassMetadataInfo.                                
  58     Parameter $classMetadata of method EDT\DqlQuerying\Utilities\JoinFinder::findNecessaryJoins() has invalid type Doctrine\ORM\Mapping\ClassMetadataInfo.                                
  93     Parameter $classMetadata of method EDT\DqlQuerying\Utilities\JoinFinder::findJoinsRecursive() has invalid type Doctrine\ORM\Mapping\ClassMetadataInfo.                                
  93     Parameter $classMetadata of method EDT\DqlQuerying\Utilities\JoinFinder::findJoinsRecursive() has invalid type Doctrine\ORM\Mapping\ClassMetadataInfo.                                
  100    Call to method getName() on an unknown class Doctrine\ORM\Mapping\ClassMetadataInfo.                                                                                                  
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                                                                                                                   
  100    Parameter #1 $name of static method EDT\DqlQuerying\Contracts\MappingException::disallowedToMany() expects class-string, mixed given.                                                 
  132    Call to method getName() on an unknown class Doctrine\ORM\Mapping\ClassMetadataInfo.                                                                                                  
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                                                                                                                   
  132    Part $classMetadata->getName() (mixed) of encapsed string cannot be cast to string.                                                                                                   
  154    Parameter $tableInfo of method EDT\DqlQuerying\Utilities\JoinFinder::createTableAlias() has invalid type Doctrine\ORM\Mapping\ClassMetadataInfo.                                      
  154    Parameter $tableInfo of method EDT\DqlQuerying\Utilities\JoinFinder::createTableAlias() has invalid type Doctrine\ORM\Mapping\ClassMetadataInfo.                                      
  156    Call to method getTableName() on an unknown class Doctrine\ORM\Mapping\ClassMetadataInfo.                                                                                             
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                                                                                                                   
  156    Part $tableInfo->getTableName() (mixed) of encapsed string cannot be cast to string.                                                                                                  
  166    Method EDT\DqlQuerying\Utilities\JoinFinder::getTargetClassMetadata() has invalid return type Doctrine\ORM\Mapping\ClassMetadataInfo.                                                 
  166    Method EDT\DqlQuerying\Utilities\JoinFinder::getTargetClassMetadata() has invalid return type Doctrine\ORM\Mapping\ClassMetadataInfo.                                                 
  166    Parameter $metadata of method EDT\DqlQuerying\Utilities\JoinFinder::getTargetClassMetadata() has invalid type Doctrine\ORM\Mapping\ClassMetadataInfo.                                 
  166    Parameter $metadata of method EDT\DqlQuerying\Utilities\JoinFinder::getTargetClassMetadata() has invalid type Doctrine\ORM\Mapping\ClassMetadataInfo.                                 
  169    Call to method getAssociationTargetClass() on an unknown class Doctrine\ORM\Mapping\ClassMetadataInfo.                                                                                
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                                                                                                                   
  170    Parameter #1 $className of method Doctrine\Persistence\Mapping\AbstractClassMetadataFactory<Doctrine\ORM\Mapping\ClassMetadata>::getMetadataFor() expects class-string, mixed given.  
  171    Class Doctrine\ORM\Mapping\ClassMetadataInfo not found.                                                                                                                               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                                                                                                                   
  178    Call to method getName() on an unknown class Doctrine\ORM\Mapping\ClassMetadataInfo.                                                                                                  
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                                                                                                                   
  178    Parameter #2 $entityName of static method EDT\DqlQuerying\Contracts\MappingException::relationshipUnavailable() expects string, mixed given.                                          
  187    Parameter $classMetadata of method EDT\DqlQuerying\Utilities\JoinFinder::isToManyRelationship() has invalid type Doctrine\ORM\Mapping\ClassMetadataInfo.                              
  187    Parameter $classMetadata of method EDT\DqlQuerying\Utilities\JoinFinder::isToManyRelationship() has invalid type Doctrine\ORM\Mapping\ClassMetadataInfo.                              
  189    Call to method getAssociationMapping() on an unknown class Doctrine\ORM\Mapping\ClassMetadataInfo.                                                                                    
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                                                                                                                   
  191    Access to constant TO_MANY on an unknown class Doctrine\ORM\Mapping\ClassMetadataInfo.                                                                                                
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                                                                                                                   
  191    Cannot access offset 'type' on mixed.                                                                                                                                                 
  198    Parameter $classMetadata of method EDT\DqlQuerying\Utilities\JoinFinder::isRelationship() has invalid type Doctrine\ORM\Mapping\ClassMetadataInfo.                                    
  198    Parameter $classMetadata of method EDT\DqlQuerying\Utilities\JoinFinder::isRelationship() has invalid type Doctrine\ORM\Mapping\ClassMetadataInfo.                                    
  200    Call to method hasAssociation() on an unknown class Doctrine\ORM\Mapping\ClassMetadataInfo.                                                                                           
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                                                                                                                   
  200    Method EDT\DqlQuerying\Utilities\JoinFinder::isRelationship() should return bool but returns mixed.                                                                                   
  207    Parameter $classMetadata of method EDT\DqlQuerying\Utilities\JoinFinder::isAttribute() has invalid type Doctrine\ORM\Mapping\ClassMetadataInfo.                                       
  207    Parameter $classMetadata of method EDT\DqlQuerying\Utilities\JoinFinder::isAttribute() has invalid type Doctrine\ORM\Mapping\ClassMetadataInfo.                                       
  209    Call to method hasField() on an unknown class Doctrine\ORM\Mapping\ClassMetadataInfo.                                                                                                 
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                                                                                                                   
  209    Method EDT\DqlQuerying\Utilities\JoinFinder::isAttribute() should return bool but returns mixed.                                                                                      
 ------ -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 

 ------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 
  Line   dql/src/Utilities/QueryBuilderPreparer.php                                                                                                                                                      
 ------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 
  65     Property EDT\DqlQuerying\Utilities\QueryBuilderPreparer::$mainClassMetadata has unknown class Doctrine\ORM\Mapping\ClassMetadataInfo as its type.                                               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                                                                                                                             
  65     Property EDT\DqlQuerying\Utilities\QueryBuilderPreparer::$mainClassMetadata has unknown class Doctrine\ORM\Mapping\ClassMetadataInfo as its type.                                               
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                                                                                                                             
  97     Property EDT\DqlQuerying\Utilities\QueryBuilderPreparer::$mainClassMetadata (Doctrine\ORM\Mapping\ClassMetadataInfo<object>) does not accept Doctrine\ORM\Mapping\ClassMetadata.                
  166    Call to method getName() on an unknown class Doctrine\ORM\Mapping\ClassMetadataInfo.                                                                                                            
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                                                                                                                             
  166    Parameter #1 $from of method Doctrine\ORM\QueryBuilder::from() expects class-string, mixed given.                                                                                               
  184    Parameter #1 $parameters of method Doctrine\ORM\QueryBuilder::setParameters() expects Doctrine\Common\Collections\ArrayCollection<int, Doctrine\ORM\Query\Parameter>, array<int, mixed> given.  
  224    Call to method getTableName() on an unknown class Doctrine\ORM\Mapping\ClassMetadataInfo.                                                                                                       
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                                                                                                                             
  283    Parameter #2 $tableInfo of method EDT\DqlQuerying\Utilities\JoinFinder::createTableAlias() expects Doctrine\ORM\Mapping\ClassMetadataInfo<object>, Doctrine\ORM\Mapping\ClassMetadata given.    
  290    Call to method getTableName() on an unknown class Doctrine\ORM\Mapping\ClassMetadataInfo.                                                                                                       
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols                                                                                                                             
  291    Parameter #2 $tableInfo of method EDT\DqlQuerying\Utilities\JoinFinder::createTableAlias() expects Doctrine\ORM\Mapping\ClassMetadataInfo<object>, Doctrine\ORM\Mapping\ClassMetadata given.    
  296    Parameter #3 $classMetadata of method EDT\DqlQuerying\Utilities\JoinFinder::findNecessaryJoins() expects Doctrine\ORM\Mapping\ClassMetadataInfo<object>,                                        
         Doctrine\ORM\Mapping\ClassMetadata|Doctrine\ORM\Mapping\ClassMetadataInfo<object> given.                                                                                                        
  298    Parameter #5 $tableAlias of method EDT\DqlQuerying\Utilities\JoinFinder::findNecessaryJoins() expects string, mixed given.                                                                      
  334    Part $entityAlias (mixed) of encapsed string cannot be cast to string.                                                                                                                          
 ------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 

 [ERROR] Found 56 errors                                                                                                

Script phpstan analyse handling the phpstan event returned with error code 1
composer phpstan  16.81s user 0.85s system 525% cpu 3.363 total
joorei commented 5 months ago

Therefore, feedback from the demosplan-core developers is required to coordinate how and when to approach this issue.

@graupnerdemos @salisdemos @mussbach: I've updated the description to the current status and added the blocked label for now. We can simply remove it again when things get more clear. Also, feel free to claim this issue if you so desire, as my available time remains unpredictable for now.