Skip to content

Commit

Permalink
Add support for PHP 8.1 and 8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
odan committed Sep 9, 2023
1 parent f0bfd7d commit b976076
Show file tree
Hide file tree
Showing 12 changed files with 158 additions and 154 deletions.
104 changes: 64 additions & 40 deletions .cs.php
Original file line number Diff line number Diff line change
@@ -1,44 +1,68 @@
<?php

return (new PhpCsFixer\Config())
use PhpCsFixer\Config;

return (new Config())
->setUsingCache(false)
->setRiskyAllowed(true)
//->setCacheFile(__DIR__ . '/.php_cs.cache')
->setRules([
'@PSR1' => true,
'@PSR2' => true,
'@Symfony' => true,
'psr_autoloading' => true,
// custom rules
'align_multiline_comment' => ['comment_type' => 'phpdocs_only'], // psr-5
'phpdoc_to_comment' => false,
'no_superfluous_phpdoc_tags' => false,
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'cast_spaces' => ['space' => 'none'],
'concat_space' => ['spacing' => 'one'],
'compact_nullable_typehint' => true,
'declare_equal_normalize' => ['space' => 'single'],
'increment_style' => ['style' => 'post'],
'list_syntax' => ['syntax' => 'short'],
'echo_tag_syntax' => ['format' => 'long'],
'phpdoc_add_missing_param_annotation' => ['only_untyped' => false],
'phpdoc_align' => false,
'phpdoc_no_empty_return' => false,
'phpdoc_order' => true, // psr-5
'phpdoc_no_useless_inheritdoc' => false,
'protected_to_private' => false,
'yoda_style' => false,
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
'ordered_imports' => [
'sort_algorithm' => 'alpha',
'imports_order' => ['class', 'const', 'function']
],
'single_line_throw' => false,
])
->setFinder(PhpCsFixer\Finder::create()
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests')
->name('*.php')
->ignoreDotFiles(true)
->ignoreVCS(true));
->setRules(
[
'@PSR1' => true,
'@PSR2' => true,
'@Symfony' => true,
'psr_autoloading' => true,
// custom rules
'align_multiline_comment' => ['comment_type' => 'phpdocs_only'], // psr-5
'phpdoc_to_comment' => false,
'no_superfluous_phpdoc_tags' => false,
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'cast_spaces' => ['space' => 'none'],
'concat_space' => ['spacing' => 'one'],
'compact_nullable_typehint' => true,
'declare_equal_normalize' => ['space' => 'single'],
'general_phpdoc_annotation_remove' => [
'annotations' => [
'author',
'package',
],
],
'increment_style' => ['style' => 'post'],
'list_syntax' => ['syntax' => 'short'],
'echo_tag_syntax' => ['format' => 'long'],
'phpdoc_add_missing_param_annotation' => ['only_untyped' => false],
'phpdoc_align' => false,
'phpdoc_no_empty_return' => false,
'phpdoc_order' => true, // psr-5
'phpdoc_no_useless_inheritdoc' => false,
'protected_to_private' => false,
'yoda_style' => false,
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
'ordered_imports' => [
'sort_algorithm' => 'alpha',
'imports_order' => ['class', 'const', 'function'],
],
'single_line_throw' => false,
'declare_strict_types' => false,
'blank_line_between_import_groups' => true,
'fully_qualified_strict_types' => true,
'no_null_property_initialization' => false,
'operator_linebreak' => [
'only_booleans' => true,
'position' => 'beginning',
],
'global_namespace_import' => [
'import_classes' => true,
'import_constants' => null,
'import_functions' => null
]
]
)
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests')
->name('*.php')
->ignoreDotFiles(true)
->ignoreVCS(true)
);
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@
*.jpg binary
*.jpeg binary
*.png binary
*.zip binary
79 changes: 36 additions & 43 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,39 @@ name: build
on: [ push, pull_request ]

jobs:
run:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ ubuntu-latest ]
php-versions: [ '7.2', '7.3', '7.4', '8.0' ]
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}

steps:
- name: Checkout
uses: actions/checkout@v1

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, pdo, pdo_mysql, intl, zip
coverage: none

- name: Check PHP Version
run: php -v

- name: Check Composer Version
run: composer -V

- name: Check PHP Extensions
run: php -m

- name: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies for PHP 7
if: matrix.php-versions < '8.0'
run: composer update --prefer-dist --no-progress

- name: Install dependencies for PHP 8
if: matrix.php-versions >= '8.0'
run: composer update --prefer-dist --no-progress --ignore-platform-reqs

- name: Run test suite
run: composer check
env:
PHP_CS_FIXER_IGNORE_ENV: 1
run:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ ubuntu-latest ]
php-versions: [ '8.1', '8.2' ]
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}

steps:
- name: Checkout
uses: actions/checkout@v1

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl, zip
coverage: none

- name: Check PHP Version
run: php -v

- name: Check Composer Version
run: composer -V

- name: Check PHP Extensions
run: php -m

- name: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest

- name: Run test suite
run: composer test:all
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ composer.lock
nbproject/
vendor/
build/
.phpunit.cache/
.phpunit.result.cache
13 changes: 7 additions & 6 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
filter:
paths: ["src/*"]
excluded_paths: ["vendor/*", "tests/*"]
paths: [ "src/*" ]
excluded_paths: [ "vendor/*", "tests/*" ]

