Skip to content

Commit

Permalink
Merge pull request #376 from Chris53897/feature/drop-support-of-php7
Browse files Browse the repository at this point in the history
feat: drop support of php 7.4
  • Loading branch information
garak committed May 17, 2023
2 parents 798662e + ac1be98 commit 923b18a
Show file tree
Hide file tree
Showing 26 changed files with 61 additions and 198 deletions.
22 changes: 7 additions & 15 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

jobs:
check:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -15,43 +15,35 @@ jobs:
- name: Validate composer.json
run: composer validate --strict --no-check-lock
cs-fixer:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
name: PHP-CS-Fixer
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Fix CS
uses: docker://oskarstark/php-cs-fixer-ga
tests:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
include:
- description: 'No Symfony specified'
php: '7.4'
- description: 'No Symfony specified'
php: '8.0'
- description: 'No Symfony specified'
php: '8.1'
- description: 'No Symfony specified'
php: '8.2'
- description: 'Lowest deps'
php: '7.4'
php: '8.0'
composer_option: '--prefer-lowest'
env:
SYMFONY_DEPRECATIONS_HELPER: max[self]=0
- description: 'Symfony 4.4'
php: '7.4'
symfony: 4.4.*
- description: 'Symfony 5.4'
php: '7.4'
symfony: 5.4.*
- description: 'Symfony 6.0'
php: '8.0'
symfony: 6.0.*
symfony: 5.4.*
- description: 'Dev deps'
php: '8.1'
php: '8.2'
dev: true
name: PHP ${{ matrix.php }} tests (${{ matrix.description }})
steps:
Expand All @@ -74,7 +66,7 @@ jobs:
- run: composer update --no-interaction --no-progress --ansi ${{ matrix.composer_option }}
- run: vendor/bin/phpunit
phpstan:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
name: PHPStan
steps:
- name: Checkout
Expand Down
4 changes: 2 additions & 2 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
'@PHP71Migration:risky' => true,
'@PHPUnit75Migration:risky' => true,
'@PHP80Migration:risky' => true,
'@PHPUnit84Migration:risky' => true,
'ordered_imports' => true,
'declare_strict_types' => false,
'native_function_invocation' => ['include' => ['@internal']],
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 3.4 (2023-xx-xx)

* Removed support for unsupported PHP version 7.4

## 3.2 (2021-05-28)

