Skip to content

Commit

Permalink
Require PHP 8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
odan committed Sep 9, 2023
1 parent fe87b6b commit 9986281
Show file tree
Hide file tree
Showing 12 changed files with 154 additions and 89 deletions.
25 changes: 23 additions & 2 deletions .cs.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

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

return (new Config())
->setUsingCache(false)
->setRiskyAllowed(true)
->setRules(
Expand All @@ -19,6 +21,12 @@
'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'],
Expand All @@ -32,9 +40,22 @@
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
'ordered_imports' => [
'sort_algorithm' => 'alpha',
'imports_order' => ['class', 'const', 'function']
'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(
Expand Down
22 changes: 22 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
root = true

[*]
charset = utf-8
indent_style = space
end_of_line = lf

[composer.json]
indent_size = 4

[*.js]
indent_size = 4

[*.neon]
indent_size = 4
indent_style = tab

[*.xml]
indent_size = 4

[*.yml]
indent_size = 4
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.3', '7.4', '8.0', '8.1' ]
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 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-req=php

- 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
14 changes: 8 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,10 @@ build:
dependencies:
before:
- composer self-update
- composer update --no-interaction --prefer-dist --no-progress
- composer install --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) 2021 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 @@ -35,7 +35,7 @@ Audio format detection library for PHP.

## Requirements

* PHP 7.3+ or 8.0+
* PHP 8.1+

## Installation

Expand Down
41 changes: 22 additions & 19 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
{
"name": "selective/audio-type",
"type": "library",
"description": "Audio format detection",
"license": "MIT",
"type": "library",
"keywords": [
"video",
"type",
"format"
],
"homepage": "https://github.com/selective-php/audio-type",
"license": "MIT",
"require": {
"php": "^7.3 || ^8.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3",
"overtrue/phplint": "^2.3",
"phpstan/phpstan": "^1",
"phpunit/phpunit": "^9",
"squizlabs/php_codesniffer": "^3.5"
},
"config": {
"sort-packages": true
"phpunit/phpunit": "^10",
"squizlabs/php_codesniffer": "^3"
},
"autoload": {
"psr-4": {
Expand All @@ -32,21 +28,28 @@
"Selective\\AudioType\\Test\\": "tests/"
}
},
"config": {
"sort-packages": true
},
"scripts": {
"check": [
"@lint",
"@cs:check",
"@sniffer:check",
"@phpstan",
"@test:coverage"
"cs:fix": [
"@putenv PHP_CS_FIXER_IGNORE_ENV=1",
"php-cs-fixer fix --config=.cs.php --ansi --verbose"
],
"cs:check": [
"@putenv PHP_CS_FIXER_IGNORE_ENV=1",
"php-cs-fixer fix --dry-run --format=txt --verbose --diff --config=.cs.php --ansi"
],
"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 src tests --level=max -c phpstan.neon --no-progress --ansi",
"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:coverage": "phpunit --configuration phpunit.xml --do-not-cache-result --colors=always --coverage-clover build/logs/clover.xml --coverage-html build/coverage"
"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"
}
}
25 changes: 25 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
parameters:
level: 8
reportUnmatchedIgnoredErrors: false
paths:
- src
ignoreErrors:
- '#Cannot cast mixed to int.#'
- '#Cannot cast mixed to string.#'
- '#Cannot cast mixed to float.#'
- '#Cannot access offset string on mixed.#'
- '#Parameter \#1 \$time of class Cake\\Chronos\\Chronos constructor expects DateTimeInterface\|int\|string\|null, mixed given.#'
- '#Parameter \#1 \$data of class Selective\\Config\\Configuration constructor expects DateTimeInterface\|int\|string\|null, mixed given.#'
- '#Parameter \#1 \$data of class Selective\\Config\\Configuration constructor expects array, mixed given.#'
- '#Parameter \#2 \$default of method Selective\\Config\\Configuration::findString\(\) expects string\|null, mixed given.#'
- '#Parameter \#2 \$default of method Selective\\Config\\Configuration::getString\(\) expects string\|null, mixed given.#'
- '#Parameter \#2 \$default of method Selective\\Config\\Configuration::findInt\(\) expects int\|null, mixed given.#'
- '#Parameter \#2 \$default of method Selective\\Config\\Configuration::getInt\(\) expects int\|null, mixed given.#'
- '#Parameter \#2 \$default of method Selective\\Config\\Configuration::findBool\(\) expects bool\|null, mixed given.#'
- '#Parameter \#2 \$default of method Selective\\Config\\Configuration::getBool\(\) expects bool\|null, mixed given.#'
- '#Parameter \#2 \$default of method Selective\\Config\\Configuration::findFloat\(\) expects float\|null, mixed given.#'
- '#Parameter \#2 \$default of method Selective\\Config\\Configuration::getFloat\(\) expects float\|null, mixed given.#'
- '#Parameter \#2 \$default of method Selective\\Config\\Configuration::findArray\(\) expects array\|null, mixed given.#'
- '#Parameter \#2 \$default of method Selective\\Config\\Configuration::getArray\(\) expects array\|null, mixed given.#'
- '#Parameter \#2 \$default of method Selective\\Config\\Configuration::findChronos\(\) expects Cake\\Chronos\\Chronos\|null, mixed given.#'
- '#Parameter \#2 \$default of method Selective\\Config\\Configuration::getChronos\(\) expects Cake\\Chronos\\Chronos\|null, mixed given.#'
24 changes: 11 additions & 13 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="vendor/autoload.php"
colors="true"
backupGlobals="false"
backupStaticAttributes="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="false">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" colors="true"
backupGlobals="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd"
cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<coverage/>
<testsuites>
<testsuite name="Tests">
<directory suffix="Test.php">tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
<exclude>
<directory>vendor</directory>
<directory>build</directory>
</exclude>
</coverage>
<testsuites>
<testsuite name="Tests">
<directory suffix="Test.php">tests</directory>
</testsuite>
</testsuites>
</source>
</phpunit>
4 changes: 2 additions & 2 deletions src/AudioType.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function getMimeType(): string
*/
public function equals(AudioType $other): bool
{
return $this->format === $other->format &&
$this->mime === $other->mime;
return $this->format === $other->format
&& $this->mime === $other->mime;
}
}
4 changes: 2 additions & 2 deletions tests/AudioTypeDetectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/**
* Test.
*/
class AudioTypeDetectorTest extends TestCase
final class AudioTypeDetectorTest extends TestCase
{
/**
* Create instance.
Expand Down Expand Up @@ -60,7 +60,7 @@ public function testGetAudioTypeFromFile(string $file, string $format, string $m
*
* @return array<string, array<string>> The test data
*/
public function providerGetAudioTypeFromFile(): array
public static function providerGetAudioTypeFromFile(): array
{
return [
'WAV' => [__DIR__ . '/files/test.wav', AudioFormat::WAV, AudioMimeType::AUDIO_WAV],
Expand Down

0 comments on commit 9986281

Please sign in to comment.