Skip to content

Commit

Permalink
Allow process 5.4 (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
eiriksm committed Aug 17, 2022
1 parent 9cdbf44 commit 123e826
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 25 deletions.
15 changes: 11 additions & 4 deletions .github/workflows/test.yml
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-versions:
php-version:
- "7.1"
- "7.2"
- "7.3"
Expand All @@ -29,7 +29,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
php-version: ${{ matrix.php-version }}

- name: Dump composer verson
run: composer --version
Expand All @@ -41,12 +41,19 @@ jobs:
run: composer --verbose install

- name: Install phpstan if we have to
if: matrix.php-versions != 7.1
if: matrix.php-version != 7.1
run: composer require --dev phpstan/phpstan

- name: Run tests
run: composer test

- name: run phpstan
if: matrix.php-versions != 7.1
if: matrix.php-version != 7.1
run: ./vendor/bin/phpstan analyze src tests

- name: Coveralls
if: matrix.php-version == 7.4
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
php vendor/bin/php-coveralls -v
12 changes: 0 additions & 12 deletions .travis.yml

This file was deleted.

3 changes: 2 additions & 1 deletion composer.json
Expand Up @@ -19,7 +19,8 @@
}
},
"require": {
"symfony/process": "^2.7 || ^3.0 || ^4.0"
"symfony/process": "^4.0 || ^5.4",
"violinist-dev/process-factory": "^2"
},
"scripts": {
"test": [
Expand Down
7 changes: 4 additions & 3 deletions src/ProcessFactory.php
Expand Up @@ -3,11 +3,12 @@
namespace Violinist\SymfonyCloudSecurityChecker;

use Symfony\Component\Process\Process;
use Violinist\ProcessFactory\ProcessFactoryInterface;

class ProcessFactory
class ProcessFactory implements ProcessFactoryInterface
{
public function getProcess($command)
public function getProcess(array $commandline, $cwd = null, array $env = null, $input = null, $timeout = 60, array $options = null)
{
return new Process($command);
return new Process($commandline, $cwd, $env, $input, $timeout);
}
}
8 changes: 4 additions & 4 deletions src/SecurityChecker.php
Expand Up @@ -17,14 +17,14 @@ public function checkDirectory($dir)
// complain about updating the symfony command.
if (getenv('HOME')) {
$sdir = sprintf('%s/.symfony/autoupdate', getenv('HOME'));
$command = sprintf('mkdir -p %s', $sdir);
$command = ['mkdir', '-p', $sdir];
$process = $this->getProcess($command);
$process->run();
$command = sprintf('touch %s/silence', $sdir);
$command = ['touch', sprintf('%s/silence', $sdir)];
$process = $this->getProcess($command);
$process->run();
}
$command = sprintf('%s security:check --dir=%s --format=json', $this->symfonyCommand, $dir);
$command = [$this->symfonyCommand, 'security:check', sprintf('--dir=%s', $dir), '--format=json'];
$process = $this->getProcess($command);
$process->run();
$string = $process->getOutput();
Expand All @@ -38,7 +38,7 @@ public function checkDirectory($dir)
return $json;
}

protected function getProcess($command)
protected function getProcess(array $command)
{
return $this->getProcessFactory()->getProcess($command);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/UnitTest.php
Expand Up @@ -58,6 +58,6 @@ public function testGetProcess()
$checker = new SecurityChecker();
$factory = $checker->getProcessFactory();
$this->assertTrue($factory instanceof ProcessFactory);
$this->assertTrue($factory->getProcess('true') instanceof Process);
$this->assertTrue($factory->getProcess(['true']) instanceof Process);
}
}

0 comments on commit 123e826

Please sign in to comment.