Skip to content

Commit

Permalink
Merge pull request #17 from dshoreman/fix/php8
Browse files Browse the repository at this point in the history
Add support for PHP 8 closes #17
  • Loading branch information
ChrisB9 authored Nov 6, 2020
2 parents 43be21d + 1731971 commit ec95a23
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 32 deletions.
28 changes: 20 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,13 @@ matrix:
include:
- php: 7.2
dist: bionic
env: COMPOSER_OPTS=""
- php: 7.3
dist: bionic
env: COMPOSER_OPTS=""
- php: 7.4
dist: bionic
env: COMPOSER_OPTS=""
- php: nightly
dist: bionic
env: COMPOSER_OPTS="--ignore-platform-reqs"
allow_failures:
- php: nightly
env: COMPOSER_OPTS="--ignore-platform-reqs"
env: COMPOSER_OPTS="--ignore-platform-req=php"

cache:
directories:
Expand All @@ -25,10 +19,28 @@ cache:
install:
- travis_retry composer install $COMPOSER_OPTS

# Where PHPUnit v8 is used, we need to replace the config.
- if [[ ${TRAVIS_PHP_VERSION:0:1} == "7" ]]
&& [ ${TRAVIS_PHP_VERSION:2:1} -lt 4 ]; then
cp -v tests/phpunit.legacy.xml tests/phpunit.xml
; fi

# PHPUnit 9 supports 7.3, but Infection PHP 18 can't read
# its config so instead we downgrade to PHPUnit 8.5 here.
- if [[ ${TRAVIS_PHP_VERSION:0:3} == "7.3" ]]; then
travis_retry composer require -W phpunit/phpunit:^8.5
; fi

script:
- vendor/bin/grumphp run
- composer test
- composer infection

- if [[ ${TRAVIS_PHP_VERSION:0:1} == "7" ]]; then composer infection; else
vendor/bin/infection --ansi --threads=4
--initial-tests-php-options="-d xdebug.mode=coverage"
--only-covered --min-msi=100 --min-covered-msi=100
; fi

- composer psalm

after_success: bash <(curl -s https://codecov.io/bash)
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
"process-timeout": 0
},
"require-dev": {
"phpunit/phpunit": "^8.5",
"vimeo/psalm": "^3.11",
"infection/infection": "^0.15.3",
"spatie/phpunit-watcher": "^1.22",
"phpunit/php-invoker": "^2.0",
"pluswerk/grumphp-config": "^3.0"
"phpunit/phpunit": "^8.5 || ^9.4",
"vimeo/psalm": "^4.1",
"infection/infection": "^0.15.3 || ^0.18.2 || ^0.20.1",
"spatie/phpunit-watcher": "^1.24 || dev-master#071fbbf",
"phpunit/php-invoker": "^2.0 || ^3.1",
"pluswerk/grumphp-config": "^4.0.1"
},
"license": "MIT",
"authors": [
Expand Down
2 changes: 1 addition & 1 deletion src/Conditional/BasicExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ abstract class BasicExpression implements ShellInterface
* This is not POSIX-compatible (only eg. Korn and Bash), beware before using it
* @var bool
*/
protected $bashEnhancedBrackets;
protected $bashEnhancedBrackets = false;
/** @var bool this is always double quoted */
protected $escapedValue = false;
/** @var bool */
Expand Down
4 changes: 2 additions & 2 deletions src/Literal/ShellWord.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ class ShellWord implements ShellInterface
/** @var string */
protected $delimiter = ' ';
/** @var string */
protected $argument;
protected $argument = '';
/** @var string|ShellInterface */
protected $value;
protected $value = '';

/**
* The constructor is protected, you must choose one of the children
Expand Down
7 changes: 7 additions & 0 deletions tests/Collection/CollectionTupleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ public function testTupleToArray(): void
$this->assertEquals(['||', 'a'], $tuple->__toArray());
}

public function testToArrayWithBuilder(): void
{
$builder = ShellBuilder::command('echo')->addArgument('hunter1');
$tuple = CollectionTuple::create($builder, ControlOperator::AND_OPERATOR);
$this->assertEquals(['&&', $builder->__toArray()], $tuple->__toArray());
}

public function testWithoutCreatingTuple(): void
{
$tuple = new Pipeline();
Expand Down
4 changes: 2 additions & 2 deletions tests/ShellBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ static function (ShellBuilder $builder) {

public function testComplexCondiditionalArgumentsWithWrongArguments(): void
{
self::expectException(\ErrorException::class);
self::expectException(\AssertionError::class);
ShellBuilder::new()
->ifThis(static function (ShellBuilder $builder) {
return 'world';
Expand All @@ -769,7 +769,7 @@ public function testComplexCondiditionalArgumentsWithWrongArguments(): void

public function testCondiditionalArgumentsWithWrongArguments(): void
{
self::expectException(\ErrorException::class);
self::expectException(\AssertionError::class);
ShellBuilder::new()
->if(
true,
Expand Down
1 change: 1 addition & 0 deletions tests/phpunit-bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
declare(strict_types=1);

error_reporting(E_ALL);
ini_set('assert.exception', '1');
ini_set('display_errors', '1');

// Currently phpunit's default error handling doesn't properly catch warnings / errors from data providers
Expand Down
36 changes: 36 additions & 0 deletions tests/phpunit.legacy.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
bootstrap="phpunit-bootstrap.php"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutChangesToGlobalState="true"
enforceTimeLimit="true"
executionOrder="default"
resolveDependencies="true"
timeoutForLargeTests="1"
timeoutForMediumTests="1"
timeoutForSmallTests="1"
colors="true">
<testsuites>
<testsuite name="All">
<directory suffix="Test.php">../tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">../src/</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="test-results/report" lowUpperBound="49" highLowerBound="89"/>
<log type="coverage-clover" target="test-results/coverage.xml"/>
<log type="coverage-text" target="test-results/report.txt" showUncoveredFiles="false"/>
<log type="junit" target="test-results/logfile.xml"/>
<log type="testdox-html" target="test-results/testdox.html"/>
<log type="testdox-text" target="test-results/testdox.txt"/>
</logging>
</phpunit>
29 changes: 16 additions & 13 deletions tests/phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="phpunit-bootstrap.php"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
Expand All @@ -14,23 +14,26 @@
timeoutForLargeTests="1"
timeoutForMediumTests="1"
timeoutForSmallTests="1"
colors="true">
colors="true"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">../src/</directory>
</include>
<report>
<clover outputFile="test-results/coverage.xml"/>
<html outputDirectory="test-results/report" lowUpperBound="49" highLowerBound="89"/>
<text outputFile="test-results/report.txt" showUncoveredFiles="false"/>
</report>
</coverage>
<testsuites>
<testsuite name="All">
<directory suffix="Test.php">../tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">../src/</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="test-results/report" lowUpperBound="49" highLowerBound="89"/>
<log type="coverage-clover" target="test-results/coverage.xml"/>
<log type="coverage-text" target="test-results/report.txt" showUncoveredFiles="false"/>
<log type="junit" target="test-results/logfile.xml"/>
<log type="testdox-html" target="test-results/testdox.html"/>
<log type="testdox-text" target="test-results/testdox.txt"/>
<junit outputFile="test-results/logfile.xml"/>
<testdoxHtml outputFile="test-results/testdox.html"/>
<testdoxText outputFile="test-results/testdox.txt"/>
</logging>
</phpunit>

0 comments on commit ec95a23

Please sign in to comment.