diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml new file mode 100644 index 0000000..e88f1ec --- /dev/null +++ b/.github/workflows/php.yml @@ -0,0 +1,18 @@ +name: PHP tests + +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Run php-cs-fixer + run: ./vendor/bin/php-cs-fixer fix diff --git a/.gitignore b/.gitignore index 85eb384..33ca698 100755 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ composer.lock +.php_cs.cache /vendor/ /.idea/ diff --git a/.php_cs b/.php_cs new file mode 100644 index 0000000..04768a8 --- /dev/null +++ b/.php_cs @@ -0,0 +1,16 @@ +in([__DIR__ . '/src', __DIR__ . '/tests']) + ->name('*.php') +; + +return PhpCsFixer\Config::create() + ->setRules([ + '@PSR1' => true, + '@PSR2' => true, + 'full_opening_tag' => true, + 'no_closing_tag' => true, + ]) + ->setFinder($finder) +; diff --git a/composer.json b/composer.json index ecc8663..632d6b6 100755 --- a/composer.json +++ b/composer.json @@ -17,7 +17,8 @@ "psr-4": {"Utopia\\Tests\\": "tests/ClamAV"} }, "require": { - "php": ">=7.1" + "php": ">=7.1", + "friendsofphp/php-cs-fixer": "^2.16" }, "require-dev": { "phpunit/phpunit": "^7.0" diff --git a/src/ClamAV/ClamAV.php b/src/ClamAV/ClamAV.php index 1402fff..1e81dc7 100644 --- a/src/ClamAV/ClamAV.php +++ b/src/ClamAV/ClamAV.php @@ -104,7 +104,7 @@ public function continueScan(string $file) { $return = []; - foreach(\explode("\n", \trim($this->sendCommand('CONTSCAN ' . $file))) as $results ) { + foreach (\explode("\n", \trim($this->sendCommand('CONTSCAN ' . $file))) as $results) { list($file, $stats) = \explode(':', $results); \array_push($return, [ 'file' => $file, 'stats' => \trim($stats) ]); } diff --git a/src/ClamAV/Network.php b/src/ClamAV/Network.php index c55cc32..ade3ee2 100644 --- a/src/ClamAV/Network.php +++ b/src/ClamAV/Network.php @@ -40,7 +40,7 @@ protected function getSocket() $socket = @\socket_create(AF_INET, SOCK_STREAM, 0); $status = @\socket_connect($socket, $this->host, $this->port); - if(!$status) { + if (!$status) { throw new \Exception('Unable to connect to ClamAV server'); } return $socket;