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

[BUGFIX] Explicitly declare nullable function parameters #1505

Merged
merged 3 commits into from
Mar 18, 2025

Conversation

stweil
Copy link
Member

@stweil stweil commented Mar 4, 2025

PHP 7.1 added support for nullable types, but they could be declared implicitly. PHP 8.4 deprecates implicitly nullable types.

Using an explicit declaration avoids several warnings with PHP 8.4.

@stweil
Copy link
Member Author

stweil commented Mar 4, 2025

I expect that there are more nullable types which should be declared explicitly, but until now only the 3 locations which are fixed here triggered warnings in my tests.

@sebastian-meyer sebastian-meyer changed the title Explicitly declare nullable function parameters [BUGFIX] Explicitly declare nullable function parameters Mar 4, 2025
@sebastian-meyer sebastian-meyer added the 🐛 bug A non-security related bug. label Mar 4, 2025
Copy link

codecov bot commented Mar 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 0.00%. Comparing base (95a1ff5) to head (30149cf).
Report is 1 commits behind head on main.

Additional details and impacted files
@@     Coverage Diff      @@
##   main   #1505   +/-   ##
============================
============================

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@stweil
Copy link
Member Author

stweil commented Mar 4, 2025

I expect that there are more nullable types which should be declared explicitly, but until now only the 3 locations which are fixed here triggered warnings in my tests.

These code lines need similar fixes:

Classes/Common/DocumentAnnotation.php:    protected function getAudioPagesByFileId($fileId, $range = null)
Classes/Common/DocumentAnnotation.php:    protected function getMeasurePagesByFileId($fileId, $range = null)
Classes/Common/Solr/Solr.php:    public static function getInstance($core = null): Solr
Classes/Common/Solr/SolrSearch.php:    public function __construct(DocumentRepository $documentRepository, $collections, array $settings, array $searchParams, QueryResult $listedMetadata = null, QueryResult $indexedMetadata = null)
Classes/Controller/Backend/NewTenantController.php:    protected function htmlResponse(?string $html = null): ResponseInterface
Classes/Controller/NavigationController.php:    public function pageSelectAction(PageSelectForm $pageSelectForm = null): ResponseInterface
Classes/Controller/PageViewController.php:    public function convertMeasureOrPage($document, $measure = null, $page = null)
Classes/Domain/Repository/DocumentRepository.php:    public function findSolrByCollection(Collection $collection, $settings, $searchParams, $listedMetadata = null, $indexedMetadata = null)
Classes/Domain/Repository/DocumentRepository.php:    public function findSolrByCollections($collections, $settings, $searchParams, $listedMetadata = null, $indexedMetadata = null): SolrSearch
Classes/Domain/Repository/DocumentRepository.php:    public function findSolrWithoutCollection($settings, $searchParams, $listedMetadata = null, $indexedMetadata = null): SolrSearch
Classes/Domain/Repository/DocumentRepository.php:    private function findSolr($collections, $settings, $searchParams, $listedMetadata = null, $indexedMetadata = null): SolrSearch
Classes/Task/BaseAdditionalFieldProvider.php:    protected function getSolrField(int $solr, int $pid = null): array
Classes/Task/BaseAdditionalFieldProvider.php:    private function getSolrCores(int $pid = null): array
Classes/Validation/AbstractDlfValidationStack.php:    protected function addValidator(string $className, string $title, bool $breakOnError = true, array $configuration = null): void

stweil and others added 2 commits March 18, 2025 11:10
PHP 7.1 added support for nullable types, but they could be declared
implicitly. PHP 8.4 deprecates implicitly nullable types.

Using an explicit declaration avoids several warnings with PHP 8.4.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Co-authored-by: Stefan Weil <sw@weilnetz.de>

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@sebastian-meyer
Copy link
Member

Since you identified more files which need adjustments: should I wait for you to fix those as well or do you want to open separate PRs for those?

@stweil
Copy link
Member Author

stweil commented Mar 18, 2025

No, please merge. I currently struggle with the broken viewer which is much more important (see #1536 (comment)).

@sebastian-meyer sebastian-meyer merged commit 3a5503d into kitodo:main Mar 18, 2025
6 checks passed
@stweil stweil deleted the php8.4 branch March 18, 2025 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug A non-security related bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants