diff --git a/.cs.php b/.cs.php
index fe2a42c..c0e1811 100644
--- a/.cs.php
+++ b/.cs.php
@@ -1,39 +1,82 @@
setUsingCache(false)
- ->setRiskyAllowed(true)
- //->setCacheFile(__DIR__ . '/.php_cs.cache')
- ->setRules([
- '@PSR1' => true,
- '@PSR2' => true,
- '@Symfony' => true,
- 'psr_autoloading' => true,
- 'yoda_style' => false,
- 'array_syntax' => ['syntax' => 'short'],
- 'list_syntax' => ['syntax' => 'short'],
- 'concat_space' => ['spacing' => 'one'],
- 'cast_spaces' => ['space' => 'none'],
- 'compact_nullable_typehint' => true,
- 'increment_style' => ['style' => 'post'],
- 'declare_equal_normalize' => ['space' => 'single'],
- 'echo_tag_syntax' => ['format' => 'long'],
- 'protected_to_private' => false,
- 'phpdoc_align' => false,
- 'phpdoc_add_missing_param_annotation' => ['only_untyped' => false],
- 'phpdoc_order' => true, // psr-5
- 'phpdoc_no_empty_return' => false,
- 'align_multiline_comment' => true, // psr-5
- 'general_phpdoc_annotation_remove' => [
- 'annotations' => [
- 'author',
- 'package',
- ],
- ],
- ])
- ->setFinder(PhpCsFixer\Finder::create()
- ->in(__DIR__ . '/src')
- ->in(__DIR__ . '/tests')
- ->name('*.php')
- ->ignoreDotFiles(true)
- ->ignoreVCS(true));
+use PhpCsFixer\Config;
+
+return (new Config())
+ ->setUsingCache(false)
+ ->setRiskyAllowed(true)
+ ->setRules(
+ [
+ '@PSR1' => true,
+ '@PSR2' => true,
+ // custom rules
+ 'psr_autoloading' => true,
+ '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_type_declaration' => 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' => [
+ 'equal' => false,
+ 'identical' => false,
+ 'less_and_greater' => 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,
+ 'nullable_type_declaration_for_default_null_value' => false,
+ 'operator_linebreak' => [
+ 'only_booleans' => true,
+ 'position' => 'beginning',
+ ],
+ 'global_namespace_import' => [
+ 'import_classes' => true,
+ 'import_constants' => null,
+ 'import_functions' => null
+ ],
+ 'class_definition' => [
+ 'space_before_parenthesis' => true,
+ ],
+ 'trailing_comma_in_multiline' => [
+ 'after_heredoc' => true,
+ 'elements' => ['array_destructuring', 'arrays', 'match']
+ ],
+ 'function_declaration' => [
+ 'closure_fn_spacing' => 'none',
+ ]
+ ]
+ )
+ ->setFinder(
+ PhpCsFixer\Finder::create()
+ ->in(__DIR__ . '/src')
+ ->in(__DIR__ . '/tests')
+ ->name('*.php')
+ ->ignoreDotFiles(true)
+ ->ignoreVCS(true)
+ );
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..930bd09
--- /dev/null
+++ b/.editorconfig
@@ -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 = 2
\ No newline at end of file
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index f49d18b..b833ac8 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -8,19 +8,19 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
- php-versions: ['7.3', '7.4', '8.0', '8.1']
+ php-versions: ['8.1', '8.2', '8.3', '8.4', '8.5']
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
steps:
- name: Checkout
- uses: actions/checkout@v1
+ uses: actions/checkout@v5
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
- extensions: mbstring, pdo, pdo_mysql, intl, zip
- coverage: none
+ extensions: mbstring, intl, zip
+ coverage: xdebug
- name: Check PHP Version
run: php -v
@@ -28,14 +28,25 @@ jobs:
- 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
+ run: composer update --prefer-dist --no-progress --no-suggest
+
+ - name: Run PHP Coding Standards Fixer
+ run: composer cs:check
+
+ - name: Run PHP CodeSniffer
+ run: composer sniffer:check
+
+ - name: Run PHPStan
+ run: composer stan
+
+ - name: Run tests
+ if: ${{ matrix.php-versions != '8.4' }}
+ run: composer test
- - name: Run test suite
- run: composer check
+ - name: Run tests with coverage
+ if: ${{ matrix.php-versions == '8.4' }}
+ run: composer test:coverage
diff --git a/LICENSE b/LICENSE
index 30d7b83..bfcf021 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
The MIT License (MIT)
-Copyright (c) 2019 odan
+Copyright (c) 2025 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
diff --git a/README.md b/README.md
index 91d3f97..b2709c3 100644
--- a/README.md
+++ b/README.md
@@ -3,10 +3,8 @@
Video type detection library for PHP.
[](https://packagist.org/packages/selective/video-type)
-[](LICENSE.md)
+[](LICENSE)
[](https://github.com/selective-php/video-type/actions)
-[](https://scrutinizer-ci.com/g/selective-php/video-type/code-structure)
-[](https://scrutinizer-ci.com/g/selective-php/video-type/?branch=master)
[](https://packagist.org/packages/selective/video-type/stats)
@@ -35,7 +33,7 @@ Video type detection library for PHP.
## Requirements
-* PHP 7.2+
+* PHP 8.1 - 8.5
## Installation
diff --git a/composer.json b/composer.json
index 67cdc24..200095b 100644
--- a/composer.json
+++ b/composer.json
@@ -1,40 +1,22 @@
{
"name": "selective/video-type",
- "type": "library",
"description": "Video type detection",
+ "license": "MIT",
+ "type": "library",
"keywords": [
"video",
"type",
"format"
],
"homepage": "https://github.com/selective-php/video-type",
- "license": "MIT",
"require": {
- "php": "^7.3 || ^8.0"
+ "php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3",
- "overtrue/phplint": "^2.3",
- "phpunit/phpunit": "^9",
- "phpstan/phpstan": "^1",
- "squizlabs/php_codesniffer": "^3.5"
- },
- "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 src tests --level=max -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"
+ "phpstan/phpstan": "^2",
+ "phpunit/phpunit": "^10",
+ "squizlabs/php_codesniffer": "^4"
},
"autoload": {
"psr-4": {
@@ -47,7 +29,29 @@
}
},
"config": {
- "sort-packages": true,
- "process-timeout": 0
+ "process-timeout": 0,
+ "sort-packages": true
+ },
+ "scripts": {
+ "cs:check": [
+ "php-cs-fixer fix --dry-run --format=txt --verbose --diff --config=.cs.php --ansi --allow-unsupported-php-version=yes"
+ ],
+ "cs:fix": [
+ "php-cs-fixer fix --config=.cs.php --ansi --verbose --allow-unsupported-php-version=yes"
+ ],
+ "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 --display-warnings --display-deprecations --no-coverage",
+ "test:all": [
+ "@cs:check",
+ "@sniffer:check",
+ "@stan",
+ "@test"
+ ],
+ "test:coverage": [
+ "@putenv XDEBUG_MODE=coverage",
+ "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"
+ ]
}
}
diff --git a/phpstan.neon b/phpstan.neon
index e69de29..51e3685 100644
--- a/phpstan.neon
+++ b/phpstan.neon
@@ -0,0 +1,5 @@
+parameters:
+ level: 8
+ paths:
+ - src
+ - tests
\ No newline at end of file
diff --git a/phpunit.xml b/phpunit.xml
index 3c3de51..cadc720 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -3,15 +3,14 @@
bootstrap="vendor/autoload.php"
colors="true"
backupGlobals="false"
- backupStaticAttributes="false"
- timeoutForLargeTests="900"
- xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
+ xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.5/phpunit.xsd"
+ >
tests
-
+
src
@@ -19,5 +18,5 @@
vendor
build
-
+
diff --git a/src/VideoType.php b/src/VideoType.php
index 365221a..87e1815 100644
--- a/src/VideoType.php
+++ b/src/VideoType.php
@@ -68,7 +68,7 @@ public function getMimeType(): string
*/
public function equals(VideoType $other): bool
{
- return $this->format === $other->format &&
- $this->mime === $other->mime;
+ return $this->format === $other->format
+ && $this->mime === $other->mime;
}
}
diff --git a/tests/VideoTypeDetectorTest.php b/tests/VideoTypeDetectorTest.php
index 280b97b..77f1254 100644
--- a/tests/VideoTypeDetectorTest.php
+++ b/tests/VideoTypeDetectorTest.php
@@ -2,6 +2,7 @@
namespace Selective\VideoType\Test;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Selective\VideoType\Exception\VideoTypeDetectorException;
use Selective\VideoType\Provider\DefaultVideoProvider;
@@ -34,12 +35,11 @@ private function createDetector(): VideoTypeDetector
/**
* Test.
*
- * @dataProvider providerGetVideoTypeFromFile
- *
* @param string $file The file
* @param string $format The expected format
* @param string $mime The expected mime type
*/
+ #[DataProvider('providerGetVideoTypeFromFile')]
public function testGetVideoTypeFromFile(string $file, string $format, string $mime): void
{
$this->assertFileExists($file);
@@ -58,7 +58,7 @@ public function testGetVideoTypeFromFile(string $file, string $format, string $m
*
* @return array> The test data
*/
- public function providerGetVideoTypeFromFile(): array
+ public static function providerGetVideoTypeFromFile(): array
{
return [
'AVI' => [__DIR__ . '/videos/avi.avi', VideoFormat::AVI, VideoMimeType::VIDEO_AVI],