Skip to content

Commit 0b03d3e

Browse files
tobias-93bobvandevijver
authored andcommitted
Fix nullable typing causing a deprecation in PHP 8.4
1 parent 386b3bd commit 0b03d3e

File tree

14 files changed

+20
-20
lines changed

14 files changed

+20
-20
lines changed

Builder/BaseBuilder.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function getTemplateName(): string
2525
return '@AdmingeneratorGenerator/templates/' . $this->getGenerator()->getTemplateBaseDir() . parent::getTemplateName();
2626
}
2727

28-
public function __construct(Environment $environment = null)
28+
public function __construct(?Environment $environment = null)
2929
{
3030
parent::__construct();
3131
$this->twigExtensions[] = ClassifyExtension::class;

EventListener/ControllerListener.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function __construct(
2727
$this->cacheSuffix = 'default';
2828
}
2929

30-
public function setCacheProvider(CacheInterface $cacheProvider = null, $cacheSuffix = 'default'): void
30+
public function setCacheProvider(?CacheInterface $cacheProvider = null, $cacheSuffix = 'default'): void
3131
{
3232
$this->cacheProvider = $cacheProvider;
3333
$this->cacheSuffix = $cacheSuffix;

Menu/AdmingeneratorMenuBuilder.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ protected function addLinkRoute(ItemInterface $menu, string $label, string $rout
5353
/**
5454
* Set active class to current item and all its parents (so it is automatically opened)
5555
*/
56-
protected function setActive(ItemInterface $item = null): void
56+
protected function setActive(?ItemInterface $item = null): void
5757
{
5858
if ($item) {
5959
$this->setActive($item->getParent());

Resources/views/templates/CommonAdmin/ActionsAction/object_action.php.twig

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
* @param \{{ model }} ${{ builder.ModelClass }} Your \{{ model }} object
103103
* @return Response Must return a response!
104104
*/
105-
protected function errorObject{{ action.name|php_name|capitalize }}(\Exception $e, \{{ model }} ${{ builder.ModelClass }} = null)
105+
protected function errorObject{{ action.name|php_name|capitalize }}(\Exception $e, ?\{{ model }} ${{ builder.ModelClass }} = null)
106106
{
107107

108108
// Throw exception if defined

Resources/views/templates/CommonAdmin/ActionsAction/object_delete.php.twig

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
* @param \{{ model }} ${{ builder.ModelClass }} Your \{{ model }} object
100100
* @return Response Must return a response!
101101
*/
102-
protected function errorObjectDelete(\Exception $e, \{{ model }} ${{ builder.ModelClass }} = null)
102+
protected function errorObjectDelete(\Exception $e, ?\{{ model }} ${{ builder.ModelClass }} = null)
103103
{
104104

105105
// Throw exception if defined

Resources/views/templates/CommonAdmin/EditType/type.php.twig

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class {{ builder.YamlKey|ucfirst }}Type extends BaseType
7171
*
7272
* @return boolean
7373
*/
74-
protected function canDisplay{{ column.name|classify|php_name }}(\{{ model }} ${{ builder.ModelClass }} = null)
74+
protected function canDisplay{{ column.name|classify|php_name }}(?\{{ model }} ${{ builder.ModelClass }} = null)
7575
{
7676
{% if column.credentials is not empty and column.credentials != 'AdmingenAllowed' %}
7777
{% if(admingenerator_config('use_jms_security')) %}

Resources/views/templates/CommonAdmin/security_action.php.twig

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* @param \{{ model }} ${{ builder.ModelClass }}
1414
* @return boolean
1515
*/
16-
protected function validateCredentials($credentials, \{{ model }} ${{ builder.ModelClass }} = null)
16+
protected function validateCredentials($credentials, ?\{{ model }} ${{ builder.ModelClass }} = null)
1717
{
1818
{% if(admingenerator_config('use_jms_security')) %}
1919
$credentials = new Expression($credentials);
@@ -29,7 +29,7 @@
2929
* @param \{{ model }} ${{ builder.ModelClass }}
3030
* @throws AccessDeniedException if is not allowed
3131
*/
32-
protected function denyAccessUnlessValidateCredentials($credentials, \{{ model }} ${{ builder.ModelClass }} = null)
32+
protected function denyAccessUnlessValidateCredentials($credentials, ?\{{ model }} ${{ builder.ModelClass }} = null)
3333
{
3434
if (!$this->validateCredentials($credentials, ${{ builder.ModelClass }})) {
3535
throw $this->createAccessDeniedException('Credentials unsatisfied');

Routing/NestedRoutingLoader.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class NestedRoutingLoader extends RoutingLoader
88
{
9-
public function load(mixed $resource, string $type = null): RouteCollection
9+
public function load(mixed $resource, ?string $type = null): RouteCollection
1010
{
1111
$this->actions['nested_move'] = array(
1212
'path' => '/nested-move/{dragged}/{action}/{dropped}',
@@ -19,7 +19,7 @@ public function load(mixed $resource, string $type = null): RouteCollection
1919
return parent::load($resource, $type);
2020
}
2121

22-
public function supports(mixed $resource, string $type = null): bool
22+
public function supports(mixed $resource, ?string $type = null): bool
2323
{
2424
return 'admingenerator_nested' == $type;
2525
}

Routing/RoutingLoader.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class RoutingLoader extends FileLoader
9191

9292
protected array $yaml = [];
9393

94-
public function load(mixed $resource, string $type = null): RouteCollection
94+
public function load(mixed $resource, ?string $type = null): RouteCollection
9595
{
9696
$collection = new RouteCollection();
9797

@@ -165,7 +165,7 @@ public function load(mixed $resource, string $type = null): RouteCollection
165165
return $collection;
166166
}
167167

168-
public function supports(mixed $resource, string $type = null): bool
168+
public function supports(mixed $resource, ?string $type = null): bool
169169
{
170170
return 'admingenerator' == $type;
171171
}

Tests/DependencyInjection/ConfigurationTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function testDefaultConfig(): void
2323
* Get waiting default values from configuration. If $key is not null
2424
* and is in first level keys, returns value of this specific key only.
2525
*/
26-
private function getBundleDefaultConfig(string $key = null): mixed
26+
private function getBundleDefaultConfig(?string $key = null): mixed
2727
{
2828
static $defaultConfiguration = [
2929
'generate_base_in_project_dir' => false,

Tests/Mocks/Doctrine/DriverMock.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class DriverMock implements Driver
1212
{
1313
private ?DatabasePlatformMock $_platformMock = null;
1414

15-
public function connect(array $params, $username = null, $password = null, array $driverOptions = array()): Driver\Connection
15+
public function connect(array $params, $username = null, $password = null, array $driverOptions = []): Driver\Connection
1616
{
1717
return new DriverConnectionMock();
1818
}

Tests/Mocks/Doctrine/EntityManagerMock.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ public function getUnitOfWork(): UnitOfWork
4343
/**
4444
* Mock factory method to create an EntityManager.
4545
*/
46-
public static function create(Connection $conn, \Doctrine\ORM\Configuration $config = null,
47-
\Doctrine\Common\EventManager $eventManager = null): EntityManagerMock
46+
public static function create(Connection $conn, ?\Doctrine\ORM\Configuration $config = null,
47+
?\Doctrine\Common\EventManager $eventManager = null): EntityManagerMock
4848
{
4949
if (is_null($config)) {
5050
$config = new \Doctrine\ORM\Configuration();

Twig/Extension/EchoExtension.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function convertAsForm(string $options, string $formType): string
8585
* Print "trans" tag for string $str with parameters $parameters
8686
* for catalog $catalog.
8787
*/
88-
public function getEchoTrans(string $str, array $parameters = [], string $catalog = 'Admingenerator', bool|string $escape = null): string
88+
public function getEchoTrans(string $str, array $parameters = [], string $catalog = 'Admingenerator', bool|string|null $escape = null): string
8989
{
9090
$transParameters = '{}';
9191
$bag_parameters = [];
@@ -120,7 +120,7 @@ public function getEchoTrans(string $str, array $parameters = [], string $catalo
120120
/**
121121
* Print "echo tag with path call" to the path $path with params $params.
122122
*/
123-
public function getEchoPath(string $path, string $params = null, array|string $filters = null): string
123+
public function getEchoPath(string $path, string $params = null, array|string|null $filters = null): string
124124
{
125125
if (null === $params) {
126126
return (null === $filters)
@@ -152,7 +152,7 @@ public function getEchoPath(string $path, string $params = null, array|string $f
152152
* Print "if" tag with condition to is_expr_granted('$credentials')
153153
* If $modelName is not null, append the $modelName to the function call.
154154
*/
155-
public function getEchoIfGranted(string $credentials, string $modelName = null): string
155+
public function getEchoIfGranted(string $credentials, ?string $modelName = null): string
156156
{
157157
if ('AdmingenAllowed' == $credentials) {
158158
return "{% if (true) %}";

Twig/Extension/SecurityExtension.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function getFunctions(): array
2626
];
2727
}
2828

29-
public function isOneGranted(array $credentials, object $object = null): bool
29+
public function isOneGranted(array $credentials, ?object $object = null): bool
3030
{
3131
if (empty($credentials)) {
3232
return true;

0 commit comments

Comments
 (0)