Skip to content

Commit

Permalink
add phpstan and cs-fixer to build
Browse files Browse the repository at this point in the history
  • Loading branch information
dbu committed Jan 9, 2024
1 parent 594a71a commit 0ef6a2c
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 5 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Linting

on:
push:
branches:
- master
pull_request:

jobs:
phpunit:
name: Lint
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- php: '8.3'
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: none

- name: Checkout code
uses: actions/checkout@v3

- name: Install composer dependencies
run: |
composer update --prefer-dist --no-interaction --no-progress --no-ansi ${COMPOSER_FLAGS}
- name: PHP CS Fixer Tests
run: composer lint
39 changes: 39 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Static analysis

on:
push:
branches:
- master
pull_request:

jobs:
phpstan:
name: phpstan ${{ matrix.php }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- php: '8.0'
- php: '8.1'
- php: '8.2'
- php: '8.3'


steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: none

- name: Checkout code
uses: actions/checkout@v3

- name: Install composer dependencies
run: |
composer update --prefer-dist --no-interaction --no-progress --no-ansi ${COMPOSER_FLAGS}
- name: PHPStan
run: composer phpstan
6 changes: 6 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.46.0",
"phpstan/phpstan": "^1.7",
"symfony/phpunit-bridge": "^5.2 || ^6.0"
},
"conflict": {
Expand All @@ -37,6 +38,11 @@
"RokkaCli\\": "src/"
}
},
"scripts": {
"phpstan": "phpstan analyze",
"lint:fix": "php-cs-fixer fix -v --diff --using-cache=yes src/",
"lint": "php-cs-fixer fix -v --dry-run --diff --using-cache=yes src/"
},
"config": {
"sort-packages": true
}
Expand Down
7 changes: 7 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
parameters:
level: 1
paths:
- src/
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false
treatPhpDocTypesAsCertain: false
5 changes: 3 additions & 2 deletions src/Command/ImageCopyAllCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}

try {
$output->writeln('Copying '.\count($hashes).' images from <comment>'.$image->organization.'</comment> to <comment>'.$orgDest.'</comment>');
$organization = isset($image) ? $image->organization : '';
$output->writeln('Copying '.\count($hashes).' images from <comment>'.$organization.'</comment> to <comment>'.$orgDest.'</comment>');

$hashes = $this->copyImages($orgDest, $orgSource, $hashes, $client);
$total = \count($hashes['existing']) + \count($hashes['created']);
$output->writeln($total.' images copied from <comment>'.$image->organization.'</comment> to <comment>'.$orgDest.'</comment> ('.
$output->writeln($total.' images copied from <comment>'.$organization.'</comment> to <comment>'.$orgDest.'</comment> ('.
\count($hashes['existing']).' existing, '.\count($hashes['created']).' newly created).'
);

Expand Down
2 changes: 1 addition & 1 deletion src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Configuration
public function __construct(string $apiUri, ?string $apiKey, ?string $organization)
{
if (4 === \func_num_args()) {
@trigger_error(sprintf('The $apiSecret argument to the configuration has been removed in version 1.5, adjust how you instantiate the configuration.', __METHOD__), \E_USER_DEPRECATED);
@trigger_error('The $apiSecret argument to the Configuration constructor has been removed in version 1.5, adjust how you instantiate the configuration.', \E_USER_DEPRECATED);
// if old sig (with $apiSecret as 3rd arg) was used
$organization = func_get_arg(3);
}
Expand Down
3 changes: 1 addition & 2 deletions tests/Unit/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ public function testConfiguration()

/**
* @group legacy
*
* @expectedDeprecation The $apiSecret argument to the configuration has been removed in version 1.5, adjust how you instantiate the configuration.
*/
public function testConfigurationBC()
{
$this->expectDeprecationMessage('The $apiSecret argument to the Configuration has been removed in version 1.5, adjust how you instantiate the configuration.');
$configuration = new Configuration('uri', 'key', 'secret', 'organization');

$this->assertEquals('uri', $configuration->getApiUri());
Expand Down

0 comments on commit 0ef6a2c

Please sign in to comment.