Skip to content

Commit

Permalink
feature #212 Updates for WebpackEncoreBundle 2.0 (weaverryan)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
weaverryan committed May 26, 2023
2 parents b8ff4a6 + 06a7eb5 commit a739610
Show file tree
Hide file tree
Showing 25 changed files with 48 additions and 1,148 deletions.
19 changes: 2 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,13 @@ jobs:
fail-fast: false
matrix:
# normal, highest, non-dev installs
php-version: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
php-version: ['8.1', '8.2']
dependency-versions: ['highest']
include:
# testing lowest PHP version with lowest dependencies
- php-version: '7.1'
- php-version: '8.1'
dependency-versions: 'lowest'

# testing dev versions with highest PHP
- php-version: '8.0'
dependency-versions: 'highest'

steps:
- name: "Checkout code"
uses: "actions/checkout@v2"
Expand All @@ -51,15 +47,4 @@ jobs:
composer-options: "--prefer-dist --no-progress"

- name: Run tests
env:
SYMFONY_DEPRECATIONS_HELPER: "max[self]=11"
SYMFONY_PHPUNIT_VERSION: "8.5"
run: ./vendor/bin/simple-phpunit
if: matrix.php-version != '7.1'

- name: Run tests
env:
SYMFONY_DEPRECATIONS_HELPER: "max[self]=0"
SYMFONY_PHPUNIT_VERSION: "7.5"
run: ./vendor/bin/simple-phpunit
if: matrix.php-version == '7.1'
10 changes: 5 additions & 5 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 8.1
coverage: none
tools: cs2pr

Expand All @@ -39,7 +39,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 8.1
coverage: none
tools: cs2pr

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

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

psalm:
name: Psalm
Expand All @@ -61,7 +61,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 8.1
coverage: none
tools: vimeo/psalm:4.11.2

Expand All @@ -84,7 +84,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 8.1
coverage: none
tools: composer-normalize

Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## v2.0.0

- Minimum PHP version is now 8.1
- Minimum Symfony version is now 5.4

## v1.17.0

