Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Gappa committed Jul 28, 2021
1 parent 97a23fb commit 243b64f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 29 deletions.
58 changes: 31 additions & 27 deletions src/Nette/Diagnostics/Panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Panel implements IBarPanel
/** @var Compiler[] */
private array $compilers = [];

private ?array $size;
private ?array $size = null;
private array $files;
private array $sizes;
private string $root;
Expand Down Expand Up @@ -86,33 +86,37 @@ private function compute(): array

$compilerCombinedSize = 0;

/** @var File $generated */
foreach ($compiler->generate() as $generated) {
$generatedSize = filesize($compiler->getOutputDir() . DIRECTORY_SEPARATOR . $generated->getFileName());
$size['combined'] += $generatedSize;
$compilerCombinedSize += $generatedSize;

foreach ($generated->getSourceFiles() as $file) {
$extension = strtolower(pathinfo($file, PATHINFO_EXTENSION));
$file = str_replace('\\', DIRECTORY_SEPARATOR, (string) realpath($file));

if (!isset($this->files[$group][$extension])) {
$this->files[$group][$extension] = [];
}
if (!isset($this->sizes[$group][$extension])) {
$this->sizes[$group][$extension] = ['original' => 0, 'combined' => 0];
}

$this->files[$group][$extension][] = [
'name' => basename($file),
'full' => $file,
'size' => $fileSize = filesize($file),
];

$size['original'] += $fileSize;
$this->sizes[$group][$extension]['original'] += $fileSize;
$this->sizes[$group]['.']['original'] += $fileSize;
$generated = $compiler->generate();

if (is_null($generated)) {
continue;
}

$generatedSize = filesize($compiler->getOutputDir() . DIRECTORY_SEPARATOR . $generated->getFileName());
$size['combined'] += $generatedSize;

$compilerCombinedSize += $generatedSize;

foreach ($generated->getSourceFiles() as $file) {
$extension = strtolower(pathinfo($file, PATHINFO_EXTENSION));
$file = str_replace('\\', DIRECTORY_SEPARATOR, (string) realpath($file));

if (!isset($this->files[$group][$extension])) {
$this->files[$group][$extension] = [];
}
if (!isset($this->sizes[$group][$extension])) {
$this->sizes[$group][$extension] = ['original' => 0, 'combined' => 0];
}

$this->files[$group][$extension][] = [
'name' => basename($file),
'full' => $file,
'size' => $fileSize = filesize($file),
];

$size['original'] += $fileSize;
$this->sizes[$group][$extension]['original'] += $fileSize;
$this->sizes[$group]['.']['original'] += $fileSize;
}

$this->sizes[$group]['.']['combined'] += $compilerCombinedSize;
Expand Down
4 changes: 2 additions & 2 deletions src/Nette/SymfonyConsole/GenerateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
{
$noFiles = true;
foreach ($this->compilers as $compiler) {
$files = $compiler->generate();
foreach ($files as $file) {
$file = $compiler->generate();
if (!is_null($file)) {
$output->writeln($file->getFileName());
$noFiles = false;
}
Expand Down

0 comments on commit 243b64f

Please sign in to comment.