Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
strategy:
max-parallel: 15
matrix:
php-versions: ['8.2', '8.3', '8.4']
php-versions: ['8.2', '8.3', '8.4', '8.5']
steps:
- name: Checkout
uses: actions/checkout@v5
Expand Down
10 changes: 2 additions & 8 deletions src/Bridge/EasyAdmin/src/Form/Type/MediaChoiceType.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@ public function __construct(
) {
}

/**
* @return string
*/
#[\Override]
public function getParent()
public function getParent(): string
{
return TextType::class;
}
Expand All @@ -37,10 +34,7 @@ public function getName(): string
return 'media_choice';
}

/**
* @return string
*/
public function getBlockPrefix()
public function getBlockPrefix(): string
{
return 'joli_media_easy_admin_choice';
}
Expand Down
10 changes: 2 additions & 8 deletions src/Bridge/SonataAdmin/src/Form/Type/MediaChoiceType.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@ public function __construct(
) {
}

/**
* @return string
*/
#[\Override]
public function getParent()
public function getParent(): string
{
return TextType::class;
}
Expand All @@ -37,10 +34,7 @@ public function getName(): string
return 'media_choice';
}

/**
* @return string
*/
public function getBlockPrefix()
public function getBlockPrefix(): string
{
return 'joli_media_sonata_admin_choice';
}
Expand Down
29 changes: 18 additions & 11 deletions tests/src/Twig/Component/PictureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ public function testComponents(string $component, array $configuration, string $
$img = $crawler->filterXPath('//body/*')->first();
$html = preg_replace(['/(\n\s*)+/', '/\s+/'], ['', ' '], $img->outerHtml());

// @phpstan-ignore-next-line
if (Kernel::MAJOR_VERSION < 8 && !(Kernel::MAJOR_VERSION === 7 && Kernel::MINOR_VERSION === 4 && \PHP_VERSION_ID >= 80400)) {
// Since Symfony 7.4 with PHP 8.4, the native HTML5 parser is used unconditionally
$expected = str_replace('</source>', '', $expected);
$expected = str_replace('&gt;', '>', $expected);
}
Comment on lines +110 to +114
Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conditional logic appears to be inverted. The condition checks if Symfony version is less than 8, but the expected strings now include </source> tags and &gt; entities, which according to the comment are used since Symfony 7.4 with PHP 8.4 (native HTML5 parser).

The condition should be checking if the version is >= 8 OR (>= 7.4 with PHP >= 8.4), not the inverse. Consider:

if (Kernel::MAJOR_VERSION >= 8 || (Kernel::MAJOR_VERSION === 7 && Kernel::MINOR_VERSION >= 4 && \PHP_VERSION_ID >= 80400)) {
    // Since Symfony 7.4 with PHP 8.4, the native HTML5 parser is used unconditionally
    $expected = str_replace('</source>', '', $expected);
    $expected = str_replace('&gt;', '>', $expected);
}

This way, for newer versions that use the HTML5 parser, we strip the closing tags and decode entities from the expected output to match the actual parser behavior.

Copilot uses AI. Check for mistakes.

if ($expected !== $html) {
echo "\n\n" . $html . "\n\n";
}
Expand All @@ -125,7 +132,7 @@ public static function provideComponentsData(): \Generator
'variation' => 'variation-standard',
'alt' => 'Alternative text',
],
'<picture><source srcset="/media/cache/variation-standard-webp/circle-pattern.d601f6f2.webp" type="image/webp" width="145" height="109"><img src="/media/cache/variation-standard/circle-pattern.jpg" loading="lazy" decoding="async" alt="Alternative text" width="145" height="109"></picture>',
'<picture><source srcset="/media/cache/variation-standard-webp/circle-pattern.d601f6f2.webp" type="image/webp" width="145" height="109"></source><img src="/media/cache/variation-standard/circle-pattern.jpg" loading="lazy" decoding="async" alt="Alternative text" width="145" height="109"></picture>',
];
yield 'partial-picture-tag' => [
Picture::class,
Expand All @@ -134,7 +141,7 @@ public static function provideComponentsData(): \Generator
'variation' => 'variation-standard',
'alt' => 'Alternative text',
],
'<picture><source srcset="/media/cache/variation-standard-webp/partially-stored-media.b16d66f4.webp"><img src="/media/cache/variation-standard/partially-stored-media.jpg" loading="lazy" decoding="async" alt="Alternative text"></picture>',
'<picture><source srcset="/media/cache/variation-standard-webp/partially-stored-media.b16d66f4.webp"></source><img src="/media/cache/variation-standard/partially-stored-media.jpg" loading="lazy" decoding="async" alt="Alternative text"></picture>',
];
yield 'picture-with-class' => [
Picture::class,
Expand All @@ -145,7 +152,7 @@ public static function provideComponentsData(): \Generator
'picture:class' => 'picture-class',
'img:class' => 'img-class',
],
'<picture class="picture-class"><source srcset="/media/cache/variation-standard-webp/circle-pattern.d601f6f2.webp" type="image/webp" width="145" height="109"><img src="/media/cache/variation-standard/circle-pattern.jpg" loading="lazy" decoding="async" class="img-class" alt="Alternative text" width="145" height="109"></picture>',
'<picture class="picture-class"><source srcset="/media/cache/variation-standard-webp/circle-pattern.d601f6f2.webp" type="image/webp" width="145" height="109"></source><img src="/media/cache/variation-standard/circle-pattern.jpg" loading="lazy" decoding="async" class="img-class" alt="Alternative text" width="145" height="109"></picture>',
];
yield 'picture-with-sources' => [
Picture::class,
Expand All @@ -157,7 +164,7 @@ public static function provideComponentsData(): \Generator
'img:class' => 'img-class',
'sources' => ['variation-standard', 'variation-large'],
],
'<picture class="picture-class"><source srcset="/media/cache/variation-standard/circle-pattern.jpg" type="image/jpeg" width="145" height="109"><source srcset="/media/cache/variation-large/circle-pattern.jpg" type="image/jpeg" width="800" height="600"><source srcset="/media/cache/variation-standard-webp/circle-pattern.d601f6f2.webp" type="image/webp" width="145" height="109"><img src="/media/cache/variation-standard/circle-pattern.jpg" loading="lazy" decoding="async" class="img-class" alt="Alternative text" width="145" height="109"></picture>',
'<picture class="picture-class"><source srcset="/media/cache/variation-standard/circle-pattern.jpg" type="image/jpeg" width="145" height="109"></source><source srcset="/media/cache/variation-large/circle-pattern.jpg" type="image/jpeg" width="800" height="600"></source><source srcset="/media/cache/variation-standard-webp/circle-pattern.d601f6f2.webp" type="image/webp" width="145" height="109"></source><img src="/media/cache/variation-standard/circle-pattern.jpg" loading="lazy" decoding="async" class="img-class" alt="Alternative text" width="145" height="109"></picture>',
];
yield 'picture-with-sources-and-skipAutoDimensions' => [
Picture::class,
Expand All @@ -170,7 +177,7 @@ public static function provideComponentsData(): \Generator
'sources' => ['variation-standard', 'variation-large'],
'skipAutoDimensions' => true,
],
'<picture class="picture-class"><source srcset="/media/cache/variation-standard/circle-pattern.jpg" type="image/jpeg"><source srcset="/media/cache/variation-large/circle-pattern.jpg" type="image/jpeg"><source srcset="/media/cache/variation-standard-webp/circle-pattern.d601f6f2.webp" type="image/webp"><img src="/media/cache/variation-standard/circle-pattern.jpg" loading="lazy" decoding="async" class="img-class" alt="Alternative text"></picture>',
'<picture class="picture-class"><source srcset="/media/cache/variation-standard/circle-pattern.jpg" type="image/jpeg"></source><source srcset="/media/cache/variation-large/circle-pattern.jpg" type="image/jpeg"></source><source srcset="/media/cache/variation-standard-webp/circle-pattern.d601f6f2.webp" type="image/webp"></source><img src="/media/cache/variation-standard/circle-pattern.jpg" loading="lazy" decoding="async" class="img-class" alt="Alternative text"></picture>',
];
yield 'partial-picture-with-sources' => [
Picture::class,
Expand All @@ -182,7 +189,7 @@ public static function provideComponentsData(): \Generator
'img:class' => 'img-class',
'sources' => ['variation-standard', 'variation-large'],
],
'<picture class="picture-class"><source srcset="/media/cache/variation-standard/partially-stored-media.jpg"><source srcset="/media/cache/variation-large/partially-stored-media.jpg"><source srcset="/media/cache/variation-standard-webp/partially-stored-media.b16d66f4.webp"><img src="/media/cache/variation-standard/partially-stored-media.jpg" loading="lazy" decoding="async" class="img-class" alt="Alternative text"></picture>',
'<picture class="picture-class"><source srcset="/media/cache/variation-standard/partially-stored-media.jpg"></source><source srcset="/media/cache/variation-large/partially-stored-media.jpg"></source><source srcset="/media/cache/variation-standard-webp/partially-stored-media.b16d66f4.webp"></source><img src="/media/cache/variation-standard/partially-stored-media.jpg" loading="lazy" decoding="async" class="img-class" alt="Alternative text"></picture>',
];
yield 'partial-picture-with-sources-and-skipAutoDimensions' => [
Picture::class,
Expand All @@ -195,7 +202,7 @@ public static function provideComponentsData(): \Generator
'sources' => ['variation-standard', 'variation-large'],
'skipAutoDimensions' => true,
],
'<picture class="picture-class"><source srcset="/media/cache/variation-standard/partially-stored-media.jpg"><source srcset="/media/cache/variation-large/partially-stored-media.jpg"><source srcset="/media/cache/variation-standard-webp/partially-stored-media.b16d66f4.webp"><img src="/media/cache/variation-standard/partially-stored-media.jpg" loading="lazy" decoding="async" class="img-class" alt="Alternative text"></picture>',
'<picture class="picture-class"><source srcset="/media/cache/variation-standard/partially-stored-media.jpg"></source><source srcset="/media/cache/variation-large/partially-stored-media.jpg"></source><source srcset="/media/cache/variation-standard-webp/partially-stored-media.b16d66f4.webp"></source><img src="/media/cache/variation-standard/partially-stored-media.jpg" loading="lazy" decoding="async" class="img-class" alt="Alternative text"></picture>',
];
yield 'auto-generate-partial-picture-with-sources' => [
Picture::class,
Expand All @@ -208,7 +215,7 @@ public static function provideComponentsData(): \Generator
'img:class' => 'img-class',
'sources' => ['variation-standard'],
],
'<picture class="picture-class"><source srcset="/media-auto-generate/cache/variation-standard/partially-stored-media.jpg" type="image/jpeg" width="145" height="109"><source srcset="/media-auto-generate/cache/variation-standard-webp/partially-stored-media.b16d66f4.webp" type="image/webp" width="145" height="109"><img src="/media-auto-generate/cache/variation-standard/partially-stored-media.jpg" loading="lazy" decoding="async" class="img-class" alt="Alternative text" width="145" height="109"></picture>',
'<picture class="picture-class"><source srcset="/media-auto-generate/cache/variation-standard/partially-stored-media.jpg" type="image/jpeg" width="145" height="109"></source><source srcset="/media-auto-generate/cache/variation-standard-webp/partially-stored-media.b16d66f4.webp" type="image/webp" width="145" height="109"></source><img src="/media-auto-generate/cache/variation-standard/partially-stored-media.jpg" loading="lazy" decoding="async" class="img-class" alt="Alternative text" width="145" height="109"></picture>',
];
yield 'picture-with-media-and-string-srcset' => [
Picture::class,
Expand All @@ -226,7 +233,7 @@ public static function provideComponentsData(): \Generator
'srcset' => 'variation-large',
]],
],
'<picture class="picture-class"><source media="(min-width: 1024px)" srcset="/media/cache/variation-extra-large-webp/circle-pattern.d601f6f2.webp" type="image/webp" width="1800" height="1200"><source media="(min-width: 1024px)" srcset="/media/cache/variation-extra-large/circle-pattern.jpg" type="image/jpeg" width="1800" height="1200"><source media="(max-width: 1023px)" srcset="/media/cache/variation-large-webp/circle-pattern.d601f6f2.webp" type="image/webp" width="800" height="600"><source media="(max-width: 1023px)" srcset="/media/cache/variation-large/circle-pattern.jpg" type="image/jpeg" width="800" height="600"><source srcset="/media/cache/variation-standard-webp/circle-pattern.d601f6f2.webp" type="image/webp" width="145" height="109"><img src="/media/cache/variation-standard/circle-pattern.jpg" loading="lazy" decoding="async" class="img-class" alt="Alternative text" width="145" height="109"></picture>',
'<picture class="picture-class"><source media="(min-width: 1024px)" srcset="/media/cache/variation-extra-large-webp/circle-pattern.d601f6f2.webp" type="image/webp" width="1800" height="1200"></source><source media="(min-width: 1024px)" srcset="/media/cache/variation-extra-large/circle-pattern.jpg" type="image/jpeg" width="1800" height="1200"></source><source media="(max-width: 1023px)" srcset="/media/cache/variation-large-webp/circle-pattern.d601f6f2.webp" type="image/webp" width="800" height="600"></source><source media="(max-width: 1023px)" srcset="/media/cache/variation-large/circle-pattern.jpg" type="image/jpeg" width="800" height="600"></source><source srcset="/media/cache/variation-standard-webp/circle-pattern.d601f6f2.webp" type="image/webp" width="145" height="109"></source><img src="/media/cache/variation-standard/circle-pattern.jpg" loading="lazy" decoding="async" class="img-class" alt="Alternative text" width="145" height="109"></picture>',
];
yield 'picture-with-sources-and-media' => [
Picture::class,
Expand All @@ -252,7 +259,7 @@ public static function provideComponentsData(): \Generator
],
]],
],
'<picture class="picture-class"><source media="(width > 1024px)" sizes="1920px" srcset="/media/cache/variation-extra-large-webp/circle-pattern.d601f6f2.webp 2560w, /media/cache/variation-large-webp/circle-pattern.d601f6f2.webp 1920w" type="image/webp" width="1800" height="1200"><source media="(width > 1024px)" sizes="1920px" srcset="/media/cache/variation-extra-large/circle-pattern.jpg 2560w, /media/cache/variation-large/circle-pattern.jpg 1920w" type="image/jpeg" width="1800" height="1200"><source media="(width >= 768px)" sizes="1024px" srcset="/media/cache/variation-large-webp/circle-pattern.d601f6f2.webp 1600w, /media/cache/variation-standard-webp/circle-pattern.d601f6f2.webp 1024w" type="image/webp" width="800" height="600"><source media="(width >= 768px)" sizes="1024px" srcset="/media/cache/variation-large/circle-pattern.jpg 1600w, /media/cache/variation-standard/circle-pattern.jpg 1024w" type="image/jpeg" width="800" height="600"><source srcset="/media/cache/variation-standard-webp/circle-pattern.d601f6f2.webp" type="image/webp" width="145" height="109"><img src="/media/cache/variation-standard/circle-pattern.jpg" loading="lazy" decoding="async" class="img-class" alt="Alternative text" width="145" height="109"></picture>',
'<picture class="picture-class"><source media="(width &gt; 1024px)" sizes="1920px" srcset="/media/cache/variation-extra-large-webp/circle-pattern.d601f6f2.webp 2560w, /media/cache/variation-large-webp/circle-pattern.d601f6f2.webp 1920w" type="image/webp" width="1800" height="1200"></source><source media="(width &gt; 1024px)" sizes="1920px" srcset="/media/cache/variation-extra-large/circle-pattern.jpg 2560w, /media/cache/variation-large/circle-pattern.jpg 1920w" type="image/jpeg" width="1800" height="1200"></source><source media="(width &gt;= 768px)" sizes="1024px" srcset="/media/cache/variation-large-webp/circle-pattern.d601f6f2.webp 1600w, /media/cache/variation-standard-webp/circle-pattern.d601f6f2.webp 1024w" type="image/webp" width="800" height="600"></source><source media="(width &gt;= 768px)" sizes="1024px" srcset="/media/cache/variation-large/circle-pattern.jpg 1600w, /media/cache/variation-standard/circle-pattern.jpg 1024w" type="image/jpeg" width="800" height="600"></source><source srcset="/media/cache/variation-standard-webp/circle-pattern.d601f6f2.webp" type="image/webp" width="145" height="109"></source><img src="/media/cache/variation-standard/circle-pattern.jpg" loading="lazy" decoding="async" class="img-class" alt="Alternative text" width="145" height="109"></picture>',
];
yield 'partial-picture-with-sources-and-media' => [
Picture::class,
Expand All @@ -278,7 +285,7 @@ public static function provideComponentsData(): \Generator
],
]],
],
'<picture class="picture-class"><source media="(width > 1024px)" sizes="1920px" srcset="/media/cache/variation-extra-large-webp/partially-stored-media.b16d66f4.webp 2560w, /media/cache/variation-large-webp/partially-stored-media.b16d66f4.webp 1920w" type="image/webp"><source media="(width > 1024px)" sizes="1920px" srcset="/media/cache/variation-extra-large/partially-stored-media.jpg 2560w, /media/cache/variation-large/partially-stored-media.jpg 1920w"><source media="(width >= 768px)" sizes="1024px" srcset="/media/cache/variation-large-webp/partially-stored-media.b16d66f4.webp 1600w, /media/cache/variation-standard-webp/partially-stored-media.b16d66f4.webp 1024w" type="image/webp"><source media="(width >= 768px)" sizes="1024px" srcset="/media/cache/variation-large/partially-stored-media.jpg 1600w, /media/cache/variation-standard/partially-stored-media.jpg 1024w"><source srcset="/media/cache/variation-standard-webp/partially-stored-media.b16d66f4.webp"><img src="/media/cache/variation-standard/partially-stored-media.jpg" loading="lazy" decoding="async" class="img-class" alt="Alternative text"></picture>',
'<picture class="picture-class"><source media="(width &gt; 1024px)" sizes="1920px" srcset="/media/cache/variation-extra-large-webp/partially-stored-media.b16d66f4.webp 2560w, /media/cache/variation-large-webp/partially-stored-media.b16d66f4.webp 1920w" type="image/webp"></source><source media="(width &gt; 1024px)" sizes="1920px" srcset="/media/cache/variation-extra-large/partially-stored-media.jpg 2560w, /media/cache/variation-large/partially-stored-media.jpg 1920w"></source><source media="(width &gt;= 768px)" sizes="1024px" srcset="/media/cache/variation-large-webp/partially-stored-media.b16d66f4.webp 1600w, /media/cache/variation-standard-webp/partially-stored-media.b16d66f4.webp 1024w" type="image/webp"></source><source media="(width &gt;= 768px)" sizes="1024px" srcset="/media/cache/variation-large/partially-stored-media.jpg 1600w, /media/cache/variation-standard/partially-stored-media.jpg 1024w"></source><source srcset="/media/cache/variation-standard-webp/partially-stored-media.b16d66f4.webp"></source><img src="/media/cache/variation-standard/partially-stored-media.jpg" loading="lazy" decoding="async" class="img-class" alt="Alternative text"></picture>',
];
}

Expand Down