Skip to content

Commit 3e6a7fa

Browse files
author
Christian Benthake
committed
Merge upstream in local
2 parents 9570ffd + 702e9b5 commit 3e6a7fa

6 files changed

Lines changed: 61 additions & 23 deletions

File tree

.github/workflows/main.yml

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

.travis.yml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,31 @@
11
language: php
22

3-
php:
4-
- "7.2"
5-
- "7.3"
6-
- "7.4"
3+
matrix:
4+
include:
5+
- php: 7.2
6+
dist: bionic
7+
env: COMPOSER_OPTS=""
8+
- php: 7.3
9+
dist: bionic
10+
env: COMPOSER_OPTS=""
11+
- php: 7.4
12+
dist: bionic
13+
env: COMPOSER_OPTS=""
14+
- php: nightly
15+
dist: bionic
16+
env: COMPOSER_OPTS="--ignore-platform-reqs"
17+
allow_failures:
18+
- php: nightly
19+
env: COMPOSER_OPTS="--ignore-platform-reqs"
720

821
cache:
922
directories:
1023
- $HOME/.composer/cache
1124

25+
install:
26+
- travis_retry composer install $COMPOSER_OPTS
27+
1228
script:
13-
- composer install
1429
- vendor/bin/grumphp run
1530
- composer test
1631
- composer infection

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
},
4040
"minimum-stability": "stable",
4141
"require": {
42-
"php": ">=7.2 <7.5",
42+
"php": ">=7.2",
4343
"ext-json": "*"
4444
},
4545
"extra": {

docker-compose.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,18 @@ services:
77
- ./:/app
88
- ~/.ssh:/home/application/.ssh
99
- ~/.gitconfig:/home/application/.gitconfig
10-
- ~/.composer/cache:/home/application/.composer/cache
1110
environment:
1211
- XDEBUG_REMOTE_HOST=${XDEBUG_REMOTE_HOST:-}
1312
- XDEBUG_REMOTE_PORT=${XDEBUG_REMOTE_PORT:-9000}
1413
- php.xdebug.idekey=${XDEBUG_IDEKEY:-PHPSTORM}
1514
- php.xdebug.remote_log=${XDEBUG_REMOTE_LOG:-/tmp/xdebug.log}
1615
- PHP_DEBUGGER=${PHP_DEBUGGER:-none}
1716
working_dir: /app
17+
18+
php8:
19+
image: chrisb9/php8-nginx-xdebug
20+
volumes:
21+
- ./:/app
22+
- ~/.ssh:/home/application/.ssh
23+
- ~/.gitconfig:/home/application/.gitconfig
24+
working_dir: /app

src/ShellBuilder.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ final class ShellBuilder implements ShellInterface, \JsonSerializable
1919
{
2020
use ShellConditional;
2121

22-
/** @var array<ShellInterface> */
22+
/** @var array<ShellInterface|string> */
2323
private $commandList = [];
2424
/** @var int */
2525
private $groupType;
@@ -100,14 +100,28 @@ public function removeVariable(string $variable): self
100100
return $this;
101101
}
102102

103+
/**
104+
* @param string|ShellInterface ...$commands
105+
* @return $this
106+
* @throws ShellBuilderException
107+
*/
108+
public function add(...$commands): self
109+
{
110+
foreach ($commands as $command) {
111+
$this->addSingle($command);
112+
}
113+
return $this;
114+
}
115+
103116
/**
104117
* @param string|ShellInterface $command
118+
* @param bool $raw
105119
* @return $this
106120
* @throws ShellBuilderException
107121
*/
108-
public function add($command): self
122+
public function addSingle($command, bool $raw = false): self
109123
{
110-
$command = $this->parseCommand($command, true);
124+
$command = $raw ? $command : $this->parseCommand($command, true);
111125
if (empty($this->commandList)) {
112126
$this->commandList[] = $command;
113127
return $this;
@@ -338,7 +352,7 @@ public function __toArray(): array
338352
{
339353
$commands = [];
340354
foreach ($this->commandList as $item) {
341-
$commands[] = $item->__toArray();
355+
$commands[] = is_string($item) ? $item : $item->__toArray();
342356
}
343357
return $commands;
344358
}

tests/ShellBuilderTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,20 @@ public function testBuilderConceptWithShortcut(): void
6363
$this->assertEquals($result, (string)$builder);
6464
}
6565

66+
public function testBuilderAddMany(): void
67+
{
68+
$builder = new ShellBuilder();
69+
$builder->add('a', 'b', 'c', 'd');
70+
$this->assertEquals('a ; b ; c ; d', (string)$builder);
71+
}
72+
73+
public function testBuilderAddRawCommand(): void
74+
{
75+
$builder = new ShellBuilder();
76+
$builder->addSingle('echo --colorize "hello world"', true);
77+
$this->assertEquals('echo --colorize "hello world"', (string)$builder);
78+
}
79+
6680
public function testCommandListDelimiter(): void
6781
{
6882
$result = (string)(new ShellBuilder())->add('a')->add('b')->add('c');

0 commit comments

Comments
 (0)