Skip to content

Commit eca5b0d

Browse files
author
Pantea Marius-ciclistu
committed
Improve di helper
1 parent 2b9a663 commit eca5b0d

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

illuminate/Foundation/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class Application extends Container implements
4444
*
4545
* @var string
4646
*/
47-
public const VERSION = '10.52.0';
47+
public const VERSION = '10.52.1';
4848

4949
/**
5050
* The base path for the Laravel installation.

illuminate/Foundation/helpers.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,26 +1086,26 @@ function arrayUniqueSortRegular(array $items): array
10861086
* Safely resolve from container a class ONLY after the app has been booted.
10871087
* If not, it will instantiate the classFqn only with $parameters as list
10881088
*/
1089-
function di(string $classFqn, array $parameters = []): mixed
1089+
function di(string $classFqn, array $parametersList = []): mixed
10901090
{
10911091
$container = Container::getInstance();
10921092

10931093
if ($container instanceof \Illuminate\Foundation\Application && $container->isBooted()) {
1094-
return $container->make($classFqn, $parameters);
1094+
return $container->make($classFqn, $parametersList);
10951095
}
10961096

10971097
if (
10981098
\class_exists($classFqn)
10991099
&& (
1100-
$parameters === []
1101-
|| \array_values($parameters) === $parameters
1100+
$parametersList === []
1101+
|| \array_values($parametersList) === $parametersList
11021102
)
11031103
) {
1104-
return new $classFqn(...$parameters);
1104+
return new $classFqn(...$parametersList);
11051105
}
11061106

11071107
throw new \Illuminate\Contracts\Container\BindingResolutionException(
1108-
'di function called before app booted for: ' . $classFqn . \json_encode(
1108+
'di function called before app booted for: ' . $classFqn . ' trace: ' . \json_encode(
11091109
\debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)
11101110
)
11111111
);

src/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public function bootstrapRouter()
169169
*/
170170
public function version()
171171
{
172-
return 'Maravel Framework 10.52.0';
172+
return 'Maravel Framework 10.52.1';
173173
}
174174

175175
/**

src/helpers.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -490,26 +490,26 @@ function arrayUniqueSortRegular(array $items): array
490490
* Safely resolve from container a class ONLY after the app has been booted.
491491
* If not, it will instantiate the classFqn only with $parameters as list
492492
*/
493-
function di(string $classFqn, array $parameters = []): mixed
493+
function di(string $classFqn, array $parametersList = []): mixed
494494
{
495495
$container = Container::getInstance();
496496

497497
if ($container instanceof \Laravel\Lumen\Application && $container->isBooted()) {
498-
return $container->make($classFqn, $parameters);
498+
return $container->make($classFqn, $parametersList);
499499
}
500500

501501
if (
502502
\class_exists($classFqn)
503503
&& (
504-
$parameters === []
505-
|| \array_values($parameters) === $parameters
504+
$parametersList === []
505+
|| \array_values($parametersList) === $parametersList
506506
)
507507
) {
508-
return new $classFqn(...$parameters);
508+
return new $classFqn(...$parametersList);
509509
}
510510

511511
throw new \Illuminate\Contracts\Container\BindingResolutionException(
512-
'di function called before app booted for: ' . $classFqn . \json_encode(
512+
'di function called before app booted for: ' . $classFqn . ' trace: ' . \json_encode(
513513
\debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)
514514
)
515515
);

0 commit comments

Comments
 (0)