Skip to content

Commit 80128ed

Browse files
committed
Add patch description display
1 parent b384345 commit 80128ed

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/StaticPHP/DI/ApplicationContext.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
use DI\Container;
88
use DI\ContainerBuilder;
99
use Psr\Container\ContainerInterface;
10+
use StaticPHP\Attribute\PatchDescription;
1011
use Symfony\Component\Console\Input\InputInterface;
1112
use Symfony\Component\Console\Output\OutputInterface;
13+
use ZM\Logger\ConsoleColor;
1214

1315
use function DI\factory;
1416

@@ -138,6 +140,14 @@ public static function getInvoker(): CallbackInvoker
138140
public static function invoke(callable $callback, array $context = []): mixed
139141
{
140142
logger()->debug('[INVOKE] ' . (is_array($callback) ? (is_object($callback[0]) ? get_class($callback[0]) : $callback[0]) . '::' . $callback[1] : (is_string($callback) ? $callback : 'Closure')));
143+
144+
// get if callback has attribute PatchDescription
145+
$ref = new \ReflectionFunction(\Closure::fromCallable($callback));
146+
$attributes = $ref->getAttributes(PatchDescription::class);
147+
foreach ($attributes as $attribute) {
148+
$attrInstance = $attribute->newInstance();
149+
logger()->info(ConsoleColor::magenta('[PATCH]') . ConsoleColor::green(" {$attrInstance->description}"));
150+
}
141151
return self::getInvoker()->invoke($callback, $context);
142152
}
143153

0 commit comments

Comments
 (0)