-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stack-trace was removed from error showing. Added phpcs:ignoreFile
- For showing stack trace should be in charge of another instruments like: whoops. - Added Makefile for local manipulation.
- Loading branch information
Showing
2 changed files
with
10 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
d.run: | ||
docker run --rm -it -v "${PWD}":/usr/src/myapp -w /usr/src/myapp pimlab/composer:2.0.0-alpha3-php7.4 sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?php | ||
<?php // phpcs:ignoreFile | ||
/** | ||
* Simple PHP DIC - DI Container in one file. | ||
* Supports autowiring and allows you to easily use it in your simple PHP applications and | ||
|
@@ -8,7 +8,7 @@ | |
* Author Email: [email protected] | ||
* Author Site: https://wp-yoda.com/en/ | ||
* | ||
* Version: 0.2.4 | ||
* Version: 0.2.5 | ||
* Source Code: https://github.com/renakdup/simple-php-dic | ||
* | ||
* Licence: MIT License | ||
|
@@ -98,7 +98,7 @@ class Container implements ContainerInterface { | |
public function __construct() { | ||
// Auto-register the container | ||
$this->resolved = [ | ||
self::class => $this, | ||
self::class => $this, | ||
ContainerInterface::class => $this, | ||
]; | ||
} | ||
|
@@ -147,9 +147,7 @@ public function has( string $id ): bool { | |
*/ | ||
public function make( string $id ): object { | ||
if ( ! class_exists( $id ) ) { | ||
$message = "Service '{$id}' could not be resolved because class not exist.\n" | ||
. "Stack trace: \n" | ||
. $this->get_stack_trace(); | ||
$message = "Service `{$id}` could not be resolved because class not exist."; | ||
throw new ContainerException( $message ); | ||
} | ||
|
||
|
@@ -178,10 +176,7 @@ protected function resolve( string $id ) { | |
return $this->resolve_object( $id ); | ||
} | ||
|
||
$message = "Service '{$id}' not found in the Container.\n" | ||
. "Stack trace: \n" | ||
. $this->get_stack_trace(); | ||
throw new ContainerNotFoundException( $message ); | ||
throw new ContainerNotFoundException( "Service `{$id}` not found in the Container." ); | ||
} | ||
|
||
/** | ||
|
@@ -211,9 +206,7 @@ protected function resolve_object( string $service ): object { | |
|
||
} catch ( ReflectionException $e ) { | ||
throw new ContainerException( | ||
"Service '{$service}' could not be resolved due the reflection issue: '" . $e->getMessage() . "'\n" . | ||
"Stack trace: \n" . | ||
$e->getTraceAsString() | ||
"Service `{$service}` could not be resolved due the reflection issue: `{$e->getMessage()}`" | ||
); | ||
} | ||
|
||
|
@@ -253,9 +246,7 @@ protected function resolve_parameter( ReflectionParameter $param ) { | |
} | ||
|
||
// @phpstan-ignore-next-line - Cannot call method getName() on ReflectionClass|null. | ||
$message = "Parameter '{$param->getName()}' of '{$param->getDeclaringClass()->getName()}' cannot be resolved.\n" . | ||
"Stack trace: \n" . | ||
$this->get_stack_trace(); | ||
$message = "Parameter `{$param->getName()}` of `{$param->getDeclaringClass()->getName()}` can't be resolved."; | ||
throw new ContainerException( $message ); | ||
} | ||
|
||
|