Skip to content
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

Run lint task under PHP 8.3 #670

Merged
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
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
sudo docker-php-ext-install pdo_mysql gd
parallel: true
- run: echo -e "memory_limit=2G" | sudo tee /usr/local/etc/php/php.ini > /dev/null
- run: /usr/local/bin/composer remove php-cs-fixer/shim --dev --no-update
- run: /usr/local/bin/composer require "elasticsearch/elasticsearch:~7.5.2" --no-update
- restore_cache:
keys:
Expand Down
17 changes: 16 additions & 1 deletion .github/workflows/test-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,18 @@ jobs:
SYMFONY_DEPRECATIONS_HELPER: weak
ELASTICSEARCH_HOST: '127.0.0.1:9200'

- php-version: '8.3'
elasticsearch-version: '7.11.1'
elasticsearch-package-constraint: '~7.11.0'
phpcr-transport: jackrabbit
dependency-versions: 'highest'
php-extensions: 'ctype, iconv, mysql, imagick'
tools: 'composer:v2'
phpstan: false
env:
SYMFONY_DEPRECATIONS_HELPER: weak
ELASTICSEARCH_HOST: '127.0.0.1:9200'

services:
mysql:
image: mysql:5.7
Expand Down Expand Up @@ -124,6 +136,9 @@ jobs:
tools: ${{ matrix.tools }}
coverage: none

- name: Remove not required tooling
run: composer remove php-cs-fixer/shim --dev --no-interaction --no-update

- name: Require elasticsearch dependency
run: composer require --dev elasticsearch/elasticsearch:"${{ matrix.elasticsearch-package-constraint }}" --no-interaction --no-update

Expand Down Expand Up @@ -155,7 +170,7 @@ jobs:
- name: Install and configure PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
php-version: 8.3
extensions: 'ctype, iconv, mysql, imagick'
tools: 'composer:v2'
coverage: none
Expand Down
2 changes: 1 addition & 1 deletion Command/ArticleImportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ArticleImportCommand extends Command
*/
private $logger;

