Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 80 additions & 37 deletions .cs.php
Original file line number Diff line number Diff line change
@@ -1,39 +1,82 @@
<?php

return (new PhpCsFixer\Config())
->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)
);
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 = 2
31 changes: 21 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,45 @@ 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

- 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
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) 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
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
Video type detection library for PHP.

[![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)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)
[![build](https://github.com/selective-php/video-type/workflows/build/badge.svg)](https://github.com/selective-php/video-type/actions)
[![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)
[![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)
[![Total Downloads](https://img.shields.io/packagist/dt/selective/video-type.svg?style=flat-square)](https://packagist.org/packages/selective/video-type/stats)


Expand Down Expand Up @@ -35,7 +33,7 @@ Video type detection library for PHP.

## Requirements

* PHP 7.2+
* PHP 8.1 - 8.5

## Installation

Expand Down
56 changes: 30 additions & 26 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand All @@ -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"
]
}
}
5 changes: 5 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
parameters:
level: 8
paths:
- src
- tests
9 changes: 4 additions & 5 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,20 @@
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"
>
<testsuites>
<testsuite name="Tests">
<directory suffix="Test.php">tests</directory>
</testsuite>
</testsuites>
<coverage processUncoveredFiles="false">
<source>
<include>
<directory suffix=".php">src</directory>
</include>
<exclude>
<directory>vendor</directory>
<directory>build</directory>
</exclude>
</coverage>
</source>
</phpunit>
4 changes: 2 additions & 2 deletions src/VideoType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
6 changes: 3 additions & 3 deletions tests/VideoTypeDetectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -58,7 +58,7 @@ public function testGetVideoTypeFromFile(string $file, string $format, string $m
*
* @return array<string, array<mixed>> The test data
*/
public function providerGetVideoTypeFromFile(): array
public static function providerGetVideoTypeFromFile(): array
{
return [
'AVI' => [__DIR__ . '/videos/avi.avi', VideoFormat::AVI, VideoMimeType::VIDEO_AVI],
Expand Down