Skip to content

Commit a6ebd13

Browse files
Add support for PHP 8.4 and 8.5 (#37)
1 parent be8f9f3 commit a6ebd13

File tree

10 files changed

+170
-88
lines changed

10 files changed

+170
-88
lines changed

.cs.php

Lines changed: 80 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,82 @@
11
<?php
22

3-
return (new PhpCsFixer\Config())
4-
->setUsingCache(false)
5-
->setRiskyAllowed(true)
6-
//->setCacheFile(__DIR__ . '/.php_cs.cache')
7-
->setRules([
8-
'@PSR1' => true,
9-
'@PSR2' => true,
10-
'@Symfony' => true,
11-
'psr_autoloading' => true,
12-
'yoda_style' => false,
13-
'array_syntax' => ['syntax' => 'short'],
14-
'list_syntax' => ['syntax' => 'short'],
15-
'concat_space' => ['spacing' => 'one'],
16-
'cast_spaces' => ['space' => 'none'],
17-
'compact_nullable_typehint' => true,
18-
'increment_style' => ['style' => 'post'],
19-
'declare_equal_normalize' => ['space' => 'single'],
20-
'echo_tag_syntax' => ['format' => 'long'],
21-
'protected_to_private' => false,
22-
'phpdoc_align' => false,
23-
'phpdoc_add_missing_param_annotation' => ['only_untyped' => false],
24-
'phpdoc_order' => true, // psr-5
25-
'phpdoc_no_empty_return' => false,
26-
'align_multiline_comment' => true, // psr-5
27-
'general_phpdoc_annotation_remove' => [
28-
'annotations' => [
29-
'author',
30-
'package',
31-
],
32-
],
33-
])
34-
->setFinder(PhpCsFixer\Finder::create()
35-
->in(__DIR__ . '/src')
36-
->in(__DIR__ . '/tests')
37-
->name('*.php')
38-
->ignoreDotFiles(true)
39-
->ignoreVCS(true));
3+
use PhpCsFixer\Config;
4+
5+
return (new Config())
6+
->setUsingCache(false)
7+
->setRiskyAllowed(true)
8+
->setRules(
9+
[
10+
'@PSR1' => true,
11+
'@PSR2' => true,
12+
// custom rules
13+
'psr_autoloading' => true,
14+
'align_multiline_comment' => ['comment_type' => 'phpdocs_only'], // psr-5
15+
'phpdoc_to_comment' => false,
16+
'no_superfluous_phpdoc_tags' => false,
17+
'array_indentation' => true,
18+
'array_syntax' => ['syntax' => 'short'],
19+
'cast_spaces' => ['space' => 'none'],
20+
'concat_space' => ['spacing' => 'one'],
21+
'compact_nullable_type_declaration' => true,
22+
'declare_equal_normalize' => ['space' => 'single'],
23+
'general_phpdoc_annotation_remove' => [
24+
'annotations' => [
25+
'author',
26+
'package',
27+
],
28+
],
29+
'increment_style' => ['style' => 'post'],
30+
'list_syntax' => ['syntax' => 'short'],
31+
'echo_tag_syntax' => ['format' => 'long'],
32+
'phpdoc_add_missing_param_annotation' => ['only_untyped' => false],
33+
'phpdoc_align' => false,
34+
'phpdoc_no_empty_return' => false,
35+
'phpdoc_order' => true, // psr-5
36+
'phpdoc_no_useless_inheritdoc' => false,
37+
'protected_to_private' => false,
38+
'yoda_style' => [
39+
'equal' => false,
40+
'identical' => false,
41+
'less_and_greater' => false
42+
],
43+
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
44+
'ordered_imports' => [
45+
'sort_algorithm' => 'alpha',
46+
'imports_order' => ['class', 'const', 'function'],
47+
],
48+
'single_line_throw' => false,
49+
'declare_strict_types' => false,
50+
'blank_line_between_import_groups' => true,
51+
'fully_qualified_strict_types' => true,
52+
'no_null_property_initialization' => false,
53+
'nullable_type_declaration_for_default_null_value' => false,
54+
'operator_linebreak' => [
55+
'only_booleans' => true,
56+
'position' => 'beginning',
57+
],
58+
'global_namespace_import' => [
59+
'import_classes' => true,
60+
'import_constants' => null,
61+
'import_functions' => null
62+
],
63+
'class_definition' => [
64+
'space_before_parenthesis' => true,
65+
],
66+
'trailing_comma_in_multiline' => [
67+
'after_heredoc' => true,
68+
'elements' => ['array_destructuring', 'arrays', 'match']
69+
],
70+
'function_declaration' => [
71+
'closure_fn_spacing' => 'none',
72+
]
73+
]
74+
)
75+
->setFinder(
76+
PhpCsFixer\Finder::create()
77+
->in(__DIR__ . '/src')
78+
->in(__DIR__ . '/tests')
79+
->name('*.php')
80+
->ignoreDotFiles(true)
81+
->ignoreVCS(true)
82+
);

.editorconfig

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
end_of_line = lf
7+
8+
[composer.json]
9+
indent_size = 4
10+
11+
[*.js]
12+
indent_size = 4
13+
14+
[*.neon]
15+
indent_size = 4
16+
indent_style = tab
17+
18+
[*.xml]
19+
indent_size = 4
20+
21+
[*.yml]
22+
indent_size = 2

.github/workflows/build.yml

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,45 @@ jobs:
88
strategy:
99
matrix:
1010
operating-system: [ubuntu-latest]
11-
php-versions: ['7.3', '7.4', '8.0', '8.1']
11+
php-versions: ['8.1', '8.2', '8.3', '8.4', '8.5']
1212
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
1313

1414
steps:
1515
- name: Checkout
16-
uses: actions/checkout@v1
16+
uses: actions/checkout@v5
1717

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

2525
- name: Check PHP Version
2626
run: php -v
2727

2828
- name: Check Composer Version
2929
run: composer -V
3030

31-
- name: Check PHP Extensions
32-
run: php -m
33-
3431
- name: Validate composer.json and composer.lock
3532
run: composer validate
3633

3734
- name: Install dependencies
38-
run: composer install --prefer-dist --no-progress --no-suggest
35+
run: composer update --prefer-dist --no-progress --no-suggest
36+
37+
- name: Run PHP Coding Standards Fixer
38+
run: composer cs:check
39+
40+
- name: Run PHP CodeSniffer
41+
run: composer sniffer:check
42+
43+
- name: Run PHPStan
44+
run: composer stan
45+
46+
- name: Run tests
47+
if: ${{ matrix.php-versions != '8.4' }}
48+
run: composer test
3949

40-
- name: Run test suite
41-
run: composer check
50+
- name: Run tests with coverage
51+
if: ${{ matrix.php-versions == '8.4' }}
52+
run: composer test:coverage

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) 2019 odan
3+
Copyright (c) 2025 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: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
Video type detection library for PHP.
44

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