* Remove Symfony 6 deprecations
Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@
}
],
"require": {
"php": "^7.4 || ^8.0"
"php": "^8.0"
},
"conflict": {
"twig/twig": "<1.42.3 || >=2,<2.9"
},
"require-dev": {
"phpstan/phpstan": "^1.8",
"phpunit/phpunit": "^9.5",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^9.6",
"psr/container": "^1.0",
"symfony/http-foundation": "^4.4 || ^5.0 || ^6.0",
"symfony/phpunit-bridge": "^6.1",
"symfony/routing": "^4.4 || ^5.0 || ^6.0",
"twig/twig": "^1.42.3 || ^2.9 || ^3.0"
"symfony/http-foundation": "^5.4 || ^6.0",
"symfony/phpunit-bridge": "^6.2",
"symfony/routing": "^5.4 || ^6.0",
"twig/twig": "^2.9 || ^3.0"
},
"suggest": {
"twig/twig": "for the TwigRenderer and the integration with your templates"
Expand Down
5 changes: 1 addition & 4 deletions src/Knp/Menu/Integration/Symfony/RoutingExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@
*/
class RoutingExtension implements ExtensionInterface
{
private UrlGeneratorInterface $generator;

public function __construct(UrlGeneratorInterface $generator)
public function __construct(private UrlGeneratorInterface $generator)
{
$this->generator = $generator;
}

public function buildOptions(array $options = []): array
Expand Down
5 changes: 1 addition & 4 deletions src/Knp/Menu/Iterator/CurrentItemFilterIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@
*/
class CurrentItemFilterIterator extends \FilterIterator
{
private MatcherInterface $matcher;

/**
* @param \Iterator<string|int, \Knp\Menu\ItemInterface> $iterator
*/
public function __construct(\Iterator $iterator, MatcherInterface $matcher)
public function __construct(\Iterator $iterator, private MatcherInterface $matcher)
{
$this->matcher = $matcher;

parent::__construct($iterator);
}
Expand Down
1 change: 1 addition & 0 deletions src/Knp/Menu/Iterator/RecursiveItemIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Recursive iterator iterating on an item
*
* @extends \IteratorIterator<string, \Knp\Menu\ItemInterface, \Traversable<string, \Knp\Menu\ItemInterface>>
*
* @implements \RecursiveIterator<string, \Knp\Menu\ItemInterface>>
*/
class RecursiveItemIterator extends \IteratorIterator implements \RecursiveIterator
Expand Down
7 changes: 2 additions & 5 deletions src/Knp/Menu/Loader/ArrayLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,14 @@
*/
class ArrayLoader implements LoaderInterface
{
private FactoryInterface $factory;

public function __construct(FactoryInterface $factory)
public function __construct(private FactoryInterface $factory)
{
$this->factory = $factory;
}

public function load($data): ItemInterface
{
if (!$this->supports($data)) {
throw new \InvalidArgumentException(\sprintf('Unsupported data. Expected an array but got %s', \is_object($data) ? \get_class($data) : \gettype($data)));
throw new \InvalidArgumentException(\sprintf('Unsupported data. Expected an array but got %s', \get_debug_type($data)));
}

return $this->fromArray($data);
Expand Down
7 changes: 2 additions & 5 deletions src/Knp/Menu/Loader/NodeLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,14 @@

class NodeLoader implements LoaderInterface
{
private FactoryInterface $factory;

public function __construct(FactoryInterface $factory)
public function __construct(private FactoryInterface $factory)
{
$this->factory = $factory;
}

public function load($data): ItemInterface
{
if (!$data instanceof NodeInterface) {
throw new \InvalidArgumentException(\sprintf('Unsupported data. Expected Knp\Menu\NodeInterface but got %s', \is_object($data) ? \get_class($data) : \gettype($data)));
throw new \InvalidArgumentException(\sprintf('Unsupported data. Expected Knp\Menu\NodeInterface but got %s', \get_debug_type($data)));
}

$item = $this->factory->createItem($data->getName(), $data->getOptions());
Expand Down
5 changes: 1 addition & 4 deletions src/Knp/Menu/Matcher/Voter/RegexVoter.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@
*/
class RegexVoter implements VoterInterface
{
private ?string $regexp;

public function __construct(?string $regexp)
public function __construct(private ?string $regexp)
{
$this->regexp = $regexp;
}

public function matchItem(ItemInterface $item): ?bool
Expand Down
7 changes: 2 additions & 5 deletions src/Knp/Menu/Matcher/Voter/RouteVoter.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@
*/
class RouteVoter implements VoterInterface
{
private RequestStack $requestStack;

public function __construct(RequestStack $requestStack)
public function __construct(private RequestStack $requestStack)
{
$this->requestStack = $requestStack;
}

public function matchItem(ItemInterface $item): ?bool
Expand Down Expand Up @@ -110,7 +107,7 @@ private function isMatchingQueryParameters(Request $request, array $testedRoute)

foreach ($testedRoute['query_parameters'] as $name => $value) {
// cast both to string so that we handle integer and other non-string parameters, but don't stumble on 0 == 'abc'.
if (!isset($routeQueryParameters[$name]) || is_array($routeQueryParameters[$name]) || (string) $routeQueryParameters[$name] !== (string) $value) {
if (!isset($routeQueryParameters[$name]) || \is_array($routeQueryParameters[$name]) || (string) $routeQueryParameters[$name] !== (string) $value) {
return false;
}
}
Expand Down
5 changes: 1 addition & 4 deletions src/Knp/Menu/Matcher/Voter/UriVoter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@
*/
class UriVoter implements VoterInterface
{
private ?string $uri;

public function __construct(?string $uri = null)
public function __construct(private ?string $uri = null)
{
$this->uri = $uri;
}

public function matchItem(ItemInterface $item): ?bool
Expand Down
14 changes: 1 addition & 13 deletions src/Knp/Menu/Provider/ArrayAccessProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,12 @@
*/
class ArrayAccessProvider implements MenuProviderInterface
{
/**
* @var \ArrayAccess<string, ItemInterface|callable>
*/
private \ArrayAccess $registry;

/**
* @var array<string, string>
*/
private array $menuIds;

/**
* @param \ArrayAccess<string, ItemInterface|callable> $registry
* @param array<string, string> $menuIds The map between menu identifiers and registry keys
*/
public function __construct(\ArrayAccess $registry, array $menuIds = [])
public function __construct(private \ArrayAccess $registry, private array $menuIds = [])
{
$this->registry = $registry;
$this->menuIds = $menuIds;
}

public function get(string $name, array $options = []): ItemInterface
Expand Down
8 changes: 1 addition & 7 deletions src/Knp/Menu/Provider/LazyProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,11 @@
*/
class LazyProvider implements MenuProviderInterface
{
/**
* @var array<string, mixed>
*/
private array $builders;

/**
* @phpstan-param array<string, callable|array{\Closure, string}> $builders
*/
public function __construct(array $builders)
public function __construct(private array $builders)
{
$this->builders = $builders;
}

public function get(string $name, array $options = []): ItemInterface
Expand Down
5 changes: 1 addition & 4 deletions src/Knp/Menu/Provider/PsrProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@
*/
class PsrProvider implements MenuProviderInterface
{
private ContainerInterface $container;

public function __construct(ContainerInterface $container)
public function __construct(private ContainerInterface $container)
{
$this->container = $container;
}

public function get(string $name, array $options = []): ItemInterface
Expand Down
17 changes: 1 addition & 16 deletions src/Knp/Menu/Renderer/ArrayAccessProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,13 @@
*/
class ArrayAccessProvider implements RendererProviderInterface
{
/**
* @var \ArrayAccess<string, RendererInterface>
*/
private \ArrayAccess $registry;

/**
* @var array<string, string>
*/
private array $rendererIds;

private string $defaultRenderer;

/**
* @param \ArrayAccess<string, RendererInterface> $registry
* @param string $defaultRenderer The name of the renderer used by default
* @param array<string, string> $rendererIds The map between renderer names and registry keys
*/
public function __construct(\ArrayAccess $registry, string $defaultRenderer, array $rendererIds)
public function __construct(private \ArrayAccess $registry, private string $defaultRenderer, private array $rendererIds)
{
$this->registry = $registry;
$this->rendererIds = $rendererIds;
$this->defaultRenderer = $defaultRenderer;
}

public function get(?string $name = null): RendererInterface
Expand Down
15 changes: 2 additions & 13 deletions src/Knp/Menu/Renderer/ListRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,11 @@
*/
class ListRenderer extends Renderer implements RendererInterface
{
/**
* @var MatcherInterface
*/
protected $matcher;

/**
* @var array<string, mixed>
*/
protected $defaultOptions;

/**
* @param array<string, mixed> $defaultOptions
*/
public function __construct(MatcherInterface $matcher, array $defaultOptions = [], ?string $charset = null)
public function __construct(protected MatcherInterface $matcher, protected array $defaultOptions = [], ?string $charset = null)
{
$this->matcher = $matcher;
$this->defaultOptions = \array_merge([
'depth' => null,
'matchingDepth' => null,
Expand Down Expand Up @@ -158,7 +147,7 @@ protected function renderItem(ItemInterface $item, array $options): string
$html = $this->format('<li'.$this->renderHtmlAttributes($attributes).'>', 'li', $item->getLevel(), $options);

// render the text/link inside the li tag
//$html .= $this->format($item->getUri() ? $item->renderLink() : $item->renderLabel(), 'link', $item->getLevel());
// $html .= $this->format($item->getUri() ? $item->renderLink() : $item->renderLabel(), 'link', $item->getLevel());
$html .= $this->renderLink($item, $options);

// renders the embedded ul
Expand Down
8 changes: 1 addition & 7 deletions src/Knp/Menu/Renderer/PsrProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,11 @@
*/
class PsrProvider implements RendererProviderInterface
{
private ContainerInterface $container;

private string $defaultRenderer;

/**
* @param string $defaultRenderer id of the default renderer (it should exist in the container to avoid weird failures)
*/
public function __construct(ContainerInterface $container, string $defaultRenderer)
public function __construct(private ContainerInterface $container, private string $defaultRenderer)
{
$this->container = $container;
$this->defaultRenderer = $defaultRenderer;
}

public function get(?string $name = null): RendererInterface
Expand Down
5 changes: 1 addition & 4 deletions src/Knp/Menu/Renderer/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@

abstract class Renderer
{
/**
* @var string
*/
protected $charset = 'UTF-8';
protected string $charset = 'UTF-8';

public function __construct(?string $charset = null)
{
Expand Down

0 comments on commit 923b18a

Please sign in to comment.