[Map] Downgrade PHP requirement from 8.3 to 8.1

This commit is contained in:
Hugo Alliaume
2025-04-15 09:45:09 +02:00
parent 062a042f59
commit 8faa581e43
20 changed files with 71 additions and 63 deletions

View File

@@ -1,5 +1,9 @@
# CHANGELOG
## 2.25
- Downgrade PHP requirement from 8.3 to 8.1
## 2.24
- Installing the package in a Symfony app using Flex won't add the `@symfony/ux-map` dependency to the `package.json` file anymore.
@@ -26,13 +30,13 @@
## 2.20
- Deprecate `render_map` Twig function (will be removed in 2.21). Use
- Deprecate `render_map` Twig function (will be removed in 2.21). Use
`ux_map` or the `<twig:ux:map />` Twig component instead.
- Add `ux_map` Twig function (replaces `render_map` with a more flexible
- Add `ux_map` Twig function (replaces `render_map` with a more flexible
interface)
- Add `<twig:ux:map />` Twig component
- The importmap entry `@symfony/ux-map/abstract-map-controller` can be removed
from your importmap, it is no longer needed.
from your importmap, it is no longer needed.
- Add `Polygon` support
## 2.19

View File

@@ -32,13 +32,13 @@
}
},
"require": {
"php": ">=8.3",
"php": ">=8.1",
"symfony/stimulus-bundle": "^2.18.1"
},
"require-dev": {
"symfony/asset-mapper": "^6.4|^7.0",
"symfony/framework-bundle": "^6.4|^7.0",
"symfony/phpunit-bridge": "^6.4|^7.0",
"symfony/phpunit-bridge": "^7.2",
"symfony/twig-bundle": "^6.4|^7.0",
"symfony/ux-twig-component": "^2.18",
"symfony/ux-icons": "^2.18"

View File

@@ -16,11 +16,11 @@ use Symfony\UX\Map\Point;
/**
* @author Simon André <smn.andre@gmail.com>
*/
final readonly class DistanceCalculator implements DistanceCalculatorInterface
final class DistanceCalculator implements DistanceCalculatorInterface
{
public function __construct(
private DistanceCalculatorInterface $calculator = new VincentyDistanceCalculator(),
private DistanceUnit $unit = DistanceUnit::Meter,
private readonly DistanceCalculatorInterface $calculator = new VincentyDistanceCalculator(),
private readonly DistanceUnit $unit = DistanceUnit::Meter,
) {
}

View File

@@ -20,7 +20,7 @@ use Symfony\UX\Map\Point;
*
* @author Simon André <smn.andre@gmail.com>
*/
final readonly class HaversineDistanceCalculator implements DistanceCalculatorInterface
final class HaversineDistanceCalculator implements DistanceCalculatorInterface
{
/**
* @const float The Earth's radius in meters.

View File

@@ -20,7 +20,7 @@ use Symfony\UX\Map\Point;
*
* @author Simon André <smn.andre@gmail.com>
*/
final readonly class SphericalCosineDistanceCalculator implements DistanceCalculatorInterface
final class SphericalCosineDistanceCalculator implements DistanceCalculatorInterface
{
/**
* @const float The Earth's radius in meters.

View File

@@ -20,7 +20,7 @@ use Symfony\UX\Map\Point;
*
* @author Simon André <smn.andre@gmail.com>
*/
final readonly class VincentyDistanceCalculator implements DistanceCalculatorInterface
final class VincentyDistanceCalculator implements DistanceCalculatorInterface
{
/**
* WS-84 ellipsoid parameters.

View File

@@ -18,10 +18,10 @@ use Symfony\UX\Icons\IconRendererInterface;
*
* @internal
*/
readonly class UxIconRenderer
class UxIconRenderer
{
public function __construct(
private ?IconRendererInterface $renderer,
private readonly ?IconRendererInterface $renderer,
) {
}

View File

@@ -16,19 +16,19 @@ namespace Symfony\UX\Map;
*
* @author Hugo Alliaume <hugo@alliau.me>
*/
final readonly class InfoWindow
final class InfoWindow
{
/**
* @param array<string, mixed> $extra Extra data, can be used by the developer to store additional information and
* use them later JavaScript side
*/
public function __construct(
private ?string $headerContent = null,
private ?string $content = null,
private ?Point $position = null,
private bool $opened = false,
private bool $autoClose = true,
private array $extra = [],
private readonly ?string $headerContent = null,
private readonly ?string $content = null,
private readonly ?Point $position = null,
private readonly bool $opened = false,
private readonly bool $autoClose = true,
private readonly array $extra = [],
) {
}

View File

@@ -26,7 +26,10 @@ use Symfony\UX\Map\Exception\UnableToNormalizeOptionsException;
*/
final class MapOptionsNormalizer
{
private const string KEY_PROVIDER = '@provider';
/**
* @var string
*/
private const KEY_PROVIDER = '@provider';
/**
* @var array<string, class-string<MapOptionsInterface>>

View File

@@ -20,19 +20,19 @@ use Symfony\UX\Map\Icon\IconType;
*
* @author Hugo Alliaume <hugo@alliau.me>
*/
final readonly class Marker implements Element
final class Marker implements Element
{
/**
* @param array<string, mixed> $extra Extra data, can be used by the developer to store additional information and
* use them later JavaScript side
*/
public function __construct(
public Point $position,
public ?string $title = null,
public ?InfoWindow $infoWindow = null,
public array $extra = [],
public ?string $id = null,
public ?Icon $icon = null,
public readonly Point $position,
public readonly ?string $title = null,
public readonly ?InfoWindow $infoWindow = null,
public readonly array $extra = [],
public readonly ?string $id = null,
public readonly ?Icon $icon = null,
) {
}

View File

@@ -18,11 +18,11 @@ use Symfony\UX\Map\Exception\InvalidArgumentException;
*
* @author Hugo Alliaume <hugo@alliau.me>
*/
final readonly class Point
final class Point
{
public function __construct(
public float $latitude,
public float $longitude,
public readonly float $latitude,
public readonly float $longitude,
) {
if ($latitude < -90 || $latitude > 90) {
throw new InvalidArgumentException(\sprintf('Latitude must be between -90 and 90 degrees, "%s" given.', $latitude));

View File

@@ -18,17 +18,17 @@ use Symfony\UX\Map\Exception\InvalidArgumentException;
*
* @author [Pierre Svgnt]
*/
final readonly class Polygon implements Element
final class Polygon implements Element
{
/**
* @param array<string, mixed> $extra Extra data, can be used by the developer to store additional information and use them later JavaScript side
*/
public function __construct(
private array $points,
private ?string $title = null,
private ?InfoWindow $infoWindow = null,
private array $extra = [],
public ?string $id = null,
private readonly array $points,
private readonly ?string $title = null,
private readonly ?InfoWindow $infoWindow = null,
private readonly array $extra = [],
public readonly ?string $id = null,
) {
}

View File

@@ -18,17 +18,17 @@ use Symfony\UX\Map\Exception\InvalidArgumentException;
*
* @author [Sylvain Blondeau]
*/
final readonly class Polyline implements Element
final class Polyline implements Element
{
/**
* @param array<string, mixed> $extra Extra data, can be used by the developer to store additional information and use them later JavaScript side
*/
public function __construct(
private array $points,
private ?string $title = null,
private ?InfoWindow $infoWindow = null,
private array $extra = [],
public ?string $id = null,
private readonly array $points,
private readonly ?string $title = null,
private readonly ?InfoWindow $infoWindow = null,
private readonly array $extra = [],
public readonly ?string $id = null,
) {
}

View File

@@ -20,11 +20,11 @@ use Symfony\UX\StimulusBundle\Helper\StimulusHelper;
/**
* @author Hugo Alliaume <hugo@alliau.me>
*/
abstract readonly class AbstractRenderer implements RendererInterface
abstract class AbstractRenderer implements RendererInterface
{
public function __construct(
private StimulusHelper $stimulus,
private UxIconRenderer $uxIconRenderer,
private readonly StimulusHelper $stimulus,
private readonly UxIconRenderer $uxIconRenderer,
) {
}

View File

@@ -16,13 +16,13 @@ use Symfony\UX\Map\Exception\InvalidArgumentException;
/**
* @author Hugo Alliaume <hugo@alliau.me>
*/
final readonly class Dsn
final class Dsn
{
private string $scheme;
private string $host;
private ?string $user;
private array $options;
private string $originalDsn;
private readonly string $scheme;
private readonly string $host;
private readonly ?string $user;
private readonly array $options;
private readonly string $originalDsn;
public function __construct(#[\SensitiveParameter] string $dsn)
{

View File

@@ -19,10 +19,10 @@ use Symfony\UX\Map\Map;
*
* @internal
*/
final readonly class NullRenderer implements RendererInterface
final class NullRenderer implements RendererInterface
{
public function __construct(
private array $availableBridges = [],
private readonly array $availableBridges = [],
) {
}

View File

@@ -13,13 +13,13 @@ namespace Symfony\UX\Map\Renderer;
use Symfony\UX\Map\Exception\UnsupportedSchemeException;
final readonly class NullRendererFactory implements RendererFactoryInterface
final class NullRendererFactory implements RendererFactoryInterface
{
/**
* @param array<string> $availableBridges
*/
public function __construct(
private array $availableBridges = [],
private readonly array $availableBridges = [],
) {
}

View File

@@ -18,13 +18,13 @@ use Symfony\UX\Map\Exception\UnsupportedSchemeException;
*
* @internal
*/
final readonly class Renderer
final class Renderer
{
public function __construct(
/**
* @param iterable<RendererFactoryInterface> $factories
*/
private iterable $factories,
private readonly iterable $factories,
) {
}

View File

@@ -16,11 +16,11 @@ namespace Symfony\UX\Map\Tests;
use Symfony\UX\Map\MapOptionsInterface;
use Symfony\UX\Map\MapOptionsNormalizer;
final readonly class DummyOptions implements MapOptionsInterface
final class DummyOptions implements MapOptionsInterface
{
public function __construct(
private string $mapId,
private string $mapType,
private readonly string $mapId,
private readonly string $mapType,
) {
}

View File

@@ -80,8 +80,9 @@ class MapExtensionTest extends KernelTestCase
if (class_exists(DeprecatedCallableInfo::class)) {
$this->expectDeprecation('Since symfony/ux-map 2.20: Twig Function "render_map" is deprecated; use "ux_map" instead in test at line 1.');
} else {
$this->expectDeprecation('Since symfony/ux-map 2.20: Twig Function "render_map" is deprecated. Use "ux_map" instead in test at line 1.');
$this->expectDeprecation('Twig Function "render_map" is deprecated since version 2.20. Use "ux_map" instead in test at line 1.');
}
$html = $twig->render('test', ['map' => $map]);
$this->assertSame('<map/>', $html);
}
@@ -103,7 +104,7 @@ class MapExtensionTest extends KernelTestCase
self::getContainer()->set('test.ux_map.renderers', $renderer);
$twig = self::getContainer()->get('twig');
$template = $twig->createTemplate('{{ ux_map(center: {lat: 5, lng: 10}, zoom: 4, attributes: attributes) }}');
$template = $twig->createTemplate('{{ ux_map(center={lat: 5, lng: 10}, zoom=4, attributes=attributes) }}');
$this->assertSame(
'<div data-controller="@symfony/ux-foobar-map"></div>',