1210

@@ -35,7 +33,7 @@ Video type detection library for PHP.
3533

3634
## Requirements
3735

38-
* PHP 7.2+
36+
* PHP 8.1 - 8.5
3937

4038
## Installation
4139

composer.json

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,22 @@
11
{
22
"name": "selective/video-type",
3-
"type": "library",
43
"description": "Video type detection",
4+
"license": "MIT",
5+
"type": "library",
56
"keywords": [
67
"video",
78
"type",
89
"format"
910
],
1011
"homepage": "https://github.com/selective-php/video-type",
11-
"license": "MIT",
1212
"require": {
13-
"php": "^7.3 || ^8.0"
13+
"php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0"
1414
},
1515
"require-dev": {
1616
"friendsofphp/php-cs-fixer": "^3",
17-
"overtrue/phplint": "^2.3",
18-
"phpunit/phpunit": "^9",
19-
"phpstan/phpstan": "^1",
20-
"squizlabs/php_codesniffer": "^3.5"
21-
},
22-
"scripts": {
23-
"check": [
24-
"@lint",
25-
"@cs:check",
26-
"@sniffer:check",
27-
"@phpstan",
28-
"@test:coverage"
29-
],
30-
"cs:check": "php-cs-fixer fix --dry-run --format=txt --verbose --diff --config=.cs.php",
31-
"cs:fix": "php-cs-fixer fix --config=.cs.php",
32-
"lint": "phplint ./ --exclude=vendor --no-interaction --no-cache",
33-
"phpstan": "phpstan analyse src tests --level=max -c phpstan.neon --no-progress --ansi",
34-
"sniffer:check": "phpcs --standard=phpcs.xml",
35-
"sniffer:fix": "phpcbf --standard=phpcs.xml",
36-
"test": "phpunit --configuration phpunit.xml --do-not-cache-result --colors=always",
37-
"test:coverage": "phpunit --configuration phpunit.xml --do-not-cache-result --colors=always --coverage-clover build/logs/clover.xml --coverage-html build/coverage"
17+
"phpstan/phpstan": "^2",
18+
"phpunit/phpunit": "^10",
19+
"squizlabs/php_codesniffer": "^4"
3820
},
3921
"autoload": {
4022
"psr-4": {
@@ -47,7 +29,29 @@
4729
}
4830
},
4931
"config": {
50-
"sort-packages": true,
51-
"process-timeout": 0
32+
"process-timeout": 0,
33+
"sort-packages": true
34+
},
35+
"scripts": {
36+
"cs:check": [
37+
"php-cs-fixer fix --dry-run --format=txt --verbose --diff --config=.cs.php --ansi --allow-unsupported-php-version=yes"
38+
],
39+
"cs:fix": [
40+
"php-cs-fixer fix --config=.cs.php --ansi --verbose --allow-unsupported-php-version=yes"
41+
],
42+
"sniffer:check": "phpcs --standard=phpcs.xml",
43+
"sniffer:fix": "phpcbf --standard=phpcs.xml",
44+
"stan": "phpstan analyse -c phpstan.neon --no-progress --ansi",
45+
"test": "phpunit --configuration phpunit.xml --do-not-cache-result --colors=always --display-warnings --display-deprecations --no-coverage",
46+
"test:all": [
47+
"@cs:check",
48+
"@sniffer:check",
49+
"@stan",
50+
"@test"
51+
],
52+
"test:coverage": [
53+
"@putenv XDEBUG_MODE=coverage",
54+
"phpunit --configuration phpunit.xml --do-not-cache-result --colors=always --display-warnings --display-deprecations --coverage-clover build/coverage/clover.xml --coverage-html build/coverage --coverage-text"
55+
]
5256
}
5357
}