- Deprecated the `stimulus_controller()`, `stimulus_action()` and `stimulus_target`
Expand Down
22 changes: 10 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,18 @@
}
],
"require": {
"php": ">=7.1.3",
"symfony/asset": "^4.4 || ^5.0 || ^6.0",
"symfony/config": "^4.4 || ^5.0 || ^6.0",
"symfony/dependency-injection": "^4.4 || ^5.0 || ^6.0",
"symfony/deprecation-contracts": "^2.1 || ^3.0",
"symfony/http-kernel": "^4.4 || ^5.0 || ^6.0",
"symfony/polyfill-php80": "^1.25.0",
"symfony/service-contracts": "^1.0 || ^2.0 || ^3.0"
"php": ">=8.1.0",
"symfony/asset": "^5.4 || ^6.2",
"symfony/config": "^5.4 || ^6.2",
"symfony/dependency-injection": "^5.4 || ^6.2",
"symfony/http-kernel": "^5.4 || ^6.2",
"symfony/service-contracts": "^3.0"
},
"require-dev": {
"symfony/framework-bundle": "^4.4 || ^5.0 || ^6.0",
"symfony/phpunit-bridge": "^5.3 || ^6.0",
"symfony/twig-bundle": "^4.4 || ^5.0 || ^6.0",
"symfony/web-link": "^4.4 || ^5.0 || ^6.0"
"symfony/framework-bundle": "^5.4 || ^6.2",
"symfony/phpunit-bridge": "^5.4 || ^6.2",
"symfony/twig-bundle": "^5.4 || ^6.2",
"symfony/web-link": "^5.4 || ^6.2"
},
"minimum-stability": "dev",
"autoload": {
Expand Down
6 changes: 3 additions & 3 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,9 @@ different ways:
Stimulus / Symfony UX Helper
----------------------------

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

.. _`Webpack Encore`: https://symfony.com/doc/current/frontend.html
.. _`enable the bundle manually`: https://symfony.com/doc/current/bundles.html
Expand Down
10 changes: 0 additions & 10 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,3 @@ parameters:
message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\TreeBuilder\\:\\:root\\(\\)\\.$#"
count: 1
path: src/DependencyInjection/Configuration.php

-
message: "#^Function twig_escape_filter not found\\.$#"
count: 1
path: src/Dto/AbstractStimulusDto.php

-
message: "#^Call to function is_array\\(\\) with string will always evaluate to false\\.$#"
count: 2
path: src/Twig/StimulusTwigExtension.php
45 changes: 0 additions & 45 deletions psalm.baseline.xml

This file was deleted.

1 change: 0 additions & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorBaseline="psalm.baseline.xml"
phpVersion="8.0"
>
<projectFiles>
Expand Down
4 changes: 3 additions & 1 deletion src/Asset/EntrypointLookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ public function getIntegrityData(): array

/**
* Resets the state of this service.
*
* @return void
*/
public function reset()
{
Expand All @@ -89,7 +91,7 @@ private function getEntryFiles(string $entryName, string $key): array
return $newFiles;
}

private function validateEntryName(string $entryName)
private function validateEntryName(string $entryName): void
{
$entriesData = $this->getEntriesData();
if (!isset($entriesData['entrypoints'][$entryName]) && $this->strictMode) {
Expand Down
21 changes: 5 additions & 16 deletions src/Asset/TagRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
namespace Symfony\WebpackEncoreBundle\Asset;

use Symfony\Component\Asset\Packages;
use Symfony\Component\DependencyInjection\ServiceLocator;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use Symfony\Contracts\Service\ResetInterface;
use Symfony\WebpackEncoreBundle\Event\RenderAssetTagEvent;
Expand All @@ -30,27 +29,14 @@ class TagRenderer implements ResetInterface
private $renderedFiles = [];

public function __construct(
$entrypointLookupCollection,
EntrypointLookupCollectionInterface $entrypointLookupCollection,
Packages $packages,
array $defaultAttributes = [],
array $defaultScriptAttributes = [],
array $defaultLinkAttributes = [],
EventDispatcherInterface $eventDispatcher = null
) {
if ($entrypointLookupCollection instanceof EntrypointLookupInterface) {
@trigger_error(sprintf('The "$entrypointLookupCollection" argument in method "%s()" must be an instance of EntrypointLookupCollection.', __METHOD__), \E_USER_DEPRECATED);

$this->entrypointLookupCollection = new EntrypointLookupCollection(
new ServiceLocator(['_default' => function () use ($entrypointLookupCollection) {
return $entrypointLookupCollection;
}])
);
} elseif ($entrypointLookupCollection instanceof EntrypointLookupCollectionInterface) {
$this->entrypointLookupCollection = $entrypointLookupCollection;
} else {
throw new \TypeError('The "$entrypointLookupCollection" argument must be an instance of EntrypointLookupCollectionInterface.');
}

$this->entrypointLookupCollection = $entrypointLookupCollection;
$this->packages = $packages;
$this->defaultAttributes = $defaultAttributes;
$this->defaultScriptAttributes = $defaultScriptAttributes;
Expand Down Expand Up @@ -150,6 +136,9 @@ public function getDefaultAttributes(): array
return $this->defaultAttributes;
}

/**
* @return void
*/
public function reset()
{
$this->renderedFiles = [
Expand Down
24 changes: 0 additions & 24 deletions src/DependencyInjection/Compiler/RemoveStimulusServicesPass.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('webpack_encore');
/** @var ArrayNodeDefinition $rootNode */
$rootNode = method_exists($treeBuilder, 'getRootNode') ? $treeBuilder->getRootNode() : $treeBuilder->root('webpack_encore');
$rootNode = $treeBuilder->getRootNode();

$rootNode
->validate()
Expand Down
67 changes: 0 additions & 67 deletions src/Dto/AbstractStimulusDto.php

This file was deleted.

0 comments on commit a739610

Please sign in to comment.