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
95 changes: 7 additions & 88 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,95 +1,14 @@
name: CI

on: [push]
on: [push, pull_request]

jobs:
phpunit:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest]
php-version: ['8.2', '8.3']
dependencies: ['lowest', 'highest']
name: 'PHPUnit'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl
coverage: none
- name: Composer
uses: "ramsey/composer-install@v2"
with:
dependency-versions: ${{ matrix.dependencies }}
- name: PHPUnit
run: vendor/bin/phpunit
blackbox:
uses: innmind/github-workflows/.github/workflows/black-box-matrix.yml@main
coverage:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest]
php-version: ['8.2', '8.3']
dependencies: ['lowest', 'highest']
name: 'Coverage'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl
coverage: xdebug
- name: Composer
uses: "ramsey/composer-install@v2"
with:
dependency-versions: ${{ matrix.dependencies }}
- name: PHPUnit
run: vendor/bin/phpunit --coverage-clover=coverage.clover
env:
BLACKBOX_SET_SIZE: 1
- uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
uses: innmind/github-workflows/.github/workflows/coverage-matrix.yml@main
secrets: inherit
psalm:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['8.2', '8.3']
dependencies: ['lowest', 'highest']
name: 'Psalm'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl
- name: Composer
uses: "ramsey/composer-install@v2"
with:
dependency-versions: ${{ matrix.dependencies }}
- name: Psalm
run: vendor/bin/psalm --shepherd
uses: innmind/github-workflows/.github/workflows/psalm-matrix.yml@main
cs:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['8.2']
name: 'CS'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl
- name: Composer
uses: "ramsey/composer-install@v2"
- name: CS
run: vendor/bin/php-cs-fixer fix --diff --dry-run
uses: innmind/github-workflows/.github/workflows/cs.yml@main
12 changes: 12 additions & 0 deletions .github/workflows/extensive.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Extensive CI

on:
push:
tags:
- '*'
paths:
- '.github/workflows/extensive.yml'

jobs:
blackbox:
uses: innmind/github-workflows/.github/workflows/extensive.yml@main
11 changes: 11 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Create release

on:
push:
tags:
- '*'

jobs:
release:
uses: innmind/github-workflows/.github/workflows/release.yml@main
secrets: inherit
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
composer.lock
vendor
.phpunit.result.cache
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Changelog

## [Unreleased]

### Added

- `Innmind\MediaType\MediaType::attempt()`

### Changed

- Require PHP `8.4`
- `Innmind\MediaType\MediaType` constructor is now private, use `::from()` instead
- `Innmind\MediaType\Parameter` constructor is now private, use `::from()` instead
- `Innmind\MediaType\MediaType` top level is now represented by `Innmind\MediaType\TopLevel`

### Removed

- `Innmind\MediaType\Exception\InvalidTopLevelType`
- `Innmind\MediaType\Exception\Exception`
- `Innmind\MediaType\Exception\DomainException`

## 2.3.0 - 2025-03-20

### Added
Expand Down
31 changes: 31 additions & 0 deletions blackbox.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
declare(strict_types = 1);

require 'vendor/autoload.php';

use Innmind\BlackBox\{
Application,
PHPUnit\Load,
Runner\CodeCoverage,
};

Application::new($argv)
->when(
\getenv('BLACKBOX_SET_SIZE') !== false,
static fn(Application $app) => $app->scenariiPerProof((int) \getenv('BLACKBOX_SET_SIZE')),
)
->when(
\getenv('ENABLE_COVERAGE') !== false,
static fn(Application $app) => $app
->scenariiPerProof(1)
->codeCoverage(
CodeCoverage::of(
__DIR__.'/src/',
__DIR__.'/tests/',
)
->dumpTo('coverage.clover')
->enableWhen(true),
),
)
->tryToProve(Load::directory(__DIR__.'/tests/'))
->exit();
13 changes: 6 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"issues": "http://github.com/Innmind/MediaType/issues"
},
"require": {
"php": "~8.2",
"innmind/immutable": "~4.15|~5.0"
"php": "~8.4",
"innmind/immutable": "~6.0"
},
"autoload": {
"psr-4": {
Expand All @@ -30,18 +30,17 @@
}
},
"require-dev": {
"phpunit/phpunit": "~10.2|~11.0|~12.0",
"innmind/black-box": "~5.0|^6.0.1",
"vimeo/psalm": "~5.6",
"innmind/static-analysis": "~1.3",
"innmind/black-box": "~6.5",
"innmind/coding-standard": "~2.0"
},
"conflict": {
"innmind/black-box": "<5.0|~7.0"
"innmind/black-box": "<6.0|~7.0"
},
"suggest": {
"innmind/black-box": "For property based testing"
},
"provide": {
"innmind/black-box-sets": "5.0"
"innmind/black-box-sets": "6.0"
}
}
45 changes: 22 additions & 23 deletions fixtures/MediaType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,60 +6,59 @@
use Innmind\MediaType\{
MediaType as Model,
Parameter,
TopLevel,
};
use Innmind\BlackBox\Set;

final class MediaType
{
/**
* @return Set<Model>
* @return Set\Provider<Model>
*/
public static function any(): Set
public static function any(): Set\Provider
{
$alphaNumerical = [...\range('A', 'Z'), ...\range('a', 'z'), ...\range(0, 9)];
$validChars = Set\Composite::immutable(
$validChars = Set::compose(
static fn($first, array $rest): string => \implode('', [$first, ...$rest]),
Set\Elements::of(...$alphaNumerical),
Set\Sequence::of(
Set\Elements::of('!', '#', '$', '&', '^', '_', '.', '-', ...$alphaNumerical),
Set\Integers::between(0, 126),
),
Set::of(...$alphaNumerical),
Set::sequence(
Set::of('!', '#', '$', '&', '^', '_', '.', '-', ...$alphaNumerical),
)->between(0, 126),
);

return Set\Composite::immutable(
return Set::compose(
static function($topLevel, $subType, $suffix, $parameterName, $parameterValue): Model {
if ($parameterName) {
return new Model(
return Model::from(
$topLevel,
$subType,
$suffix,
new Parameter(
Parameter::from(
$parameterName,
$parameterValue,
),
);
}

return new Model(
return Model::from(
$topLevel,
$subType,
$suffix,
);
},
Set\Elements::of(...Model::topLevels()->toList()),
Set::of(...TopLevel::cases()),
$validChars,
Set\Either::any(
Set\Elements::of(''),
$validChars,
),
Set\Either::any(
Set::either(
Set::of(''),
$validChars,
Set\Elements::of(null), // to generate a type without a parameter
),
Set\Strings::madeOf(
Set\Chars::alphanumerical(),
Set\Elements::of('-', '.'),
)->between(1, 100),
$validChars->nullable(), // to generate a type without a parameter
Set::strings()
->madeOf(
Set::strings()->chars()->alphanumerical(),
Set::of('-', '.'),
)
->between(1, 100),
);
}
}
22 changes: 0 additions & 22 deletions phpunit.xml.dist

This file was deleted.

8 changes: 0 additions & 8 deletions src/Exception/DomainException.php

This file was deleted.

8 changes: 0 additions & 8 deletions src/Exception/Exception.php

This file was deleted.

8 changes: 0 additions & 8 deletions src/Exception/InvalidTopLevelType.php

This file was deleted.

Loading