public function __construct(ArticleImportInterface $articleImporter, LoggerInterface $logger = null)
public function __construct(ArticleImportInterface $articleImporter, ?LoggerInterface $logger = null)
{
parent::__construct();

Expand Down
4 changes: 2 additions & 2 deletions Content/ArticleDataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ public function __construct(
ArticleResourceItemFactory $articleResourceItemFactory,
string $articleDocumentClass,
int $defaultLimit,
MetadataProviderInterface $formMetadataProvider = null,
TokenStorageInterface $tokenStorage = null,
?MetadataProviderInterface $formMetadataProvider = null,
?TokenStorageInterface $tokenStorage = null,
bool $hasAudienceTargeting = false
) {
$this->searchManager = $searchManager;
Expand Down
4 changes: 2 additions & 2 deletions Controller/ArticleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,8 @@ public function cgetAction(Request $request): Response
$search->addQuery(new MatchAllQuery());
}

if (null !== $this->restHelper->getSortColumn() &&
$sortField = $this->getSortFieldName($this->restHelper->getSortColumn())
if (null !== $this->restHelper->getSortColumn()
&& $sortField = $this->getSortFieldName($this->restHelper->getSortColumn())
) {
$search->addSort(
new FieldSort($sortField, $this->restHelper->getSortOrder())
Expand Down
1 change: 1 addition & 0 deletions DependencyInjection/SuluArticleExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ public function load(array $configs, ContainerBuilder $container)
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.xml');

/** @var array<string, string> $bundles */
$bundles = $container->getParameter('kernel.bundles');
if (\array_key_exists('SuluAutomationBundle', $bundles)) {
$loader->load('automation.xml');
Expand Down
2 changes: 0 additions & 2 deletions Document/ArticlePageDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,6 @@ public function setTitle($title)

/**
* Returns pageTitle.
*
* @return string
*/
public function getPageTitle(): ?string
{
Expand Down
4 changes: 2 additions & 2 deletions Document/ArticleViewDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ public function getAuthored()
return $this->authored;
}

public function setAuthored(\DateTime $authored = null)
public function setAuthored(?\DateTime $authored = null)
{
$this->authored = $authored;

Expand Down Expand Up @@ -537,7 +537,7 @@ public function getPublished()
return $this->published;
}

public function setPublished(\DateTime $published = null)
public function setPublished(?\DateTime $published = null)
{
$this->published = $published;

Expand Down
8 changes: 2 additions & 6 deletions Document/ArticleViewDocumentInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,9 @@ public function getAuthored();
/**
* Set authored date.
*
* @param \DateTime $authored
*
* @return $this
*/
public function setAuthored(\DateTime $authored = null);
public function setAuthored(?\DateTime $authored = null);

/**
* Returns author full name.
Expand Down Expand Up @@ -331,11 +329,9 @@ public function getPublished();
/**
* Set published.
*
* @param \DateTime $published
*
* @return $this
*/
public function setPublished(\DateTime $published = null);
public function setPublished(?\DateTime $published = null);

/**
* Get published state.
Expand Down
2 changes: 1 addition & 1 deletion Document/LocalizationStateViewObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class LocalizationStateViewObject
*/
public $locale;

public function __construct(string $state = null, string $locale = null)
public function __construct(?string $state = null, ?string $locale = null)
{
$this->state = $state;
$this->locale = $locale;
Expand Down
4 changes: 2 additions & 2 deletions Document/Repository/ArticleViewDocumentRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function __construct(
public function findRecent(
?string $excludeUuid = null,
int $limit = self::DEFAULT_LIMIT,
array $types = null,
?array $types = null,
?string $locale = null,
?string $webspaceKey = null
): DocumentIterator {
Expand All @@ -97,7 +97,7 @@ public function findRecent(
public function findSimilar(
string $uuid,
int $limit = self::DEFAULT_LIMIT,
array $types = null,
?array $types = null,
?string $locale = null,
?string $webspaceKey = null
): DocumentIterator {
Expand Down
6 changes: 3 additions & 3 deletions Document/Serializer/WebsiteArticleUrlsSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ public function __construct(
RequestStack $requestStack,
RouteRepositoryInterface $routeRepository,
WebspaceManagerInterface $webspaceManager,
DocumentInspector $documentInspector = null,
DocumentRegistry $documentRegistry = null,
NodeManager $nodeManager = null
?DocumentInspector $documentInspector = null,
?DocumentRegistry $documentRegistry = null,
?NodeManager $nodeManager = null
) {
$this->requestStack = $requestStack;
$this->routeRepository = $routeRepository;
Expand Down
2 changes: 1 addition & 1 deletion Document/Structure/ArticleBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ArticleBridge extends StructureBridge implements RoutableStructureInterfac
/**
* @var string
*/
private $webspaceKey = null;
private $webspaceKey;

/**
* @var string
Expand Down
2 changes: 1 addition & 1 deletion Document/Subscriber/ArticleSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public static function getSubscribedEvents()
Events::FLUSH => [['handleFlush', -2048], ['handleFlushLive', -2048]],
Events::COPY => ['handleCopy'],
Events::METADATA_LOAD => ['handleMetadataLoad'],
EVENTS::REMOVE_LOCALE => [['handleRemoveLocale', -500], ['handleRemoveLocaleLive', -500]],
Events::REMOVE_LOCALE => [['handleRemoveLocale', -500], ['handleRemoveLocaleLive', -500]],
];
}

Expand Down
2 changes: 1 addition & 1 deletion Export/ExportFormatNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ExportFormatNotFoundException extends \Exception
*/
private $format;

public function __construct(string $format, int $code = 0, \Throwable $previous = null)
public function __construct(string $format, int $code = 0, ?\Throwable $previous = null)
{
parent::__construct(\sprintf('No format "%s" configured for Snippet export', $format), $code, $previous);

Expand Down
4 changes: 2 additions & 2 deletions Import/ArticleImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function __construct(
ExtensionManagerInterface $extensionManager,
ImportManagerInterface $importManager,
FormatImportInterface $xliff12,
LoggerInterface $logger = null
?LoggerInterface $logger = null
) {
parent::__construct($importManager, $legacyPropertyFactory, ['1.2.xliff' => $xliff12]);

Expand All @@ -108,7 +108,7 @@ public function __construct(
public function import(
string $locale,
string $filePath,
OutputInterface $output = null,
?OutputInterface $output = null,
string $format = '1.2.xliff',
bool $overrideSettings = false
): ImportResult {
Expand Down
2 changes: 1 addition & 1 deletion Import/ArticleImportInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface ArticleImportInterface
public function import(
string $locale,
string $filePath,
OutputInterface $output = null,
?OutputInterface $output = null,
string $format = '1.2.xliff',
bool $overrideSettings = false
): ImportResult;
Expand Down
6 changes: 3 additions & 3 deletions ListBuilder/ElasticSearchFieldDescriptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
class ElasticSearchFieldDescriptor extends FieldDescriptor
{
public static function create(string $name, string $translation = null): ElasticSearchFieldDescriptorBuilder
public static function create(string $name, ?string $translation = null): ElasticSearchFieldDescriptorBuilder
{
return new ElasticSearchFieldDescriptorBuilder($name, $translation);
}
Expand All @@ -37,8 +37,8 @@ public static function create(string $name, string $translation = null): Elastic

public function __construct(
string $name,
string $sortField = null,
string $translation = null,
?string $sortField = null,
?string $translation = null,
string $visibility = FieldDescriptorInterface::VISIBILITY_YES,
string $searchability = FieldDescriptorInterface::SEARCHABILITY_NEVER,
string $type = '',
Expand Down
4 changes: 2 additions & 2 deletions ListBuilder/ElasticSearchFieldDescriptorBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ final class ElasticSearchFieldDescriptorBuilder
/**
* @var string
*/
private $sortField = null;
private $sortField;

/**
* @var string
Expand All @@ -55,7 +55,7 @@ final class ElasticSearchFieldDescriptorBuilder
*/
private $searchField = '';

public function __construct(string $name, string $translation = null)
public function __construct(string $name, ?string $translation = null)
{
$this->name = $name;
$this->translation = $translation;
Expand Down
4 changes: 2 additions & 2 deletions Routing/ArticleRouteDefaultProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ public function isPublished($entityClass, $id, $locale)
}

$webspace = $this->requestAnalyzer->getWebspace();
if (!$webspace ||
(
if (!$webspace
|| (
$this->webspaceResolver->resolveMainWebspace($object) !== $webspace->getKey()
&& !\in_array($webspace->getKey(), $this->webspaceResolver->resolveAdditionalWebspaces($object))
)
Expand Down
2 changes: 1 addition & 1 deletion Tests/Application/bin/console.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
if (\class_exists(Debug::class)) {
Debug::enable();
} else {
\Symfony\Component\Debug\Debug::enable();
Symfony\Component\Debug\Debug::enable();
}
}

Expand Down
3 changes: 0 additions & 3 deletions Tests/Functional/Controller/ArticlePageControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,6 @@ private function purgeIndex()
}

/**
* @param $uuid
* @param $locale
*
* @return ArticleViewDocumentInterface
*/
private function findViewDocument($uuid, $locale)
Expand Down
18 changes: 9 additions & 9 deletions Tests/Unit/Content/ArticleSelectionContentTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ function($id) {
Argument::that(
function(IdsQuery $query) use ($ids) {
return $query->toArray() === [
'ids' => [
'values' => \array_map(
function($id) {
return $id . '-de';
},
$ids
),
],
];
'ids' => [
'values' => \array_map(
function($id) {
return $id . '-de';
},
$ids
),
],
];
}
)
)->shouldBeCalled();
Expand Down
2 changes: 1 addition & 1 deletion Tests/Unit/Document/Subscriber/ArticleSubscriberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ public function testHydratePageDataShadow()
$this->document->reveal()
)->willReturn(LocalizationState::SHADOW);

$propertyNameEN = 'i18n:' . 'en' . '-' . ArticleSubscriber::PAGES_PROPERTY;
$propertyNameEN = 'i18n:en-' . ArticleSubscriber::PAGES_PROPERTY;
$this->propertyEncoder->localizedSystemName(ArticleSubscriber::PAGES_PROPERTY, 'en')
->willReturn($propertyNameEN);

Expand Down
8 changes: 4 additions & 4 deletions Twig/ArticleViewDocumentTwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function getFunctions()
*/
public function loadRecent(
int $limit = ArticleViewDocumentRepository::DEFAULT_LIMIT,
array $types = null,
?array $types = null,
?string $locale = null,
bool $ignoreWebspaces = false
): array {
Expand Down Expand Up @@ -131,13 +131,13 @@ public function loadRecent(
/**
* Loads similar articles with given parameters.
*
* @throws ArticleInRequestNotFoundException
*
* @return ArticleResourceItem[]
*
* @throws ArticleInRequestNotFoundException
*/
public function loadSimilar(
int $limit = ArticleViewDocumentRepository::DEFAULT_LIMIT,
array $types = null,
?array $types = null,
?string $locale = null,
bool $ignoreWebspaces = false
): array {
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
},
"require-dev": {
"doctrine/data-fixtures": "^1.1",
"friendsofphp/php-cs-fixer": "^3.0",
"handcraftedinthealps/zendsearch": "^2.0",
"jackalope/jackalope-doctrine-dbal": "^1.3.4",
"jackalope/jackalope-jackrabbit": "^1.3",
"jangregor/phpstan-prophecy": "^1.0",
"massive/build-bundle": "^0.3 || ^0.4 || ^0.5",
"php-cs-fixer/shim": "^3.0",
"phpcr/phpcr-shell": "^1.1",
"phpspec/prophecy": "^1.15",
"phpstan/phpstan": "^1.0",
Expand Down
5 changes: 0 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -505,11 +505,6 @@ parameters:
count: 1
path: DependencyInjection/StructureValidatorCompilerPass.php

-
message: "#^Call to function array_key_exists\\(\\) with 'SuluAutomationBundle' and array\\{FrameworkBundle\\: string, TwigBundle\\: string, SuluCoreBundle\\: string, DoctrineBundle\\: string, DoctrinePHPCRBundle\\: string, PhpcrMigrationsBundle\\: string, StofDoctrineExtensionsBundle\\: string, JMSSerializerBundle\\: string, \\.\\.\\.\\} will always evaluate to false\\.$#"
count: 1
path: DependencyInjection/SuluArticleExtension.php

-
message: "#^Method Sulu\\\\Bundle\\\\ArticleBundle\\\\DependencyInjection\\\\SuluArticleExtension\\:\\:appendDefaultAuthor\\(\\) has parameter \\$config with no value type specified in iterable type array\\.$#"
count: 1
Expand Down
Loading