-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Enable PHPStan strict rules #3932
Conversation
35ac9c7
to
3eeee24
Compare
…y the ones that remain unchanged.
3eeee24
to
b8066db
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Document the no longer ignored empty values.
Is this something you plan to do before merging? Approving in case it isn't
I think Scrutinizer fails because if views the change in SQLSeverSchemaManager as an increase in complexity, but to me the if
is easier to understand than the ternary
I was going to put this in the PR description, no more code changes expected.
Yes, and we can't do anything else with it than ignore it.
I agree. Furthermore, the original reason for this was to pass the option down the line only if it's explicitly set. There's no point in passing the default explicitly. Also, it makes line coverage report more accurate. |
The initial work was done on top of
master
and then backported to3.0.x
to get the tests improved as well. This is an important addition on top of the existing code quality checks since it helps to find potential bugs and prevents the new code of questionable quality from being introduced.Additionally, in
master
the test suite will be cleaned up since a lot of assertions are no longer needed thanks to the improved type system (#3348).Fixed issues:
The analysis identified a couple of potential issues and deviations from the best practices:
$name
variable declared in theforeach
loop overrides the table$name
method argument that is used down the line. Most likely, a table with such constraints will have an invalid name:dbal/src/Platforms/SqlitePlatform.php
Lines 329 to 331 in 8be6d16
strpos()
return value looks suspicious:dbal/src/Schema/OracleSchemaManager.php
Line 127 in 8be6d16
dbal/src/Cache/ResultCacheStatement.php
Lines 84 to 85 in 936e7e3
"0"
set on a table in Oracle may be ignored:dbal/src/Platforms/OraclePlatform.php
Lines 788 to 790 in 8be6d16
TRUE
is when the counts are not equal which should have been coded explicitly:dbal/src/Platforms/SQLServer2012Platform.php
Line 1353 in 8be6d16
Technically, BC-breaks:
$fetchMode
argument in theStatement
methods is no longer ignored. Not that anyone should have used it but in order to use the default mode, it should be omitted or expressed asNULL
.oci8
andpdo_oci
drivers are no longer ignored if passed explicitly.pdo_sqlsrv
driver is no longer ignored if passed explicitly.QueryBuilder
methods still accept null as an optional parameter but will no longer ignore another explicitly passed empty value:::select()
,::addSelect()
,::insert()
,::update()
,::delete()
.Statement::execute()
,QueryBuilder::groupBy()
and::addGroupBy()
will no longer an explicitly passed non-array empty value.AbstractPlatform::getTrimExpression()
will no longer ignore an empty value of$mode
(useTrimMode::UNSPECIFIED
or omit); and an empty value of$char
(usefalse
or omit).Other empty values in various configurations are not ignored if passed explicitly
Future improvements identified
The errors suppressed in the PHPStan configuration identify the by-design issues that need to be fixed in the future:
AbstractSchemaManager::tryMethod()
implements dynamic method calls and needs to be redesigned and internalized to DBAL.Additional, not strictly relevant issues fixed:
dbal/src/Schema/MySqlSchemaManager.php
Line 146 in 936e7e3
TODO:
master
, revisit the list of whitelisted errors. Some of them will be no longer relevant.