phpstan.neon

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
parameters:
2+
level: 8
3+
paths:
4+
- src
5+
- tests

phpunit.xml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,20 @@
33
bootstrap="vendor/autoload.php"
44
colors="true"
55
backupGlobals="false"
6-
backupStaticAttributes="false"
7-
timeoutForLargeTests="900"
8-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
6+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.5/phpunit.xsd"
7+
>
98
<testsuites>
109
<testsuite name="Tests">
1110
<directory suffix="Test.php">tests</directory>
1211
</testsuite>
1312
</testsuites>
14-
<coverage processUncoveredFiles="false">
13+
<source>
1514
<include>
1615
<directory suffix=".php">src</directory>
1716
</include>
1817
<exclude>
1918
<directory>vendor</directory>
2019
<directory>build</directory>
2120
</exclude>
22-
</coverage>
21+
</source>
2322
</phpunit>

src/VideoType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function getMimeType(): string
6868
*/
6969
public function equals(VideoType $other): bool
7070
{
71-
return $this->format === $other->format &&
72-
$this->mime === $other->mime;
71+
return $this->format === $other->format
72+
&& $this->mime === $other->mime;
7373
}
7474
}

tests/VideoTypeDetectorTest.php

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

33
namespace Selective\VideoType\Test;
44

5+
use PHPUnit\Framework\Attributes\DataProvider;
56
use PHPUnit\Framework\TestCase;
67
use Selective\VideoType\Exception\VideoTypeDetectorException;
78
use Selective\VideoType\Provider\DefaultVideoProvider;
@@ -34,12 +35,11 @@ private function createDetector(): VideoTypeDetector
3435
/**
3536
* Test.
3637
*
37-
* @dataProvider providerGetVideoTypeFromFile
38-
*
3938
* @param string $file The file
4039
* @param string $format The expected format
4140
* @param string $mime The expected mime type
4241
*/
42+
#[DataProvider('providerGetVideoTypeFromFile')]
4343
public function testGetVideoTypeFromFile(string $file, string $format, string $mime): void
4444
{
4545
$this->assertFileExists($file);
@@ -58,7 +58,7 @@ public function testGetVideoTypeFromFile(string $file, string $format, string $m
5858
*
5959
* @return array<string, array<mixed>> The test data
6060
*/
61-
public function providerGetVideoTypeFromFile(): array
61+
public static function providerGetVideoTypeFromFile(): array
6262
{
6363
return [
6464
'AVI' => [__DIR__ . '/videos/avi.avi', VideoFormat::AVI, VideoMimeType::VIDEO_AVI],

0 commit comments

Comments
 (0)