Skip to content

Compatibility with Doctrine ORM 3.0 and DBAL 4.0 #535

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Feb 9, 2024
Merged

Conversation

ondrejmirtes
Copy link
Member

No description provided.

!is_file(__DIR__ . '/../vendor/doctrine/orm/src/Mapping/Driver/AnnotationDriver.php')
&& !is_file(__DIR__ . '/../vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php')
) {
require_once __DIR__ . '/../compatibility/AnnotationDriver.php';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nice idea indeed in order to have less code to update currently.

But I feel like it could still be useful in long term (certainly in another PR which can be merged before or after the doctrine bump) to add Attributes everywhere Annotation is used in tests in order to tests them too. Also, rather having some time data/ and data-attributes folders with duplicated tests, a unique data/ folder can be used with both annotation and attribute in the same class without any issue.

This way the logic

if (! class_exists(AnnotationDriver::class) {
    // use AttributeReader
} else {
   // use AnnotationReader (or decide based on PHP version if wanted)
}

can be use in the entity-manager.php.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to add Attributes everywhere Annotation

I disagree with this approach. I consider existing tests to be immutable. By changing them we might start testing different things by accident than originally intended.

@ondrejmirtes ondrejmirtes force-pushed the doctrine-orm-3 branch 3 times, most recently from f20fe7b to 0046cf0 Compare February 8, 2024 13:56
@VincentLanglet
Copy link
Contributor

For all the

Method PHPStan\Type\Doctrine\Query\QueryResultTypeWalker::walkEntityIdentificationVariable() has parameter $identVariable with no type specified.

PHPStan errors, it's because the inheritdoc phpdoc is useless ; doctrine/orm 3 use typehint and no phpdoc.

I fixed them by adding @param on every QueryResultTypeWalker method.

I can extract the commit from #531 if you want to cherry pick it.

(also, do you want / can I help for something ?)

@ondrejmirtes
Copy link
Member Author

Please do, that would be helpful 😊

@VincentLanglet
Copy link
Contributor

Please do, that would be helpful 😊

Commit is here 3ebf91f

@ondrejmirtes
Copy link
Member Author

Can you send it as a PR with base branch doctrine-orm-3, so I can just merge it from my phone? Thanks.

@VincentLanglet
Copy link
Contributor

Can you send it as a PR with base branch doctrine-orm-3, so I can just merge it from my phone? Thanks.

#538

@ondrejmirtes
Copy link
Member Author

Signing off today, if you could look at any of these failures https://github.com/phpstan/phpstan-doctrine/actions/runs/7833385749 @VincentLanglet, I'd appreciate it :) Thanks.

@VincentLanglet
Copy link
Contributor

VincentLanglet commented Feb 8, 2024

Signing off today, if you could look at any of these failures phpstan/phpstan-doctrine/actions/runs/7833385749 @VincentLanglet, I'd appreciate it :) Thanks.

I fixed some tests on #540

I let you the PHPStan error, since I'm not sure how you prefer to fix them.

@lugosium
Copy link

lugosium commented Feb 8, 2024

I tried this branch and everythings work fine for me

645/645 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100% 30 secs

👏

@ondrejmirtes ondrejmirtes marked this pull request as ready for review February 9, 2024 13:43
@ondrejmirtes ondrejmirtes merged commit f3f1dae into 1.3.x Feb 9, 2024
@ondrejmirtes ondrejmirtes deleted the doctrine-orm-3 branch February 9, 2024 13:43
@arderyp
Copy link

arderyp commented Mar 5, 2024

hey @ondrejmirtes it looks like this was completed and merged into 1.3.61.

I'm running:

phpstan-doctrine 1.3.62
orm 3.1.0
dbal 3.8.3

When I upgraded orm from latest 2.x to 3.0.x and 3.1.x, I got lots of errors about EntityManager methods returning mixed.

Am I missing something, or is orm3 only supported WITH dbal4?

I opened another issue before finding this one.

EDIT: bumping to dbal4 is throwing different errors now:

1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 -- -------------------------------------------------------------------------------------------------------------------------------------------- 
     Error                                                                                                                                       
 -- -------------------------------------------------------------------------------------------------------------------------------------------- 
     Internal error: Internal error: Doctrine\DBAL\Connection\StaticServerVersionProvider::__construct(): Argument #1 ($version) must be of      
     type string, float given, called in /app/vendor/doctrine/dbal/src/Connection.php on line 186 while  
     analysing file /app/src/Common/Repository/ApplicationsRepository.php                                
     Run PHPStan with -v option and post the stack trace to:                                                                                     
     https://github.com/phpstan/phpstan/issues/new?template=Bug_report.yaml                                                                      
     Child process error (exit code 1):                                                                                                          
 -- -------------------------------------------------------------------------------------------------------------------------------------------- 
                                                                                                               
 [ERROR] Found 2 errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants