Skip to content

github: fix static workflows update dependencies #516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Mar 27, 2025
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
18 changes: 9 additions & 9 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ on: [pull_request]
jobs:
phpstan:
name: PHPStan
runs-on: Ubuntu-20.04
runs-on: Ubuntu-22.04

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Cache PHPStan
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: .github/.cache/phpstan/
key: phpstan-${{ github.sha }}
Expand All @@ -26,7 +26,7 @@ jobs:
coverage: none

- name: Download dependencies
uses: ramsey/composer-install@v2
uses: ramsey/composer-install@v3
with:
composer-options: --no-interaction --prefer-dist --optimize-autoloader

Expand All @@ -40,21 +40,21 @@ jobs:
name: PHP-CS-Fixer
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: PHP-CS-Fixer
uses: docker://oskarstark/php-cs-fixer-ga
with:
args: --diff --dry-run

psalm:
name: Psalm
runs-on: Ubuntu-20.04
runs-on: Ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Cache Psalm
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: .github/.cache/psalm/
key: psalm-${{ github.sha }}
Expand All @@ -67,7 +67,7 @@ jobs:
coverage: none

- name: Download dependencies
uses: ramsey/composer-install@v1
uses: ramsey/composer-install@v3
with:
composer-options: --no-interaction --prefer-dist --optimize-autoloader

Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/TranslationExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\HttpKernel\Kernel;
use Translation\Bundle\EventListener\AutoAddMissingTranslations;
use Translation\Bundle\EventListener\EditInPlaceResponseListener;
Expand Down
4 changes: 2 additions & 2 deletions Tests/Functional/Controller/EditInPlaceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function testActivatedTest(): void
self::assertStringContainsString('<!-- TranslationBundle -->', $response->getContent());

$dom = new \DOMDocument('1.0', 'utf-8');
@$dom->loadHTML(mb_convert_encoding($response->getContent(), 'HTML-ENTITIES', 'UTF-8'));
@$dom->loadHTML(mb_encode_numericentity($response->getContent(), [0x80, 0x10FFFF, 0, ~0], 'UTF-8'));
$xpath = new \DOMXPath($dom);

// Check number of x-trans tags
Expand Down Expand Up @@ -79,7 +79,7 @@ public function testIfUntranslatableLabelGetsDisabled(): void
self::assertStringContainsString('<!-- TranslationBundle -->', $response->getContent());

$dom = new \DOMDocument('1.0', 'utf-8');
@$dom->loadHTML(mb_convert_encoding($response->getContent(), 'HTML-ENTITIES', 'UTF-8'));
@$dom->loadHTML(mb_encode_numericentity($response->getContent(), [0x80, 0x10FFFF, 0, ~0], 'UTF-8'));
$xpath = new \DOMXPath($dom);

// Check number of x-trans tags
Expand Down
53 changes: 40 additions & 13 deletions Twig/Visitor/DefaultApplyingNodeVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@
use Twig\Node\Expression\ConditionalExpression;
use Twig\Node\Expression\ConstantExpression;
use Twig\Node\Expression\FilterExpression;
use Twig\Node\Expression\Ternary\ConditionalTernary;
use Twig\Node\Node;
use Twig\Node\Nodes;
use Twig\NodeVisitor\AbstractNodeVisitor;
use Twig\TwigFilter;

/**
* Applies the value of the "desc" filter if the "trans" filter has no
Expand Down Expand Up @@ -93,22 +96,46 @@ public function doEnterNode(Node $node, Environment $env): Node
$testNode->getNode('arguments')->setNode(0, new ArrayExpression([], $lineno));

// wrap the default node in a |replace filter
$defaultNode = new FilterExpression(
clone $node->getNode('arguments')->getNode(0),
new ConstantExpression('replace', $lineno),
new Node([
clone $wrappingNode->getNode('arguments')->getNode(0),
]),
$lineno
if (Environment::VERSION_ID >= 31500) {
$defaultNode = new FilterExpression(
clone $node->getNode('arguments')->getNode(0),
new TwigFilter('replace'),
new Nodes([
clone $wrappingNode->getNode('arguments')->getNode(0),
]),
$lineno
);
} else {
$defaultNode = new FilterExpression(
clone $node->getNode('arguments')->getNode(0),
new ConstantExpression('replace', $lineno),
new Node([
clone $wrappingNode->getNode('arguments')->getNode(0),
]),
$lineno
);
}
}

$expr = new EqualBinary($testNode, $transNode->getNode('node'), $wrappingNode->getTemplateLine());
if (Environment::VERSION_ID >= 31700) {
$expr->setAttribute('operator', 'binary_==');

$condition = new ConditionalTernary(
$expr,
$defaultNode,
clone $wrappingNode,
$wrappingNode->getTemplateLine()
);
} else {
$condition = new ConditionalExpression(
$expr,
$defaultNode,
clone $wrappingNode,
$wrappingNode->getTemplateLine()
);
}

$condition = new ConditionalExpression(
new EqualBinary($testNode, $transNode->getNode('node'), $wrappingNode->getTemplateLine()),
$defaultNode,
clone $wrappingNode,
$wrappingNode->getTemplateLine()
);
$node->setNode('node', $condition);

return $node;
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"php-translation/symfony-storage": "^2.1",
"php-translation/extractor": "^2.0",
"nyholm/nsa": "^1.1",
"twig/twig": "^2.14.4 || ^3.3",
"twig/twig": "^3.3",
"symfony/asset": "^5.3 || ^6.0 || ^7.0"
},
"require-dev": {
Expand Down
59 changes: 23 additions & 36 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,38 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="./vendor/autoload.php"
>
<php>
<env name="ENV" value="test" />
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[direct]=29&amp;verbose=1" />
<env name="KERNEL_CLASS" value="Nyholm\BundleTest\TestKernel" />
</php>

<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
</listeners>

<testsuites>
<testsuite name="Test Suite">
<directory>./Tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory suffix=".php">./</directory>
<exclude>
<directory>vendor</directory>
<directory>Tests</directory>
</exclude>
</whitelist>
</filter>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" colors="false" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" bootstrap="./vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">./</directory>
</include>
<exclude>
<directory>vendor</directory>
<directory>Tests</directory>
</exclude>
</coverage>
<php>
<env name="ENV" value="test"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[direct]=83&amp;verbose=1"/>
<env name="KERNEL_CLASS" value="Nyholm\BundleTest\TestKernel"/>
</php>
<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
</listeners>
<testsuites>
<testsuite name="Test Suite">
<directory>./Tests</directory>
</testsuite>
</testsuites>
</phpunit>