rector icon indicating copy to clipboard operation
rector copied to clipboard

RemoveExtraParametersRector removes all parameters

Open anibalsanchez opened this issue 1 year ago • 1 comments

Bug Report

Subject Details
Rector version v1.2.4

The RemoveExtraParametersRector removes the mandatory parameter.

Minimal PHP Code Causing Issue

INPUT

        $query = $xtf0FDatabaseDriver->getQuery(true);
        $query->select('extension_id')
            ->from('#__extensions')
            ->where($xtf0FDatabaseDriver->qn('type').' = '.$xtf0FDatabaseDriver->q('component'))
            ->where($xtf0FDatabaseDriver->qn('element').' = '.$xtf0FDatabaseDriver->q($this->componentName));
        $xtf0FDatabaseDriver->setQuery($query);

qn is an alias of quoteName defined via a magic method. public function __call($name, array $arguments) calls public function quoteName($name, $as = null)

OUTPUT

        $xtf0FDatabaseDriver = XTF0FPlatform::getInstance()->getDbo();
        $query = $xtf0FDatabaseDriver->getQuery(true);
        $query->select('extension_id')
            ->from('#__extensions')
            ->where($xtf0FDatabaseDriver->qn().' = '.$xtf0FDatabaseDriver->q())
            ->where($xtf0FDatabaseDriver->qn().' = '.$xtf0FDatabaseDriver->q());
        $xtf0FDatabaseDriver->setQuery($query);

I tried to create the isolated test case, but it didn't produce the same result.

Expected Behaviour

Rector shouldn't drop the required parameters.

anibalsanchez avatar Aug 27 '24 10:08 anibalsanchez

That's usually due to some autoload not setup properly, ensure it setup properly, and it will works as is, see https://getrector.com/documentation/static-reflection-and-autoload

samsonasik avatar Aug 27 '24 14:08 samsonasik

closing as answered and needs reproducible code/config to make a fix.

samsonasik avatar Sep 01 '24 13:09 samsonasik