Skip to content

Commit 17803d6

Browse files
committed
Add PHP 8 support
1 parent a81e6dc commit 17803d6

File tree

8 files changed

+109
-94
lines changed

8 files changed

+109
-94
lines changed

.cs.php

Lines changed: 43 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,47 @@
11
<?php
22

3-
return PhpCsFixer\Config::create()
3+
return (new PhpCsFixer\Config())
44
->setUsingCache(false)
55
->setRiskyAllowed(true)
6-
//->setCacheFile(__DIR__ . '/.php_cs.cache')
7-
->setRules([
8-
'@PSR1' => true,
9-
'@PSR2' => true,
10-
'@Symfony' => true,
11-
'psr4' => true,
12-
// custom rules
13-
'align_multiline_comment' => ['comment_type' => 'phpdocs_only'], // psr-5
14-
'phpdoc_to_comment' => false,
15-
'array_indentation' => true,
16-
'array_syntax' => ['syntax' => 'short'],
17-
'cast_spaces' => ['space' => 'none'],
18-
'concat_space' => ['spacing' => 'one'],
19-
'compact_nullable_typehint' => true,
20-
'declare_equal_normalize' => ['space' => 'single'],
21-
'increment_style' => ['style' => 'post'],
22-
'list_syntax' => ['syntax' => 'long'],
23-
'no_short_echo_tag' => true,
24-
'phpdoc_add_missing_param_annotation' => ['only_untyped' => false],
25-
'phpdoc_align' => false,
26-
'phpdoc_no_empty_return' => false,
27-
'phpdoc_order' => true, // psr-5
28-
'phpdoc_no_useless_inheritdoc' => false,
29-
'protected_to_private' => false,
30-
'yoda_style' => false,
31-
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
32-
'ordered_imports' => [
33-
'sort_algorithm' => 'alpha',
34-
'imports_order' => ['class', 'const', 'function']
35-
],
36-
])
37-
->setFinder(PhpCsFixer\Finder::create()
38-
->in(__DIR__ . '/src')
39-
->in(__DIR__ . '/tests')
40-
->name('*.php')
41-
->ignoreDotFiles(true)
42-
->ignoreVCS(true));
6+
->setRules(
7+
[
8+
'@PSR1' => true,
9+
'@PSR2' => true,
10+
'@Symfony' => true,
11+
'psr4' => true,
12+
// custom rules
13+
'align_multiline_comment' => ['comment_type' => 'phpdocs_only'], // psr-5
14+
'phpdoc_to_comment' => false,
15+
'no_superfluous_phpdoc_tags' => false,
16+
'array_indentation' => true,
17+
'array_syntax' => ['syntax' => 'short'],
18+
'cast_spaces' => ['space' => 'none'],
19+
'concat_space' => ['spacing' => 'one'],
20+
'compact_nullable_typehint' => true,
21+
'declare_equal_normalize' => ['space' => 'single'],
22+
'increment_style' => ['style' => 'post'],
23+
'list_syntax' => ['syntax' => 'short'],
24+
'no_short_echo_tag' => true,
25+
'phpdoc_add_missing_param_annotation' => ['only_untyped' => false],
26+
'phpdoc_align' => false,
27+
'phpdoc_no_empty_return' => false,
28+
'phpdoc_order' => true, // psr-5
29+
'phpdoc_no_useless_inheritdoc' => false,
30+
'protected_to_private' => false,
31+
'yoda_style' => false,
32+
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
33+
'ordered_imports' => [
34+
'sort_algorithm' => 'alpha',
35+
'imports_order' => ['class', 'const', 'function']
36+
],
37+
'single_line_throw' => false,
38+
]
39+
)
40+
->setFinder(
41+
PhpCsFixer\Finder::create()
42+
->in(__DIR__ . '/src')
43+
->in(__DIR__ . '/tests')
44+
->name('*.php')
45+
->ignoreDotFiles(true)
46+
->ignoreVCS(true)
47+
);
Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
name: PHP
1+
name: build
22

3-
on: [push, pull_request]
3+
on: [ push, pull_request ]
44

55
jobs:
66
run:
77
runs-on: ${{ matrix.operating-system }}
88
strategy:
99
matrix:
1010
operating-system: [ubuntu-latest]
11-
php-versions: ['7.0', '7.1', '7.2', '7.3', '7.4']
11+
php-versions: ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
1212
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
1313

