Repository: symfony/ux (php)

Issue:
Deprecate LazyImage for 2.x, remove it for 3.x
The [documentation already mention that LazyImage is no longer recommended](https://github.com/symfony/ux/blob/2.x/src/LazyImage/doc/index.rst), but I believe we can make it more "official".

Pull request:
[LazyImage] Deprecate the package
| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes <!-- please update src/**/CHANGELOG.md files -->
| Docs?         | no <!-- required for new features -->
| Issues        | Fix #2732 <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License       | MIT

<!--
Replace this notice by a description of your feature/bugfix.
This will help reviewers and should be a good start for the documentation.

Additionally (see https://symfony.com/releases):
 - Always add tests and ensure they pass.
 - For new features, provide some code snippets to help understand usage.
 - Features and deprecations must be submitted against branch main.
 - Update/add documentation as required (we can help!)
 - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry
 - Never break backward compatibility (see https://symfony.com/bc).
-->

I must admit my defeat here @smnandre and @javiereguiluz, you finally got me 😛 


Patch:
diff --git a/src/LazyImage/CHANGELOG.md b/src/LazyImage/CHANGELOG.md
index bb989a0e..7a27e2ba 100644
--- a/src/LazyImage/CHANGELOG.md
+++ b/src/LazyImage/CHANGELOG.md
@@ -1,5 +1,9 @@
 # CHANGELOG
 
+## 2.27.0
+
+-   Deprecate the package
+
 ## 2.17.0
 
 -   Add support for `intervention/image` 3.0+
diff --git a/src/LazyImage/README.md b/src/LazyImage/README.md
index 8a771c40..2578b75b 100644
--- a/src/LazyImage/README.md
+++ b/src/LazyImage/README.md
@@ -1,5 +1,15 @@
 # Symfony UX LazyImage
 
+> [!WARNING]
+> **Deprecated**: This package has been **deprecated** in 2.x and will be removed in the next major version.
+
+The package has been deprecated in favor of [modern techniques to improve image loading performance](https://web.dev/learn/images/performance-issues) natively supported
+by all major browsers (`<img loading="lazy">`).
+
+To keep using BlurHash functionality, you can use the package [kornrunner/php-blurhash](https://github.com/kornrunner/php-blurhash).
+
+---
+
 Symfony UX LazyImage is a Symfony bundle providing utilities to improve
 image loading performance. It is part of [the Symfony UX initiative](https://ux.symfony.com/).
 
diff --git a/src/LazyImage/composer.json b/src/LazyImage/composer.json
index b964763c..f15a99ed 100644
--- a/src/LazyImage/composer.json
+++ b/src/LazyImage/composer.json
@@ -31,7 +31,8 @@
         "php": ">=8.1",
         "symfony/config": "^5.4|^6.0|^7.0",
         "symfony/http-kernel": "^5.4|^6.0|^7.0",
-        "symfony/dependency-injection": "^5.4|^6.0|^7.0"
+        "symfony/dependency-injection": "^5.4|^6.0|^7.0",
+        "symfony/deprecation-contracts": "^2.5|^3"
     },
     "require-dev": {
         "intervention/image": "^2.5|^3.0",
diff --git a/src/LazyImage/doc/index.rst b/src/LazyImage/doc/index.rst
index 89126924..fd767d00 100644
--- a/src/LazyImage/doc/index.rst
+++ b/src/LazyImage/doc/index.rst
@@ -7,6 +7,10 @@ Symfony UX LazyImage
     `modern techniques to improve image loading performance`_ natively supported
     by all major browsers.
 
+.. warning::
+
+    **Deprecated: This package has been deprecated in 2.x and will be removed in the next major version.**
+
 Symfony UX LazyImage is a Symfony bundle providing utilities to improve
 image loading performance. It is part of `the Symfony UX initiative`_.
 
diff --git a/src/LazyImage/phpunit.xml.dist b/src/LazyImage/phpunit.xml.dist
index ba15dfc2..8fe2e0f2 100644
--- a/src/LazyImage/phpunit.xml.dist
+++ b/src/LazyImage/phpunit.xml.dist
@@ -14,7 +14,7 @@
         <ini name="intl.error_level" value="0" />
         <ini name="memory_limit" value="-1" />
         <env name="SHELL_VERBOSITY" value="-1" />
-        <server name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0&amp;max[direct]=0"/>
+        <server name="SYMFONY_DEPRECATIONS_HELPER" value="ignoreFile=./tests/baseline-ignore&amp;max[self]=0&amp;max[direct]=0"/>
     </php>
 
     <testsuites>
diff --git a/src/LazyImage/src/BlurHash/BlurHash.php b/src/LazyImage/src/BlurHash/BlurHash.php
index 447a6f4f..6778e029 100644
--- a/src/LazyImage/src/BlurHash/BlurHash.php
+++ b/src/LazyImage/src/BlurHash/BlurHash.php
@@ -18,6 +18,8 @@ use Intervention\Image\ImageManagerStatic;
 use kornrunner\Blurhash\Blurhash as BlurhashEncoder;
 use Symfony\Contracts\Cache\CacheInterface;
 
+trigger_deprecation('symfony/ux-lazy-image', '2.27.0', 'The package is deprecated and will be removed in 3.0.');
+
 /**
  * @author Titouan Galopin <galopintitouan@gmail.com>
  *
diff --git a/src/LazyImage/src/BlurHash/BlurHashInterface.php b/src/LazyImage/src/BlurHash/BlurHashInterface.php
index c4ac1d7f..aaad364b 100644
--- a/src/LazyImage/src/BlurHash/BlurHashInterface.php
+++ b/src/LazyImage/src/BlurHash/BlurHashInterface.php
@@ -11,6 +11,8 @@
 
 namespace Symfony\UX\LazyImage\BlurHash;
 
+trigger_deprecation('symfony/ux-lazy-image', '2.27.0', 'The package is deprecated and will be removed in 3.0.');
+
 /**
  * @author Titouan Galopin <galopintitouan@gmail.com>
  */
diff --git a/src/LazyImage/src/DependencyInjection/Configuration.php b/src/LazyImage/src/DependencyInjection/Configuration.php
index 4c2fd632..9e4927d6 100644
--- a/src/LazyImage/src/DependencyInjection/Configuration.php
+++ b/src/LazyImage/src/DependencyInjection/Configuration.php
@@ -14,6 +14,8 @@ namespace Symfony\UX\LazyImage\DependencyInjection;
 use Symfony\Component\Config\Definition\Builder\TreeBuilder;
 use Symfony\Component\Config\Definition\ConfigurationInterface;
 
+trigger_deprecation('symfony/ux-lazy-image', '2.27.0', 'The package is deprecated and will be removed in 3.0.');
+
 /**
  * @author Hugo Alliaume <hugo@alliau.me>
  *
diff --git a/src/LazyImage/src/DependencyInjection/LazyImageExtension.php b/src/LazyImage/src/DependencyInjection/LazyImageExtension.php
index ccddfd34..52405f71 100644
--- a/src/LazyImage/src/DependencyInjection/LazyImageExtension.php
+++ b/src/LazyImage/src/DependencyInjection/LazyImageExtension.php
@@ -25,6 +25,8 @@ use Symfony\UX\LazyImage\BlurHash\BlurHashInterface;
 use Symfony\UX\LazyImage\Twig\BlurHashExtension;
 use Symfony\UX\LazyImage\Twig\BlurHashRuntime;
 
+trigger_deprecation('symfony/ux-lazy-image', '2.27.0', 'The package is deprecated and will be removed in 3.0.');
+
 /**
  * @author Titouan Galopin <galopintitouan@gmail.com>
  *
diff --git a/src/LazyImage/src/LazyImageBundle.php b/src/LazyImage/src/LazyImageBundle.php
index b222a688..b39725c9 100644
--- a/src/LazyImage/src/LazyImageBundle.php
+++ b/src/LazyImage/src/LazyImageBundle.php
@@ -13,6 +13,8 @@ namespace Symfony\UX\LazyImage;
 
 use Symfony\Component\HttpKernel\Bundle\Bundle;
 
+trigger_deprecation('symfony/ux-lazy-image', '2.27.0', 'The package is deprecated and will be removed in 3.0.');
+
 /**
  * @author Titouan Galopin <galopintitouan@gmail.com>
  *
diff --git a/src/LazyImage/src/Twig/BlurHashExtension.php b/src/LazyImage/src/Twig/BlurHashExtension.php
index 5ac2f3b5..1b31a233 100644
--- a/src/LazyImage/src/Twig/BlurHashExtension.php
+++ b/src/LazyImage/src/Twig/BlurHashExtension.php
@@ -14,6 +14,8 @@ namespace Symfony\UX\LazyImage\Twig;
 use Twig\Extension\AbstractExtension;
 use Twig\TwigFunction;
 
+trigger_deprecation('symfony/ux-lazy-image', '2.27.0', 'The package is deprecated and will be removed in 3.0.');
+
 /**
  * @author Titouan Galopin <galopintitouan@gmail.com>
  *
diff --git a/src/LazyImage/src/Twig/BlurHashRuntime.php b/src/LazyImage/src/Twig/BlurHashRuntime.php
index 49d931ca..25a96466 100644
--- a/src/LazyImage/src/Twig/BlurHashRuntime.php
+++ b/src/LazyImage/src/Twig/BlurHashRuntime.php
@@ -14,6 +14,8 @@ namespace Symfony\UX\LazyImage\Twig;
 use Symfony\UX\LazyImage\BlurHash\BlurHashInterface;
 use Twig\Extension\RuntimeExtensionInterface;
 
+trigger_deprecation('symfony/ux-lazy-image', '2.27.0', 'The package is deprecated and will be removed in 3.0.');
+
 /**
  * @author Hugo Alliaume <hugo@alliau.me>
  */


Test patch:
diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml
index 7891d8c3..2d0d8b52 100644
--- a/.github/workflows/unit-tests.yaml
+++ b/.github/workflows/unit-tests.yaml
@@ -51,7 +51,14 @@ jobs:
                   [ 'lowest' = '${{ matrix.dependency-version }}' ] && export SYMFONY_DEPRECATIONS_HELPER=weak
 
                   # Swup and Typed have no tests, Turbo has its own workflow file
-                  PACKAGES=$(find src/ -mindepth 2 -type f -name composer.json -not -path "*/vendor/*" -printf '%h\n' | sed 's/^src\///' | grep -Ev "Swup|Turbo|Typed" | sort |  tr '\n' ' ')
+                  EXCLUDED_PACKAGES="Typed|Swup|Turbo"
+
+                  # Exclude deprecated packages when testing against lowest dependencies
+                  if [ "${{ matrix.dependency-version }}" = "lowest" ]; then
+                    EXCLUDED_PACKAGES="$EXCLUDED_PACKAGES|LazyImage"
+                  fi
+
+                  PACKAGES=$(find src/ -mindepth 2 -type f -name composer.json -not -path "*/vendor/*" -printf '%h\n' | sed 's/^src\///' | grep -Ev "$EXCLUDED_PACKAGES" | sort |  tr '\n' ' ')
                   echo "Packages: $PACKAGES"
                   echo "PACKAGES=$PACKAGES" >> $GITHUB_ENV
 
diff --git a/src/LazyImage/tests/baseline-ignore b/src/LazyImage/tests/baseline-ignore
new file mode 100644
index 00000000..8661cedc
--- /dev/null
+++ b/src/LazyImage/tests/baseline-ignore
@@ -0,0 +1,1 @@
+%Since symfony/ux-lazy-image 2\.27\.0: The package is deprecated and will be removed in 3\.0\.%
diff --git a/ux.symfony.com/tests/baseline-ignore b/ux.symfony.com/tests/baseline-ignore
index ed1c435d..b6c26bc2 100644
--- a/ux.symfony.com/tests/baseline-ignore
+++ b/ux.symfony.com/tests/baseline-ignore
@@ -1,1 +1,2 @@
 %Since symfony/ux-typed 2\.27\.0: The package is deprecated and will be removed in 3\.0\.%
+%Since symfony/ux-lazy-image 2\.27\.0: The package is deprecated and will be removed in 3\.0\.%