Skip to content
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

Remove baseline #3955

Merged
merged 8 commits into from
Apr 16, 2020
Merged

Remove baseline #3955

merged 8 commits into from
Apr 16, 2020

Conversation

greg0ire
Copy link
Member

@greg0ire greg0ire commented Apr 15, 2020

Q A
Type improvement
BC Break no
Fixed issues n / a

@greg0ire greg0ire marked this pull request as draft April 15, 2020 16:51
@greg0ire greg0ire added the CI label Apr 15, 2020
@greg0ire
Copy link
Member Author

greg0ire commented Apr 15, 2020

@morozov not sure why this is ignored:

dbal/phpstan.neon.dist

Lines 48 to 49 in 72d9081

- '~^Class Doctrine\\Common\\(Collections\\Collection|Persistence\\Proxy) not found\.\z~'
- '~^.+ on an unknown class Doctrine\\Common\\(Collections\\Collection|Persistence\\Proxy)\.\z~'

AFAIK, Collection is still using the old Common namespace, and we depend on that lib:

if ($var instanceof Collection) {

IMO we should add doctrine/collection to at least require-dev (in the case that dependency is considered "optional"), and remove that exclusion rule from the phpstan config file. WDYT?

@greg0ire
Copy link
Member Author

Also, I can't seem to be able to run phpstan locally:

vendor/bin/phpstan analyze
Note: Using configuration file /home/greg/dev/doctrine-dbal/phpstan.neon.dist.
PHP Fatal error:  Class mysqli_result must implement interface Traversable as part of either Iterator or IteratorAggregate in Unknown on line 0
Fatal error: Class mysqli_result must implement interface Traversable as part of either Iterator or IteratorAggregate in Unknown on line 0

@greg0ire greg0ire marked this pull request as ready for review April 15, 2020 17:31
@greg0ire greg0ire requested a review from morozov April 15, 2020 17:31
@greg0ire
Copy link
Member Author

@morozov I think I fixed everything I could. Please tell me if you would like some commits to move to a PR targeting 2.11.x

@morozov
Copy link
Member

morozov commented Apr 15, 2020

@greg0ire judging by the if-statement, it's an optional dependency. So instead of a dev-dependency, we could additionally install it for static analysis if we don't want to ignore those errors.

@greg0ire
Copy link
Member Author

So instead of a dev-dependency, we could additionally install it for static analysis if we don't want to ignore those errors.

Installing it as a dev-dependency would make Psalm happy both for a Doctrine dev and for our CI, I'm not following you 🤔

@morozov
Copy link
Member

morozov commented Apr 15, 2020

Would it be possible to convert specific baseline errors into more generic ones that wouldn't require future maintenance? E.g. we don't care of all missing sasql_* functions and constants regardless of their name and the location. The same is for PDO::PGSQL_ATTR_DISABLE_PREPARES.

Ideally, I'd like to get rid of the baseline entirely and turn it into configuration like we do with PHPStan.

@greg0ire
Copy link
Member Author

Also, I was expecting phpstan to fail because of useless ignore rules, but it doesn't 🤔

@morozov
Copy link
Member

morozov commented Apr 15, 2020

This is because those are disabled (reportUnmatchedIgnoredErrors: false). They may or may not be useless depending on the environment (e.g. the PDO::PGSQL_ATTR_DISABLE_PREPARES constant may or may not be missing depending on whether pdo_pgsql is installed) and I don't see another way to fix that.

@greg0ire
Copy link
Member Author

Would it be possible to convert specific baseline errors into more generic ones that wouldn't require future maintenance? E.g. we don't care of all missing sasql_* functions and constants regardless of their name and the location. The same is for PDO::PGSQL_ATTR_DISABLE_PREPARES.

Ideally, I'd like to get rid of the baseline entirely and turn it into configuration like we do with PHPStan.

A quick look at the docs does not yield much…

@morozov
Copy link
Member

morozov commented Apr 15, 2020

Installing it as a dev-dependency would make Psalm happy both for a Doctrine dev and for our CI, I'm not following you

I just don't want to abuse dev-dependencies. This library is not a requirement for development. I'd rather ignore those errors than add the dependency.

@greg0ire
Copy link
Member Author

I just don't want to abuse dev-dependencies. This library is not a requirement for development. I'd rather ignore those errors than add the dependency.

Ok, I will drop both commits.

@morozov
Copy link
Member

morozov commented Apr 15, 2020

A quick look at the docs does not yield much…

E.g. we can suppress all UndefinedFuncion errors in lib/Doctrine/DBAL/Driver/SQLAnywhere/. It's unlikely that we will introduce some other missing functions there than the ones defined by the extension. We may use a similar approach for the rest.

@greg0ire
Copy link
Member Author

I agree but I can't find a way to do this here: https://psalm.dev/docs/running_psalm/configuration

@greg0ire
Copy link
Member Author

For some reason adding PDO to the phpstan stubs did not help. I will revert that.

@morozov
Copy link
Member

morozov commented Apr 15, 2020

I think it's something like:

<psalm>
    <issueHandlers>
        <UndefinedFuncion>
            <errorLevel type="suppress">
                <directory name="lib/Doctrine/DBAL/Driver/SQLAnywhere"/>
            </errorLevel>
        </UndefinedFuncion>
    </issueHandlers>
</psalm>

@greg0ire
Copy link
Member Author

Oh right, I didn't use the right keywords in my research (ignore vs suppress)

@greg0ire
Copy link
Member Author

greg0ire commented Apr 15, 2020

Ideally, I'd like to get rid of the baseline entirely and turn it into configuration like we do with PHPStan.

We may use a similar approach for the rest.

Done, I suppressed errors related to SQLAnywhere.

@morozov
Copy link
Member

morozov commented Apr 15, 2020

I think we should get rid of the baseline file as such and move all the suppressions in the config. The entries about PDO::PGSQL_ATTR_DISABLE_PREPARES will need to be reworked in a similar way as the ones about sasql_*. As for the remaining ones, it'd be nice to have a comment for each on why it's being left suppressed (e.g. by design or would require a BC break or a bug in Psalm, etc.). This way we know what we can improve next.

@greg0ire
Copy link
Member Author

Ok, I'll do that.

@@ -816,16 +816,16 @@
},
{
"name": "nikic/php-parser",
"version": "v4.3.0",
"version": "v4.4.0",
Copy link
Member

@morozov morozov Apr 15, 2020

Choose a reason for hiding this comment

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

We do test with the lowest dependencies on Travis, so I'm surprised why just fixing the lock file helps. The build would fail when I tried to update PHPUnit to ^9.1 because of a bug in PHPUnit 9.1.0. Requiring ^9.1.1 solved the problem.

Depending on the exact nature of the issue, should we introduce a requirement or a conflict, or we bump/adjust some other constraint that would eliminate the conflict?

Copy link
Member Author

Choose a reason for hiding this comment

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

We do test with the lowest dependencies on Travis, so I'm surprised why just fixing the lock file helps.

This helps fix a crash I had when running Psalm, and we don't run Psalm after running composer --prefer-lowest

I think we should not use a conflict when it's something that fails in dev/CI, I can add a require-dev constraint if you want me to

Copy link
Member

@morozov morozov Apr 15, 2020

Choose a reason for hiding this comment

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

Agree. Let's do a temporary require-dev. Additionally, is it worth reporting to Psalm so that they could fix it on their end and we could remove this later? There's either a bug on their end or an incorrect version constraint for PHPParser.

Copy link
Member Author

Choose a reason for hiding this comment

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

Requirement added, bug reported here: vimeo/psalm#3155

@greg0ire greg0ire changed the title Smaller baseline Remove baseline Apr 15, 2020
psalm.xml Outdated Show resolved Hide resolved
For some reason a low version crashes Psalm.
psalm.xml Outdated Show resolved Hide resolved
psalm.xml Outdated Show resolved Hide resolved
null contradicts the phpdoc
@greg0ire
Copy link
Member Author

@morozov 🚢 ?

Copy link
Member

@morozov morozov left a comment

Choose a reason for hiding this comment

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

@greg0ire, 🚢!

@morozov morozov merged commit 95ab020 into doctrine:2.10.x Apr 16, 2020
@morozov morozov self-assigned this Apr 16, 2020
@morozov morozov added this to the 2.10.2 milestone Apr 16, 2020
@greg0ire greg0ire deleted the smaller-baseline branch April 17, 2020 05:29
rgrellmann added a commit to Rossmann-IT/dbal that referenced this pull request Apr 22, 2020
Release [2.10.2](https://github.com/doctrine/dbal/milestone/75)

2.10.2
======

- Total issues resolved: **4**
- Total pull requests resolved: **19**
- Total contributors: **10**

Improvement,Static Analysis
---------------------------

 - [3964: Mark every exception as immutable](doctrine#3964) thanks to @greg0ire

CI,Improvement,Static Analysis
------------------------------

 - [3961: Stop relying on the master version of Psalm](doctrine#3961) thanks to @greg0ire
 - [3951: Setup static analysis with Psalm](doctrine#3951) thanks to @greg0ire
 - [3799: Upgrade to PHPStan v0.12](doctrine#3799) thanks to @lcobucci

Improvement,Logging,Test Suite
------------------------------

 - [3957: Reworked LoggingTest to be able to test Statement::executeUpdate()](doctrine#3957) thanks to @morozov

CI,Code Style,Improvement,Strict Typing
---------------------------------------

 - [3955: Remove baseline](doctrine#3955) thanks to @greg0ire

Bug,SQLite,Schema Introspection,Schema Managers
-----------------------------------------------

 - [3937: Column comment incorrectly introspected on SQLite](doctrine#3937) thanks to @morozov

Bug,Documentation,Prepared Statements,Query
-------------------------------------------

 - [3896: Updated documentation for QueryBuilder::execute() return value type](doctrine#3896) thanks to @morozov

Bug,Prepared Statements
-----------------------

 - [3894: Make sure that the $types array has the same keys $params](doctrine#3894) thanks to @morozov
 - [3893: Ensure the constructor arguments are passed to custom classes](doctrine#3893) thanks to @duncan3dc
 - [3843: Fix unquoted stmt fragments backslash escaping](doctrine#3843) thanks to @morozov

Documentation,Improvement
-------------------------

 - [3886: Update readme](doctrine#3886) thanks to @greg0ire
 - [3834: Fix docblock typos in DriverManager docs](doctrine#3834) thanks to @CHItA

CI,Improvement,MariaDB,MySQL
----------------------------

 - [3884: Use Docker consistently](doctrine#3884) thanks to @greg0ire
 - [3478: Improve readiness probe stability for containerized databases on CI](doctrine#3478) thanks to @morozov

 - [3883: Fix broken build](doctrine#3883) thanks to @greg0ire

Bug,Documentation,Query,Query Limit/Offset Modification
-------------------------------------------------------

 - [3842: Fixed the QueryBuilder::setMaxResults() signature to accept NULL](doctrine#3842) thanks to @morozov

Bug,Query
---------

 - [3832: Fix JOIN with no condition bug](doctrine#3832) thanks to @BenMorel

Bug,PostgreSQL,Schema Introspection
-----------------------------------

 - [3821: &doctrine#91;pg&doctrine#93; fix getting table information if search&doctrine#95;path contains escaped schema name](doctrine#3821) thanks to @linniksa

Documentation,Improvement,Logging
---------------------------------

 - [3812: Fix DebugStack#queries docblock type](doctrine#3812) thanks to @ostrolucky

Bug,Regression,Schema
---------------------

 - [3790: fixed unqualified table name of fk constraints when using schemas](doctrine#3790) thanks to @stlrnz and @Alarich

# gpg: Signature made Mon Apr 20 19:59:36 2020
# gpg:                using DSA key 2C3A645671828132
# gpg: Can't check signature: public key not found

# Conflicts:
#	README.md
@vv12131415
Copy link

@morozov I think 2 PRs from phpstorm-stubs that you've mentioned here are released (talking about this JetBrains/phpstorm-stubs#732 and JetBrains/phpstorm-stubs#727 )

@morozov
Copy link
Member

morozov commented Dec 13, 2020

Thanks, @vladyslavstartsev. Will be addressed in #4465.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants