Skip to content

Commit

Permalink
Add PHP-8.2 verison test in GitHub action
Browse files Browse the repository at this point in the history
  • Loading branch information
peter279k committed Sep 5, 2023
1 parent fe87b6b commit 6a1574b
Show file tree
Hide file tree
Showing 22 changed files with 46 additions and 76 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
operating-system: [ ubuntu-latest ]
php-versions: [ '7.3', '7.4', '8.0', '8.1' ]
php-versions: [ '7.3', '7.4', '8.0', '8.1', '8.2' ]
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}

steps:
Expand All @@ -34,14 +34,9 @@ jobs:
- name: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies for PHP 7
if: matrix.php-versions < '8.0'
- name: Install dependencies for PHP
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:
Expand Down
10 changes: 4 additions & 6 deletions src/AudioType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Selective\AudioType;

use InvalidArgumentException;

/**
* Audio type value object.
*/
Expand All @@ -28,11 +26,11 @@ final class AudioType
public function __construct(string $format, string $mime)
{
if (empty($format)) {
throw new InvalidArgumentException(sprintf('Invalid type: %s', $format));
throw new \InvalidArgumentException(sprintf('Invalid type: %s', $format));
}

if (empty($mime)) {
throw new InvalidArgumentException(sprintf('Invalid mime type: %s', $format));
throw new \InvalidArgumentException(sprintf('Invalid mime type: %s', $format));
}

$this->format = $format;
Expand Down Expand Up @@ -68,7 +66,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;
}
}
9 changes: 4 additions & 5 deletions src/AudioTypeDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Selective\AudioType\Detector\AudioDetectorInterface;
use Selective\AudioType\Exception\AudioTypeDetectorException;
use Selective\AudioType\Provider\ProviderInterface;
use SplFileObject;

