Skip to content

Commit

Permalink
Merge branch '7.0' into 7.1
Browse files Browse the repository at this point in the history
* 7.0:
  [AdminListBundle] Fix doctrine related unit tests
  Apply nullable_type_declaration_for_default_null_value and skip fully_qualified_strict_types
  • Loading branch information
acrobat committed Mar 5, 2024
2 parents 7d0aeec + 181125f commit d7b7894
Show file tree
Hide file tree
Showing 89 changed files with 126 additions and 118 deletions.
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@
'yoda_style' => false,
'visibility_required' => ['elements' => ['property', 'method']],
'phpdoc_separation' => ['skip_unlisted_annotations' => true],
'fully_qualified_strict_types' => false,
])
->setFinder($finder);
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class ExceptionAdminListConfigurator extends AbstractDoctrineORMAdminListConfigurator
{
public function __construct(EntityManager $em, AclHelper $aclHelper = null)
public function __construct(EntityManager $em, ?AclHelper $aclHelper = null)
{
parent::__construct($em, $aclHelper);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Kunstmaan/AdminBundle/Entity/BaseUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ public function getLastLogin()
/**
* @return static
*/
public function setLastLogin(\DateTime $lastLogin = null)
public function setLastLogin(?\DateTime $lastLogin = null)
{
$this->lastLogin = $lastLogin;

Expand Down
2 changes: 1 addition & 1 deletion src/Kunstmaan/AdminBundle/Entity/UserInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function setConfirmationToken($confirmationToken);
*
* @return static
*/
public function setLastLogin(\DateTime $time = null);
public function setLastLogin(?\DateTime $time = null);

/**
* Never use this to check if this user has access to anything!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function onKernelRequest(RequestEvent $event)
}
}

private function isAdminToken($providerKey, TokenInterface $token = null): bool
private function isAdminToken($providerKey, ?TokenInterface $token = null): bool
{
if (null === $token) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final class AdminPanelLogoutAction implements AdminPanelActionInterface
/** @var string */
private $template = '@KunstmaanAdmin/AdminPanel/_admin_panel_logout_action.html.twig';

public function __construct(string $url, string $label, string $icon = null, string $template = null)
public function __construct(string $url, string $label, ?string $icon = null, ?string $template = null)
{
$this->logoutUrl = $url;
$this->label = $label;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class DefaultAdminPanelAdaptor implements AdminPanelAdaptorInterface
/** @var LogoutUrlGenerator */
private $logoutUrlGenerator;

public function __construct(TokenStorageInterface $tokenStorage, LogoutUrlGenerator $logoutUrlGenerator)
public function __construct(TokenStorageInterface $tokenStorage, ?LogoutUrlGenerator $logoutUrlGenerator)
{
$this->tokenStorage = $tokenStorage;
$this->logoutUrlGenerator = $logoutUrlGenerator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ interface MenuAdaptorInterface
*
* @return void
*/
public function adaptChildren(MenuBuilder $menu, array &$children, MenuItem $parent = null, Request $request = null);
public function adaptChildren(MenuBuilder $menu, array &$children, ?MenuItem $parent = null, ?Request $request = null);
}
2 changes: 1 addition & 1 deletion src/Kunstmaan/AdminBundle/Helper/Menu/MenuBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function getTopChildren()
*
* @return MenuItem[]
*/
public function getChildren(MenuItem $parent = null)
public function getChildren(?MenuItem $parent = null)
{
if ($parent === null) {
return $this->getTopChildren();
Expand Down
2 changes: 1 addition & 1 deletion src/Kunstmaan/AdminBundle/Helper/Menu/MenuItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public function getParent()
*
* @return MenuItem
*/
public function setParent(MenuItem $parent = null)
public function setParent(?MenuItem $parent = null)
{
$this->parent = $parent;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
class ModulesMenuAdaptor implements MenuAdaptorInterface
{
public function adaptChildren(MenuBuilder $menu, array &$children, MenuItem $parent = null, Request $request = null)
public function adaptChildren(MenuBuilder $menu, array &$children, ?MenuItem $parent = null, ?Request $request = null)
{
if (\is_null($parent)) {
$menuItem = new TopMenuItem($menu);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct(AuthorizationCheckerInterface $authorizationChecker,
$this->exceptionLoggingEnabled = $exceptionLoggingEnabled;
}

public function adaptChildren(MenuBuilder $menu, array &$children, MenuItem $parent = null, Request $request = null)
public function adaptChildren(MenuBuilder $menu, array &$children, ?MenuItem $parent = null, ?Request $request = null)
{
if (\is_null($parent)) {
$menuItem = new TopMenuItem($menu);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct(AuthorizationCheckerInterface $authorizationChecker,
$this->menuItems = $menuItems;
}

public function adaptChildren(MenuBuilder $menu, array &$children, MenuItem $parent = null, Request $request = null)
public function adaptChildren(MenuBuilder $menu, array &$children, ?MenuItem $parent = null, ?Request $request = null)
{
foreach ($this->menuItems as $item) {
if (false === $this->parentMatches($parent, $item)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class AclVoter extends BaseAclVoter
/** @var bool */
private $permissionsEnabled;

public function __construct(AclProviderInterface $aclProvider, ObjectIdentityRetrievalStrategyInterface $oidRetrievalStrategy, SecurityIdentityRetrievalStrategyInterface $sidRetrievalStrategy, PermissionMapInterface $permissionMap, LoggerInterface $logger = null, $allowIfObjectIdentityUnavailable = true, $permissionsEnabled = true)
public function __construct(AclProviderInterface $aclProvider, ObjectIdentityRetrievalStrategyInterface $oidRetrievalStrategy, SecurityIdentityRetrievalStrategyInterface $sidRetrievalStrategy, PermissionMapInterface $permissionMap, ?LoggerInterface $logger = null, $allowIfObjectIdentityUnavailable = true, $permissionsEnabled = true)
{
parent::__construct($aclProvider, $oidRetrievalStrategy, $sidRetrievalStrategy, $permissionMap, $logger, $allowIfObjectIdentityUnavailable);
$this->permissionsEnabled = $permissionsEnabled;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function testExceptionExcludesFromExceptionLoggingConfig()
$this->assertContainerBuilderHasParameter('kunstmaan_admin.admin_exception_excludes', ['test_exclude_new_config']);
}

private function getRequiredConfig(string $excludeKey = null)
private function getRequiredConfig(?string $excludeKey = null)
{
$requiredConfig = [
'website_title' => 'Example title',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function setUp(): void
/**
* @return \PHPUnit\Framework\MockObject\MockObject|VersionChecker
*/
public function setUpVersionCheckerMock(?array $methods, string $projectDir = null)
public function setUpVersionCheckerMock(?array $methods, ?string $projectDir = null)
{
$versionCheckerMock = $this->getMockBuilder(VersionChecker::class)
->setConstructorArgs([$this->cache, $this->translator, $this->requestStack, 'url', 300, true, $projectDir ?? 'project_dir', 'website_title'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function collectData()
/**
* @return void
*/
public function collect(Request $request, Response $response, \Throwable $exception = null)
public function collect(Request $request, Response $response, ?\Throwable $exception = null)
{
if (!$this->isEnabled()) {
$this->data = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function collectData()
/**
* @return void
*/
public function collect(Request $request, Response $response, \Throwable $exception = null)
public function collect(Request $request, Response $response, ?\Throwable $exception = null)
{
if (false === $this->isEnabled()) {
$this->data = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ public function canExport()
*
* @return AbstractAdminListConfigurator
*/
public function addField($name, $header, $sort, $template = null, FieldAlias $alias = null)
public function addField($name, $header, $sort, $template = null, ?FieldAlias $alias = null)
{
$this->fields[] = new Field($name, $header, $sort, $template, $alias);

Expand All @@ -387,7 +387,7 @@ public function addField($name, $header, $sort, $template = null, FieldAlias $al
*
* @return AbstractAdminListConfigurator
*/
public function addExportField($name, $header, $template = null, FieldAlias $alias = null)
public function addExportField($name, $header, $template = null, ?FieldAlias $alias = null)
{
$this->exportFields[] = new Field($name, $header, false, $template, $alias);

Expand All @@ -404,7 +404,7 @@ public function addExportField($name, $header, $template = null, FieldAlias $ali
*/
public function addFilter(
$columnName,
FilterTypeInterface $type = null,
?FilterTypeInterface $type = null,
$filterName = null,
array $options = []
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ abstract class AbstractDoctrineORMAdminListConfigurator extends AbstractAdminLis
*/
protected $aclHelper;

public function __construct(EntityManagerInterface $em, AclHelper $aclHelper = null)
public function __construct(EntityManagerInterface $em, ?AclHelper $aclHelper = null)
{
$this->em = $em;
$this->aclHelper = $aclHelper;
Expand Down
2 changes: 1 addition & 1 deletion src/Kunstmaan/AdminListBundle/AdminList/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Field
* @param string $template The template
* @param FieldAlias $alias The alias
*/
public function __construct($name, $header, $sort = false, $template = null, FieldAlias $alias = null)
public function __construct($name, $header, $sort = false, $template = null, ?FieldAlias $alias = null)
{
$this->name = $name;
$this->header = $header;
Expand Down
2 changes: 1 addition & 1 deletion src/Kunstmaan/AdminListBundle/AdminList/FilterBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class FilterBuilder
*
* @return FilterBuilder
*/
public function add($columnName, FilterTypeInterface $type = null, $filterName = null, array $options = [])
public function add($columnName, ?FilterTypeInterface $type = null, $filterName = null, array $options = [])
{
$this->filterDefinitions[$columnName] = [
'type' => $type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected function doIndexAction(AdminListConfiguratorInterface $configurator, R
*
* @throws AccessDeniedHttpException
*/
protected function doExportAction(AdminListConfiguratorInterface $configurator, $_format, Request $request = null)
protected function doExportAction(AdminListConfiguratorInterface $configurator, $_format, ?Request $request = null)
{
if (!$configurator->canExport()) {
throw $this->createAccessDeniedException('You do not have sufficient rights to access this page.');
Expand Down
2 changes: 1 addition & 1 deletion src/Kunstmaan/AdminListBundle/Event/AdminListEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ final class AdminListEvent extends Event
/**
* @param object $entity
*/
public function __construct($entity, Request $request, FormInterface $form = null)
public function __construct($entity, Request $request, ?FormInterface $form = null)
{
$this->entity = $entity;
$this->request = $request;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ExportException extends \RuntimeException
* @param string $message
* @param int $code
*/
public function __construct($message, $data, $code = 0, \Throwable $previous = null)
public function __construct($message, $data, $code = 0, ?\Throwable $previous = null)
{
parent::__construct($message, $code, $previous);
$this->data = $data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class EntityVersionLockRepository extends EntityRepository
*
* @return LockableEntity[]
*/
public function getLocksForLockableEntity(LockableEntity $entity, $threshold, UserInterface $userToExclude = null)
public function getLocksForLockableEntity(LockableEntity $entity, $threshold, ?UserInterface $userToExclude = null)
{
$qb = $this->createQueryBuilder('evl')
->select('evl')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ protected function createEntityVersionLock(UserInterface $user, LockableEntity $
/**
* @return array
*/
public function getUsersWithEntityVersionLock(LockableEntityInterface $entity, UserInterface $userToExclude = null)
public function getUsersWithEntityVersionLock(LockableEntityInterface $entity, ?UserInterface $userToExclude = null)
{
/** @var LockableEntity $lockable */
$lockable = $this->getLockableEntity($entity);
Expand Down Expand Up @@ -125,7 +125,7 @@ protected function removeExpiredLocks(LockableEntity $entity)
*
* @return EntityVersionLock[]
*/
protected function getEntityVersionLocksByLockableEntity(LockableEntity $entity, UserInterface $userToExclude = null)
protected function getEntityVersionLocksByLockableEntity(LockableEntity $entity, ?UserInterface $userToExclude = null)
{
/** @var EntityVersionLockRepository $objectRepository */
$objectRepository = $this->objectManager->getRepository(EntityVersionLock::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\ForwardCompatibility\DriverStatement;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\Query\QueryBuilder;
use Doctrine\DBAL\Result;
use Doctrine\DBAL\Statement;
Expand All @@ -24,6 +25,7 @@ class AbstractDoctrineDBALAdminListConfiguratorTest extends TestCase
public function setUp(): void
{
$this->connectionMock = $this->createMock(Connection::class);
$this->connectionMock->method('getDatabasePlatform')->willReturn(new MySQLPlatform());
$this->connectionMock
->expects($this->any())
->method('executeQuery')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Kunstmaan\AdminListBundle\Tests\AdminList\FilterType\DBAL;

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\Query\Expression\ExpressionBuilder;
use Doctrine\DBAL\Query\QueryBuilder;
use PHPUnit\Framework\TestCase;
Expand All @@ -14,6 +15,10 @@ public function getQueryBuilder()
$conn = $this->createMock(Connection::class);
$expressionBuilder = new ExpressionBuilder($conn);

$conn->method('getDatabasePlatform')->willReturn(new MySQLPlatform());
if (method_exists(Connection::class, 'createExpressionBuilder')) {
$conn->method('createExpressionBuilder')->willReturn($expressionBuilder);
}
$conn->method('getExpressionBuilder')->willReturn($expressionBuilder);

return new QueryBuilder($conn);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class VarnishMenuAdaptor implements MenuAdaptorInterface
{
public function adaptChildren(MenuBuilder $menu, array &$children, MenuItem $parent = null, Request $request = null)
public function adaptChildren(MenuBuilder $menu, array &$children, ?MenuItem $parent = null, ?Request $request = null)
{
if (!is_null($parent) && 'KunstmaanAdminBundle_settings' == $parent->getRoute()) {
$menuItem = new MenuItem($menu);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct($configuration, AuthorizationCheckerInterface $autho
$this->authorizationChecker = $authorizationChecker;
}

public function adaptChildren(MenuBuilder $menu, array &$children, MenuItem $parent = null, Request $request = null)
public function adaptChildren(MenuBuilder $menu, array &$children, ?MenuItem $parent = null, ?Request $request = null)
{
if (!\is_null($parent) && 'KunstmaanAdminBundle_settings' == $parent->getRoute()) {
// Load all the kunstmaan_config entities and create a menu item for them.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class CookieAdminListConfigurator extends AbstractDoctrineORMAdminListConfigurat
*/
private $domainConfiguration;

public function __construct(EntityManager $em, AclHelper $aclHelper = null, DomainConfigurationInterface $domainConfiguration = null)
public function __construct(EntityManager $em, ?AclHelper $aclHelper = null, ?DomainConfigurationInterface $domainConfiguration = null)
{
parent::__construct($em, $aclHelper);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class CookieTypeAdminListConfigurator extends AbstractDoctrineORMAdminListConfig
* @param EntityManager $em The entity manager
* @param AclHelper $aclHelper The acl helper
*/
public function __construct(EntityManager $em, AclHelper $aclHelper = null)
public function __construct(EntityManager $em, ?AclHelper $aclHelper = null)
{
parent::__construct($em, $aclHelper);
$this->setAdminType(CookieTypeAdminType::class);
Expand Down
2 changes: 1 addition & 1 deletion src/Kunstmaan/CookieBundle/Entity/Cookie.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function getDescription()
/**
* @return Cookie
*/
public function setType(CookieType $type = null)
public function setType(?CookieType $type = null)
{
$this->type = $type;

Expand Down
4 changes: 2 additions & 2 deletions src/Kunstmaan/CookieBundle/Helper/Menu/CookieMenuAdaptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class CookieMenuAdaptor implements MenuAdaptorInterface
* @param MenuItem $parent The parent Menu item
* @param Request $request The Request
*/
public function adaptChildren(MenuBuilder $menu, array &$children, MenuItem $parent = null, Request $request = null)
public function adaptChildren(MenuBuilder $menu, array &$children, ?MenuItem $parent = null, ?Request $request = null)
{
if (null !== $parent && 'KunstmaanAdminBundle_modules' === $parent->getRoute()) {
$this->addMenuItem(
Expand Down Expand Up @@ -63,7 +63,7 @@ public function adaptChildren(MenuBuilder $menu, array &$children, MenuItem $par
* @param string $uniqueId
* @param string $label
*/
private function addMenuItem(MenuBuilder $menu, array &$children, MenuItem $parent, Request $request = null, $route, $uniqueId, $label)
private function addMenuItem(MenuBuilder $menu, array &$children, MenuItem $parent, ?Request $request = null, $route, $uniqueId, $label)
{
$menuItem = new TopMenuItem($menu);
$menuItem
Expand Down
2 changes: 1 addition & 1 deletion src/Kunstmaan/FixturesBundle/Loader/FixtureLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function getProviders()
*
* @api
*/
public function setContainer(ContainerInterface $container = null)
public function setContainer(?ContainerInterface $container = null)
{
$this->container = $container;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Kunstmaan/FormBundle/Helper/FormHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ class FormHandler implements FormHandlerInterface

public function __construct(
ContainerInterface $container,
EntityManagerInterface $em,
FormFactoryInterface $formFactory,
RouterInterface $router,
EventDispatcherInterface $eventDispatcher
?EntityManagerInterface $em,
?FormFactoryInterface $formFactory,
?RouterInterface $router,
?EventDispatcherInterface $eventDispatcher
) {
$this->container = $container;
$this->em = $em;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class FormSubmissionsMenuAdaptor implements MenuAdaptorInterface
{
public function adaptChildren(MenuBuilder $menu, array &$children, MenuItem $parent = null, Request $request = null)
public function adaptChildren(MenuBuilder $menu, array &$children, ?MenuItem $parent = null, ?Request $request = null)
{
if (!is_null($parent) && 'KunstmaanAdminBundle_modules' == $parent->getRoute()) {
$menuitem = new TopMenuItem($menu);
Expand Down
Loading

0 comments on commit d7b7894

Please sign in to comment.