Skip to content

Commit

Permalink
Add support for Symfony 7, require Symfony 5.4+ and PHP 7.4+
Browse files Browse the repository at this point in the history
  • Loading branch information
mbabker committed Oct 9, 2023
1 parent d6d0d31 commit 98ee547
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 37 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/ci.yaml
Expand Up @@ -17,16 +17,14 @@ jobs:
strategy:
matrix:
php-version:
- "7.2"
- "7.3"
- "7.4"
- "8.0"
- "8.1"
- "8.2"
dependencies:
- "highest"
include:
- php-version: "7.2"
- php-version: "7.4"
dependencies: "lowest"

steps:
Expand Down
2 changes: 1 addition & 1 deletion .phpcs.xml.dist
Expand Up @@ -10,7 +10,7 @@
<arg name="colors"/>
<arg value="nps"/>

<config name="php_version" value="70200"/>
<config name="php_version" value="70400"/>

<file>Cache/</file>
<file>ContextFactory/</file>
Expand Down
2 changes: 1 addition & 1 deletion Cache/CacheWarmer.php
Expand Up @@ -38,7 +38,7 @@ public function __construct(array $includePaths, MetadataFactoryInterface $metad
*
* @return string[] A list of classes or files to preload on PHP 7.4+
*/
public function warmUp($cacheDir)
public function warmUp(string $cacheDir): array
{
$finder = Finder::create()
->ignoreVCS(true)
Expand Down
5 changes: 1 addition & 4 deletions DependencyInjection/Configuration.php
Expand Up @@ -25,10 +25,7 @@ public function __construct($debug = false)
$this->debug = $debug;
}

/**
* @return TreeBuilder
*/
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$tb = new TreeBuilder('jms_serializer');

Expand Down
12 changes: 4 additions & 8 deletions DependencyInjection/JMSSerializerExtension.php
Expand Up @@ -253,14 +253,10 @@ private function loadInternal(array $config, ScopedContainer $container, array $
$container->removeDefinition('jms_serializer.metadata.doc_block_driver');
}

// enable the typed props reader on php 7.4+
if (PHP_VERSION_ID >= 70400) {
$container->getDefinition('jms_serializer.metadata.typed_properties_driver')
->setDecoratedService('jms_serializer.metadata_driver')
->setPublic(false);
} else {
$container->removeDefinition('jms_serializer.metadata.typed_properties_driver');
}
// enable the typed props reader
$container->getDefinition('jms_serializer.metadata.typed_properties_driver')
->setDecoratedService('jms_serializer.metadata_driver')
->setPublic(false);

if ($config['enum_support']) {
$container->getDefinition('jms_serializer.metadata.enum_driver')
Expand Down
2 changes: 1 addition & 1 deletion ExpressionLanguage/BasicSerializerFunctionsProvider.php
Expand Up @@ -12,7 +12,7 @@ class BasicSerializerFunctionsProvider implements ExpressionFunctionProviderInte
/**
* @return ExpressionFunction[]
*/
public function getFunctions()
public function getFunctions(): array
{
return [
new ExpressionFunction('service', static function ($arg) {
Expand Down
6 changes: 1 addition & 5 deletions Tests/DependencyInjection/JMSSerializerExtensionTest.php
Expand Up @@ -32,7 +32,7 @@
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Twig\Loader\ContainerRuntimeLoader;
use Twig\RuntimeLoader\ContainerRuntimeLoader;

class JMSSerializerExtensionTest extends TestCase
{
Expand Down Expand Up @@ -777,10 +777,6 @@ public function testAutoconfigureHandlers()

public function testTypedDriverIsEnabled()
{
if (PHP_VERSION_ID < 70400) {
$this->markTestSkipped(sprintf('%s requires PHP 7.4', __METHOD__));
}

if (!class_exists(TypedPropertiesDriver::class)) {
$this->markTestSkipped(sprintf('%s requires %s', __METHOD__, TypedPropertiesDriver::class));
}
Expand Down
28 changes: 14 additions & 14 deletions composer.json
Expand Up @@ -21,29 +21,29 @@
}
],
"require": {
"php": "^7.2 || ^8.0",
"php": "^7.4 || ^8.0",
"jms/serializer": "^3.28",
"jms/metadata": "^2.6",
"symfony/dependency-injection": "^3.4 || ^4.0 || ^5.0 || ^6.0",
"symfony/framework-bundle": "^3.4 || ^4.0 || ^5.0 || ^6.0"
"symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0",
"symfony/framework-bundle": "^5.4 || ^6.0 || ^7.0"
},
"require-dev": {
"doctrine/coding-standard": "^8.1",
"doctrine/orm": "^2.4",
"phpunit/phpunit": "^8.0 || ^9.0",
"symfony/expression-language": "^3.4 || ^4.0 || ^5.0 || ^6.0",
"symfony/finder": "^3.4 || ^4.0 || ^5.0 || ^6.0",
"symfony/form": "^3.4 || ^4.0 || ^5.0 || ^6.0",
"symfony/stopwatch": "^3.4 || ^4.0 || ^5.0 || ^6.0",
"symfony/templating": "^3.4 || ^4.0 || ^5.0 || ^6.0",
"symfony/twig-bundle": "^3.4 || ^4.0 || ^5.0 || ^6.0",
"symfony/uid": "^5.1 || ^6.0",
"symfony/validator": "^3.4 || ^4.0 || ^5.0 || ^6.0",
"symfony/yaml": "^3.4 || ^4.0 || ^5.0 || ^6.0"
"symfony/expression-language": "^5.4 || ^6.0 || ^7.0",
"symfony/finder": "^5.4 || ^6.0 || ^7.0",
"symfony/form": "^5.4 || ^6.0 || ^7.0",
"symfony/stopwatch": "^5.4 || ^6.0 || ^7.0",
"symfony/templating": "^5.4 || ^6.0 || ^7.0",
"symfony/twig-bundle": "^5.4 || ^6.0 || ^7.0",
"symfony/uid": "^5.4 || ^6.0 || ^7.0",
"symfony/validator": "^5.4 || ^6.0 || ^7.0",
"symfony/yaml": "^5.4 || ^6.0 || ^7.0"
},
"suggest": {
"symfony/expression-language": "Required for opcache preloading ^3.4 || ^4.0 || ^5.0 || ^6.0",
"symfony/finder": "Required for cache warmup, supported versions ^3.4 || ^4.0 || ^5.0 || ^6.0"
"symfony/expression-language": "Required for opcache preloading ^5.4 || ^6.0 || ^7.0",
"symfony/finder": "Required for cache warmup, supported versions ^5.4 || ^6.0 || ^7.0"
},
"config": {
"allow-plugins": {
Expand Down

0 comments on commit 98ee547

Please sign in to comment.