Skip to content

Commit a739610

Browse files
committed
feature #212 Updates for WebpackEncoreBundle 2.0 (weaverryan)
This PR was squashed before being merged into the 2.x branch. Discussion ---------- Updates for WebpackEncoreBundle 2.0 Hi! Soon we will release the final 1.17, which will deprecate the `stimulus_*` Twig functions in favor of `symfony/stimulus-bundle`. I plan to release 2.0 at the same time, which will be equivalent to 1.17, except without the deprecated code paths. Also the PHP and Symfony minimum requirements are bumped. Cheers! Commits ------- 06a7eb5 Updates for WebpackEncoreBundle 2.0
2 parents b8ff4a6 + 06a7eb5 commit a739610

25 files changed

+48
-1148
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,13 @@ jobs:
1515
fail-fast: false
1616
matrix:
1717
# normal, highest, non-dev installs
18-
php-version: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
18+
php-version: ['8.1', '8.2']
1919
dependency-versions: ['highest']
2020
include:
2121
# testing lowest PHP version with lowest dependencies
22-
- php-version: '7.1'
22+
- php-version: '8.1'
2323
dependency-versions: 'lowest'
2424

25-
# testing dev versions with highest PHP
26-
- php-version: '8.0'
27-
dependency-versions: 'highest'
28-
2925
steps:
3026
- name: "Checkout code"
3127
uses: "actions/checkout@v2"
@@ -51,15 +47,4 @@ jobs:
5147
composer-options: "--prefer-dist --no-progress"
5248

5349
- name: Run tests
54-
env:
55-
SYMFONY_DEPRECATIONS_HELPER: "max[self]=11"
56-
SYMFONY_PHPUNIT_VERSION: "8.5"
57-
run: ./vendor/bin/simple-phpunit
58-
if: matrix.php-version != '7.1'
59-
60-
- name: Run tests
61-
env:
62-
SYMFONY_DEPRECATIONS_HELPER: "max[self]=0"
63-
SYMFONY_PHPUNIT_VERSION: "7.5"
6450
run: ./vendor/bin/simple-phpunit
65-
if: matrix.php-version == '7.1'

.github/workflows/static.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- name: Setup PHP
1414
uses: shivammathur/setup-php@v2
1515
with:
16-
php-version: 8.0
16+
php-version: 8.1
1717
coverage: none
1818
tools: cs2pr
1919

@@ -39,7 +39,7 @@ jobs:
3939
- name: Setup PHP
4040
uses: shivammathur/setup-php@v2
4141
with:
42-
php-version: 8.0
42+
php-version: 8.1
4343
coverage: none
4444
tools: cs2pr
4545

@@ -49,7 +49,7 @@ jobs:
4949
composer-options: "--working-dir=tools/php-cs-fixer"
5050

5151
- name: PHP-CS-Fixer
52-
run: tools/php-cs-fixer/vendor/bin/php-cs-fixer fix --dry-run
52+
run: tools/php-cs-fixer/vendor/bin/php-cs-fixer fix --dry-run --diff
5353

5454
psalm:
5555
name: Psalm
@@ -61,7 +61,7 @@ jobs:
6161
- name: Setup PHP
6262
uses: shivammathur/setup-php@v2
6363
with:
64-
php-version: 8.0
64+
php-version: 8.1
6565
coverage: none
6666
tools: vimeo/psalm:4.11.2
6767

@@ -84,7 +84,7 @@ jobs:
8484
- name: Setup PHP
8585
uses: shivammathur/setup-php@v2
8686
with:
87-
php-version: 8.0
87+
php-version: 8.1
8888
coverage: none
8989
tools: composer-normalize
9090

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## v2.0.0
4+
5+
- Minimum PHP version is now 8.1
6+
- Minimum Symfony version is now 5.4
7+
38
## v1.17.0
49

510
- Deprecated the `stimulus_controller()`, `stimulus_action()` and `stimulus_target`

