Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ksn135 committed Jun 16, 2024
1 parent ccf5c91 commit 8d3c991
Show file tree
Hide file tree
Showing 17 changed files with 46 additions and 46 deletions.
2 changes: 1 addition & 1 deletion src/Config/Crud.php
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ public function setColumnChooserColumns(array $defaultColumns = [], array $avail
return $this;
}

public function setColumnChooserSelectedColumnStorageProvider(SelectedColumnStorageProviderInterface $selectedColumnStorageProvider = null): self
public function setColumnChooserSelectedColumnStorageProvider(?SelectedColumnStorageProviderInterface $selectedColumnStorageProvider = null): self
{
$this->dto->setColumnChooserSelectedColumnStorageProvider($selectedColumnStorageProvider);

Expand Down
2 changes: 1 addition & 1 deletion src/Config/Menu/SubMenuItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class SubMenuItem implements MenuItemInterface
/** @var MenuItemInterface[] */
private array $subMenuItems = [];

public function __construct(TranslatableInterface|string $label, string $icon = null)
public function __construct(TranslatableInterface|string $label, ?string $icon = null)
{
$this->dto = new MenuItemDto();

Expand Down
10 changes: 5 additions & 5 deletions src/Config/MenuItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,23 @@ public static function linkToCrud(TranslatableInterface|string $label, ?string $
/**
* @param string|null $icon The full CSS classes of the FontAwesome icon to render (see https://fontawesome.com/v6/search?m=free)
*/
public static function linkToDashboard(TranslatableInterface|string $label, string $icon = null): DashboardMenuItem
public static function linkToDashboard(TranslatableInterface|string $label, ?string $icon = null): DashboardMenuItem
{
return new DashboardMenuItem($label, $icon);
}

/**
* @param string|null $icon The full CSS classes of the FontAwesome icon to render (see https://fontawesome.com/v6/search?m=free)
*/
public static function linkToExitImpersonation(TranslatableInterface|string $label, string $icon = null): ExitImpersonationMenuItem
public static function linkToExitImpersonation(TranslatableInterface|string $label, ?string $icon = null): ExitImpersonationMenuItem
{
return new ExitImpersonationMenuItem($label, $icon);
}

/**
* @param string|null $icon The full CSS classes of the FontAwesome icon to render (see https://fontawesome.com/v6/search?m=free)
*/
public static function linkToLogout(TranslatableInterface|string $label, string $icon = null): LogoutMenuItem
public static function linkToLogout(TranslatableInterface|string $label, ?string $icon = null): LogoutMenuItem
{
return new LogoutMenuItem($label, $icon);
}
Expand All @@ -72,15 +72,15 @@ public static function linkToUrl(TranslatableInterface|string $label, ?string $i
/**
* @param string|null $icon The full CSS classes of the FontAwesome icon to render (see https://fontawesome.com/v6/search?m=free)
*/
public static function section(TranslatableInterface|string|null $label = null, string $icon = null): SectionMenuItem
public static function section(TranslatableInterface|string|null $label = null, ?string $icon = null): SectionMenuItem
{
return new SectionMenuItem($label, $icon);
}

/**
* @param string|null $icon The full CSS classes of the FontAwesome icon to render (see https://fontawesome.com/v6/search?m=free)
*/
public static function subMenu(TranslatableInterface|string $label, string $icon = null): SubMenuItem
public static function subMenu(TranslatableInterface|string $label, ?string $icon = null): SubMenuItem
{
return new SubMenuItem($label, $icon);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Contracts/Field/FieldInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
interface FieldInterface
{
public static function new(string $propertyName, string /* TranslatableInterface|string|false|null */ $label = null);
public static function new(string $propertyName, ?string /* TranslatableInterface|string|false|null */ $label = null);

public function getAsDto(): FieldDto;

Expand Down
16 changes: 8 additions & 8 deletions src/Controller/AbstractCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,14 @@ protected function createColumnsForm(CrudDto $crud): FormInterface
{
return $this->createFormBuilder(['columns' => $crud->getSelectedColumns()])
->add('columns', ChoiceType::class, [
'label' => t('columnchooser.modal.help', [], 'EasyAdminBundle'),
'multiple' => true,
'expanded' => true,
'required' => false,
'choices' => $crud->getCurrentColumns(),
'choice_translation_domain' => true,
'translation_domain' => 'messages',
])
'label' => t('columnchooser.modal.help', [], 'EasyAdminBundle'),
'multiple' => true,
'expanded' => true,
'required' => false,
'choices' => $crud->getCurrentColumns(),
'choice_translation_domain' => true,
'translation_domain' => 'messages',
])
->getForm();
}

Expand Down
4 changes: 2 additions & 2 deletions src/Dto/CrudDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ public function setupColumnChooser(SelectedColumnStorageProviderInterface $selec
return $this;
}

public function setColumnChooserSelectedColumnStorageProvider(SelectedColumnStorageProviderInterface $selectedColumnStorageProvider = null): self
public function setColumnChooserSelectedColumnStorageProvider(?SelectedColumnStorageProviderInterface $selectedColumnStorageProvider = null): self
{
$this->selectedColumnStorageProvider = $selectedColumnStorageProvider;

Expand Down Expand Up @@ -662,7 +662,7 @@ public function columnChooserProcessFields(FieldCollection $fieldsColl): FieldCo

return \count($result) > 0 ? FieldCollection::new($result) : $fieldsColl;
}

public function areNullValuesHidden(): bool
{
return $this->hideNullValues;
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/FlattenException.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ final class FlattenException extends BaseFlattenException
{
private ?ExceptionContext $context = null;

public static function create(\Exception $exception, int $statusCode = null, array $headers = []): static
public static function create(\Exception $exception, ?int $statusCode = null, array $headers = []): static
{
if (!$exception instanceof BaseException) {
throw new \RuntimeException(sprintf('You should only try to create an instance of "%s" with a "EasyCorp\Bundle\EasyAdminBundle\Exception\BaseException" instance, or subclass. "%s" given.', __CLASS__, $exception::class));
Expand Down
2 changes: 1 addition & 1 deletion src/Factory/MenuFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ private function generateMenuItemUrl(MenuItemDto $menuItemDto): string
// 1. if CRUD controller is defined, use it...
if (null !== $crudControllerFqcn) {
$this->adminUrlGenerator->setController($crudControllerFqcn);
// 2. ...otherwise, find the CRUD controller from the entityFqcn
// 2. ...otherwise, find the CRUD controller from the entityFqcn
} else {
$crudControllers = $this->adminContextProvider->getContext()?->getCrudControllers();
if (null === $controllerFqcn = $crudControllers->findCrudFqcnByEntityFqcn($entityFqcn)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Field/AssociationField.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function setQueryBuilder(\Closure $queryBuilderCallable): self
return $this;
}

public function renderAsEmbeddedForm(string $crudControllerFqcn = null, string $crudNewPageName = null, string $crudEditPageName = null): self
public function renderAsEmbeddedForm(?string $crudControllerFqcn = null, ?string $crudNewPageName = null, ?string $crudEditPageName = null): self
{
$this->setCustomOption(self::OPTION_RENDER_AS_EMBEDDED_FORM, true);
$this->setCustomOption(self::OPTION_EMBEDDED_CRUD_FORM_CONTROLLER, $crudControllerFqcn);
Expand Down
2 changes: 1 addition & 1 deletion src/Field/CollectionField.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function renderExpanded(bool $renderExpanded = true): self
return $this;
}

public function useEntryCrudForm(string $crudControllerFqcn = null, string $crudNewPageName = null, string $crudEditPageName = null): self
public function useEntryCrudForm(?string $crudControllerFqcn = null, ?string $crudNewPageName = null, ?string $crudEditPageName = null): self
{
$this->setCustomOption(self::OPTION_ENTRY_USES_CRUD_FORM, true);
$this->setCustomOption(self::OPTION_ENTRY_CRUD_CONTROLLER_FQCN, $crudControllerFqcn);
Expand Down
2 changes: 1 addition & 1 deletion src/Field/FormField.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static function new(string $propertyName, $label = null)
* @param TranslatableInterface|string|false|null $label
* @param string|null $icon The full CSS classes of the FontAwesome icon to render (see https://fontawesome.com/v6/search?m=free)
*/
public static function addPanel($label = false, string $icon = null): self
public static function addPanel($label = false, ?string $icon = null): self
{
trigger_deprecation(
'easycorp/easyadmin-bundle',
Expand Down
2 changes: 1 addition & 1 deletion src/Form/ChoiceList/Loader/DynamicChoiceLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class DynamicChoiceLoader implements ChoiceLoaderInterface
private bool $cached = false;
private ?ArrayChoiceList $choiceList = null;

public function loadChoiceList(callable $value = null): ChoiceListInterface
public function loadChoiceList(?callable $value = null): ChoiceListInterface
{
if (null === $this->choiceList || !$this->cached) {
$this->choiceList = new ArrayChoiceList(array_combine($this->choices, $this->choices));
Expand Down
2 changes: 1 addition & 1 deletion src/Test/Exception/InvalidClassPropertyTypeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

final class InvalidClassPropertyTypeException extends \Exception
{
public function __construct(string $propertyName, string $propertyType, int $code = 0, \Throwable $previous = null)
public function __construct(string $propertyName, string $propertyType, int $code = 0, ?\Throwable $previous = null)
{
$message = sprintf('The test class should have a property named %s of type %s', $propertyName, $propertyType);

Expand Down
2 changes: 1 addition & 1 deletion src/Test/Exception/MissingClassMethodException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ final class MissingClassMethodException extends \Exception
/**
* @param array<array-key, string> $methodsName
*/
public function __construct(array $methodsName, int $code = 0, \Throwable $previous = null)
public function __construct(array $methodsName, int $code = 0, ?\Throwable $previous = null)
{
$message = 'The class should implement the following methods :';

Expand Down
8 changes: 4 additions & 4 deletions src/Test/Trait/CrudTestFormAsserts.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ trait CrudTestFormAsserts
{
use CrudTestSelectors;

protected function assertFormFieldExists(string $fieldName, string $message = null): void
protected function assertFormFieldExists(string $fieldName, ?string $message = null): void
{
$message ??= sprintf('The field %s is not existing in the form', $fieldName);

self::assertSelectorExists($this->getFormFieldSelector($fieldName), $message);
}

protected function assertFormFieldNotExists(string $fieldName, string $message = null): void
protected function assertFormFieldNotExists(string $fieldName, ?string $message = null): void
{
$message ??= sprintf('The field %s is existing in the form', $fieldName);

self::assertSelectorNotExists($this->getFormFieldSelector($fieldName), $message);
}

protected function assertFormFieldHasLabel(string $fieldName, string $label, string $message = null): void
protected function assertFormFieldHasLabel(string $fieldName, string $label, ?string $message = null): void
{
$message ??= sprintf('The field %s has not the correct label %s', $fieldName, $label);

Expand All @@ -34,7 +34,7 @@ protected function assertFormFieldHasLabel(string $fieldName, string $label, str
self::assertSelectorTextSame($this->getFormFieldLabelSelector($fieldName), $label, $message);
}

protected function assertFormFieldNotHasLabel(string $fieldName, string $label, string $message = null): void
protected function assertFormFieldNotHasLabel(string $fieldName, string $label, ?string $message = null): void
{
$message ??= sprintf('The field %s has the label %s', $fieldName, $label);

Expand Down
30 changes: 15 additions & 15 deletions src/Test/Trait/CrudTestIndexAsserts.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ trait CrudTestIndexAsserts
{
use CrudTestSelectors;

protected static function assertIndexFullEntityCount(int $expectedIndexFullEntityCount, string $message = null): void
protected static function assertIndexFullEntityCount(int $expectedIndexFullEntityCount, ?string $message = null): void
{
if (0 > $expectedIndexFullEntityCount) {
throw new \InvalidArgumentException();
Expand All @@ -24,7 +24,7 @@ protected static function assertIndexFullEntityCount(int $expectedIndexFullEntit
static::assertSelectorTextSame('.list-pagination-counter strong', (string) $expectedIndexFullEntityCount, $message);
}

protected function assertIndexPageEntityCount(int $expectedIndexPageEntityCount, string $message = null): void
protected function assertIndexPageEntityCount(int $expectedIndexPageEntityCount, ?string $message = null): void
{
if (0 > $expectedIndexPageEntityCount) {
throw new \InvalidArgumentException();
Expand All @@ -45,7 +45,7 @@ protected function assertIndexPageEntityCount(int $expectedIndexPageEntityCount,
static::assertEquals($expectedIndexPageEntityCount, $indexPageEntityRows->count(), $message);
}

protected function assertIndexPagesCount(int $expectedIndexPagesCount, string $message = null): void
protected function assertIndexPagesCount(int $expectedIndexPagesCount, ?string $message = null): void
{
if (0 >= $expectedIndexPagesCount) {
throw new \InvalidArgumentException();
Expand All @@ -61,7 +61,7 @@ protected function assertIndexPagesCount(int $expectedIndexPagesCount, string $m
static::assertEquals((string) $expectedIndexPagesCount, $lastNumberedPageItem->filter('a')->text(), $message);
}

protected function assertIndexEntityActionExists(string $action, string|int $entityId, string $message = null): void
protected function assertIndexEntityActionExists(string $action, string|int $entityId, ?string $message = null): void
{
$message ??= sprintf('The action %s has not been found for entity id %s', $action, (string) $entityId);

Expand All @@ -72,7 +72,7 @@ protected function assertIndexEntityActionExists(string $action, string|int $ent
self::assertCount(1, $action, $message);
}

protected function assertIndexEntityActionNotExists(string $action, string|int $entityId, string $message = null): void
protected function assertIndexEntityActionNotExists(string $action, string|int $entityId, ?string $message = null): void
{
$message ??= sprintf('The action %s has been found for entity id %s', $action, (string) $entityId);

Expand All @@ -83,65 +83,65 @@ protected function assertIndexEntityActionNotExists(string $action, string|int $
self::assertCount(0, $action, $message);
}

protected function assertIndexEntityActionTextSame(string $action, string $actionDisplay, string|int $entityId, string $message = null): void
protected function assertIndexEntityActionTextSame(string $action, string $actionDisplay, string|int $entityId, ?string $message = null): void
{
$this->assertIndexEntityActionExists($action, $entityId);

$message ??= sprintf('The action %s is not labelled with the following text : %s', $action, $actionDisplay);
self::assertSelectorTextSame($this->getIndexEntityActionSelector($action, $entityId), $actionDisplay, $message);
}

protected function assertIndexEntityActionNotTextSame(string $action, string $actionDisplay, string|int $entityId, string $message = null): void
protected function assertIndexEntityActionNotTextSame(string $action, string $actionDisplay, string|int $entityId, ?string $message = null): void
{
$this->assertIndexEntityActionExists($action, $entityId);

$message ??= sprintf('The action %s is labelled with the following text : %s', $action, $actionDisplay);
self::assertSelectorTextNotContains($this->getIndexEntityActionSelector($action, $entityId), $actionDisplay, $message);
}

protected function assertGlobalActionExists(string $action, string $message = null): void
protected function assertGlobalActionExists(string $action, ?string $message = null): void
{
$message ??= sprintf('The global action %s does not exist', $action);
self::assertSelectorExists($this->getGlobalActionSelector($action), $message);
}

protected function assertGlobalActionNotExists(string $action, string $message = null): void
protected function assertGlobalActionNotExists(string $action, ?string $message = null): void
{
$message ??= sprintf('The global action %s does exist', $action);
self::assertSelectorNotExists($this->getGlobalActionSelector($action), $message);
}

protected function assertGlobalActionDisplays(string $action, string $actionDisplay, string $message = null): void
protected function assertGlobalActionDisplays(string $action, string $actionDisplay, ?string $message = null): void
{
$message ??= sprintf('The global action %s does not display %s', $action, $actionDisplay);
self::assertSelectorTextSame($this->getGlobalActionSelector($action), $actionDisplay, $message);
}

protected function assertGlobalActionNotDisplays(string $action, string $actionDisplay, string $message = null): void
protected function assertGlobalActionNotDisplays(string $action, string $actionDisplay, ?string $message = null): void
{
$message ??= sprintf('The global action %s does display %s', $action, $actionDisplay);
self::assertSelectorTextNotContains($this->getGlobalActionSelector($action), $actionDisplay, $message);
}

protected function assertIndexColumnExists(string $columnName, string $message = null): void
protected function assertIndexColumnExists(string $columnName, ?string $message = null): void
{
$message ??= sprintf('The column %s is not existing', $columnName);
self::assertSelectorExists($this->getIndexHeaderColumnSelector($columnName), $message);
}

protected function assertIndexColumnNotExists(string $columnName, string $message = null): void
protected function assertIndexColumnNotExists(string $columnName, ?string $message = null): void
{
$message ??= sprintf('The column %s is existing', $columnName);
self::assertSelectorNotExists($this->getIndexHeaderColumnSelector($columnName), $message);
}

protected function assertIndexColumnHeaderContains(string $columnName, string $columnHeaderValue, string $message = null): void
protected function assertIndexColumnHeaderContains(string $columnName, string $columnHeaderValue, ?string $message = null): void
{
$message ??= sprintf('The column %s does not contain %s', $columnName, $columnHeaderValue);
self::assertSelectorTextSame($this->getIndexHeaderColumnSelector($columnName), $columnHeaderValue, $message);
}

protected function assertIndexColumnHeaderNotContains(string $columnName, string $columnHeaderValue, string $message = null): void
protected function assertIndexColumnHeaderNotContains(string $columnName, string $columnHeaderValue, ?string $message = null): void
{
$message ??= sprintf('The column %s contains %s', $columnName, $columnHeaderValue);
self::assertSelectorTextNotContains($this->getIndexHeaderColumnSelector($columnName), $columnHeaderValue, $message);
Expand Down
2 changes: 1 addition & 1 deletion tests/Test/Trait/CrudTestUrlGenerationTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function test(?string $dashboardFqcn, ?string $controllerFqcn): string
public function testUrlDetailGeneration()
{
$testClass = new class($this->adminUrlGenerator) extends CrudTestUrlGenerationTraitTestClass {
public function test(string|int $id, string $dashboardFqcn = null, string $controllerFqcn = null): string
public function test(string|int $id, ?string $dashboardFqcn = null, ?string $controllerFqcn = null): string
{
return $this->generateDetailUrl($id, dashboardFqcn: $dashboardFqcn, controllerFqcn: $controllerFqcn);
}
Expand Down

0 comments on commit 8d3c991

Please sign in to comment.