Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
4 changes: 2 additions & 2 deletions .github/workflows/coding-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: 8.2
php-version: 8.3
coverage: none

- run: composer create-project nette/code-checker temp/code-checker ^3 --no-progress
Expand All @@ -24,7 +24,7 @@ jobs:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: 8.2
php-version: 8.3
coverage: none

- run: composer create-project nette/coding-standard temp/coding-standard ^3 --no-progress
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ jobs:
- run: composer install --no-progress --prefer-dist
- run: vendor/bin/tester tests -s -C
- if: failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: output
name: output-${{ matrix.php }}
path: tests/**/output


Expand Down
13 changes: 8 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,22 @@
"php": "8.1 - 8.4",
"ext-tokenizer": "*",
"ext-ctype": "*",
"nette/neon": "^3.3",
"nette/neon": "^3.4",
"nette/php-generator": "^4.1.6",
"nette/robot-loader": "^4.0",
"nette/schema": "^1.2.5",
"nette/schema": "^1.3",
"nette/utils": "^4.0"
},
"require-dev": {
"nette/tester": "^2.5.2",
"tracy/tracy": "^2.9",
"phpstan/phpstan": "^1.0"
"phpstan/phpstan-nette": "^2.0@stable"
},
"autoload": {
"classmap": ["src/"]
"classmap": ["src/"],
"psr-4": {
"Nette\\": "src"
}
},
"minimum-stability": "dev",
"scripts": {
Expand All @@ -39,7 +42,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "3.2-dev"
"dev-master": "3.3-dev"
}
}
}
5 changes: 3 additions & 2 deletions src/Bridges/DITracy/ContainerPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Nette;
use Nette\DI\Container;
use Tracy;
use const SORT_NATURAL;


