Skip to content

Commit

Permalink
minor #141 [CI] Add Symfony 6.1 check (ogizanagi)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 0.x-dev branch.

Discussion
----------

[CI] Add Symfony 6.1 check

Waiting for #142 merge first

Commits
-------

920fba1 [ExpressionLanguage] Disable test case for conflicting function on Sf 6.1
42d6e7f Upgrade php-cs-fixer version
f82b502 Fix 6.1 deprecation: public and protected properties are final
7fb8d59 Fix 6.1 Serializer ContextAwareDenormalizerInterface deprecation
eceb27e Fix framework.http_method_override deprecation
f5d242b Fix decoder deprecations
8152567 [CI] Add Symfony 6.1 check
  • Loading branch information
ogizanagi committed May 20, 2022
2 parents 2b72c8f + 920fba1 commit 4a705cc
Show file tree
Hide file tree
Showing 14 changed files with 84 additions and 46 deletions.
19 changes: 11 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
coverage: "none"
extensions: "json"
ini-values: "memory_limit=-1"
php-version: "8.0"
php-version: "8.1"

- name: 'Determine composer cache directory'
id: composer-cache
Expand All @@ -34,8 +34,8 @@ jobs:
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.directory }}
key: 7.4-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: 7.4-composer-
key: lint-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: lint-composer-

- name: 'Install dependencies'
id: deps
Expand Down Expand Up @@ -97,19 +97,22 @@ jobs:
- name: 'Test Symfony 5.4 [Linux, PHP 8.1]'
os: 'ubuntu-latest'
php: '8.1'
symfony: '5.4.*@dev'
allow-unstable: true
symfony: '5.4.*'

- name: 'Test Symfony 5.4 [Windows, PHP 8.0]'
os: 'windows-latest'
php: '8.0'
symfony: '5.4.*@dev'
allow-unstable: true
symfony: '5.4.*'

- name: 'Test Symfony 6.0 [Linux, PHP 8.1]'
os: 'ubuntu-latest'
php: '8.1'
symfony: '6.0.*@dev'
symfony: '6.0.*'

- name: 'Test Symfony 6.1 [Linux, PHP 8.1]'
os: 'ubuntu-latest'
php: '8.1'
symfony: '6.1.*@dev'
allow-unstable: true

steps:
Expand Down
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: dist

PHP_CS_FIXER_VERSION=v3.3.2
PHP_CS_FIXER_VERSION=v3.8.0

##########
# Colors #
Expand Down Expand Up @@ -40,15 +40,19 @@ install-54: setup
install-54: export SYMFONY_REQUIRE = 5.4.*@dev
install-54:
rm -f composer.lock
composer config minimum-stability dev
composer update
composer config minimum-stability --unset

install-60: setup
install-60: export SYMFONY_REQUIRE = 6.0.*@dev
install-60:
rm -f composer.lock
composer config minimum-stability dev
composer update

install-61: setup
install-61: export SYMFONY_REQUIRE = 6.1.*@dev
install-61:
rm -f composer.lock
composer config minimum-stability RC
composer update
composer config minimum-stability --unset

Expand Down
6 changes: 6 additions & 0 deletions bin/lint.twig.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#!/usr/bin/env php
<?php

/*
* This file is part of the "StenopePHP/Stenope" bundle.
*
* @author Thomas Jarrand <[email protected]>
*/

require __DIR__ . '/../vendor/autoload.php';

use Symfony\Bridge\Twig\Command\LintCommand;
Expand Down
4 changes: 2 additions & 2 deletions config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
'$stopwatch' => service('stenope.build.stopwatch'),
'$registeredTypes' => 'The known content types, defined by the extension',
])
->tag('console.command', ['command' => DebugCommand::getDefaultName()])
->tag('console.command', ['command' => 'debug:stenope:content'])

// Expression Language
->set(ExpressionLanguage::class)->args([
Expand All @@ -96,7 +96,7 @@
'$builder' => service(Builder::class),
'$stopwatch' => service('stenope.build.stopwatch'),
])
->tag('console.command', ['command' => BuildCommand::getDefaultName()])
->tag('console.command', ['command' => 'stenope:build'])

