1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PhpUnitGen\Console; |
4
|
|
|
|
5
|
|
|
use PhpUnitGen\Configuration\ConsoleConfig; |
6
|
|
|
use PhpUnitGen\Configuration\ConsoleConfigFactoryInterface; |
7
|
|
|
use PhpUnitGen\Configuration\ConsoleConfigInterface; |
8
|
|
|
use PhpUnitGen\Configuration\DefaultConsoleConfigFactory; |
9
|
|
|
use PhpUnitGen\Configuration\JsonConsoleConfigFactory; |
10
|
|
|
use PhpUnitGen\Configuration\PhpConsoleConfigFactory; |
11
|
|
|
use PhpUnitGen\Configuration\YamlConsoleConfigFactory; |
12
|
|
|
use PhpUnitGen\Exception\InvalidConfigException; |
13
|
|
|
use Respect\Validation\Validator; |
14
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
15
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Class DefaultGenerateCommand. |
19
|
|
|
* |
20
|
|
|
* @author Paul Thébaud <[email protected]>. |
21
|
|
|
* @copyright 2017-2018 Paul Thébaud <[email protected]>. |
22
|
|
|
* @license https://opensource.org/licenses/MIT The MIT license. |
23
|
|
|
* @link https://github.com/paul-thebaud/phpunit-generator |
24
|
|
|
* @since Class available since Release 2.0.0. |
25
|
|
|
*/ |
26
|
|
|
class DefaultGenerateCommand extends AbstractGenerateCommand |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* {@inheritdoc} |
30
|
|
|
*/ |
31
|
|
|
protected function configure() |
32
|
|
|
{ |
33
|
|
|
$this->setName("generate-default") |
34
|
|
|
->setDescription("Generate unit tests skeletons") |
35
|
|
|
->setHelp("Use it to generate your unit tests skeletons from a default config") |
36
|
|
|
->addArgument('source-path', InputArgument::REQUIRED, 'The source directory path.') |
37
|
|
|
->addArgument('target-path', InputArgument::REQUIRED, 'The target directory path.'); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* {@inheritdoc} |
42
|
|
|
*/ |
43
|
|
|
public function getConfiguration(InputInterface $input): ConsoleConfigInterface |
44
|
|
|
{ |
45
|
|
|
$sourceDirectory = $input->getArgument('source-path'); |
46
|
|
|
$targetDirectory = $input->getArgument('target-path'); |
47
|
|
|
|
48
|
|
|
/** @var ConsoleConfigFactoryInterface $factory */ |
49
|
|
|
$factory = new DefaultConsoleConfigFactory(); |
50
|
|
|
return $factory->invoke($sourceDirectory, $targetDirectory); |
|
|
|
|
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.