Skip to content

Commit 71288b5

Browse files
authored
Merge pull request #2 from phphd/refactor-rearrange-component-namespaces
refactor: Rearrange component namespaces
2 parents cf40c53 + f6b1c14 commit 71288b5

36 files changed

+128
-119
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
run: vendor/bin/psalm --stats --no-progress --output-format=github --shepherd --threads=$(nproc)
6161

6262
- name: 'PHPStan'
63-
run: vendor/bin/phpstan analyze --no-progress --error-format=github --ansi --configuration=phpstan.dist.neon ./
63+
run: vendor/bin/phpstan analyze --no-progress --error-format=github --ansi --configuration=phpstan.dist.neon
6464
steps:
6565
- name: 'Checkout Code'
6666
uses: actions/checkout@v4

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
# PhdExceptionHandlerBundle
22

3-
🧰 Provides [Symfony Messenger](https://symfony.com/doc/current/messenger.html) middlewares tailored for exception
4-
handling. You can easily re-raise exceptions, chain them, or handle with a dedicated bus.
3+
🧰 PHP Exception Handler built on top of [Symfony Messenger](https://symfony.com/doc/current/messenger.html) component.
4+
Provides middlewares that allow you to easily re-raise exceptions, chain them, or handle with a dedicated handler.
55

6-
[![Build Status](https://img.shields.io/github/actions/workflow/status/phphd/exception-handler-bundle/ci.yaml?branch=main)](https://github.com/phphd/exception-handler-bundle/actions?query=branch%3Amain)
7-
[![Codecov](https://codecov.io/gh/phphd/exception-handler-bundle/graph/badge.svg?token=GZRXWYT55Z)](https://codecov.io/gh/phphd/exception-handler-bundle)
8-
[![Psalm coverage](https://shepherd.dev/github/phphd/exception-handler-bundle/coverage.svg)](https://shepherd.dev/github/phphd/exception-handler-bundle)
9-
[![Psalm level](https://shepherd.dev/github/phphd/exception-handler-bundle/level.svg)](https://shepherd.dev/github/phphd/exception-handler-bundle)
10-
[![Packagist Downloads](https://img.shields.io/packagist/dt/phphd/exception-handler-bundle.svg)](https://packagist.org/packages/phphd/exception-handler-bundle)
11-
[![Licence](https://img.shields.io/github/license/phphd/exception-handler-bundle.svg)](https://github.com/phphd/exception-handler-bundle/blob/main/LICENSE)
6+
[![Build Status](https://img.shields.io/github/actions/workflow/status/phphd/exception-handler/ci.yaml?branch=main)](https://github.com/phphd/exception-handler/actions?query=branch%3Amain)
7+
[![Codecov](https://codecov.io/gh/phphd/exception-handler/graph/badge.svg?token=GZRXWYT55Z)](https://codecov.io/gh/phphd/exception-handler)
8+
[![Psalm coverage](https://shepherd.dev/github/phphd/exception-handler/coverage.svg)](https://shepherd.dev/github/phphd/exception-handler)
9+
[![Psalm level](https://shepherd.dev/github/phphd/exception-handler/level.svg)](https://shepherd.dev/github/phphd/exception-handler)
10+
[![Packagist Downloads](https://img.shields.io/packagist/dt/phphd/exception-handler.svg)](https://packagist.org/packages/phphd/exception-handler)
11+
[![Licence](https://img.shields.io/github/license/phphd/exception-handler.svg)](https://github.com/phphd/exception-handler/blob/main/LICENSE)
1212

1313
## Installation 📥
1414

1515
1. Install via composer
1616

1717
```sh
18-
composer require phphd/exception-handler-bundle
18+
composer require phphd/exception-handler
1919
```
2020

2121
2. Enable the bundle in the `bundles.php`
2222

2323
```php
24-
PhPhD\ExceptionHandlerBundle\PhdExceptionHandlerBundle::class => ['all' => true],
24+
PhPhD\ExceptionHandler\Bundle\PhdExceptionHandlerBundle::class => ['all' => true],
2525
```
2626

2727
## Configuration ⚒️
@@ -88,7 +88,7 @@ Filters out all null results of exception handlers.
8888
The simplest use-case is defining `#[RaiseAs]` attribute on your exception class:
8989

9090
```php
91-
use PhPhD\ExceptionHandler\Chain\Escalator\RaiseAs;
91+
use PhPhD\ExceptionHandler\Middleware\Chain\Escalator\RaiseAs;
9292
9393
#[RaiseAs(AccessDeniedHttpException::class, bus: 'api.exception.bus')]
9494
final class NonWhiteListedUserException extends DomainException
@@ -104,7 +104,7 @@ contexts (hence, different buses), it is required to explicitly specify the bus
104104
must be raised, so that in other scenarios another exceptions could be escalated:
105105
106106
```php
107-
use PhPhD\ExceptionHandler\Chain\Escalator\RaiseAs;
107+
use PhPhD\ExceptionHandler\Middleware\Chain\Escalator\RaiseAs;
108108
109109
#[RaiseAs(ImportLockedHttpException::class, bus: 'api.exception.bus')]
110110
#[RaiseAs(RecoverableMessageHandlingException::class, bus: 'consumer.exception.bus')]

Resources/config/services.yaml

Lines changed: 0 additions & 19 deletions
This file was deleted.

composer.json

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "phphd/exception-handler-bundle",
2+
"name": "phphd/exception-handler",
33
"description": "Message Bus Exception Handler",
44
"type": "symfony-bundle",
55
"license": "MIT",
@@ -12,21 +12,28 @@
1212
"minimum-stability": "stable",
1313
"require": {
1414
"php": ">=8.1",
15-
"symfony/dependency-injection": "^6.0 | ^7.0",
16-
"symfony/http-kernel": "^6.0 | ^7.0",
1715
"symfony/messenger": "^6.2 | ^7.0",
18-
"symfony/string": "^6.0 | ^7.0"
16+
"symfony/string": "^6.0 | ^7.0",
17+
"symfony/polyfill-php83": "^1.31"
18+
},
19+
"conflict": {
20+
"symfony/http-kernel": "<6.0 || >=8.0",
21+
"symfony/dependency-injection": "<6.0 || >=8.0",
22+
"symfony/config": "<6.0 || >=8.0"
1923
},
2024
"require-dev": {
21-
"tomasvotruba/type-coverage": "^0.2.3",
25+
"symfony/http-kernel": "*",
26+
"symfony/dependency-injection":"*",
27+
"symfony/config": "*",
28+
"tomasvotruba/type-coverage": "^1.0",
2229
"phpstan/phpstan": "^1.10.60",
23-
"vimeo/psalm": "^5.23.1",
24-
"phpat/phpat": "^0.10.15",
25-
"phpstan/phpstan-phpunit": "^1.3.16",
30+
"vimeo/psalm": "^5.26.1",
31+
"phpat/phpat": "^0.10.18",
32+
"phpstan/phpstan-phpunit": "^1.4.0",
2633
"psalm/plugin-phpunit": "^0.18.4",
2734
"nyholm/symfony-bundle-test": "^3.0",
28-
"phphd/coding-standard": "~0.5.0",
29-
"phpunit/phpunit": "^10.5.13"
35+
"phphd/coding-standard": "~0.5.3",
36+
"phpunit/phpunit": "^10.5.36"
3037
},
3138
"repositories": [
3239
{
@@ -35,17 +42,13 @@
3542
}
3643
],
3744
"autoload": {
38-
"classmap": [
39-
"DependencyInjection",
40-
"PhdExceptionHandlerBundle.php"
41-
],
4245
"psr-4": {
4346
"PhPhD\\ExceptionHandler\\": "src"
4447
}
4548
},
4649
"autoload-dev": {
4750
"psr-4": {
48-
"PhPhD\\ExceptionHandlerBundle\\Tests\\": "tests"
51+
"PhPhD\\ExceptionHandler\\Bundle\\Tests\\": "tests"
4952
}
5053
},
5154
"scripts": {
@@ -61,7 +64,7 @@
6164
"ci:ecs-fix": "vendor/bin/ecs check --fix",
6265
"ci:rector": "vendor/bin/rector process --dry-run -vv",
6366
"ci:rector-fix": "vendor/bin/rector process",
64-
"ci:phpstan": "vendor/bin/phpstan analyze ./",
67+
"ci:phpstan": "vendor/bin/phpstan analyze",
6568
"ci:psalm": "vendor/bin/psalm",
6669
"ci:test": "vendor/bin/phpunit --testdox --colors=always",
6770
"ci:unit-test": "vendor/bin/phpunit --testdox --colors=always --testsuite=Unit",

phpstan.dist.neon

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@ parameters:
88
level: 9
99
phpVersion: 80213
1010
editorUrl: 'phpstorm://open?file=%%file%%&line=%%line%%'
11+
paths:
12+
- src
13+
- tests
1114
excludePaths:
1215
analyseAndScan:
13-
- vendor
1416
- tests/*/Stub/*
15-
- rector.php
16-
- ecs.php
1717
type_coverage:
1818
return_type: 100
1919
param_type: 100
2020
property_type: 100
21+
constant: 0
2122
fileExtensions:
2223
- 'php'
2324
phpat:

phpunit.xml.dist

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,18 @@
1313
<directory>tests/Unit</directory>
1414
</testsuite>
1515
<testsuite name="Integration">
16-
<directory>tests/Integration</directory>
16+
<directory suffix="IntegrationTest.php">src</directory>
1717
</testsuite>
1818
</testsuites>
1919

2020
<source restrictDeprecations="true" restrictNotices="true" restrictWarnings="true">
2121
<include>
22-
<directory>.</directory>
22+
<directory>src</directory>
2323
</include>
2424
<exclude>
25-
<directory>vendor</directory>
26-
<directory>tests</directory>
27-
<file>rector.php</file>
28-
<file>ecs.php</file>
25+
<directory>src/*/*/Tests</directory>
26+
<directory>src/*/*/*/Tests</directory>
27+
<directory>src/*/*/*/*/Tests</directory>
2928
</exclude>
3029
</source>
3130
</phpunit>

psalm.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
findUnusedCode="true"
1010
>
1111
<projectFiles>
12-
<directory name="./"/>
12+
<directory name="src"/>
1313
<ignoreFiles>
1414
<directory name="vendor"/>
15-
<file name="rector.php"/>
1615
</ignoreFiles>
1716
</projectFiles>
1817
<plugins>

rector.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
$rectorConfig->skip([
1818
LocallyCalledStaticMethodToNonStaticRector::class => [
1919
__DIR__.'/tests',
20+
__DIR__.'/src/*/Tests/*.php',
2021
],
2122
]);
2223
};

src/Bundle/.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/Tests export-ignore

DependencyInjection/PhdExceptionHandlerExtension.php renamed to src/Bundle/DependencyInjection/PhdExceptionHandlerExtension.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
declare(strict_types=1);
44

5-
namespace PhPhD\ExceptionHandlerBundle\DependencyInjection;
5+
namespace PhPhD\ExceptionHandler\Bundle\DependencyInjection;
66

77
use Exception;
8+
use Override;
89
use Symfony\Component\Config\FileLocator;
910
use Symfony\Component\DependencyInjection\ContainerBuilder;
1011
use Symfony\Component\DependencyInjection\Extension\Extension;
@@ -17,10 +18,9 @@ final class PhdExceptionHandlerExtension extends Extension
1718
/**
1819
* @param array<array-key,mixed> $configs
1920
*
20-
* @override
21-
*
2221
* @throws Exception
2322
*/
23+
#[Override]
2424
public function load(array $configs, ContainerBuilder $container): void
2525
{
2626
/** @var ?string $env */
@@ -30,7 +30,7 @@ public function load(array $configs, ContainerBuilder $container): void
3030
$loader->load(__DIR__.'/../Resources/config/services.yaml');
3131
}
3232

33-
/** @override */
33+
#[Override]
3434
public function getAlias(): string
3535
{
3636
return self::ALIAS;

0 commit comments

Comments
 (0)