Problem/Motivation
Follow up from #3565604: Remove an unnecessary isset() from Renderer::doRender()
PHPStan level 1 reports 47 isset.variable violations.
Variable $foo in isset() always exists and is not nullable.
I suspect they are all fairly simple to fix.
Steps to reproduce
Violation count:
$ grep 'isset.variable' core/.phpstan-baseline.php | wc -l
47Violation list:
grep 'isset.variable' core/.phpstan-baseline.php -B2 -A3
But this doesn't give you the actual line numbers, that requires removing the violations from the baseline and rescanning:
# Clear the baseline
$ rm core/.phpstan-baseline.php && echo "<?php return [];" > core/.phpstan-baseline.php
# Run phpstan and grep for the error
$ ./vendor/bin/phpstan analyse -c core/phpstan.neon.dist --error-format=raw \
| sed "s|$PWD|.|g" \
| grep -F 'isset() always exists and is not nullable'
# Reset the baseline
$ git checkout main core/.phpstan-baseline.php
I've attached the output to this issue.
Proposed resolution
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| isset-variable.txt | 7.5 KB | mstrelan |
Issue fork drupal-3569099
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
mstrelan commentedI was going to tag this as novice, but I don't think they are necessarily all straightforward. For example,
\Drupal\Core\Config\Entity\Query\Condition::matchcallsisset($value), which is documented as a string, but since it is not strictly typed, it could be null. It would make sense to update the typehint fromstringtostring|null.Comment #5
nitinkumar_7 commentedComment #6
skifdesu commentedAdded MR which fixes all isset.variable PHPStan violations.
Comment #7
nitinkumar_7 commentedTested the MR !16013 and the full CI pipeline shows Job succeeded with no errors. All isset.variable PHPStan violations appear to be correctly fixed. No issues found.