File tree 6 files changed +72
-13
lines changed
6 files changed +72
-13
lines changed Original file line number Diff line number Diff line change 7
7
- $HOME/.composer/cache/files
8
8
9
9
env :
10
- matrix :
11
- - COMPOSER_FLAGS='--no-interaction --no-progress --no-suggest --prefer-dist'
10
+ - COMPOSER_FLAGS='--no-interaction --no-progress --no-suggest --prefer-dist'
12
11
13
12
matrix :
14
13
include :
15
14
- php : ' 7.2'
16
15
env : PREFER_LOWEST='--prefer-lowest'
17
16
- php : ' 7.3'
17
+ - php : ' 7.4'
18
+ env : SYMFONY_VERSION='~4.4.0'
19
+ - php : ' 7.4'
20
+ env : SYMFONY_VERSION='~5.0.0'
18
21
fast_finish : true
19
22
20
23
before_install :
21
24
- phpenv config-rm xdebug.ini || true
22
25
- set -eo pipefail
23
26
- echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
24
27
- composer validate --strict
28
+ - |
29
+ if [ -n "$SYMFONY_VERSION" ]; then
30
+ composer require --no-update "symfony/console:${SYMFONY_VERSION}" "symfony/dependency-injection:${SYMFONY_VERSION}" "symfony/process:${SYMFONY_VERSION}" "symfony/framework-bundle:${SYMFONY_VERSION}";
31
+ fi
25
32
26
33
install :
27
34
- composer update $COMPOSER_FLAGS $PREFER_LOWEST
Original file line number Diff line number Diff line change 15
15
],
16
16
17
17
"require" : {
18
- "php" : " ^7.1 " ,
19
- "symfony/console" : " ^ 3.0 || ^4.0" ,
20
- "symfony/dependency-injection" : " ^3.0 || ^4.1.12" ,
21
- "symfony/process" : " ^3.0 || ^4.0" ,
18
+ "php" : " ^7.2 " ,
19
+ "symfony/console" : " 3.0 || ^4.0 || ^5 .0" ,
20
+ "symfony/dependency-injection" : " ^3.0 || ^4.1.12 || ^5.0 " ,
21
+ "symfony/process" : " ^3.0 || ^4.0 || ^5.0 " ,
22
22
"webmozart/assert" : " ^1.5" ,
23
23
"psr/log" : " ^1.1"
24
24
},
25
25
"require-dev" : {
26
26
"ext-json" : " *" ,
27
27
"friendsofphp/php-cs-fixer" : " ^2.15" ,
28
28
"phpunit/phpunit" : " ^8.4" ,
29
- "symfony/framework-bundle" : " ^4.1"
29
+ "symfony/framework-bundle" : " ^3.0 || ^ 4.1 || ^5.0 "
30
30
},
31
31
32
32
"autoload" : {
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Webmozarts Console Parallelization package.
5
+ *
6
+ * (c) Webmozarts GmbH <office@webmozarts.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ declare (strict_types=1 );
13
+
14
+ namespace Webmozarts \Console \Parallelization ;
15
+
16
+ use Symfony \Component \Console \Command \Command ;
17
+ use Symfony \Component \DependencyInjection \ContainerAwareInterface ;
18
+ use Symfony \Component \DependencyInjection \ContainerInterface ;
19
+ use Webmozart \Assert \Assert ;
20
+
21
+ abstract class ContainerAwareCommand extends Command implements ContainerAwareInterface
22
+ {
23
+ /**
24
+ * @var ContainerInterface|null
25
+ */
26
+ private $ container ;
27
+
28
+ public function setContainer (ContainerInterface $ container = null ): void
29
+ {
30
+ $ this ->container = $ container ;
31
+ }
32
+
33
+ protected function getContainer (): ContainerInterface
34
+ {
35
+ if (null !== $ this ->container ) {
36
+ return $ this ->container ;
37
+ }
38
+
39
+ $ application = $ this ->getApplication ();
40
+
41
+ Assert::notNull (
42
+ $ application ,
43
+ 'The container cannot be retrieved as the application instance is not yet set '
44
+ );
45
+
46
+ return $ this ->container = $ application ->getKernel ()->getContainer ();
47
+ }
48
+ }
Original file line number Diff line number Diff line change 30
30
use Symfony \Component \DependencyInjection \ContainerInterface ;
31
31
use Symfony \Component \DependencyInjection \ResettableContainerInterface ;
32
32
use Symfony \Component \Process \PhpExecutableFinder ;
33
+ use Symfony \Contracts \Service \ResetInterface ;
33
34
use Throwable ;
34
35
use function trim ;
35
36
use Webmozart \Assert \Assert ;
@@ -272,15 +273,17 @@ protected function getBatchSize(): int
272
273
/**
273
274
* Executes the parallelized command.
274
275
*/
275
- protected function execute (InputInterface $ input , OutputInterface $ output ): void
276
+ protected function execute (InputInterface $ input , OutputInterface $ output ): int
276
277
{
277
278
if ($ input ->getOption ('child ' )) {
278
279
$ this ->executeChildProcess ($ input , $ output );
279
280
280
- return ;
281
+ return 0 ;
281
282
}
282
283
283
284
$ this ->executeMasterProcess ($ input , $ output );
285
+
286
+ return 0 ;
284
287
}
285
288
286
289
/**
@@ -505,7 +508,10 @@ private function runTolerantSingleCommand(
505
508
506
509
$ container = $ this ->getContainer ();
507
510
508
- if ($ container instanceof ResettableContainerInterface) {
511
+ if (
512
+ (class_exists (ResetInterface::class) && $ container instanceof ResetInterface)
513
+ || (class_exists (ResettableContainerInterface::class) && $ container instanceof ResettableContainerInterface)
514
+ ) {
509
515
$ container ->reset ();
510
516
}
511
517
}
Original file line number Diff line number Diff line change 13
13
14
14
namespace Webmozarts \Console \Parallelization ;
15
15
16
- use Symfony \Bundle \FrameworkBundle \Command \ContainerAwareCommand ;
17
16
use Symfony \Component \Console \Input \InputInterface ;
18
17
use Symfony \Component \Console \Output \OutputInterface ;
19
18
Original file line number Diff line number Diff line change 13
13
14
14
namespace Webmozarts \Console \Parallelization ;
15
15
16
- use function method_exists ;
17
16
use PHPUnit \Framework \TestCase ;
18
17
use function preg_replace ;
19
18
use function str_replace ;
@@ -263,6 +262,6 @@ private function getOutput(): string
263
262
264
263
private function isSymfony3 (): bool
265
264
{
266
- return method_exists (Application::class, ' getTerminalDimensions ' ) ;
265
+ return Kernel:: VERSION_ID < 40000 ;
267
266
}
268
267
}
You can’t perform that action at this time.
0 commit comments