Skip to content

Commit f77a876

Browse files
committed
cs fixes
1 parent cbc304b commit f77a876

File tree

5 files changed

+36
-11
lines changed

5 files changed

+36
-11
lines changed

src/Icons/src/DependencyInjection/UXIconsExtension.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use Symfony\Component\Config\FileLocator;
1717
use Symfony\Component\DependencyInjection\ContainerBuilder;
1818
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
19-
use Symfony\Component\DependencyInjection\Reference;
2019
use Symfony\Component\HttpKernel\DependencyInjection\ConfigurableExtension;
2120

2221
/**

src/Icons/src/Svg/Icon.php

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Symfony\UX\Icons\Svg;
413

514
/**
6-
*
715
* @author Simon André <[email protected]>
816
*
917
* @internal
@@ -14,6 +22,7 @@ final class Icon implements \Stringable, \Serializable, \ArrayAccess
1422
* Transforms a valid icon ID into an icon name.
1523
*
1624
* @throws \InvalidArgumentException if the ID is not valid
25+
*
1726
* @see isValidId()
1827
*/
1928
public static function idToName(string $id): string
@@ -29,6 +38,7 @@ public static function idToName(string $id): string
2938
* Transforms a valid icon name into an ID.
3039
*
3140
* @throws \InvalidArgumentException if the name is not valid
41+
*
3242
* @see isValidName()
3343
*/
3444
public static function nameToId(string $name): string
@@ -69,8 +79,7 @@ public static function isValidName(string $name): bool
6979
public function __construct(
7080
private readonly string $innerSvg,
7181
private readonly array $attributes = [],
72-
)
73-
{
82+
) {
7483
// @todo validate attributes (?)
7584
// the main idea is to have a way to validate the attributes
7685
// before the icon is cached to improve performances
@@ -86,8 +95,8 @@ public function toHtml(): string
8695
}
8796
$htmlAttributes .= ' '.$name;
8897
if (true !== $value) {
89-
$value = htmlspecialchars($value, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
90-
$htmlAttributes .= '="'. $value .'"';
98+
$value = htmlspecialchars($value, \ENT_QUOTES | \ENT_SUBSTITUTE, 'UTF-8');
99+
$htmlAttributes .= '="'.$value.'"';
91100
}
92101
}
93102

@@ -109,19 +118,18 @@ public function getAttributes(): array
109118

110119
/**
111120
* @param array<string, string|bool> $attributes
112-
* @return self
113121
*/
114122
public function withAttributes(array $attributes): self
115123
{
116124
foreach ($attributes as $name => $value) {
117-
if (!is_string($name)) {
125+
if (!\is_string($name)) {
118126
throw new \InvalidArgumentException(sprintf('Attribute names must be string, "%s" given.', get_debug_type($name)));
119127
}
120128
// @todo regexp would be better ?
121129
if (!ctype_alnum($name) && !str_contains($name, '-')) {
122130
throw new \InvalidArgumentException(sprintf('Invalid attribute name "%s".', $name));
123131
}
124-
if (!is_string($value) && !is_bool($value)) {
132+
if (!\is_string($value) && !\is_bool($value)) {
125133
throw new \InvalidArgumentException(sprintf('Invalid value type for attribute "%s". Boolean or string allowed, "%s" provided. ', $name, get_debug_type($value)));
126134
}
127135
}

src/Icons/src/Twig/UXIconComponentListener.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Symfony\UX\Icons\Twig;
413

514
use Symfony\UX\Icons\IconRenderer;

src/Icons/tests/Integration/Twig/UXIconExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function testRenderIcons(): void
4141
<li id="sixth"><svg viewBox="0 0 24 24" fill="currentColor"><path fill-rule="evenodd" d="M19.916 4.626a.75.75 0 0 1 .208 1.04l-9 13.5a.75.75 0 0 1-1.154.114l-6-6a.75.75 0 0 1 1.06-1.06l5.353 5.353 8.493-12.74a.75.75 0 0 1 1.04-.207Z" clip-rule="evenodd"></path></svg></li>
4242
</ul>
4343
HTML,
44-
preg_replace("#(\s+)</li>#m", "</li>", $output)
44+
preg_replace("#(\s+)</li>#m", '</li>', $output)
4545
);
4646
}
4747
}

src/Icons/tests/Unit/Svg/IconTest.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Symfony\UX\Icons\Tests\Unit\Svg;
413

514
use PHPUnit\Framework\TestCase;
615
use Symfony\UX\Icons\Svg\Icon;
716

8-
class IconTest extends TestCase
17+
final class IconTest extends TestCase
918
{
1019
public function testConstructor()
1120
{

0 commit comments

Comments
 (0)