Skip to content

Commit 8aab2bd

Browse files
authored
DX: maintenance (#5)
* DX: update PHP and deps * CI * update CS fixer * apply CS * migrate to PHP 7.1 * allow PHPUnit Bridge ^6 too
1 parent c181d55 commit 8aab2bd

12 files changed

+84
-136
lines changed

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
/.php_cs
2-
/.php_cs.cache
1+
/.php-cs-fixer.cache
2+
/.php-cs-fixer.php
3+
/.phpunit.result.cache
34
/composer.lock
45
/phpunit.xml
56
/vendor/

.php-cs-fixer.dist.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
$header = <<<'EOF'
4+
This file is part of CLI Executor.
5+
6+
(c) Dariusz Rumiński <dariusz.ruminski@gmail.com>
7+
8+
This source file is subject to the MIT license that is bundled
9+
with this source code in the file LICENSE.
10+
EOF;
11+
12+
return (new PhpCsFixer\Config())
13+
->setRiskyAllowed(true)
14+
->setRules(array(
15+
'@PHP71Migration' => true,
16+
'@PHP71Migration:risky' => true,
17+
'@PHPUnit75Migration:risky' => true,
18+
'@PhpCsFixer' => true,
19+
'@PhpCsFixer:risky' => true,
20+
// 'general_phpdoc_annotation_remove' => ['annotations' => ['expectedDeprecation']], // one should use PHPUnit built-in method instead
21+
'header_comment' => ['header' => $header],
22+
))
23+
->setFinder(
24+
PhpCsFixer\Finder::create()
25+
->in(__DIR__)
26+
)
27+
;

.php_cs.dist

Lines changed: 0 additions & 49 deletions
This file was deleted.

.travis.yml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
include:
2424
-
2525
stage: Static Code Analysis
26-
php: 7.2
26+
php: 7.1
2727
install:
2828
- travis_retry composer update $DEFAULT_COMPOSER_FLAGS $COMPOSER_FLAGS
2929
- composer info -D | sort
@@ -33,28 +33,23 @@ jobs:
3333

3434
- &STANDARD_TEST_JOB
3535
stage: Test
36-
php: 7.0
36+
php: 7.2
3737
install:
3838
- travis_retry composer update $DEFAULT_COMPOSER_FLAGS $COMPOSER_FLAGS
3939
- composer info -D | sort
4040
script:
4141
- vendor/bin/phpunit || travis_terminate 1
4242

43-
-
44-
<<: *STANDARD_TEST_JOB
45-
stage: Test
46-
php: 5.6
47-
env: COMPOSER_FLAGS="--ignore-platform-reqs --prefer-stable --prefer-lowest"
48-
4943
-
5044
<<: *STANDARD_TEST_JOB
5145
stage: Test
5246
php: 7.1
47+
env: COMPOSER_FLAGS="--ignore-platform-reqs --prefer-stable --prefer-lowest"
5348

5449
-
5550
<<: *STANDARD_TEST_JOB
5651
stage: Test
57-
php: 7.2
52+
php: 7.3
5853

5954
-
6055
<<: *STANDARD_TEST_JOB
@@ -64,5 +59,4 @@ jobs:
6459
-
6560
<<: *STANDARD_TEST_JOB
6661
stage: Test
67-
php: nightly
68-
env: COMPOSER_FLAGS="--ignore-platform-reqs"
62+
php: 8.0

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
}
1111
],
1212
"require": {
13-
"php": "^5.6 || ^7.0 || ^8.0",
14-
"symfony/process": "^3.4 || ^4 || ^5"
13+
"php": "^7.1.3 || ^8.0",
14+
"symfony/process": "^4.4 || ^5 || ^6"
1515
},
1616
"require-dev": {
17-
"friendsofphp/php-cs-fixer": "^2.16",
18-
"maglnet/composer-require-checker": "^0.1.6",
19-
"phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1 || ^8 || ^9",
20-
"symfony/phpunit-bridge": "^4.0 || ^5.0"
17+
"friendsofphp/php-cs-fixer": "^3.1",
18+
"maglnet/composer-require-checker": "^2 || ^3",
19+
"phpunit/phpunit": "^7.5.20 || ^8.5.14 || ^9.5",
20+
"symfony/phpunit-bridge": "^5.3.7 || ^6"
2121
},
2222
"config": {
2323
"optimize-autoloader": true,

src/BashScriptExecutor.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/*
46
* This file is part of CLI Executor.
57
*
@@ -23,31 +25,25 @@ final class BashScriptExecutor
2325

2426
/**
2527
* @param string[] $scriptParts
26-
* @param string $cwd
2728
*/
28-
public function __construct($scriptParts, $cwd)
29+
public function __construct(array $scriptParts, string $cwd)
2930
{
3031
@trigger_error('`\Keradus\CliExecutor\BashScriptExecutor` is deprecated, use `\Keradus\CliExecutor\ScriptExecutor` instead.', E_USER_DEPRECATED);
3132
$this->scriptExecutor = new ScriptExecutor($scriptParts, $cwd, ['#!/usr/bin/env bash', 'set -e', '']);
3233
}
3334

3435
/**
3536
* @param string[] $scriptParts
36-
* @param string $cwd
37-
*
38-
* @return self
3937
*/
40-
public static function create($scriptParts, $cwd)
38+
public static function create(array $scriptParts, string $cwd): self
4139
{
4240
return new self($scriptParts, $cwd);
4341
}
4442

4543
/**
4644
* @throws ExecutionException
47-
*
48-
* @return CliResult
4945
*/
50-
public function getResult()
46+
public function getResult(): CliResult
5147
{
5248
return $this->scriptExecutor->getResult();
5349
}

src/CliResult.php

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/*
46
* This file is part of CLI Executor.
57
*
@@ -28,38 +30,24 @@ final class CliResult
2830
*/
2931
private $error;
3032

31-
/**
32-
* @param int $code
33-
* @param string $output
34-
* @param string $error
35-
*/
36-
public function __construct($code, $output, $error)
33+
public function __construct(int $code, string $output, string $error)
3734
{
3835
$this->code = $code;
3936
$this->output = $output;
4037
$this->error = $error;
4138
}
4239

43-
/**
44-
* @return int
45-
*/
46-
public function getCode()
40+
public function getCode(): int
4741
{
4842
return $this->code;
4943
}
5044

51-
/**
52-
* @return string
53-
*/
54-
public function getOutput()
45+
public function getOutput(): string
5546
{
5647
return $this->output;
5748
}
5849

59-
/**
60-
* @return string
61-
*/
62-
public function getError()
50+
public function getError(): string
6351
{
6452
return $this->error;
6553
}

src/CommandExecutor.php

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/*
46
* This file is part of CLI Executor.
57
*
@@ -16,7 +18,7 @@
1618
final class CommandExecutor
1719
{
1820
/**
19-
* @var string|array
21+
* @var array|string
2022
*/
2123
private $command;
2224

@@ -31,34 +33,26 @@ final class CommandExecutor
3133
private $result;
3234

3335
/**
34-
* @param string|array $command
35-
* @param string $cwd
36+
* @param array|string $command
3637
*/
37-
public function __construct($command, $cwd)
38+
public function __construct($command, string $cwd)
3839
{
3940
$this->command = $command;
4041
$this->cwd = $cwd;
4142
}
4243

4344
/**
44-
* @param string|array $command
45-
* @param string $cwd
46-
*
47-
* @return self
45+
* @param array|string $command
4846
*/
49-
public static function create($command, $cwd)
47+
public static function create($command, string $cwd): self
5048
{
5149
return new self($command, $cwd);
5250
}
5351

5452
/**
55-
* @param bool $checkCode
56-
*
5753
* @throws ExecutionException
58-
*
59-
* @return CliResult
6054
*/
61-
public function getResult($checkCode = true)
55+
public function getResult(bool $checkCode = true): CliResult
6256
{
6357
if (null === $this->result) {
6458
if (\is_string($this->command) && method_exists(Process::class, 'fromShellCommandline')) {

src/ExecutionException.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/*
46
* This file is part of CLI Executor.
57
*
@@ -25,10 +27,7 @@ public function __construct(CliResult $result, $message = '', $code = 0, \Except
2527
$this->result = $result;
2628
}
2729

28-
/**
29-
* @return CliResult
30-
*/
31-
public function getResult()
30+
public function getResult(): CliResult
3231
{
3332
return $this->result;
3433
}

src/ScriptExecutor.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/*
46
* This file is part of CLI Executor.
57
*
@@ -47,10 +49,9 @@ final class ScriptExecutor
4749

4850
/**
4951
* @param string[] $scriptParts
50-
* @param string $cwd
5152
* @param ?string[] $scriptInit
5253
*/
53-
public function __construct($scriptParts, $cwd, array $scriptInit = null)
54+
public function __construct(array $scriptParts, string $cwd, array $scriptInit = null)
5455
{
5556
$this->scriptParts = $scriptParts;
5657
$this->cwd = $cwd;
@@ -66,24 +67,17 @@ public function __destruct()
6667

6768
/**
6869
* @param string[] $scriptParts
69-
* @param string $cwd
7070
* @param ?string[] $scriptInit
71-
*
72-
* @return self
7371
*/
74-
public static function create($scriptParts, $cwd, array $scriptInit = null)
72+
public static function create(array $scriptParts, string $cwd, array $scriptInit = null): self
7573
{
7674
return new self($scriptParts, $cwd, $scriptInit);
7775
}
7876

7977
/**
80-
* @param bool $checkCode
81-
*
8278
* @throws ExecutionException
83-
*
84-
* @return CliResult
8579
*/
86-
public function getResult($checkCode = true)
80+
public function getResult(bool $checkCode = true): CliResult
8781
{
8882
if (null === $this->result) {
8983
$tmpFileName = 'tmp-'.self::$tmpCounter++.'.sh';
@@ -109,7 +103,7 @@ public function getResult($checkCode = true)
109103
sprintf(
110104
"Cannot execute `%s`:\n%s\nCode: %s\nExit text: %s\nError output: %s\nDetails:\n%s",
111105
$command,
112-
implode("\n", array_map(function ($line) { return "$ ${line}"; }, $tmpFileLines)),
106+
implode("\n", array_map(function ($line) { return "$ {$line}"; }, $tmpFileLines)),
113107
$this->result->getCode(),
114108
isset(Process::$exitCodes[$this->result->getCode()]) ? Process::$exitCodes[$this->result->getCode()] : 'Unknown exit code',
115109
$this->result->getError(),

0 commit comments

Comments
 (0)