Skip to content

Fix nullable typing causing a deprecation in PHP 8.4 #350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Builder/BaseBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function getTemplateName(): string
return '@AdmingeneratorGenerator/templates/' . $this->getGenerator()->getTemplateBaseDir() . parent::getTemplateName();
}

public function __construct(Environment $environment = null)
public function __construct(?Environment $environment = null)
{
parent::__construct();
$this->twigExtensions[] = ClassifyExtension::class;
Expand Down
2 changes: 1 addition & 1 deletion EventListener/ControllerListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct(
$this->cacheSuffix = 'default';
}

public function setCacheProvider(CacheInterface $cacheProvider = null, $cacheSuffix = 'default'): void
public function setCacheProvider(?CacheInterface $cacheProvider = null, $cacheSuffix = 'default'): void
{
$this->cacheProvider = $cacheProvider;
$this->cacheSuffix = $cacheSuffix;
Expand Down
2 changes: 1 addition & 1 deletion Menu/AdmingeneratorMenuBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected function addLinkRoute(ItemInterface $menu, string $label, string $rout
/**
* Set active class to current item and all its parents (so it is automatically opened)
*/
protected function setActive(ItemInterface $item = null): void
protected function setActive(?ItemInterface $item = null): void
{
if ($item) {
$this->setActive($item->getParent());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
* @param \{{ model }} ${{ builder.ModelClass }} Your \{{ model }} object
* @return Response Must return a response!
*/
protected function errorObject{{ action.name|php_name|capitalize }}(\Exception $e, \{{ model }} ${{ builder.ModelClass }} = null)
protected function errorObject{{ action.name|php_name|capitalize }}(\Exception $e, ?\{{ model }} ${{ builder.ModelClass }} = null)
{

// Throw exception if defined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
* @param \{{ model }} ${{ builder.ModelClass }} Your \{{ model }} object
* @return Response Must return a response!
*/
protected function errorObjectDelete(\Exception $e, \{{ model }} ${{ builder.ModelClass }} = null)
protected function errorObjectDelete(\Exception $e, ?\{{ model }} ${{ builder.ModelClass }} = null)
{

// Throw exception if defined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class {{ builder.YamlKey|ucfirst }}Type extends BaseType
*
* @return boolean
*/
protected function canDisplay{{ column.name|classify|php_name }}(\{{ model }} ${{ builder.ModelClass }} = null)
protected function canDisplay{{ column.name|classify|php_name }}(?\{{ model }} ${{ builder.ModelClass }} = null)
{
{% if column.credentials is not empty and column.credentials != 'AdmingenAllowed' %}
{% if(admingenerator_config('use_jms_security')) %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @param \{{ model }} ${{ builder.ModelClass }}
* @return boolean
*/
protected function validateCredentials($credentials, \{{ model }} ${{ builder.ModelClass }} = null)
protected function validateCredentials($credentials, ?\{{ model }} ${{ builder.ModelClass }} = null)
{
{% if(admingenerator_config('use_jms_security')) %}
$credentials = new Expression($credentials);
Expand All @@ -29,7 +29,7 @@
* @param \{{ model }} ${{ builder.ModelClass }}
* @throws AccessDeniedException if is not allowed
*/
protected function denyAccessUnlessValidateCredentials($credentials, \{{ model }} ${{ builder.ModelClass }} = null)
protected function denyAccessUnlessValidateCredentials($credentials, ?\{{ model }} ${{ builder.ModelClass }} = null)
{
if (!$this->validateCredentials($credentials, ${{ builder.ModelClass }})) {
throw $this->createAccessDeniedException('Credentials unsatisfied');
Expand Down
4 changes: 2 additions & 2 deletions Routing/NestedRoutingLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

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

public function supports(mixed $resource, string $type = null): bool
public function supports(mixed $resource, ?string $type = null): bool
{
return 'admingenerator_nested' == $type;
}
Expand Down
4 changes: 2 additions & 2 deletions Routing/RoutingLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class RoutingLoader extends FileLoader

protected array $yaml = [];

public function load(mixed $resource, string $type = null): RouteCollection
public function load(mixed $resource, ?string $type = null): RouteCollection
{
$collection = new RouteCollection();

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

public function supports(mixed $resource, string $type = null): bool
public function supports(mixed $resource, ?string $type = null): bool
{
return 'admingenerator' == $type;
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function testDefaultConfig(): void
* Get waiting default values from configuration. If $key is not null
* and is in first level keys, returns value of this specific key only.
*/
private function getBundleDefaultConfig(string $key = null): mixed
private function getBundleDefaultConfig(?string $key = null): mixed
{
static $defaultConfiguration = [
'generate_base_in_project_dir' => false,
Expand Down
2 changes: 1 addition & 1 deletion Tests/Mocks/Doctrine/DriverMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class DriverMock implements Driver
{
private ?DatabasePlatformMock $_platformMock = null;

public function connect(array $params, $username = null, $password = null, array $driverOptions = array()): Driver\Connection
public function connect(array $params, $username = null, $password = null, array $driverOptions = []): Driver\Connection
{
return new DriverConnectionMock();
}
Expand Down
4 changes: 2 additions & 2 deletions Tests/Mocks/Doctrine/EntityManagerMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public function getUnitOfWork(): UnitOfWork
/**
* Mock factory method to create an EntityManager.
*/
public static function create(Connection $conn, \Doctrine\ORM\Configuration $config = null,
\Doctrine\Common\EventManager $eventManager = null): EntityManagerMock
public static function create(Connection $conn, ?\Doctrine\ORM\Configuration $config = null,
?\Doctrine\Common\EventManager $eventManager = null): EntityManagerMock
{
if (is_null($config)) {
$config = new \Doctrine\ORM\Configuration();
Expand Down
6 changes: 3 additions & 3 deletions Twig/Extension/EchoExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function convertAsForm(string $options, string $formType): string
* Print "trans" tag for string $str with parameters $parameters
* for catalog $catalog.
*/
public function getEchoTrans(string $str, array $parameters = [], string $catalog = 'Admingenerator', bool|string $escape = null): string
public function getEchoTrans(string $str, array $parameters = [], string $catalog = 'Admingenerator', bool|string|null $escape = null): string
{
$transParameters = '{}';
$bag_parameters = [];
Expand Down Expand Up @@ -120,7 +120,7 @@ public function getEchoTrans(string $str, array $parameters = [], string $catalo
/**
* Print "echo tag with path call" to the path $path with params $params.
*/
public function getEchoPath(string $path, string $params = null, array|string $filters = null): string
public function getEchoPath(string $path, string $params = null, array|string|null $filters = null): string
{
if (null === $params) {
return (null === $filters)
Expand Down Expand Up @@ -152,7 +152,7 @@ public function getEchoPath(string $path, string $params = null, array|string $f
* Print "if" tag with condition to is_expr_granted('$credentials')
* If $modelName is not null, append the $modelName to the function call.
*/
public function getEchoIfGranted(string $credentials, string $modelName = null): string
public function getEchoIfGranted(string $credentials, ?string $modelName = null): string
{
if ('AdmingenAllowed' == $credentials) {
return "{% if (true) %}";
Expand Down
2 changes: 1 addition & 1 deletion Twig/Extension/SecurityExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function getFunctions(): array
];
}

public function isOneGranted(array $credentials, object $object = null): bool
public function isOneGranted(array $credentials, ?object $object = null): bool
{
if (empty($credentials)) {
return true;
Expand Down