checks:
php:
Expand All @@ -12,7 +12,10 @@ tools:

build:
environment:
php: 7.4
php:
version: 8.1.2
ini:
xdebug.mode: coverage
mysql: false
node: false
postgresql: false
Expand All @@ -30,11 +33,9 @@ build:
dependencies:
before:
- composer self-update
- composer update --no-interaction --prefer-dist --no-progress
tests:
before:
-
command: composer test:coverage
- command: composer test:coverage
coverage:
file: 'build/logs/clover.xml'
format: 'clover'
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2020 odan
Copyright (c) 2023 odan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ A URL base path detector for Slim 4.

## Requirements

* PHP 7.2+ or 8.0+
* PHP 7.2+ or 8.1+

## Installation

Expand Down
53 changes: 28 additions & 25 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,44 +1,26 @@
{
"name": "selective/basepath",
"type": "library",
"description": "A URL base path detector for Slim 4",
"license": "MIT",
"type": "library",
"keywords": [
"basepath",
"slim",
"slim4"
],
"homepage": "https://github.com/selective-php/basepath",
"license": "MIT",
"require": {
"php": "^7.2 || ^8.0",
"php": "^8.1",
"psr/http-server-middleware": "^1"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3",
"overtrue/phplint": "^2",
"phpstan/phpstan": "^1",
"phpunit/phpunit": "^8 || ^9",
"slim/slim": "^4",
"phpunit/phpunit": "^10",
"slim/psr7": "^1",
"slim/slim": "^4",
"squizlabs/php_codesniffer": "^3"
},
"scripts": {
"check": [
"@lint",
"@cs:check",
"@sniffer:check",
"@phpstan",
"@test:coverage"
],
"cs:check": "php-cs-fixer fix --dry-run --format=txt --verbose --diff --config=.cs.php",
"cs:fix": "php-cs-fixer fix --config=.cs.php",
"lint": "phplint ./ --exclude=vendor --no-interaction --no-cache",
"phpstan": "phpstan analyse -c phpstan.neon --no-progress --ansi",
"sniffer:check": "phpcs --standard=phpcs.xml",
"sniffer:fix": "phpcbf --standard=phpcs.xml",
"test": "phpunit --configuration phpunit.xml --do-not-cache-result --colors=always",
"test:coverage": "phpunit --configuration phpunit.xml --do-not-cache-result --colors=always --coverage-clover build/logs/clover.xml --coverage-html build/coverage"
},
"autoload": {
"psr-4": {
"Selective\\BasePath\\": "src/"
Expand All @@ -50,7 +32,28 @@
}
},
"config": {
"sort-packages": true,
"process-timeout": 0
"process-timeout": 0,
"sort-packages": true
},
"scripts": {
"cs:check": [
"@putenv PHP_CS_FIXER_IGNORE_ENV=1",
"php-cs-fixer fix --dry-run --format=txt --verbose --diff --config=.cs.php --ansi"
],
"cs:fix": [
"@putenv PHP_CS_FIXER_IGNORE_ENV=1",
"php-cs-fixer fix --config=.cs.php --ansi --verbose"
],
"sniffer:check": "phpcs --standard=phpcs.xml",
"sniffer:fix": "phpcbf --standard=phpcs.xml",
"stan": "phpstan analyse -c phpstan.neon --no-progress --ansi",
"test": "phpunit --configuration phpunit.xml --do-not-cache-result --colors=always",
"test:all": [
"@cs:check",
"@sniffer:check",
"@stan",
"@test"
],
"test:coverage": "php -d xdebug.mode=coverage -r \"require 'vendor/bin/phpunit';\" -- --configuration phpunit.xml --do-not-cache-result --colors=always --coverage-clover build/logs/clover.xml --coverage-html build/coverage"
}
}
21 changes: 1 addition & 20 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,8 @@
<file>./src</file>
<file>./tests</file>

<rule ref="PSR2"></rule>
<rule ref="PSR12"></rule>
<rule ref="PSR12"/>

<rule ref="Squiz.Commenting.ClassComment">
<exclude name="Squiz.Commenting.ClassComment.TagNotAllowed"/>
<type>warning</type>
<exclude-pattern>*/tests/</exclude-pattern>
</rule>
<rule ref="Squiz.Commenting.ClassComment.Missing">
<type>warning</type>
</rule>
<rule ref="Squiz.Commenting.FunctionComment.Missing">
<type>warning</type>
<exclude-pattern>*/config/</exclude-pattern>
</rule>
<rule ref="Squiz.Commenting.FunctionComment.MissingParamTag">
<type>warning</type>
</rule>
<rule ref="Squiz.Commenting.FunctionComment.MissingParamComment">
<type>warning</type>
</rule>
<rule ref="Squiz.Commenting.FunctionComment.ParamCommentNotCapital">
<type>warning</type>
</rule>
Expand Down
8 changes: 3 additions & 5 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
parameters:
level: 8
checkMissingIterableValueType: false
paths:
- src
- tests
level: 8
paths:
- src
Loading

0 comments on commit b976076

Please sign in to comment.