/**
* Audio type detection.
Expand Down Expand Up @@ -44,13 +43,13 @@ public function addProvider(ProviderInterface $provider): void
/**
* Detect audio type.
*
* @param SplFileObject $file The audio file
* @param \SplFileObject $file The audio file
*
* @throws AudioTypeDetectorException
*
* @return AudioType The audio type
*/
public function getAudioTypeFromFile(SplFileObject $file): AudioType
public function getAudioTypeFromFile(\SplFileObject $file): AudioType
{
$type = $this->detectFile($file);

Expand All @@ -64,11 +63,11 @@ public function getAudioTypeFromFile(SplFileObject $file): AudioType
/**
* Reads and returns the type of the audio file.
*
* @param SplFileObject $file The audio file
* @param \SplFileObject $file The audio file
*
* @return AudioType|null
*/
private function detectFile(SplFileObject $file): ?AudioType
private function detectFile(\SplFileObject $file): ?AudioType
{
foreach ($this->detectors as $detector) {
$file->rewind();
Expand Down
5 changes: 2 additions & 3 deletions src/Detector/AacDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Selective\AudioType\AudioFormat;
use Selective\AudioType\AudioMimeType;
use Selective\AudioType\AudioType;
use SplFileObject;

/**
* Detector.
Expand All @@ -15,11 +14,11 @@ final class AacDetector implements AudioDetectorInterface
/**
* Detect AAC audio file format.
*
* @param SplFileObject $file The audio file
* @param \SplFileObject $file The audio file
*
* @return AudioType|null The audio type
*/
public function detect(SplFileObject $file): ?AudioType
public function detect(\SplFileObject $file): ?AudioType
{
// Skip 8 bytes
$file->fread(8);
Expand Down
5 changes: 2 additions & 3 deletions src/Detector/AiffDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Selective\AudioType\AudioFormat;
use Selective\AudioType\AudioMimeType;
use Selective\AudioType\AudioType;
use SplFileObject;

/**
* Detector.
Expand All @@ -15,11 +14,11 @@ final class AiffDetector implements AudioDetectorInterface
/**
* Detect AIFF/AIFC soundfile format.
*
* @param SplFileObject $file The audio file
* @param \SplFileObject $file The audio file
*
* @return AudioType|null The audio type
*/
public function detect(SplFileObject $file): ?AudioType
public function detect(\SplFileObject $file): ?AudioType
{
$ckID = (string)$file->fread(4);

Expand Down
5 changes: 2 additions & 3 deletions src/Detector/AuDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Selective\AudioType\AudioFormat;
use Selective\AudioType\AudioMimeType;
use Selective\AudioType\AudioType;
use SplFileObject;

/**
* Detector.
Expand All @@ -15,11 +14,11 @@ final class AuDetector implements AudioDetectorInterface
/**
* Detect AU audio file.
*
* @param SplFileObject $file The audio file
* @param \SplFileObject $file The audio file
*
* @return AudioType|null The audio type
*/
public function detect(SplFileObject $file): ?AudioType
public function detect(\SplFileObject $file): ?AudioType
{
$bytes = (string)$file->fread(4);

Expand Down
5 changes: 2 additions & 3 deletions src/Detector/AudioDetectorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Selective\AudioType\Detector;

use Selective\AudioType\AudioType;
use SplFileObject;

/**
* Detector.
Expand All @@ -13,9 +12,9 @@ interface AudioDetectorInterface
/**
* Detect.
*
* @param SplFileObject $file The file
* @param \SplFileObject $file The file
*
* @return AudioType|null The audio type
*/
public function detect(SplFileObject $file): ?AudioType;
public function detect(\SplFileObject $file): ?AudioType;
}
5 changes: 2 additions & 3 deletions src/Detector/CafDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Selective\AudioType\AudioFormat;
use Selective\AudioType\AudioMimeType;
use Selective\AudioType\AudioType;
use SplFileObject;

/**
* Detector.
Expand All @@ -15,11 +14,11 @@ final class CafDetector implements AudioDetectorInterface
/**
* Detects CAF (Apple Core Audio File).
*
* @param SplFileObject $file The file
* @param \SplFileObject $file The file
*
* @return AudioType|null The audio type
*/
public function detect(SplFileObject $file): ?AudioType
public function detect(\SplFileObject $file): ?AudioType
{
return (string)$file->fread(4) === 'caff' ? new AudioType(
AudioFormat::CAF,
Expand Down
5 changes: 2 additions & 3 deletions src/Detector/FlacDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Selective\AudioType\AudioFormat;
use Selective\AudioType\AudioMimeType;
use Selective\AudioType\AudioType;
use SplFileObject;

/**
* Detector.
Expand All @@ -15,11 +14,11 @@ final class FlacDetector implements AudioDetectorInterface
/**
* Detect FLAC soundfile format.
*
* @param SplFileObject $file The audio file
* @param \SplFileObject $file The audio file
*
* @return AudioType|null The audio type
*/
public function detect(SplFileObject $file): ?AudioType
public function detect(\SplFileObject $file): ?AudioType
{
// Signature bytes
$signature = (string)$file->fread(4);
Expand Down
5 changes: 2 additions & 3 deletions src/Detector/MidiDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Selective\AudioType\AudioFormat;
use Selective\AudioType\AudioMimeType;
use Selective\AudioType\AudioType;
use SplFileObject;

/**
* Detector.
Expand All @@ -15,11 +14,11 @@ final class MidiDetector implements AudioDetectorInterface
/**
* Detects MIDI format.
*
* @param SplFileObject $file The audio file
* @param \SplFileObject $file The audio file
*
* @return AudioType|null The audio type
*/
public function detect(SplFileObject $file): ?AudioType
public function detect(\SplFileObject $file): ?AudioType
{
$chunkType = (string)$file->fread(4);

Expand Down
5 changes: 2 additions & 3 deletions src/Detector/MkaDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Selective\AudioType\AudioFormat;
use Selective\AudioType\AudioMimeType;
use Selective\AudioType\AudioType;
use SplFileObject;

/**
* Detector.
Expand All @@ -15,11 +14,11 @@ final class MkaDetector implements AudioDetectorInterface
/**
* Detect MKA (audio-only Matroska) container.
*
* @param SplFileObject $file The audio file
* @param \SplFileObject $file The audio file
*
* @return AudioType|null The audio type
*/
public function detect(SplFileObject $file): ?AudioType
public function detect(\SplFileObject $file): ?AudioType
{
$bytes = bin2hex((string)$file->fread(4));
$containedMatroska = strpos((string)$file->fread(46), 'matroska') !== false;
Expand Down
5 changes: 2 additions & 3 deletions src/Detector/Mp3Detector.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Selective\AudioType\AudioFormat;
use Selective\AudioType\AudioMimeType;
use Selective\AudioType\AudioType;
use SplFileObject;

/**
* Detector.
Expand All @@ -15,11 +14,11 @@ final class Mp3Detector implements AudioDetectorInterface
/**
* Detect MP3 (MPEG-1 Audio Layer 3 (MP3) audio file) format.
*
* @param SplFileObject $file The audio file
* @param \SplFileObject $file The audio file
*
* @return AudioType|null The audio type
*/
public function detect(SplFileObject $file): ?AudioType
public function detect(\SplFileObject $file): ?AudioType
{
// MP3 file with an ID3v2 container
$hasId3v2Container = (string)$file->fread(3) === 'ID3';
Expand Down
5 changes: 2 additions & 3 deletions src/Detector/OgaDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Selective\AudioType\AudioFormat;
use Selective\AudioType\AudioMimeType;
use Selective\AudioType\AudioType;
use SplFileObject;

/**
* Detector.
Expand All @@ -15,11 +14,11 @@ final class OgaDetector implements AudioDetectorInterface
/**
* Detect FLAC soundfile format.
*
* @param SplFileObject $file The audio file
* @param \SplFileObject $file The audio file
*
* @return AudioType|null The audio type
*/
public function detect(SplFileObject $file): ?AudioType
public function detect(\SplFileObject $file): ?AudioType
{
$bytes = (string)$file->fread(4);

Expand Down
5 changes: 2 additions & 3 deletions src/Detector/RealAudioDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Selective\AudioType\AudioFormat;
use Selective\AudioType\AudioMimeType;
use Selective\AudioType\AudioType;
use SplFileObject;

/**
* Detector.
Expand All @@ -15,11 +14,11 @@ final class RealAudioDetector implements AudioDetectorInterface
/**
* Detects RealAudio.
*
* @param SplFileObject $file The file
* @param \SplFileObject $file The file
*
* @return AudioType|null The audio type
*/
public function detect(SplFileObject $file): ?AudioType
public function detect(\SplFileObject $file): ?AudioType
{
return (string)$file->fread(3) === '.ra' ? new AudioType(
AudioFormat::RA,
Expand Down
5 changes: 2 additions & 3 deletions src/Detector/RmiDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Selective\AudioType\AudioFormat;
use Selective\AudioType\AudioMimeType;
use Selective\AudioType\AudioType;
use SplFileObject;

/**
* Detector.
Expand All @@ -15,11 +14,11 @@ final class RmiDetector implements AudioDetectorInterface
/**
* Detect RMI, RIFF-MIDI audio format.
*
* @param SplFileObject $file The audio file
* @param \SplFileObject $file The audio file
*
* @return AudioType|null The audio type
*/
public function detect(SplFileObject $file): ?AudioType
public function detect(\SplFileObject $file): ?AudioType
{
$magicNumber = (string)$file->fread(4);
$header = (string)$file->fread(25);
Expand Down
5 changes: 2 additions & 3 deletions src/Detector/WavDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Selective\AudioType\AudioFormat;
use Selective\AudioType\AudioMimeType;
use Selective\AudioType\AudioType;
use SplFileObject;

/**
* Detector.
Expand All @@ -17,11 +16,11 @@ final class WavDetector implements AudioDetectorInterface
*
* http://soundfile.sapp.org/doc/WaveFormat/
*
* @param SplFileObject $file The audio file
* @param \SplFileObject $file The audio file
*
* @return AudioType|null The audio type
*/
public function detect(SplFileObject $file): ?AudioType
public function detect(\SplFileObject $file): ?AudioType
{
$chunkId = (string)$file->fread(4);

Expand Down
Loading

0 comments on commit 6a1574b

Please sign in to comment.