sascha-egerer / phpstan-typo3

TYPO3 CMS class reflection extension for PHPStan & framework-specific rules
MIT License
42 stars 22 forks source link

Add rule to check Viewhelper arguments #129

Closed sabbelasichon closed 8 months ago

sabbelasichon commented 1 year ago

Imagine the following code

class MyViewHelper extends AbstractViewHelper
{
    public function initializeArguments(): void
    {
        $this->registerArgument('uid', 'integer', 'UID of the newsletter to be rendered', true);
    }

    public function render()
    {
        $uid = $this->arguments['uid'];
        if (null !== $uid && $uid > 10) {
            return 10
        }
        return $uid;
    }
}

The null check is not necessary because the argument must be an integer anyways.

Provide a rule for PHPStan to take this into account.

sabbelasichon commented 8 months ago

I could not find a way to implement this feature.