Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Dmitri Perunov <[email protected]>
  • Loading branch information
loic425 and diimpp authored Jun 21, 2024
1 parent d93f990 commit 07bac40
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 15 deletions.
2 changes: 1 addition & 1 deletion docs/twig-extra/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ This is slightly the same behaviour as `sylius_test_html_attribute` Twig functio
```

```html
<!-- The real results depend on your form theme. -->
<!-- Actual html output bellow depends on your form theme -->
<label for="book_title">Title</label>
<input
type="text"
Expand Down
2 changes: 1 addition & 1 deletion src/TwigExtra/config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
return function (ContainerConfigurator $configurator): void {
$services = $configurator->services();

$services->set('twig_extra.twig.extension.test_form_attribute', TestFormAttributeExtension::class)
$services->set('sylius_twig_extra.twig.extension.test_form_attribute', TestFormAttributeExtension::class)
->args([
param('kernel.environment'),
param('kernel.debug'),
Expand Down
6 changes: 2 additions & 4 deletions src/TwigExtra/src/Twig/Extension/SortByExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,14 @@ public function getFilters(): array
];
}

/**
* @throws NoSuchPropertyException
*/
/** @throws NoSuchPropertyException */
public function sortBy(iterable $iterable, string $field, string $order = 'ASC'): array
{
$array = $this->transformIterableToArray($iterable);

usort(
$array,
function (array|object $firstElement, array|object $secondElement) use ($field, $order) {
function (array|object $firstElement, array|object $secondElement): int use ($field, $order) {
$accessor = PropertyAccess::createPropertyAccessor();

$firstProperty = (string) $accessor->getValue($firstElement, $field);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@ final class TestFormAttributeExtension extends AbstractExtension
public function __construct(
private readonly string $environment,
private readonly bool $isDebugEnabled,
)
{
) {
}

/**
* @return TwigFunction[]
*/
/** @return TwigFunction[] */
public function getFunctions(): array
{
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ public function __construct(
) {
}

/**
* @return TwigFunction[]
*/
/** @return TwigFunction[] */
public function getFunctions(): array
{
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public function testItReturnsInputArrayIfThereIsOnlyOneObjectInside(): void
{
$data = [(object) []];

$this->assertEquals($data, (new SortByExtension())->sortBy($data, 'property'), );
$this->assertEquals($data, (new SortByExtension())->sortBy($data, 'property'));
}

public function testItDoesNothingIfArrayIsEmpty(): void
Expand Down

0 comments on commit 07bac40

Please sign in to comment.