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
27 changes: 23 additions & 4 deletions .github/workflows/coverage_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,44 @@ on:
push:
branches: [master]
jobs:
install_tools:
name: Install tools
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v7
- name: Install tools
uses: ngmy/phive-install-action@master
- name: Upload tools to artifact store
uses: actions/upload-artifact@v7
with:
name: tools
path: tools
coverage:
name: coverage
needs: install_tools
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v7
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
php-version: 8.5
coverage: pcov
- name: Install composer dependencies
uses: ramsey/composer-install@v3
uses: ramsey/composer-install@v4
with:
composer-options: "--prefer-dist --optimize-autoloader"
- name: Download tools from artifact store
uses: actions/download-artifact@v7
with:
name: tools
path: tools
- name: Build the code coverage report
run: composer coverage:clover
- name: Upload code coverage report
uses: qltysh/qlty-action/coverage@v1
uses: qltysh/qlty-action/coverage@v2
with:
token: ${{ secrets.QLTY_COVERAGE_TOKEN }}
files: clover.xml
33 changes: 28 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,51 @@
name: Tests
on: [push, pull_request]
jobs:
install_tools:
name: Install tools
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v7
- name: Install tools
uses: ngmy/phive-install-action@master
- name: Upload tools to artifact store
uses: actions/upload-artifact@v7
with:
name: tools
path: tools
test:
name: test
needs: install_tools
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
php-versions: ['8.2', '8.3', '8.4']
operating-system: ["ubuntu-latest", "windows-latest", "macOs-latest"]
php-versions: ["8.5"]
runs-on: ${{ matrix.operating-system }}
steps:
- name: Set autocrlf on windows
if: matrix.operating-system == 'windows-latest'
run: git config --global core.autocrlf false
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v7
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
coverage: none
- name: Install composer dependencies
uses: ramsey/composer-install@v3
uses: ramsey/composer-install@v4
with:
composer-options: "--prefer-dist --optimize-autoloader"
- name: Download tools from artifact store
uses: actions/download-artifact@v7
with:
name: tools
path: tools
- name: Check coding standard
run: composer cs:check
- name: Static analysis tool
run: composer analytics
- name: Test suite
run: composer test
run: composer test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ clover.xml
composer.phar
composer.lock
coverage/
tools/
vendor/
6 changes: 6 additions & 0 deletions .phive/phars.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="phpunit" version="^13.3.2" installed="13.3.2" location="./tools/phpunit" copy="false"/>
<phar name="php-cs-fixer" version="^3.95.23" installed="3.95.23" location="./tools/php-cs-fixer" copy="false"/>
<phar name="phpstan" version="^2.2.9" installed="2.2.11" location="./tools/phpstan" copy="false"/>
</phive>
22 changes: 12 additions & 10 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
<?php declare(strict_types=1);
/*
* Copyright (c) Cristiano Cinotti 2021.
* Copyright (c) Cristiano Cinotti 2024 - 2026.
*
* This file is part of siad-pdf-compressor package, release under the APACHE-2 license.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

$config = new Susina\CodingStandard\Config();
$config->getFinder()
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests')
;
$finder = new PhpCsFixer\Finder()->in(__DIR__ . '/src')->in(__DIR__ . '/tests');

return $config;
return new PhpCsFixer\Config()->setRules(['@PER-CS3x0' => true])->setFinder($finder);
32 changes: 21 additions & 11 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,52 @@ First of all, many thanks to spend your time on this library!

## Workflow

1. Fork [susina/param-resolver](https://github.com/susina/param-resolver) repository, clone it locally and apply your patches.
2. Run the test suite by `composer test` command and fix all red tests.
3. Run static analysis tool by `composer analytics` command and fix all errors.
4. Fix the coding standard by running `composer cs:fix`.
### Pre-requisites

We provide a __check__ command for all the previously described actions: run `composer check` before submitting a pull request.
1. Have [PHP 8.5](https://php.net) installed.
2. Have [Composer](https://getcomposer.org) installed to manage dependencies and autoloading.
3. Have [Phive](https://phive.io) to install and manage our development tools (PhpUnit, PhpStan etc.) avoiding dependencies conflicts.

1. Fork [susina/param-resolver](https://github.com/susina/param-resolver) repository.
2. Run `composer install` to install dependencies and create the correct autoloading map.
3. Run `phive install` to safely install our development tools.
4. Apply your patches.
5. Run the test suite by `composer test` command and fix all red tests.
6. Run static analysis tool by `composer analytics` command and fix all errors.
7. Fix the coding standard by running `composer cs:fix`.

> [!TIP]
> We provide a __check__ command which runs the test suite, analytics tool and coding standard fix.
> So, before submitting a pull request you can simply run `composer check`.

## Running the Test Suite

While developing, the test part is very important: if you apply a patch to the existing code, the test suite must run without errors or failures and if you add a new functionality, no one will consider it without tests.

Our test tool is [Pest](https://pestphp.com/) and we provide a script to launch it:
Our test tool is [PhpUnit](https://phpunit.de/) and we provide a script to launch it:

```bash
composer test
```

## Code Coverage

We provides three commands to print the code coverage report or to generate it in _html_ or _xml_ format:
We provides two commands to generate the code coverage report in _html_ or _xml_ format:

- `composer coverage` to print a coverage summary on your console
- `composer coverage:html` command generates a code coverage report in _html_ format, into the directory `coverage/`
- `composer coverage:clover` generates the report in _xml_ format, into `clover.xml` file.


## Static Analysis Tool

To prevent as many bugs as possible, we use a static analysis tool called [Psalm](https://psalm.dev/).
To prevent as many bugs as possible, we use a static analysis tool called [PHPStan](https://phpstan.org/).
To launch it, run the following command:

```bash
composer analytics
```

After its analysis, Psalm outputs errors and issues with its suggestions on how to fix them.
After its analysis, PHPStan outputs errors and issues with its suggestions on how to fix them.


## Coding Standard
Expand All @@ -57,4 +67,4 @@ and to show the errors without fixing them, run:
composer cs:check
```

If you want to learn more about our code style, see [https://github.com/susina/coding-standard](https://github.com/susina/coding-standard).
All the repositories inside Susina Project follow [PER 3.x](https://www.php-fig.org/per/coding-style/) coding style.
22 changes: 5 additions & 17 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}
],
"require": {
"php": ">=8.2"
"php": ">=8.5"
},
"autoload": {
"psr-4": {
Expand All @@ -22,38 +22,26 @@
"Susina\\ParamResolver\\Tests\\": "tests/"
}
},
"require-dev": {
"psalm/phar": "^6",
"susina/coding-standard": "^2",
"pestphp/pest": "^3"
},
"scripts": {
"analytics": "php vendor/bin/psalm.phar",
"analytics": "php tools/phpstan",
"check": [
"@test",
"@analytics",
"@cs:fix"
],
"coverage": "@test --coverage",
"coverage:html": "@test --coverage-html coverage/",
"coverage:clover": "@test --coverage-clover clover.xml",
"cs:check": "php-cs-fixer fix -v --diff --dry-run",
"cs:fix": "php-cs-fixer fix -v --diff",
"test": "pest"
"cs:check": "php tools/php-cs-fixer fix -v --diff --dry-run",
"cs:fix": "php tools/php-cs-fixer fix -v --diff",
"test": "php tools/phpunit"
},
"scripts-descriptions": {
"analytics": "Run static analysis tool",
"check": "Perform all tests and analysis, required before submitting a pull request",
"cs:check": "Run code style analysis, without fixing errors",
"cs:fix": "Run code style analysis and fix errors",
"coverage": "Show coverage report to the console",
"coverage:html": "Create a code coverage report in html format, into the `coverage/` directory",
"coverage:clover": "Create a code coverage report in xml format, into the `clover.xml` file",
"test": "Run the test suite"
},
"config": {
"allow-plugins": {
"pestphp/pest-plugin": true
}
}
}
4 changes: 4 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
parameters:
level: 8
paths:
- src
1 change: 0 additions & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
</testsuites>
<source>
<include>
<directory suffix=".php">./app</directory>
<directory suffix=".php">./src</directory>
</include>
</source>
Expand Down
17 changes: 0 additions & 17 deletions psalm.xml

This file was deleted.

10 changes: 5 additions & 5 deletions src/Exception/ParamResolverException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);
/*
* Copyright (c) Cristiano Cinotti 2024.
* Copyright (c) Cristiano Cinotti 2024 - 2026.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,6 +17,4 @@

namespace Susina\ParamResolver\Exception;

final class ParamResolverException extends \RuntimeException
{
}
final class ParamResolverException extends \RuntimeException {}
Loading