7
7
use Assert \Assert ;
8
8
use Roave \BackwardCompatibility \Changes ;
9
9
use Roave \BackwardCompatibility \CompareApi ;
10
- use Roave \BackwardCompatibility \Factory \DirectoryReflectorFactory ;
10
+ use Roave \BackwardCompatibility \Factory \ComposerInstallationReflectorFactory ;
11
11
use Roave \BackwardCompatibility \Formatter \MarkdownPipedToSymfonyConsoleFormatter ;
12
12
use Roave \BackwardCompatibility \Formatter \SymfonyConsoleTextFormatter ;
13
13
use Roave \BackwardCompatibility \Git \CheckedOutRepository ;
22
22
use Symfony \Component \Console \Command \Command ;
23
23
use Symfony \Component \Console \Exception \InvalidArgumentException ;
24
24
use Symfony \Component \Console \Exception \LogicException ;
25
- use Symfony \Component \Console \Input \InputArgument ;
26
25
use Symfony \Component \Console \Input \InputInterface ;
27
26
use Symfony \Component \Console \Input \InputOption ;
28
27
use Symfony \Component \Console \Output \ConsoleOutputInterface ;
@@ -37,8 +36,8 @@ final class AssertBackwardsCompatible extends Command
37
36
/** @var PerformCheckoutOfRevision */
38
37
private $ git ;
39
38
40
- /** @var DirectoryReflectorFactory */
41
- private $ reflectorFactory ;
39
+ /** @var ComposerInstallationReflectorFactory */
40
+ private $ makeComposerInstallationReflector ;
42
41
43
42
/** @var ParseRevision */
44
43
private $ parseRevision ;
@@ -60,7 +59,7 @@ final class AssertBackwardsCompatible extends Command
60
59
*/
61
60
public function __construct (
62
61
PerformCheckoutOfRevision $ git ,
63
- DirectoryReflectorFactory $ reflectorFactory ,
62
+ ComposerInstallationReflectorFactory $ makeComposerInstallationReflector ,
64
63
ParseRevision $ parseRevision ,
65
64
GetVersionCollection $ getVersions ,
66
65
PickVersionFromVersionCollection $ pickFromVersion ,
@@ -69,13 +68,13 @@ public function __construct(
69
68
) {
70
69
parent ::__construct ();
71
70
72
- $ this ->git = $ git ;
73
- $ this ->reflectorFactory = $ reflectorFactory ;
74
- $ this ->parseRevision = $ parseRevision ;
75
- $ this ->getVersions = $ getVersions ;
76
- $ this ->pickFromVersion = $ pickFromVersion ;
77
- $ this ->locateDependencies = $ locateDependencies ;
78
- $ this ->compareApi = $ compareApi ;
71
+ $ this ->git = $ git ;
72
+ $ this ->makeComposerInstallationReflector = $ makeComposerInstallationReflector ;
73
+ $ this ->parseRevision = $ parseRevision ;
74
+ $ this ->getVersions = $ getVersions ;
75
+ $ this ->pickFromVersion = $ pickFromVersion ;
76
+ $ this ->locateDependencies = $ locateDependencies ;
77
+ $ this ->compareApi = $ compareApi ;
79
78
}
80
79
81
80
/**
@@ -105,12 +104,6 @@ protected function configure() : void
105
104
InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY ,
106
105
'Currently only supports "markdown" '
107
106
)
108
- ->addArgument (
109
- 'sources-path ' ,
110
- InputArgument::OPTIONAL ,
111
- 'Path to the sources, relative to the repository root ' ,
112
- 'src '
113
- )
114
107
->addUsage (
115
108
<<<'USAGE'
116
109
@@ -126,7 +119,7 @@ protected function configure() : void
126
119
127
120
It will then install all required dependencies in both copies
128
121
and compare the APIs, looking for breaking changes in the
129
- given `<sources-path>` ("src" by default) .
122
+ defined "autoload" paths in your `composer.json` definition .
130
123
131
124
Once completed, it will print out the results to `STDERR`
132
125
and terminate with `3` if breaking changes were detected.
@@ -156,32 +149,25 @@ public function execute(InputInterface $input, OutputInterface $output) : int
156
149
? $ this ->parseRevisionFromInput ($ input , $ sourceRepo )
157
150
: $ this ->determineFromRevisionFromRepository ($ sourceRepo , $ stdErr );
158
151
159
- $ toRevision = $ this ->parseRevision ->fromStringForRepository ($ input ->getOption ('to ' ), $ sourceRepo );
160
- $ sourcesPath = $ input ->getArgument ('sources-path ' );
152
+ $ toRevision = $ this ->parseRevision ->fromStringForRepository ($ input ->getOption ('to ' ), $ sourceRepo );
161
153
162
154
$ stdErr ->writeln (sprintf ('Comparing from %s to %s... ' , (string ) $ fromRevision , (string ) $ toRevision ));
163
155
164
156
$ fromPath = $ this ->git ->checkout ($ sourceRepo , $ fromRevision );
165
157
$ toPath = $ this ->git ->checkout ($ sourceRepo , $ toRevision );
166
158
167
159
try {
168
- $ fromSources = $ fromPath . '/ ' . $ sourcesPath ;
169
- $ toSources = $ toPath . '/ ' . $ sourcesPath ;
170
-
171
- Assert::that ($ fromSources )->directory ();
172
- Assert::that ($ toSources )->directory ();
173
-
174
160
$ changes = $ this ->compareApi ->__invoke (
175
- $ this ->reflectorFactory ->__invoke (
176
- $ fromPath . ' / ' . $ sourcesPath ,
161
+ $ this ->makeComposerInstallationReflector ->__invoke (
162
+ $ fromPath-> __toString () ,
177
163
new AggregateSourceLocator () // no dependencies
178
164
),
179
- $ this ->reflectorFactory ->__invoke (
180
- $ fromPath . ' / ' . $ sourcesPath ,
165
+ $ this ->makeComposerInstallationReflector ->__invoke (
166
+ $ fromPath-> __toString () ,
181
167
$ this ->locateDependencies ->__invoke ((string ) $ fromPath )
182
168
),
183
- $ this ->reflectorFactory ->__invoke (
184
- $ toPath . ' / ' . $ sourcesPath ,
169
+ $ this ->makeComposerInstallationReflector ->__invoke (
170
+ $ toPath-> __toString () ,
185
171
$ this ->locateDependencies ->__invoke ((string ) $ toPath )
186
172
)
187
173
);
0 commit comments