1414
steps:
1515
- name: Checkout
1616
uses: actions/checkout@v1
1717

1818
- name: Setup PHP
19-
uses: shivammathur/setup-php@v1
19+
uses: shivammathur/setup-php@v2
2020
with:
2121
php-version: ${{ matrix.php-versions }}
22-
extensions: mbstring, pdo, pdo_mysql, intl, zip
22+
extensions: mbstring, intl, zip
2323
coverage: none
2424

2525
- name: Check PHP Version
@@ -34,8 +34,15 @@ jobs:
3434
- name: Validate composer.json and composer.lock
3535
run: composer validate
3636

37-
- name: Install dependencies
38-
run: composer install --prefer-dist --no-progress --no-suggest
37+
- name: Install dependencies for PHP 7
38+
if: matrix.php-versions < '8.0'
39+
run: composer update --prefer-dist --no-progress
40+
41+
- name: Install dependencies for PHP 8
42+
if: matrix.php-versions >= '8.0'
43+
run: composer update --prefer-dist --no-progress --ignore-platform-req=php
3944

4045
- name: Run test suite
41-
run: composer check-all
46+
run: composer check
47+
env:
48+
PHP_CS_FIXER_IGNORE_ENV: 1

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
composer.lock
33
nbproject/
44
vendor/
5-
build/
5+
build/
6+
.phpunit.result.cache

.scrutinizer.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ tools:
1212

1313
build:
1414
environment:
15-
php: 7.2
15+
php: 7.4
1616
mysql: false
1717
node: false
1818
postgresql: false
@@ -34,7 +34,7 @@ build:
3434
tests:
3535
before:
3636
-
37-
command: composer test-coverage
37+
command: composer test:coverage
3838
coverage:
3939
file: 'build/logs/clover.xml'
4040
format: 'clover'

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2020 odan
3+
Copyright (c) 2021 odan
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
A strictly typed array reader for PHP.
44

