Skip to content

Commit

Permalink
Merge branch 'release/v0.4.0' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
betterthanclay committed Aug 23, 2022
2 parents f410abc + c48e31c commit dc3df19
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1']
php-versions: ['8.0', '8.1']
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}

steps:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v0.4.0 (2022-08-23)
* Removed PHP7 compatibility
* Added try/catch around URL resolver
* Updated ECS to v11
* Updated PHPUnit to v9

## v0.3.6 (2022-03-15)
* Added simple URL resolver support

Expand Down
9 changes: 1 addition & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Pandora
# Metamorph

[![PHP from Packagist](https://img.shields.io/packagist/php-v/decodelabs/metamorph?style=flat)](https://packagist.org/packages/decodelabs/metamorph)
[![Latest Version](https://img.shields.io/packagist/v/decodelabs/metamorph.svg?style=flat)](https://packagist.org/packages/decodelabs/metamorph)
Expand All @@ -20,12 +20,5 @@ composer require decodelabs/metamorph

Coming shortly...

### PHP version

_Please note, the final v1 releases of all Decode Labs libraries will target **PHP8** or above._

Current support for earlier versions of PHP will be phased out in the coming months.


## Licensing
Metamorph is licensed under the MIT License. See [LICENSE](./LICENSE) for the full license text.
27 changes: 16 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@
"email": "tom@inflatablecookie.com"
}],
"require": {
"php": "^7.2|^8.0",
"symfony/polyfill-php80": "^1.22",
"php": "^8.0",
"symfony/polyfill-mbstring": "^1.7",

"decodelabs/archetype": "^0.1",
"decodelabs/coercion": "^0.1",
"decodelabs/glitch-support": "^0.3",
"decodelabs/exceptional": "^0.3",
"decodelabs/tagged": "^0.12|^0.13"
"decodelabs/archetype": "^0.2",
"decodelabs/coercion": "^0.2",
"decodelabs/glitch-support": "^0.4",
"decodelabs/exceptional": "^0.4",
"decodelabs/tagged": "^0.14"
},
"require-dev": {
"phpunit/phpunit": "^8",
"phpunit/phpunit": "^9",
"phpstan/phpstan": "^1",
"phpstan/extension-installer": "^1.0",
"decodelabs/phpstan-decodelabs": "^0.5",
"symplify/easy-coding-standard": "^10",
"symplify/easy-coding-standard": "^11",

"decodelabs/phpstan-decodelabs": "^0.6",

"soundasleep/html2text": "^1.1",
"erusev/parsedown": "^1.7",
Expand All @@ -42,7 +42,12 @@
},
"extra": {
"branch-alias": {
"dev-develop": "0.3.x-dev"
"dev-develop": "0.4.x-dev"
}
},
"config": {
"allow-plugins": {
"phpstan/extension-installer": true
}
},
"scripts": {
Expand Down
12 changes: 4 additions & 8 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@

declare(strict_types=1);

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\ValueObject\Option;
use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;

return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->import(SetList::CLEAN_CODE);
$containerConfigurator->import(SetList::PSR_12);

$parameters = $containerConfigurator->parameters();
$parameters->set(Option::PATHS, [__DIR__ . '/src']);
return static function (ECSConfig $ecsConfig): void {
$ecsConfig->paths([__DIR__ . '/src']);
$ecsConfig->sets([SetList::CLEAN_CODE, SetList::PSR_12]);
};
12 changes: 9 additions & 3 deletions src/Metamorph.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use DecodeLabs\Tagged\ContentCollection;
use ReflectionClass;
use Stringable;
use Throwable;

class Metamorph
{
Expand All @@ -37,8 +38,13 @@ public static function setUrlResolver(?callable $resolver): void
*/
public static function resolveUrl(string $url): string
{
if ($resolver = static::$urlResolver) {
if (!$resolver = static::$urlResolver) {
return $url;
}

try {
$url = $resolver($url);
} catch (Throwable $e) {
}

return $url;
Expand Down Expand Up @@ -115,15 +121,15 @@ public static function loadHandler(
$name = $parts[0];
$macro = $parts[1] ?? null;

/** @var class-string<Handler> */
/** @phpstan-var class-string<Handler> */
$class = Archetype::resolve(Handler::class, ucfirst($name));
$reflection = new ReflectionClass($class);

if (
$reflection->implementsInterface(MacroHandler::class) &&
$macro !== null
) {
/** @var class-string<MacroHandler> $class */
/** @phpstan-var class-string<MacroHandler> $class */
$options = array_merge($class::loadMacro($macro) ?? [], $options ?? []);
}

Expand Down

0 comments on commit dc3df19

Please sign in to comment.