Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Full package refactoring #21

Merged
merged 5 commits into from
May 20, 2023
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
20 changes: 9 additions & 11 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# Path-based git attributes
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html

# Ignore all test and documentation with "export-ignore".
/.github export-ignore
/tests export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.php_cs.dist export-ignore
/phpunit.xml.dist export-ignore
/.github export-ignore
/tests export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.php-cs-fixer.dist.php export-ignore
/phpstan.neon.dis export-ignore
/phpunit.xml.dist export-ignore
/rector.php export-ignore
50 changes: 18 additions & 32 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,68 +1,54 @@
name: ci

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
tests:

runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
php-version: [ '7.4', '8.0' ]
allow-failure: [ false ]
coverage: [ false ]
composer-flags: [ '' ]
include:
- php-version: '7.3'
coverage: true
- php-version: '8.1'
allow-failure: true
composer-flags: '--ignore-platform-req php'

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: php-setup
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
php-version: '8.2'
coverage: xdebug
extensions: xdebug

- name: composer-validate
run: composer validate

- name: composer-cache
id: composer-cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.php-version }}-composer-

- name: composer-install
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install --prefer-dist --no-progress --no-suggest ${{ matrix.composer-flags }}

- name: phpstan
run: vendor/bin/phpstan --level=max --memory-limit="-1" --no-progress analyze
run: composer install --prefer-dist --no-progress --no-interaction

- name: php-cs-fixer
continue-on-error: ${{ matrix.allow-failure }}
env:
PHP_CS_FIXER_IGNORE_ENV: ${{ matrix.allow-failure }}
run: vendor/bin/php-cs-fixer fix --dry-run --diff --verbose --config=.php_cs.dist
run: vendor/bin/php-cs-fixer fix --dry-run --diff --verbose --ansi

- name: phpstan
run: vendor/bin/phpstan analyse --memory-limit 256M

- name: phpunit
run: vendor/bin/phpunit --coverage-text --coverage-clover=build/coverage.xml
env:
FCM_OAUTH_TOKEN: ${{ secrets.FCM_OAUTH_TOKEN }}
FCM_PROJECT_ID: ${{ secrets.FCM_PROJECT_ID }}
run: vendor/bin/phpunit

- name: coverage
if: ${{ matrix.coverage }}
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ./build
files: ./.coverage/coverage.xml
10 changes: 4 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
build/
vendor/
/.coverage/
/.phpunit.cache/
/vendor/
.php-cs-fixer.cache
composer.lock
.php_cs
.php_cs.cache
.phpunit.result.cache
phpunit.xml
15 changes: 15 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

$finder = (new PhpCsFixer\Finder())
->in(__DIR__)
;

return (new PhpCsFixer\Config())
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
'declare_strict_types' => true,
])
->setRiskyAllowed(true)
->setFinder($finder)
;
35 changes: 0 additions & 35 deletions .php_cs.dist

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Tests](https://img.shields.io/github/actions/workflow/status/ker0x/fcm/ci.yml?label=tests&style=for-the-badge)](https://github.com/ker0x/fcm/actions/workflows/ci.yml)
[![Coverage](https://img.shields.io/codecov/c/gh/ker0x/fcm?style=for-the-badge)](https://codecov.io/gh/ker0x/fcm/)
![PHP Version](https://img.shields.io/badge/php->=7.3-4f5b93.svg?style=for-the-badge)
![PHP Version](https://img.shields.io/badge/php->=8.2-4f5b93.svg?style=for-the-badge)
[![Download](https://img.shields.io/packagist/dt/kerox/fcm.svg?style=for-the-badge)](https://packagist.org/packages/kerox/fcm)
[![Packagist](https://img.shields.io/packagist/v/kerox/fcm.svg?style=for-the-badge)](https://packagist.org/packages/kerox/fcm)
[![License](https://img.shields.io/github/license/talesfromadev/flowbite-bundle?style=for-the-badge)](https://github.com/ker0x/fcm/blob/main/LICENSE)
Expand Down
34 changes: 23 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,34 @@
{
"name": "Romain Monteil",
"email": "monteil.romain@gmail.com",
"homepage": "https://kerox.fr",
"homepage": "https://talesfroma.dev",
"role": "Author"
}
],
"require": {
"php": ">=7.3.0",
"ext-json": "*",
"guzzlehttp/guzzle": "^7.2"
"php": ">=8.2",
"fig/http-message-util": "^1.1",
"php-http/discovery": "^1.18",
"psr/http-client": "^1.0",
"psr/http-client-implementation": "*",
"psr/http-factory-implementation": "*",
"symfony/property-access": "^6.2",
"symfony/serializer": "^6.2"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.5",
"phpstan/phpstan": "^0.12",
"phpunit/phpunit": "^8.0"
"friendsofphp/php-cs-fixer": "^3.16",
"nyholm/psr7": "^1.8",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^10.1",
"rector/rector": "^0.16.0",
"symfony/http-client": "^6.2"
},
"config": {
"optimize-autoloader": true,
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"php-http/discovery": false
}
},
"autoload": {
"psr-4": {
Expand All @@ -43,8 +54,9 @@
}
},
"scripts": {
"php-cs-fixer": "vendor/bin/php-cs-fixer fix --diff --verbose --config=.php_cs",
"phpstan": "vendor/bin/phpstan --level=max --memory-limit=\"-1\" --no-progress analyze",
"phpunit": "vendor/bin/phpunit --coverage-text --coverage-clover=build/coverage.xml"
"php-cs-fixer": "vendor/bin/php-cs-fixer fix --diff --verbose --ansi",
"phpstan": "vendor/bin/phpstan",
"phpunit": "vendor/bin/phpunit",
"rector": "vendor/bin/rector process src"
}
}
12 changes: 0 additions & 12 deletions phpstan.neon

This file was deleted.

8 changes: 8 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
parameters:
paths:
- src

fileExtensions:
- php

level: 8
37 changes: 18 additions & 19 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
<?xml version="1.0" encoding="utf-8" ?>
<phpunit processIsolation="false"
stopOnFailure="false"
bootstrap="vendor/autoload.php">
<testsuites>
<testsuite name="Fcm Test Suite">
<directory>./tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>

<logging>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd" bootstrap="vendor/autoload.php" cacheDirectory=".phpunit.cache" executionOrder="depends,defects" requireCoverageMetadata="false" beStrictAboutCoverageMetadata="true" beStrictAboutOutputDuringTests="true" failOnRisky="true" failOnWarning="true" testdox="true">
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<report>
<clover outputFile=".coverage/coverage.xml"/>
<html outputDirectory=".coverage/html/"/>
</report>
</coverage>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</source>
</phpunit>
26 changes: 26 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__.'/src',
__DIR__.'/tests',
]);

// register a single rule
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);

// define sets of rules
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_82,

// PHP version
SetList::PHP_82,
]);
};
35 changes: 0 additions & 35 deletions src/Api/AbstractApi.php

This file was deleted.

Loading