Skip to content

Commit

Permalink
Merge pull request #29 from felixdorn/php-cs-fixer-fix
Browse files Browse the repository at this point in the history
Follow up of #28
  • Loading branch information
freekmurze authored May 7, 2021
2 parents 67c8bc0 + 9fc7620 commit 6cf5b46
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 55 deletions.
30 changes: 15 additions & 15 deletions .github/workflows/php-cs-fixer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ name: Check & fix styling
on: [push]

jobs:
php-cs-fixer:
runs-on: ubuntu-latest
php-cs-fixer:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}

- name: Run PHP CS Fixer
uses: docker://oskarstark/php-cs-fixer-ga
with:
args: --config=.php_cs.dist.php --allow-risky=yes
- name: Run PHP CS Fixer
uses: docker://oskarstark/php-cs-fixer-ga
with:
args: --config=.php-cs-fixer.dist.php --allow-risky=yes

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Fix styling
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Fix styling
65 changes: 33 additions & 32 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,41 @@
name: run-tests

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
php: [8.0]
stability: [ prefer-stable ]
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest ]
php: [8.0]
stability: [ prefer-stable ]
name: P${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }}

name: P${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v2

steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
coverage: none

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
coverage: none

- name: Setup problem matchers
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Install dependencies
run: |
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
- name: Execute tests
run: vendor/bin/phpunit
- name: Setup problem matchers
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Install dependencies
run: |
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
- name: Lint
run: vendor/bin/php-cs-fixer fix
- name: Execute tests
run: vendor/bin/phpunit
35 changes: 35 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

$finder = Symfony\Component\Finder\Finder::create()
->in([
__DIR__ . '/src',
__DIR__ . '/tests',
])
->name('*.php')
->notName('*.blade.php')
->ignoreDotFiles(true)
->ignoreVCS(true);

return (new PhpCsFixer\Config())
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => ['sort_algorithm' => 'alpha'],
'no_unused_imports' => true,
'not_operator_with_successor_space' => true,
'trailing_comma_in_multiline' => true,
'phpdoc_scalar' => true,
'unary_operator_spaces' => true,
'binary_operator_spaces' => true,
'blank_line_before_statement' => [
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
],
'phpdoc_single_line_var_spacing' => true,
'phpdoc_var_without_name' => true,
'method_argument_space' => [
'on_multiline' => 'ensure_fully_multiline',
'keep_multiple_spaces_after_comma' => true,
],
'single_trait_insert_per_statement' => true,
])
->setFinder($finder);
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
},
"require-dev": {
"phpunit/phpunit": "^9",
"spatie/laravel-ray": "^1",
"spatie/laravel-ray": "^1",
"friendsofphp/php-cs-fixer": "^3.0",
"vimeo/psalm": "^4"
},
"autoload": {
Expand All @@ -35,7 +36,8 @@
}
},
"scripts": {
"psalm": "vendor/bin/psalm",
"lint": "./vendor/bin/php-cs-fixer fix",
"psalm": "./vendor/bin/psalm",
"test": "./vendor/bin/phpunit",
"test-coverage": "vendor/bin/phpunit --coverage-html coverage"
},
Expand Down
11 changes: 5 additions & 6 deletions src/PublicStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ public function __construct(
string $accessSecret,
string $consumerKey,
string $consumerSecret
)
{
) {
$this->stream = $this->createStream(
$accessToken,
$accessSecret,
Expand All @@ -22,9 +21,9 @@ public function __construct(
);
}

public function whenHears(string|array $listenFor, callable $whenHears): self
public function whenHears(string | array $listenFor, callable $whenHears): self
{
if (!is_array($listenFor)) {
if (! is_array($listenFor)) {
$listenFor = [$listenFor];
}

Expand All @@ -44,9 +43,9 @@ public function whenFrom(array $boundingBoxes, callable $whenFrom): self
return $this;
}

public function whenTweets(string|array $twitterUserIds, callable $whenTweets): self
public function whenTweets(string | array $twitterUserIds, callable $whenTweets): self
{
if (!is_array($twitterUserIds)) {
if (! is_array($twitterUserIds)) {
$twitterUserIds = [$twitterUserIds];
}

Expand Down

0 comments on commit 6cf5b46

Please sign in to comment.