Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade container:0.3 #24

Merged
merged 1 commit into from
Apr 24, 2023
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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "MIT",
"require": {
"php": ">=8.0.2",
"gacela-project/resolver": "^0.2"
"gacela-project/container": "^0.3"
},
"require-dev": {
"ext-mbstring": "*",
Expand Down
2 changes: 2 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<psalm
errorLevel="1"
phpVersion="8.0"
findUnusedBaselineEntry="true"
findUnusedCode="false"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
Expand Down
6 changes: 3 additions & 3 deletions src/Router/Entities/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Gacela\Router\Entities;

use Gacela\Resolver\InstanceCreator;
use Gacela\Container\Container;
use Gacela\Router\Bindings;

use Gacela\Router\Exceptions\UnsupportedResponseTypeException;
Expand Down Expand Up @@ -34,8 +34,8 @@ public function run(Bindings $bindings): string|Stringable
$params = (new RouteParams($this))->asArray();

if (!is_object($this->controller)) {
$creator = new InstanceCreator($bindings->getAllBindings());
$controller = $creator->createByClassName($this->controller);
$creator = new Container($bindings->getAllBindings());
$controller = $creator->get($this->controller);
$response = $controller->{$this->action}(...$params);
} else {
/** @var string|Stringable $response */
Expand Down
4 changes: 2 additions & 2 deletions src/Router/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Closure;
use Exception;
use Gacela\Resolver\InstanceCreator;
use Gacela\Container\Container;
use Gacela\Router\Entities\Route;
use Gacela\Router\Exceptions\NotFound404Exception;
use ReflectionFunction;
Expand Down Expand Up @@ -58,7 +58,7 @@ private static function handleException(Handlers $handlers, Exception $exception
return $handler($exception);
}

$instance = InstanceCreator::create($handler);
$instance = Container::create($handler);

if (is_callable($instance)) {
return $instance($exception);
Expand Down