mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-17 21:38:22 +01:00
report invalid array/param syntax in config [closes #983]
This commit is contained in:
parent
91960dd621
commit
aa1083882e
@ -23,6 +23,8 @@ final class OptionNameRectorTest extends AbstractRectorTestCase
|
||||
*/
|
||||
protected function getRectorConfiguration(): array
|
||||
{
|
||||
return [FormBuilder::class];
|
||||
return [
|
||||
'$formBuilderType' => FormBuilder::class
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -3,8 +3,10 @@
|
||||
namespace Rector\DependencyInjection\Loader;
|
||||
|
||||
use Nette\Utils\Strings;
|
||||
use Rector\Exception\Configuration\InvalidConfigurationException;
|
||||
use ReflectionClass;
|
||||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
/**
|
||||
* Before:
|
||||
@ -74,7 +76,12 @@ final class RectorServiceParametersShifter
|
||||
|
||||
// we can autowire exclusively 1 parameter only
|
||||
if (count($arrayParameterNames) !== 1) {
|
||||
continue;
|
||||
throw new InvalidConfigurationException(sprintf(
|
||||
'There must be array argument in "%s" constructor or explicit $argument name in configuration:%s%s',
|
||||
$serviceName,
|
||||
PHP_EOL . PHP_EOL,
|
||||
Yaml::dump($serviceDefinition, Yaml::DUMP_OBJECT_AS_MAP)
|
||||
));
|
||||
}
|
||||
|
||||
$serviceDefinition['arguments']['$' . $arrayParameterNames[0]] = $nonReservedNonVariables;
|
||||
|
@ -2,11 +2,9 @@
|
||||
|
||||
namespace Rector\DependencyInjection;
|
||||
|
||||
use Rector\Contract\Rector\PhpRectorInterface;
|
||||
use Rector\Contract\Rector\RectorInterface;
|
||||
use Rector\DependencyInjection\CompilerPass\RemoveExcludedRectorsCompilerPass;
|
||||
use Rector\DependencyInjection\Loader\TolerantRectorYamlFileLoader;
|
||||
use Rector\FileSystemRector\Contract\FileSystemRectorInterface;
|
||||
use Symfony\Component\Config\Loader\DelegatingLoader;
|
||||
use Symfony\Component\Config\Loader\GlobFileLoader;
|
||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
|
@ -28,9 +28,6 @@ final class NewObjectToFactoryCreateRector extends AbstractRector
|
||||
*/
|
||||
public function __construct(array $objectToFactoryMethod)
|
||||
{
|
||||
dump($objectToFactoryMethod);
|
||||
die;
|
||||
|
||||
$this->objectToFactoryMethod = $objectToFactoryMethod;
|
||||
}
|
||||
|
||||
@ -65,7 +62,7 @@ CODE_SAMPLE
|
||||
'MyClass' => [
|
||||
'class' => 'MyClassFactory',
|
||||
'method' => 'create',
|
||||
]
|
||||
],
|
||||
]
|
||||
),
|
||||
]);
|
||||
|
@ -28,7 +28,7 @@ final class NewObjectToFactoryCreateRectorTest extends AbstractRectorTestCase
|
||||
MyClass::class => [
|
||||
'class' => MyClassFactory::class,
|
||||
'method' => 'create',
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user