Skip to content

Support for doctrine/dbal v4 #754

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 7 commits into from
May 16, 2025
Merged

Conversation

bnowak
Copy link
Contributor

@bnowak bnowak commented Apr 18, 2025

No description provided.

@bnowak bnowak marked this pull request as ready for review April 18, 2025 13:02
@staabm
Copy link
Owner

staabm commented Apr 19, 2025

CI seems no longer running properly with your changes. jobs no longer start

@bnowak
Copy link
Contributor Author

bnowak commented Apr 19, 2025

Yeah, but I wasn't sure why exactly 😅 do you have any idea?

I'll try to back to this in couple of days 😉

@@ -120,7 +144,7 @@ jobs:
run: composer require sqlftw/sqlftw --ignore-platform-req=php+

- name: Install doctrine/dbal (optional dependency)
run: composer require doctrine/dbal:^3 --ignore-platform-req=php+
run: composer require doctrine/dbal:${{ matrix.dbal-version }} --ignore-platform-req=php+
Copy link
Owner

Choose a reason for hiding this comment

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

I guess this command now needs to be wrapped into double quotes

@bnowak bnowak force-pushed the add-support-for-dbal-v4 branch from 51deb2d to f74b52f Compare April 24, 2025 12:25
@bnowak bnowak marked this pull request as draft April 24, 2025 12:37
@staabm staabm force-pushed the add-support-for-dbal-v4 branch from f74b52f to 9a432ae Compare April 25, 2025 07:22
@bnowak bnowak force-pushed the add-support-for-dbal-v4 branch from 9a432ae to f3f862b Compare May 16, 2025 07:35
@bnowak
Copy link
Contributor Author

bnowak commented May 16, 2025

@staabm I guess now the PR is in state that would be ready for review, however there're still some jobs blocked and not triggered.

I'm not sure what is the cause they don't want to start. I tried wrapping in double quotes of require dbal lib in both ways:

    - name: Install doctrine/dbal (optional dependency)
      run: "composer require doctrine/dbal:${{ matrix.dbal-version }} --ignore-platform-req=php+"
    ...
      run: composer require "doctrine/dbal:${{ matrix.dbal-version }}" --ignore-platform-req=php+

but there's the same result.

I'm not sure that's related 😞 🤔

Do you have any other idea?

@bnowak bnowak marked this pull request as ready for review May 16, 2025 11:51
Copy link
Owner

@staabm staabm left a comment

Choose a reason for hiding this comment

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

since you changed the jobmatrix its fine that some jobs are no longer triggered.. I need to adjust the 'required branches' in the repo-settings as the jobs changed.

I think this PR is mostly done, just a few nits left.

@@ -79,13 +79,13 @@ public function syntaxErrorPdoPrepare(PDO $pdo)
public function syntaxErrorDoctrineDbal(\Doctrine\DBAL\Connection $conn)
{
$sql = 'SELECT email adaid WHERE gesperrt freigabe1u1 FROM ada';
$conn->query($sql);
$conn->executeQuery($sql);
Copy link
Owner

Choose a reason for hiding this comment

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

why do we need this changes?

Copy link
Owner

@staabm staabm May 16, 2025

Choose a reason for hiding this comment

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

said differently: we also need the previous test with ->query() but just run it on 3.x

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Connection::query method was deprecated in DBAL 3 and was deleted in DBAL 4.

Target solution is to use executeQuery in both, so I adjusted test to be valid for both versions.
Also, I added Connection::executeQuery and Connection::executeStatement in injected methods to validate in SyntaxErrorInQueryMethodRule class - IMO they should be there from the very beginning as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you want to keep that test-case, I'd need to create separate test data file and include it conditionally only for dbal3 (simillary as with doctrine-dbal3.php file). It's because of the Connection::query method is missing in dbal4 and it wouldn't be parsed by phpstan (it would skip analyzing query syntax, so expected test error wouldn't be thrown)

Will that be fine?

Copy link
Owner

Choose a reason for hiding this comment

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

Sounds good

Copy link
Owner

@staabm staabm May 16, 2025

Choose a reason for hiding this comment

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

to be precise: just copy the previous code into a new file and make it beeing analyzed by the corresponding rule-test.

we only need the 3.x only-api tested in the new file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@staabm done :)

@staabm staabm merged commit d930145 into staabm:main May 16, 2025
28 checks passed
@staabm
Copy link
Owner

staabm commented May 16, 2025

thank you!

@bnowak bnowak deleted the add-support-for-dbal-v4 branch May 16, 2025 12:48
@bnowak
Copy link
Contributor Author

bnowak commented May 16, 2025

Thanks as well :)

any chances that could be released soon?

@staabm
Copy link
Owner

staabm commented May 16, 2025

here we go: https://github.com/staabm/phpstan-dba/releases/tag/0.4

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.

2 participants