->set(Builder::class)->args([
'$router' => service('router'),
Expand Down
5 changes: 1 addition & 4 deletions src/Command/BuildCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
namespace Stenope\Bundle\Command;

use Stenope\Bundle\Builder;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputArgument;
Expand All @@ -20,13 +19,10 @@
use Symfony\Component\Console\Terminal;
use Symfony\Component\Stopwatch\Stopwatch;

#[AsCommand('stenope:build')]
class BuildCommand extends Command
{
use StopwatchHelperTrait;

protected static $defaultName = 'stenope:build';

private Builder $builder;
private Stopwatch $stopwatch;

Expand All @@ -44,6 +40,7 @@ public function __construct(Builder $builder, Stopwatch $stopwatch)
protected function configure(): void
{
$this
->setName('stenope:build')
->setDescription('Build static website')
->addArgument(
'buildDir',
Expand Down
5 changes: 1 addition & 4 deletions src/Command/DebugCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Stenope\Bundle\ExpressionLanguage\Expression;
use Stenope\Bundle\TableOfContent\Headline;
use Stenope\Bundle\TableOfContent\TableOfContent;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\Dumper;
use Symfony\Component\Console\Input\InputArgument;
Expand All @@ -27,13 +26,10 @@
use Symfony\Component\VarDumper\Cloner\Stub;
use Symfony\Component\VarDumper\Cloner\VarCloner;

#[AsCommand('debug:stenope:content')]
class DebugCommand extends Command
{
use StopwatchHelperTrait;

protected static $defaultName = 'debug:stenope:content';

private ContentManagerInterface $manager;
private Stopwatch $stopwatch;
private array $registeredTypes;
Expand All @@ -53,6 +49,7 @@ public function __construct(ContentManagerInterface $manager, Stopwatch $stopwat
protected function configure(): void
{
$this
->setName('debug:stenope:content')
->setDescription('Debug Stenope managed contents')
->addArgument('class', InputArgument::REQUIRED, 'Content FQCN')
->addArgument('id', InputArgument::OPTIONAL, 'Content identifier')
Expand Down
2 changes: 1 addition & 1 deletion src/Decoder/HtmlDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function decode($data, $format, array $context = []): array
/**
* {@inheritdoc}
*/
public function supportsDecoding($format): bool
public function supportsDecoding($format, array $context = []): bool
{
return self::FORMAT === $format;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Decoder/MarkdownDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function decode($data, $format, array $context = []): array
/**
* {@inheritdoc}
*/
public function supportsDecoding($format): bool
public function supportsDecoding($format, array $context = []): bool
{
return self::FORMAT === $format;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,48 @@

namespace Stenope\Bundle\Serializer\Normalizer;

use Composer\InstalledVersions;
use Symfony\Component\Serializer\Normalizer\ContextAwareDenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;

/**
* Avoiding double-denormalization for already instantiated objects inside $data.
*
* @final
*/
class SkippingInstantiatedObjectDenormalizer implements ContextAwareDenormalizerInterface
{
public const SKIP = 'skip_instantiated_object';

public function denormalize($data, string $type, string $format = null, array $context = []): object
if (-1 === version_compare(InstalledVersions::getVersion('symfony/serializer'), '6.1.0')) {
/**
* Avoiding double-denormalization for already instantiated objects inside $data.
*
* @final
*/
class SkippingInstantiatedObjectDenormalizer implements ContextAwareDenormalizerInterface
{
return $data;
}
public const SKIP = 'skip_instantiated_object';

public function supportsDenormalization($data, string $type, string $format = null, array $context = []): bool
public function denormalize($data, string $type, string $format = null, array $context = []): object
{
return $data;
}

public function supportsDenormalization($data, string $type, string $format = null, array $context = []): bool
{
return (bool) ($context[self::SKIP] ?? false) && \is_object($data);
}
}
} else {
/**
* Avoiding double-denormalization for already instantiated objects inside $data.
*
* @final
*/
class SkippingInstantiatedObjectDenormalizer implements DenormalizerInterface
{
return (bool) ($context[self::SKIP] ?? false) && \is_object($data);
public const SKIP = 'skip_instantiated_object';

public function denormalize($data, string $type, string $format = null, array $context = []): object
{
return $data;
}

public function supportsDenormalization($data, string $type, string $format = null, array $context = []): bool
{
return (bool) ($context[self::SKIP] ?? false) && \is_object($data);
}
}
}
6 changes: 3 additions & 3 deletions src/Service/HtmlUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class HtmlUtils
/**
* Add class to the given element
*/
public static function addClass(\DomElement $element, string $class): void
public static function addClass(\DOMElement $element, string $class): void
{
$element->setAttribute('class', implode(' ', array_filter([
trim($element->getAttribute('class')),
Expand All @@ -24,7 +24,7 @@ public static function addClass(\DomElement $element, string $class): void
/**
* Set element HTML content
*/
public static function setContent(\DomElement $element, string $content): void
public static function setContent(\DOMElement $element, string $content): void
{
$element->nodeValue = '';

Expand All @@ -38,7 +38,7 @@ public static function setContent(\DomElement $element, string $content): void
/**
* Wrap content
*/
public static function wrapContent(\DomElement $element, string $wrapTag, array $wrapAttributes = []): void
public static function wrapContent(\DOMElement $element, string $wrapTag, array $wrapAttributes = []): void
{
$wrapper = $element->ownerDocument->createElement($wrapTag);

Expand Down
6 changes: 3 additions & 3 deletions tests/Integration/Command/DebugCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function testList(string $class, string $expected, array $filters = [], a
$kernel = static::createKernel();
$application = new Application($kernel);

$command = $application->find(DebugCommand::getDefaultName());
$command = $application->find('debug:stenope:content');
$tester = new CommandTester($command);
$tester->execute([
'class' => $class,
Expand Down Expand Up @@ -160,7 +160,7 @@ public function testShow(): void
$kernel = static::createKernel();
$application = new Application($kernel);

$command = $application->find(DebugCommand::getDefaultName());
$command = $application->find('debug:stenope:content');
$tester = new CommandTester($command);
$tester->execute([
'class' => Author::class,
Expand Down Expand Up @@ -201,7 +201,7 @@ public function testUnavailableExpressionLanguageHint(): void
$kernel = static::createKernel();
$application = new Application($kernel);

$command = $application->find(DebugCommand::getDefaultName());
$command = $application->find('debug:stenope:content');
$tester = new CommandTester($command);

try {
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Provider/LocalFilesystemProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public function provideListContentsData(): iterable
// This one cannot be resolved until https://github.com/symfony/symfony/issues/28158 is.
// If one really needs to exclude a dir but not subdirs with the same name, they must use the glob pattern
// as in the previous test case sample, despite it may have a big performances impact
//yield 'config excluding explicit dir (not as a glob)' => [
// yield 'config excluding explicit dir (not as a glob)' => [
// new LocalFilesystemProvider(
// 'App\Foo',
// self::FIXTURES_DIR . '/content/excluded_dirs',
Expand All @@ -211,6 +211,6 @@ public function provideListContentsData(): iterable
// 'foo/bar (markdown)',
// 'foo/bar/baz (markdown)',
// ],
//];
// ];
}
}
6 changes: 6 additions & 0 deletions tests/fixtures/Unit/Service/Git/bin/git.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#!/usr/bin/env php
<?php

/*
* This file is part of the "StenopePHP/Stenope" bundle.
*
* @author Thomas Jarrand <[email protected]>
*/

/**
* @see \Stenope\Bundle\Tests\Unit\Service\Git\LastModifiedFetcherTest
*/
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/app/config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ framework:
utf8: true

disallow_search_engine_index: false
http_method_override: false

twig:
default_path: '%kernel.project_dir%/templates'
Expand Down

0 comments on commit 4a705cc

Please sign in to comment.