mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
Add phpstan ignores
This commit is contained in:
parent
7d6b4d6e5b
commit
0e0847c200
3 changed files with 20 additions and 5 deletions
|
|
@ -7179,3 +7179,14 @@ parameters:
|
|||
message: "#^Method Sylius\\\\Component\\\\User\\\\Security\\\\Checker\\\\TokenUniquenessChecker\\:\\:__construct\\(\\) has parameter \\$repository with generic interface Sylius\\\\Component\\\\Resource\\\\Repository\\\\RepositoryInterface but does not specify its types\\: T$#"
|
||||
count: 1
|
||||
path: src/Sylius/Component/User/Security/Checker/TokenUniquenessChecker.php
|
||||
|
||||
-
|
||||
message: "#^Call to method sanitize\\(\\) on an unknown class enshrined\\\\svgSanitize\\\\Sanitizer.$#"
|
||||
count: 1
|
||||
path: src/Sylius/Component/Core/Uploader/ImageUploader.php
|
||||
|
||||
-
|
||||
message: "#^Property Sylius\\\\Component\\\\Core\\\\Uploader\\\\ImageUploader\\:\\:\\$sanitizer has unknown class enshrined\\\\svgSanitize\\\\Sanitizer as its type.$#"
|
||||
count: 1
|
||||
path: src/Sylius/Component/Core/Uploader/ImageUploader.php
|
||||
|
||||
|
|
|
|||
|
|
@ -133,7 +133,9 @@
|
|||
<argument>%sylius_core.max_int_value%</argument>
|
||||
<tag name="validator.constraint_validator" alias="sylius_max_integer" />
|
||||
</service>
|
||||
|
||||
<service id="sylius.validator.max_integer" alias="Sylius\Bundle\CoreBundle\Validator\Constraints\MaxIntegerValidator" />
|
||||
|
||||
<service id="sylius.validator.allowed_mime_types" class="Sylius\Bundle\CoreBundle\Validator\Constraints\AllowedImageMimeTypesValidator">
|
||||
<argument>%sylius_core.allowed_images_mime_types%</argument>
|
||||
<tag name="validator.constraint_validator" alias="sylius_image_allowed_mime_types_validator" />
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace Sylius\Component\Core\Uploader;
|
||||
|
||||
use enshrined\svgSanitize\Sanitizer;
|
||||
use Gaufrette\FilesystemInterface;
|
||||
use Sylius\Component\Core\Filesystem\Adapter\FilesystemAdapterInterface;
|
||||
use Sylius\Component\Core\Filesystem\Adapter\GaufretteFilesystemAdapter;
|
||||
|
|
@ -30,8 +29,8 @@ class ImageUploader implements ImageUploaderInterface
|
|||
|
||||
private const MIME_SVG = 'image/svg';
|
||||
|
||||
/** @var Sanitizer */
|
||||
protected $sanitizer;
|
||||
/** @var \enshrined\svgSanitize\Sanitizer|null */
|
||||
protected ?object $sanitizer = null;
|
||||
|
||||
public function __construct(
|
||||
/** @var FilesystemAdapterInterface $filesystem */
|
||||
|
|
@ -59,7 +58,10 @@ class ImageUploader implements ImageUploaderInterface
|
|||
}
|
||||
|
||||
$this->imagePathGenerator = $imagePathGenerator ?? new UploadedImagePathGenerator();
|
||||
$this->sanitizer = new Sanitizer();
|
||||
|
||||
if (class_exists(\enshrined\svgSanitize\Sanitizer::class)) {
|
||||
$this->sanitizer = new \enshrined\svgSanitize\Sanitizer();
|
||||
}
|
||||
}
|
||||
|
||||
public function upload(ImageInterface $image): void
|
||||
|
|
@ -101,7 +103,7 @@ class ImageUploader implements ImageUploaderInterface
|
|||
|
||||
protected function sanitizeContent(string $fileContent, string $mimeType): string
|
||||
{
|
||||
if (self::MIME_SVG_XML === $mimeType || self::MIME_SVG === $mimeType) {
|
||||
if ((self::MIME_SVG_XML === $mimeType || self::MIME_SVG === $mimeType) && $this->sanitizer !== null) {
|
||||
$fileContent = $this->sanitizer->sanitize($fileContent);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue