Skip to content

Commit

Permalink
jump arround
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Sep 7, 2024
1 parent 4826e98 commit 73ba92b
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 22 deletions.
35 changes: 32 additions & 3 deletions app/Repository/ToolRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,17 @@ public function fetchAll(): array
'https://tomasvotruba.com/blog/how-to-measure-your-type-coverage',
'composer require tomasvotruba/type-coverage --dev',
[],
true
true,
<<<'PHPSTAN'
parameters:
type_coverage:
return: 5
param: 5
# enable on PHP 7.4+
# property: 5
# enable on PHP 8.3+
# constant: 5
PHPSTAN
);

$tools[] = new Tool(
Expand All @@ -59,7 +69,16 @@ public function fetchAll(): array
'https://tomasvotruba.com/blog/can-phpstan-find-dead-public-methods/',
'composer require tomasvotruba/unused-public --dev',
[],
true
true,
<<<'PHPSTAN'
parameters:
unused_public:
constants: true
# handle one by one
# properties: true
# methods: true
PHPSTAN

);

$tools[] = new Tool(
Expand All @@ -83,7 +102,17 @@ public function fetchAll(): array
'https://getrector.com/blog/introducing-type-perfect-for-extra-safety',
'composer require rector/type-perfect --dev',
[],
true
true,
<<<'PHPSTAN'
parameters:
type_perfect:
null_over_false: true
# enable one a by one
# no_mixed: true
# narrow_param: true
# narrow_return: true
PHPSTAN

);

$tools[] = new Tool(
Expand Down
8 changes: 7 additions & 1 deletion app/ValueObject/Tool.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public function __construct(
private string $composer,
private array $tryCommands = [],
private bool $isPhpstanExtension = false,
private ?string $phpstanContents = null,
) {
Assert::allString(array_keys($tryCommands));
Assert::allString($tryCommands);
Expand Down Expand Up @@ -50,7 +51,7 @@ public function getPost(): ?string
return $this->post;
}

public function getComposer(): ?string
public function getComposer(): string
{
return $this->composer;
}
Expand All @@ -72,4 +73,9 @@ public function getSlug(): string
{
return str($this->name)->slug()->toString();
}

public function getPhpstanContents(): ?string
{
return $this->phpstanContents;
}
}
9 changes: 9 additions & 0 deletions resources/css/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -396,3 +396,12 @@ pre.shiki {
margin-right: 1rem;
flex-shrink: 0;
}

// hover of badge
a > .text-bg-dark {
background-color: rgba(77, 81, 84, 0.82) !important;

&:hover {
background-color: #4d5154 !important;
}
}
60 changes: 42 additions & 18 deletions resources/views/tools.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,22 @@
<div class="col-12 col-lg-6">
<div class="card mb-5 shadow">
<div class="card-body ps-4 pe-4">
<a href="{{ $tool->getLink() }}" class="btn btn-sm btn-dark
mt-3 float-end">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512" style="width:1.1em;" fill="white"><!--!Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3 .3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5 .3-6.2 2.3zm44.2-1.7c-2.9 .7-4.9 2.6-4.6 4.9 .3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3 .7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3 .3 2.9 2.3 3.9 1.6 1 3.6 .7 4.3-.7 .7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3 .7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3 .7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"/></svg>
<a name="{{ $tool->getSlug() }}"></a>

&nbsp;Github
<a href="{{ $tool->getLink() }}" class="me-2" style="text-decoration: none;">
<div class="badge text-bg-dark">GitHub</div>
</a>

<a name="{{ $tool->getSlug() }}"></a>
<h2 class="mt-3">{{ $tool->getName() }}</h2>

@if ($tool->isPhpstanExtension())
<div class="badge text-bg-warning">PHPStan extension</div>
@endif

<h2 class="mt-5" style="font-size: 2em; margin-bottom: 1.1em">{{ $tool->getName() }}</h2>

<p class="mt-5">
<em class="text-secondary">Why use?</em>
</p><p>
</p>
<p>
{{ $tool->getWhy() }}
</p>

Expand All @@ -57,30 +56,40 @@
</p>
</div>

@if ($tool->getComposer())
<div class="card-body border-top border-primary border-bottom bg-primary-subtle">
<div class="card-body border-top border-primary border-bottom bg-primary-subtle">
<div class="form-floating m-2">
<textarea class="form-control border border-primary">{{ $tool->getComposer() }}</textarea>
<label>Install</label>
</div>
</div>
@endif
</div>

@if ($tool->getTryCommands())
<div class="card-body mt-2 mb-2 ms-2">
<em class="text-secondary">First commands to try</em>
</div>

@foreach ($tool->getTryCommands() as $label => $tryCommand)
<div class="card-body border-top border-success bg-success-subtle">
<div class="form-floating m-2">
<textarea class="form-control border border-success">{{ $tryCommand }}</textarea>
<label>{{ $label }}</label>
</div>
</div>
@endforeach
@endif

@foreach ($tool->getTryCommands() as $label => $tryCommand)
@if ($tool->getPhpstanContents())
<div class="card-body mt-2 mb-2 ms-2">
<em class="text-secondary">Copy-paste to <code>phpstan.neon</code></em>
</div>

<div class="card-body border-top border-success bg-success-subtle">
<div class="form-floating m-2">
<textarea class="form-control border border-success">{{ $tryCommand }}</textarea>
<label>{{ $label }}</label>
<div class="m-2">
<textarea class="form-control border border-success autoresize">{{ $tool->getPhpstanContents() }}</textarea>
</div>
</div>
@endforeach
</div>
@endif
</div>
</div>

@endforeach
Expand All @@ -95,5 +104,20 @@
this.select();
};
});
// make textarea as long to fit the contents
function autoResize(textarea) {
// Reset height to handle reducing content
textarea.style.height = 'auto';
// Set height to match the scroll height (content height)
textarea.style.height = textarea.scrollHeight + 5 + 'px';
}
// Trigger resize for all textareas with the class "autoresize" on page load
document.addEventListener('DOMContentLoaded', function() {
document.querySelectorAll('.autoresize').forEach(textarea => {
autoResize(textarea);
});
});
</script>
@endsection

0 comments on commit 73ba92b

Please sign in to comment.