@@ -45,8 +45,7 @@ public function __construct(ValidatorInterface $validator)
45
45
protected function configure ()
46
46
{
47
47
$ this
48
- ->addArgument ('class ' , InputArgument::OPTIONAL , 'A class to debug ' )
49
- ->addOption ('path ' , null , InputOption::VALUE_OPTIONAL , 'A path for the classes to debug ' , 'src/Entity ' )
48
+ ->addArgument ('class ' , InputArgument::REQUIRED , 'A fully qualified class name or a path ' )
50
49
->addOption ('show-all ' , null , InputOption::VALUE_NONE , 'Show all classes event if they have no validation constraints ' )
51
50
->setDescription ('Displays validation constraints for classes ' )
52
51
->setHelp (<<<'EOF'
@@ -55,26 +54,24 @@ protected function configure()
55
54
56
55
The <info>%command.name% 'App\Entity\Dummy'</info> command dumps the validators for the dummy class.
57
56
58
- The <info>%command.name% --path= src/</info> command dumps the validators for the `src` directory.
57
+ The <info>%command.name% src/</info> command dumps the validators for the `src` directory.
59
58
EOF
60
59
)
61
60
;
62
61
}
63
62
64
63
protected function execute (InputInterface $ input , OutputInterface $ output ): int
65
64
{
66
- if (null !== $ class = $ input ->getArgument ('class ' )) {
65
+ $ class = $ input ->getArgument ('class ' );
66
+
67
+ if (class_exists ($ class )) {
67
68
$ this ->dumpValidatorsForClass ($ input , $ output , $ class );
68
69
69
70
return 0 ;
70
71
}
71
72
72
- if (null !== $ path = $ input ->getOption ('path ' )) {
73
- foreach ($ this ->getResourcesByPath ($ path ) as $ class ) {
74
- $ this ->dumpValidatorsForClass ($ input , $ output , $ class );
75
- }
76
-
77
- return 0 ;
73
+ foreach ($ this ->getResourcesByPath ($ class ) as $ class ) {
74
+ $ this ->dumpValidatorsForClass ($ input , $ output , $ class );
78
75
}
79
76
80
77
return 0 ;
@@ -170,7 +167,7 @@ private function getConstraintOptions(Constraint $constraint): array
170
167
private function getResourcesByPath (string $ path ): array
171
168
{
172
169
$ finder = new Finder ();
173
- $ finder ->in ($ path )->name ('*.php ' )->sortByName (true );
170
+ $ finder ->files ()-> in ($ path )->name ('*.php ' )->sortByName (true );
174
171
$ classes = [];
175
172
176
173
foreach ($ finder as $ file ) {
0 commit comments