Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
on: [push, pull_request, release, workflow_dispatch]
name: Test
jobs:
test:
runs-on: ubuntu-latest
container:
image: pluswerk/php-dev:nginx-${{ matrix.php }}
options: -t
strategy:
fail-fast: false
matrix:
php: ['8.1', '8.2', '8.3', '8.4']
name: 'PHP ${{ matrix.php }}'
steps:
- run: git config --global --add safe.directory /__w/ShellCommandBuilder/ShellCommandBuilder
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.composer/cache/files
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
- run: composer install --prefer-dist --no-progress --no-suggest
- run: vendor/bin/grumphp run
- run: script -q -e -c "composer test"
- run: script -q -e -c "composer infection"
- uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./tests/test-results/coverage.xml
16 changes: 0 additions & 16 deletions .github/workflows/shepherd.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/tests/test-results/
/tests/.phpunit.result.cache
composer.lock
/var/
46 changes: 0 additions & 46 deletions .travis.yml

This file was deleted.

96 changes: 46 additions & 50 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,53 +1,49 @@
{
"name": "phpsu/shellcommandbuilder",
"description": "Fluid Builder to create shell commands",
"type": "library",
"config": {
"optimize-autoloader": true,
"process-timeout": 0
},
"require-dev": {
"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": [
{
"name": "Christian Rodriguez Benthake",
"email": "git@cben.co"
}
],
"autoload": {
"psr-4": {
"PHPSu\\ShellCommandBuilder\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"PHPSu\\ShellCommandBuilder\\Tests\\": "tests"
}
},
"scripts": {
"test": "vendor/bin/phpunit -c tests/phpunit.xml --testdox --color=always",
"test:watch": "vendor/bin/phpunit-watcher watch -c tests/phpunit.xml --testdox",
"infection": "vendor/bin/infection --threads=4 --only-covered --min-msi=100 --min-covered-msi=100 --ansi",
"psalm": "vendor/bin/psalm"
},
"minimum-stability": "stable",
"require": {
"php": ">=7.2",
"ext-json": "*"
},
"extra": {
"pluswerk/grumphp-config": {
"auto-setting": false
},
"grumphp": {
"config-default-path": "vendor/pluswerk/grumphp-config/grumphp.yml"
}
"name": "phpsu/shellcommandbuilder",
"description": "Fluid Builder to create shell commands",
"license": "MIT",
"type": "library",
"authors": [
{
"name": "Christian Rodriguez Benthake",
"email": "git@cben.co"
}
],
"require": {
"php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0",
"ext-json": "*"
},
"require-dev": {
"infection/infection": "^0.28.1 || ^0.29.14",
"phpunit/phpunit": "^10.0 || ^12.0",
"pluswerk/grumphp-config": "^7 || ^10",
"spatie/phpunit-watcher": "^1.24 || dev-master#071fbbf"
},
"minimum-stability": "stable",
"autoload": {
"psr-4": {
"PHPSu\\ShellCommandBuilder\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"PHPSu\\ShellCommandBuilder\\Tests\\": "tests"
}
},
"config": {
"allow-plugins": {
"ergebnis/composer-normalize": true,
"infection/extension-installer": true,
"phpro/grumphp": true,
"phpstan/extension-installer": true,
"pluswerk/grumphp-config": true
},
"optimize-autoloader": true,
"process-timeout": 0
},
"scripts": {
"infection": "XDEBUG_MODE=coverage vendor/bin/infection --threads=4 --only-covered --min-msi=99 --min-covered-msi=99 --ansi",
"test": "XDEBUG_MODE=coverage vendor/bin/phpunit -c tests/phpunit.xml --testdox --color=always",
"test:watch": "XDEBUG_MODE=coverage vendor/bin/phpunit-watcher watch -c tests/phpunit.xml --testdox"
}
}
1 change: 0 additions & 1 deletion docs/api.md

This file was deleted.

16 changes: 16 additions & 0 deletions grumphp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
imports:
- { resource: vendor/pluswerk/grumphp-config/grumphp.yml }
parameters:
convention.process_timeout: 240
convention.security_checker_blocking: true
convention.jsonlint_ignore_pattern: { }
convention.xmllint_ignore_pattern: { }
convention.yamllint_ignore_pattern: { }
convention.phpcslint_ignore_pattern: { }
convention.phpcslint_exclude: { }
convention.xlifflint_ignore_pattern: { }
convention.rector_ignore_pattern: { }
convention.rector_enabled: true
convention.rector_config: rector.php
convention.rector_clear-cache: false
convention.phpstan_level: null
6 changes: 1 addition & 5 deletions infection.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@
},
"logs": {
"text": "tests/test-results/infection.log",
"summary": "tests/test-results/summary.log",
"perMutator": "tests/test-results/per-mutator.md",
"badge": {
"branch": "master"
}
"html": "tests/test-results/infection.html"
},
"mutators": {
"@default": true,
Expand Down
19 changes: 19 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
parameters:
ignoreErrors:
-
message: '#^Call to function assert\(\) with true will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
count: 3
path: packages/grumphp-xliff-task/src/XliffLinter.php

-
message: '#^Instanceof between DOMElement and DOMElement will always evaluate to true\.$#'
identifier: instanceof.alwaysTrue
count: 3
path: packages/grumphp-xliff-task/src/XliffLinter.php

-
message: '#^Method Andersundsehr\\RectorP\\PartialCommand\:\:getAllFiles\(\) should return list\<string\> but returns array\<string\>\.$#'
identifier: return.type
count: 1
path: packages/rector-p/src/PartialCommand.php
7 changes: 7 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
includes:
- phpstan-baseline.neon
- vendor/andersundsehr/phpstan-git-files/extension.php

parameters:
level: 8
reportUnmatchedIgnoredErrors: false
42 changes: 42 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

declare(strict_types=1);

use PLUS\GrumPHPConfig\RectorSettings;
use Rector\Config\RectorConfig;
use Rector\Caching\ValueObject\Storage\FileCacheStorage;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->parallel();
$rectorConfig->importNames();
$rectorConfig->importShortClasses();
$rectorConfig->cacheClass(FileCacheStorage::class);
$rectorConfig->cacheDirectory('./var/cache/rector');

$rectorConfig->paths(
array_filter(explode("\n", (string)shell_exec("git ls-files | xargs ls -d 2>/dev/null | grep -E '\.(php)$'")))
);

// define sets of rules
$rectorConfig->sets(
[
...RectorSettings::sets(true),
...RectorSettings::setsTypo3(false),
]
);

// remove some rules
// ignore some files
$rectorConfig->skip(
[
...RectorSettings::skip(),
...RectorSettings::skipTypo3(),

/**
* rector should not touch these files
*/
//__DIR__ . '/src/Example',
//__DIR__ . '/src/Example.php',
]
);
};
14 changes: 4 additions & 10 deletions src/Collection/AbstractCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,23 @@
*/
abstract class AbstractCollection implements ShellInterface
{
/** @var CollectionTuple|null */
protected $tuple;
protected CollectionTuple|null $tuple = null;

/**
* @param string|ShellInterface $command
* @param string $join
* @return CollectionTuple
* @throws ShellBuilderException
*/
protected function toTuple($command, string $join): CollectionTuple
protected function toTuple(ShellInterface|string $command, string $join): CollectionTuple
{
return CollectionTuple::create($command, $join);
}

/**
* @return array<string|ShellInterface|array<mixed>>
* @return array<ShellInterface|string|array<mixed>>
* @throws ShellBuilderException
*/
public function __toArray(): array
{
if ($this->tuple === null) {
throw new ShellBuilderException('Tuple has not been set yet - collection cannot be parsed to array');
}

return $this->tuple->__toArray();
}

Expand Down
28 changes: 8 additions & 20 deletions src/Collection/CollectionTuple.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace PHPSu\ShellCommandBuilder\Collection;

use PHPSu\ShellCommandBuilder\Exception\ShellBuilderException;
use PHPSu\ShellCommandBuilder\ShellInterface;

/**
Expand All @@ -13,27 +12,16 @@
*/
final class CollectionTuple implements ShellInterface
{
/** @var string */
protected $join = '';
private string $join = '';

/** @var string|ShellInterface */
protected $value = '';
/** @var bool */
private $noSpaceBeforeJoin = false;
/** @var bool */
private $noSpaceAfterJoin = false;
private ShellInterface|string $value = '';

/**
* @param string|ShellInterface|mixed $value
* @param string $join
* @return static
* @throws ShellBuilderException
*/
public static function create($value, string $join = ''): self
private bool $noSpaceBeforeJoin = false;

private bool $noSpaceAfterJoin = false;

public static function create(ShellInterface|string $value, string $join = ''): self
{
if (!(is_string($value) || $value instanceof ShellInterface)) {
throw new ShellBuilderException('Value must be of Type string or an instance of ShellInterface');
}
$tuple = new self();
$tuple->value = $value;
$tuple->join = $join;
Expand All @@ -53,7 +41,7 @@ public function noSpaceAfterJoin(bool $space): self
}

/**
* @return array<string|ShellInterface|array<mixed>>
* @return array<ShellInterface|string|array<mixed>>
*/
public function __toArray(): array
{
Expand Down
Loading
Loading