5-
[![Latest Version on Packagist](https://img.shields.io/github/release/selective-php/array-reader.svg?style=flat-square)](https://packagist.org/packages/selective/array-reader)
6-
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)
7-
[![Build Status](https://github.com/selective-php/array-reader/workflows/PHP/badge.svg)](https://github.com/selective-php/array-reader/actions)
8-
[![Coverage Status](https://img.shields.io/scrutinizer/coverage/g/selective-php/array-reader.svg?style=flat-square)](https://scrutinizer-ci.com/g/selective-php/array-reader/code-structure)
9-
[![Quality Score](https://img.shields.io/scrutinizer/quality/g/selective-php/array-reader.svg?style=flat-square)](https://scrutinizer-ci.com/g/selective-php/array-reader/?branch=master)
10-
[![Total Downloads](https://img.shields.io/packagist/dt/selective/array-reader.svg?style=flat-square)](https://packagist.org/packages/selective/array-reader/stats)
5+
[![Latest Version on Packagist](https://img.shields.io/github/release/selective-php/array-reader.svg)](https://packagist.org/packages/selective/array-reader)
6+
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE)
7+
[![Build Status](https://github.com/selective-php/array-reader/workflows/build/badge.svg)](https://github.com/selective-php/array-reader/actions)
8+
[![Coverage Status](https://img.shields.io/scrutinizer/coverage/g/selective-php/array-reader.svg)](https://scrutinizer-ci.com/g/selective-php/array-reader/code-structure)
9+
[![Quality Score](https://img.shields.io/scrutinizer/quality/g/selective-php/array-reader.svg)](https://scrutinizer-ci.com/g/selective-php/array-reader/?branch=master)
10+
[![Total Downloads](https://img.shields.io/packagist/dt/selective/array-reader.svg)](https://packagist.org/packages/selective/array-reader/stats)
1111

1212

1313
## Requirements
1414

15-
* PHP 7.0+
15+
* PHP 7.0+ or 8.0+
1616

1717
## Installation
1818

composer.json

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,43 +13,44 @@
1313
"homepage": "https://github.com/selective-php/array-reader",
1414
"license": "MIT",
1515
"require": {
16-
"php": "^7.0",
17-
"cakephp/chronos": "^1.2|^2"
16+
"php": "^7.0 || ^8.0",
17+
"cakephp/chronos": "^1.2 || ^2"
1818
},
1919
"require-dev": {
20-
"overtrue/phplint": "^1.1",
21-
"phpstan/phpstan": "*",
22-
"phpunit/phpunit": "^6|^7",
23-
"squizlabs/php_codesniffer": "^3.4"
20+
"friendsofphp/php-cs-fixer": "^2.16",
21+
"overtrue/phplint": "^2.3",
22+
"phpstan/phpstan": "0.*",
23+
"phpunit/phpunit": "^9",
24+
"squizlabs/php_codesniffer": "^3.5"
2425
},
25-
"scripts": {
26-
"test": "phpunit --configuration phpunit.xml",
27-
"test-coverage": "phpunit --configuration phpunit.xml --coverage-clover build/logs/clover.xml --coverage-html build/coverage",
28-
"check-style": "phpcs --standard=phpcs.xml",
29-
"fix-style": "phpcbf --standard=phpcs.xml",
30-
"phpstan": "phpstan analyse src tests --level=max -c phpstan.neon --no-progress",
31-
"lint": "phplint ./ --exclude=vendor --no-interaction --no-cache",
32-
"install-cs": "php -r \"@mkdir('build'); copy('https://cs.symfony.com/download/php-cs-fixer-v2.phar', 'build/php-cs-fixer-v2.phar');\"",
33-
"fix-cs": "php build/php-cs-fixer-v2.phar fix --config=.cs.php",
34-
"check-cs": "php build/php-cs-fixer-v2.phar fix --dry-run --format=txt --verbose --diff --diff-format=udiff --config=.cs.php",
35-
"check-all": [
36-
"@lint",
37-
"@check-style",
38-
"@phpstan",
39-
"@test-coverage"
40-
]
26+
"config": {
27+
"sort-packages": true
4128
},
4229
"autoload": {
4330
"psr-4": {
44-
"Selective\\ArrayReader\\": "src"
31+
"Selective\\ArrayReader\\": "src/"
4532
}
4633
},
4734
"autoload-dev": {
4835
"psr-4": {
49-
"Selective\\ArrayReader\\Test\\": "tests"
36+
"Selective\\ArrayReader\\Test\\": "tests/"
5037
}
5138
},
52-
"config": {
53-
"sort-packages": true
39+
"scripts": {
40+
"check": [
41+
"@lint",
42+
"@cs:check",
43+
"@sniffer:check",
44+
"@phpstan",
45+
"@test:coverage"
46+
],
47+
"cs:check": "php-cs-fixer fix --dry-run --format=txt --verbose --diff --diff-format=udiff --config=.cs.php",
48+
"cs:fix": "php-cs-fixer fix --config=.cs.php",
49+
"lint": "phplint ./ --exclude=vendor --no-interaction --no-cache",
50+
"phpstan": "phpstan analyse src tests --level=max -c phpstan.neon --no-progress --ansi",
51+
"sniffer:check": "phpcs --standard=phpcs.xml",
52+
"sniffer:fix": "phpcbf --standard=phpcs.xml",
53+
"test": "phpunit --configuration phpunit.xml --do-not-cache-result --colors=always",
54+
"test:coverage": "phpunit --configuration phpunit.xml --do-not-cache-result --colors=always --coverage-clover build/logs/clover.xml --coverage-html build/coverage"
5455
}
5556
}

phpunit.xml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit bootstrap="vendor/autoload.php"
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
bootstrap="vendor/autoload.php"
34
colors="true"
45
backupGlobals="false"
56
backupStaticAttributes="false"
6-
timeoutForLargeTests="900">
7+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
8+
<coverage processUncoveredFiles="false">
9+
<include>
10+
<directory suffix=".php">src</directory>
11+
</include>
12+
<exclude>
13+
<directory>vendor</directory>
14+
<directory>build</directory>
15+
</exclude>
16+
</coverage>
717
<testsuites>
818
<testsuite name="Tests">
919
<directory suffix="Test.php">tests</directory>
1020
</testsuite>
1121
</testsuites>
12-
<filter>
13-
<whitelist processUncoveredFilesFromWhitelist="false">
14-
<directory suffix=".php">src</directory>
15-
<exclude>
16-
<directory>vendor</directory>
17-
<directory>build</directory>
18-
</exclude>
19-
</whitelist>
20-
</filter>
2122
</phpunit>

0 commit comments

Comments
 (0)