/**
Expand Down Expand Up @@ -40,7 +41,7 @@ public function getTab(): string
{
return Nette\Utils\Helpers::capture(function () {
$elapsedTime = $this->elapsedTime;
require __DIR__ . '/templates/ContainerPanel.tab.phtml';
require __DIR__ . '/dist/tab.phtml';
});
}

Expand Down Expand Up @@ -76,7 +77,7 @@ public function getPanel(): string
$parameters = $rc->getMethod('getStaticParameters')->getDeclaringClass()->getName() === Container::class
? null
: $container->getParameters();
require __DIR__ . '/templates/ContainerPanel.panel.phtml';
require __DIR__ . '/dist/panel.phtml';
});
}
}
87 changes: 87 additions & 0 deletions src/Bridges/DITracy/dist/panel.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?php
declare(strict_types=1);
?>
<?php use Tracy\Dumper ?>
<style class="tracy-debug">
#tracy-debug .nette-ContainerPanel table {
width: 100%;
white-space: nowrap;
}

#tracy-debug .nette-ContainerPanel .created {
font-weight: bold;
}

#tracy-debug .nette-ContainerPanel .yes {
color: green;
font-weight: bold;
}

#tracy-debug .nette-ContainerPanel table pre {
display: inline;
background: transparent;
padding: 0;
word-break: normal;
}
</style>

<h1>Nette DI Container</h1>

<div class="tracy-inner nette-ContainerPanel">
<div class="tracy-inner-container">
<p>Source: <?= Tracy\Helpers::editorLink($file) ?>
</p>

<table class="tracy-sortable">
<thead>
<tr>
<th>Name</th>
<th>Autowired</th>
<th>Service</th>
<th>Tags</th>
</tr>
</thead>
<tbody>
<?php foreach ($services as $name => $type): ?><?php $name = (string) $name ?><?php $autowired = in_array($name, array_merge($wiring[$type][0] ?? [], $wiring[$type][1] ?? []), strict: true) ?> <tr>
<td class="<?= Tracy\Helpers::escapeHtml(isset($instances[$name]) ? 'created' : '') ?>
">
<?php if (is_numeric($name)): ?>
<small><?= Tracy\Helpers::escapeHtml($name) ?>
</small><?php else: ?>
<?= Tracy\Helpers::escapeHtml($name) ?>

<?php endif ?>
</td>
<td class="<?= Tracy\Helpers::escapeHtml($autowired ? 'yes' : '') ?>
">
<?= Tracy\Helpers::escapeHtml($autowired ? 'yes' : (isset($wiring[$type]) ? 'no' : '?')) ?>

</td>
<td>
<?php if (isset($instances[$name]) && !$instances[$name] instanceof Nette\DI\Container): ?> <?= Dumper::toHtml($instances[$name], [Dumper::COLLAPSE => true, Dumper::LIVE => true, Dumper::DEPTH => 5]) ?>

<?php elseif (isset($instances[$name])): ?> <code><?= Tracy\Helpers::escapeHtml(get_class($instances[$name])) ?>
</code>
<?php elseif (is_string($type)): ?> <code><?= Tracy\Helpers::escapeHtml($type) ?>
</code>
<?php endif ?> </td>
<td>
<?php if (!isset($tags[$name])): ?><?php elseif (count($tags[$name]) === 1): ?> <?= Tracy\Helpers::escapeHtml(key($tags[$name])) ?>
 = <?= Dumper::toHtml(current($tags[$name]), [Dumper::COLLAPSE => true]) ?>

<?php else: ?> <?= Dumper::toHtml($tags[$name], [Dumper::COLLAPSE => true]) ?>

<?php endif ?> </td>
</tr>
<?php endforeach ?> </tbody>
</table>

<h2>Parameters</h2>

<div class="nette-ContainerPanel-parameters">
<?php if ($parameters === null): ?> <i>disabled via 'di › export › parameters'</i>
<?php else: ?> <?= Dumper::toHtml($parameters) ?>

<?php endif ?> </div>
</div>
</div>
10 changes: 10 additions & 0 deletions src/Bridges/DITracy/dist/tab.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
?>
<span title="Nette DI Container">
<svg viewBox="0 0 2048 2048">
<path fill="#ae7c21" d="m1675 690.55v-125c0-36-4-60-13-71-9-12-26-18-52-18s-43 6-52 17c-8 11-12 36-12 72v910.62c0 37 4 61 12 72 9 11 26 17 52 17s44-6 52-17c9-12 13-36 13-72v-207h243v165c0 86-4 148-12 187-8 38-21 70-39 96-20 28-45 48-77 59-31 11-87 16-170 16-96 0-161-5-196-16-34-11-63-31-86-59-21-26-36-59-45-97-9-39-14-101-14-186v-826.62c0-85 4-147 13-185s25-71 46-97c23-29 54-49 92-60s102-17 189-17c75 0 130 6 164 17s61 30 81 59c19 26 33 59 41 99 8 39 12 101 12 185v84zm-524 1086.6h-254v-1514.6h254zm-1025 0v-1514.6h316c127 0 212 27 257 81 44 53 66 159 66 316v721.62c0 157-22 263-66 317-44 53-130 80-257 80zm388-314v-884.62c0-35-4-58-13-70-9-11-26-17-53-17h-66v1058.6h66c26 0 44-6 53-17 9-12 14-35 14-70z"/>
</svg
><span class="tracy-label"><?= Tracy\Helpers::escapeHtml($elapsedTime ? sprintf('%0.1f ms', $elapsedTime * 1000) : '') ?>
</span>
</span>
84 changes: 84 additions & 0 deletions src/Bridges/DITracy/panel.latte
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{use Tracy\Dumper}

<style class="tracy-debug">
#tracy-debug .nette-ContainerPanel table {
width: 100%;
white-space: nowrap;
}

#tracy-debug .nette-ContainerPanel .created {
font-weight: bold;
}

#tracy-debug .nette-ContainerPanel .yes {
color: green;
font-weight: bold;
}

#tracy-debug .nette-ContainerPanel table pre {
display: inline;
background: transparent;
padding: 0;
word-break: normal;
}
</style>

<h1>Nette DI Container</h1>

<div class="tracy-inner nette-ContainerPanel">
<div class="tracy-inner-container">
<p>Source: {Tracy\Helpers::editorLink($file)}</p>

<table class="tracy-sortable">
<thead>
<tr>
<th>Name</th>
<th>Autowired</th>
<th>Service</th>
<th>Tags</th>
</tr>
</thead>
<tbody>
{foreach $services as $name => $type}
{do $name = (string) $name}
{do $autowired = in_array($name, array_merge($wiring[$type][0] ?? [], $wiring[$type][1] ?? []), strict: true)}
<tr>
<td class="{isset($instances[$name]) ? created : ''}">
{if is_numeric($name)}<small>{$name}</small>{else}{$name}{/if}
</td>
<td class="{$autowired ? yes : ''}">
{$autowired ? yes : (isset($wiring[$type]) ? no : '?')}
</td>
<td>
{if isset($instances[$name]) && !$instances[$name] instanceof Nette\DI\Container}
{Dumper::toHtml($instances[$name], [Dumper::COLLAPSE => true, Dumper::LIVE => true, Dumper::DEPTH => 5])}
{elseif isset($instances[$name])}
<code>{get_class($instances[$name])}</code>
{elseif is_string($type)}
<code>{$type}</code>
{/if}
</td>
<td>
{if !isset($tags[$name])}
{elseif count($tags[$name]) === 1}
{key($tags[$name])} = {Dumper::toHtml(current($tags[$name]), [Dumper::COLLAPSE => true])}
{else}
{Dumper::toHtml($tags[$name], [Dumper::COLLAPSE => true])}
{/if}
</td>
</tr>
{/foreach}
</tbody>
</table>

<h2>Parameters</h2>

<div class="nette-ContainerPanel-parameters">
{if $parameters === null}
<i>disabled via 'di › export › parameters'</i>
{else}
{Dumper::toHtml($parameters)}
{/if}
</div>
</div>
</div>
6 changes: 6 additions & 0 deletions src/Bridges/DITracy/tab.latte
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<span title="Nette DI Container">
<svg viewBox="0 0 2048 2048">
<path fill="#ae7c21" d="m1675 690.55v-125c0-36-4-60-13-71-9-12-26-18-52-18s-43 6-52 17c-8 11-12 36-12 72v910.62c0 37 4 61 12 72 9 11 26 17 52 17s44-6 52-17c9-12 13-36 13-72v-207h243v165c0 86-4 148-12 187-8 38-21 70-39 96-20 28-45 48-77 59-31 11-87 16-170 16-96 0-161-5-196-16-34-11-63-31-86-59-21-26-36-59-45-97-9-39-14-101-14-186v-826.62c0-85 4-147 13-185s25-71 46-97c23-29 54-49 92-60s102-17 189-17c75 0 130 6 164 17s61 30 81 59c19 26 33 59 41 99 8 39 12 101 12 185v84zm-524 1086.6h-254v-1514.6h254zm-1025 0v-1514.6h316c127 0 212 27 257 81 44 53 66 159 66 316v721.62c0 157-22 263-66 317-44 53-130 80-257 80zm388-314v-884.62c0-35-4-58-13-70-9-11-26-17-53-17h-66v1058.6h66c26 0 44-6 53-17 9-12 14-35 14-70z"/>
</svg
><span class="tracy-label">{$elapsedTime ? sprintf('%0.1f ms', $elapsedTime * 1000) : ''}</span>
</span>
81 changes: 0 additions & 81 deletions src/Bridges/DITracy/templates/ContainerPanel.panel.phtml

This file was deleted.

11 changes: 0 additions & 11 deletions src/Bridges/DITracy/templates/ContainerPanel.tab.phtml

This file was deleted.

6 changes: 5 additions & 1 deletion src/DI/Attributes/Inject.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
use Attribute;


#[Attribute(Attribute::TARGET_PROPERTY)]
#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)]
class Inject
{
public function __construct(
public readonly ?string $tag = null,
) {
}
}
Loading
Loading