4
4
5
5
namespace Safe \Commands ;
6
6
7
- use Safe \XmlDocParser \Scanner ;
7
+ use Safe \XmlDocParser \Method ;
8
8
use Safe \XmlDocParser \DocPage ;
9
+ use Safe \PhpStanFunctions \PhpStanFunctionMapReader ;
9
10
use Symfony \Component \Console \Command \Command ;
10
11
use Symfony \Component \Console \Input \InputInterface ;
11
12
use Symfony \Component \Console \Input \InputArgument ;
12
13
use Symfony \Component \Console \Output \OutputInterface ;
14
+ use Symfony \Component \Finder \Finder ;
13
15
14
16
class FunctionInfoCommand extends Command
15
17
{
@@ -24,14 +26,26 @@ protected function configure(): void
24
26
25
27
protected function execute (InputInterface $ input , OutputInterface $ output ): int
26
28
{
27
- $ scanner = new Scanner (DocPage:: findReferenceDir () );
28
- $ res = $ scanner -> getMethods ( $ scanner -> getFunctionsPaths () , $ output ) ;
29
+ $ target = $ input -> getArgument ( " function " );
30
+ $ targetFilename = str_replace ( " _ " , " - " , $ target ) . " .xml " ;
29
31
30
- foreach ($ res ->methods as $ function ) {
31
- $ name = $ function ->getFunctionName ();
32
- if ($ name == $ input ->getArgument ("function " )) {
32
+ $ phpStanFunctionMapReader = new PhpStanFunctionMapReader ();
33
+
34
+ $ finder = new Finder ();
35
+ $ finder ->in (DocPage::findReferenceDir ())->name ($ targetFilename )->sortByName ();
36
+
37
+ foreach ($ finder as $ file ) {
38
+ $ docPage = new DocPage ($ file ->getPathname ());
39
+ $ isFalsy = $ docPage ->detectFalsyFunction ();
40
+ $ isNullsy = $ docPage ->detectNullsyFunction ();
41
+ $ isEmpty = $ docPage ->detectEmptyFunction ();
42
+ $ errorType = $ isFalsy ? Method::FALSY_TYPE : ($ isNullsy ? Method::NULLSY_TYPE : Method::EMPTY_TYPE );
43
+
44
+ $ functionObjects = $ docPage ->getMethodSynopsis ();
45
+ $ rootEntity = $ docPage ->loadAndResolveFile ();
46
+ foreach ($ functionObjects as $ functionObject ) {
47
+ $ function = new Method ($ functionObject , $ rootEntity , $ docPage ->getModule (), $ phpStanFunctionMapReader , $ errorType );
33
48
$ output ->writeln ((string )$ function );
34
- break ;
35
49
}
36
50
}
37
51
0 commit comments