- Issue created by @bohart
- Merge request !76Issue #3401293 by bohart: Fixed phpstan jobs fails at GitLab, added phpstan configuration file. β (Merged) created by bohart
- Status changed to Needs review
over 1 year ago 4:38pm 13 November 2023 - πΊπ¦Ukraine bohart Lutsk, Ukraine
Here are the current `phpstan` job results ([ERROR] Found 43 errors):
https://git.drupalcode.org/project/symfony_mailer/-/jobs/322855The Drupal core `phpstan` configuration has been applied:
https://git.drupalcode.org/project/drupal/-/blob/10.0.x/core/phpstan.neo...Here are the current results ([ERROR] Found 8 errors):
https://git.drupalcode.org/issue/symfony_mailer-3401293/-/jobs/323458@Adam, could you please review the current changes and commit them if everything looks okay?
Then, we will process with the rest (to avoid huge MRs).____
The rest of the errors are related to using methods/classes from 3rd party modules (like simplenews, commerce, etc).
I assume the best way is to have submodules (with the appropriate dependencies) like symfony_mailer_simplenews, symfony_mailer_commerce and move everything related to those modules into them. In this case, we will be able better to control the dependencies / tests / phpstan errors.
@Adam, what do you think?Thanks!
- π¬π§United Kingdom adamps
Thanks for your enthusiasm to improve this module. I see phpstan in the same category as grammar checkers in word processors. Sometimes it can help, but also it can have a lot of wrong ideasπ.
I see a mixture of:
- real bugs - let's fix them
- not actually bugs, but they look a bit like bugs: as a human I can understand that in fact the for loop must always be executed. For example, the fix to TransportAddButtonForm doesn't really make sense, because if $options actually could be empty, then you would have a select with no possible values which would be incorrect. Fortunately there are always options as this module defines some transports, so therefore the code is fine as it is.
- just pedantic and not really important:
isset
orempty
- making the code worse: most of the changes to constants. What we actually want is like this question. The base class should not have a value because the child should be forced to define one. 'To' is not correct as the default for an address.
- the tool seems wrong: in Core the @param sometimes doesn't have a question mark when there is = NULL
- the tool is wrong: SWIFTMAILER_TRANSPORT_SMTP is fine because it is only used inside a test that the module exists
- the tool is wrong: surely the whole point of ?? is for something that might not be defined?
I assume the best way is to have submodules (with the appropriate dependencies) like symfony_mailer_simplenews, symfony_mailer_commerce and move everything related to those modules into them
This would add quite a lot of complexity and be difficult for back-compatibility of existing sites. What is the benefit - it seems only to cover limitations in a tool, and the tool anyway isn't that important. It seems like a clear no to me.
It feels to me that we should fix the missing use statements, and probably not most of the rest.
- Status changed to Needs work
about 1 year ago 11:42am 5 January 2024 - π¬π§United Kingdom adamps
I am willing to compromise. In some cases although the change to code isn't necessary also it is harmless, so we could change it. However I don't agree to make the code worse or wrong just because the tool doesn't understand - maybe we could add a comment to disable the check of the specific line?? If you are interested then let's discuss it.
-
AdamPS β
committed 55f4708d on 1.x
Issue #3401293 by bohart, AdamPS: phpstan jobs fails at GitLab
-
AdamPS β
committed 55f4708d on 1.x
- π¬π§United Kingdom adamps
I committed the 2 use statements which are of course real bugs - thanksπ
-
adamps β
committed de64674b on 1.x authored by
bohart β
Issue #3401293 by bohart, adamps: phpstan jobs fails at GitLab
-
adamps β
committed de64674b on 1.x authored by
bohart β
- π¬π§United Kingdom adamps
Thanks @bohart . I found a compromise that avoids making the code worse yet removes the warnings.
Automatically closed - issue fixed for 2 weeks with no activity.