composer.json

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,18 @@
1010
}
1111
],
1212
"require": {
13-
"php": ">=7.1.3",
14-
"symfony/asset": "^4.4 || ^5.0 || ^6.0",
15-
"symfony/config": "^4.4 || ^5.0 || ^6.0",
16-
"symfony/dependency-injection": "^4.4 || ^5.0 || ^6.0",
17-
"symfony/deprecation-contracts": "^2.1 || ^3.0",
18-
"symfony/http-kernel": "^4.4 || ^5.0 || ^6.0",
19-
"symfony/polyfill-php80": "^1.25.0",
20-
"symfony/service-contracts": "^1.0 || ^2.0 || ^3.0"
13+
"php": ">=8.1.0",
14+
"symfony/asset": "^5.4 || ^6.2",
15+
"symfony/config": "^5.4 || ^6.2",
16+
"symfony/dependency-injection": "^5.4 || ^6.2",
17+
"symfony/http-kernel": "^5.4 || ^6.2",
18+
"symfony/service-contracts": "^3.0"
2119
},
2220
"require-dev": {
23-
"symfony/framework-bundle": "^4.4 || ^5.0 || ^6.0",
24-
"symfony/phpunit-bridge": "^5.3 || ^6.0",
25-
"symfony/twig-bundle": "^4.4 || ^5.0 || ^6.0",
26-
"symfony/web-link": "^4.4 || ^5.0 || ^6.0"
21+
"symfony/framework-bundle": "^5.4 || ^6.2",
22+
"symfony/phpunit-bridge": "^5.4 || ^6.2",
23+
"symfony/twig-bundle": "^5.4 || ^6.2",
24+
"symfony/web-link": "^5.4 || ^6.2"
2725
},
2826
"minimum-stability": "dev",
2927
"autoload": {

doc/index.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,9 @@ different ways:
204204
Stimulus / Symfony UX Helper
205205
----------------------------
206206

207-
The ``stimulus_controller()``, ``stimulus_action()`` and ``stimulus_target()``
208-
Twig functions are deprecated in WebpackEncoreBundle 1.17.0. Install and
209-
use `symfony/stimulus-bundle`_ for that functionality.
207+
Version 1 of this bundle came with ``stimulus_controller()``,
208+
``stimulus_action()`` and ``stimulus_target()`` Twig functions. These have been
209+
removed: use `symfony/stimulus-bundle`_ instead.
210210

211211
.. _`Webpack Encore`: https://symfony.com/doc/current/frontend.html
212212
.. _`enable the bundle manually`: https://symfony.com/doc/current/bundles.html

phpstan-baseline.neon

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,3 @@ parameters:
99
message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\TreeBuilder\\:\\:root\\(\\)\\.$#"
1010
count: 1
1111
path: src/DependencyInjection/Configuration.php
12-
13-
-
14-
message: "#^Function twig_escape_filter not found\\.$#"
15-
count: 1
16-
path: src/Dto/AbstractStimulusDto.php
17-
18-
-
19-
message: "#^Call to function is_array\\(\\) with string will always evaluate to false\\.$#"
20-
count: 2
21-
path: src/Twig/StimulusTwigExtension.php

psalm.baseline.xml

Lines changed: 0 additions & 45 deletions
This file was deleted.

psalm.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
66
xmlns="https://getpsalm.org/schema/config"
77
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
8-
errorBaseline="psalm.baseline.xml"
98
phpVersion="8.0"
109
>
1110
<projectFiles>

src/Asset/EntrypointLookup.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ public function getIntegrityData(): array
6464

6565
/**
6666
* Resets the state of this service.
67+
*
68+
* @return void
6769
*/
6870
public function reset()
6971
{
@@ -89,7 +91,7 @@ private function getEntryFiles(string $entryName, string $key): array
8991
return $newFiles;
9092
}
9193

92-
private function validateEntryName(string $entryName)
94+
private function validateEntryName(string $entryName): void
9395
{
9496
$entriesData = $this->getEntriesData();
9597
if (!isset($entriesData['entrypoints'][$entryName]) && $this->strictMode) {

src/Asset/TagRenderer.php

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
namespace Symfony\WebpackEncoreBundle\Asset;
1111

1212
use Symfony\Component\Asset\Packages;
13-
use Symfony\Component\DependencyInjection\ServiceLocator;
1413
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
1514
use Symfony\Contracts\Service\ResetInterface;
1615
use Symfony\WebpackEncoreBundle\Event\RenderAssetTagEvent;
@@ -30,27 +29,14 @@ class TagRenderer implements ResetInterface
3029
private $renderedFiles = [];
3130

3231
public function __construct(
33-
$entrypointLookupCollection,
32+
EntrypointLookupCollectionInterface $entrypointLookupCollection,
3433
Packages $packages,
3534
array $defaultAttributes = [],
3635
array $defaultScriptAttributes = [],
3736
array $defaultLinkAttributes = [],
3837
EventDispatcherInterface $eventDispatcher = null
3938
) {
40-
if ($entrypointLookupCollection instanceof EntrypointLookupInterface) {
41-
@trigger_error(sprintf('The "$entrypointLookupCollection" argument in method "%s()" must be an instance of EntrypointLookupCollection.', __METHOD__), \E_USER_DEPRECATED);
42-
43-
$this->entrypointLookupCollection = new EntrypointLookupCollection(
44-
new ServiceLocator(['_default' => function () use ($entrypointLookupCollection) {
45-
return $entrypointLookupCollection;
46-
}])
47-
);
48-
} elseif ($entrypointLookupCollection instanceof EntrypointLookupCollectionInterface) {
49-
$this->entrypointLookupCollection = $entrypointLookupCollection;
50-
} else {
51-
throw new \TypeError('The "$entrypointLookupCollection" argument must be an instance of EntrypointLookupCollectionInterface.');
52-
}
53-
39+
$this->entrypointLookupCollection = $entrypointLookupCollection;
5440
$this->packages = $packages;
5541
$this->defaultAttributes = $defaultAttributes;
5642
$this->defaultScriptAttributes = $defaultScriptAttributes;
@@ -150,6 +136,9 @@ public function getDefaultAttributes(): array
150136
return $this->defaultAttributes;
151137
}
152138

139+
/**
140+
* @return void
141+
*/
153142
public function reset()
154143
{
155144
$this->renderedFiles = [

0 commit comments

Comments
 (0)