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

Update CameraManufacturerVisitor signatures #2577

Closed
wants to merge 3 commits into from

Conversation

adriendupuis
Copy link
Contributor

Question Answer
JIRA Ticket
Versions
Edition

Fix several PHPStan errors

  • Parameter #1 $criterion (Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion) of method App\Query\Criterion\Elasticsearch\CameraManufacturerVisitor::supports() is not contravariant with parameter #1 $criterion (Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface) of method Ibexa\Contracts\Elasticsearch\Query\CriterionVisitor::supports().
  • Parameter #2 $criterion (Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion) of method App\Query\Criterion\Elasticsearch\CameraManufacturerVisitor::visit() is not contravariant with parameter #2 $criterion (Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface) of method Ibexa\Contracts\Elasticsearch\Query\CriterionVisitor::visit().
  • Parameter #1 $criterion (Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion) of method App\Query\Criterion\Solr\CameraManufacturerVisitor::canVisit() is not contravariant with parameter #1 $criterion (Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface) of method Ibexa\Contracts\Solr\Query\CriterionVisitor::canVisit().
  • Parameter #1 $criterion (Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion) of method App\Query\Criterion\Solr\CameraManufacturerVisitor::visit() is not contravariant with parameter #1 $criterion (Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface) of method Ibexa\Contracts\Solr\Query\CriterionVisitor::visit().

Checklist

  • Text renders correctly
  • Text has been checked with vale
  • Description metadata is up to date
  • Redirects cover removed/moved pages
  • Code samples are working
  • PHP code samples have been fixed with PHP CS fixer
  • Added link to this PR in relevant JIRA ticket or code PR

@adriendupuis adriendupuis marked this pull request as ready for review December 10, 2024 20:07
@adriendupuis adriendupuis marked this pull request as draft December 10, 2024 20:09
Copy link

code_samples/ change report

Before (on target branch)After (in current PR)

code_samples/search/elasticsearch/src/Query/Criterion/Elasticsearch/CameraManufacturerVisitor.php

docs/search/extensibility/create_custom_search_criterion.md@43: ``` php
docs/search/extensibility/create_custom_search_criterion.md@44: --8<--
docs/search/extensibility/create_custom_search_criterion.md@45: code_samples/search/elasticsearch/src/Query/Criterion/Elasticsearch/CameraManufacturerVisitor.php
docs/search/extensibility/create_custom_search_criterion.md@46: --8<--
docs/search/extensibility/create_custom_search_criterion.md@47: ```

001⫶<?php
002⫶
003⫶declare(strict_types=1);
004⫶
005⫶namespace App\Query\Criterion\Elasticsearch;
006⫶

code_samples/search/elasticsearch/src/Query/Criterion/Elasticsearch/CameraManufacturerVisitor.php

docs/search/extensibility/create_custom_search_criterion.md@43: ``` php
docs/search/extensibility/create_custom_search_criterion.md@44: --8<--
docs/search/extensibility/create_custom_search_criterion.md@45: code_samples/search/elasticsearch/src/Query/Criterion/Elasticsearch/CameraManufacturerVisitor.php
docs/search/extensibility/create_custom_search_criterion.md@46: --8<--
docs/search/extensibility/create_custom_search_criterion.md@47: ```

001⫶<?php
002⫶
003⫶declare(strict_types=1);
004⫶
005⫶namespace App\Query\Criterion\Elasticsearch;
006⫶
007⫶use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion;
007⫶use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface;
008⫶use Ibexa\Contracts\Elasticsearch\Query\CriterionVisitor;
009⫶use Ibexa\Contracts\Elasticsearch\Query\LanguageFilter;
010⫶
011⫶final class CameraManufacturerVisitor implements CriterionVisitor
012⫶{
008⫶use Ibexa\Contracts\Elasticsearch\Query\CriterionVisitor;
009⫶use Ibexa\Contracts\Elasticsearch\Query\LanguageFilter;
010⫶
011⫶final class CameraManufacturerVisitor implements CriterionVisitor
012⫶{
013⫶    public function supports(Criterion $criterion, LanguageFilter $languageFilter): bool
013⫶    public function supports(CriterionInterface $criterion, LanguageFilter $languageFilter): bool
014⫶    {
015⫶ return $criterion instanceof CameraManufacturerCriterion;
016⫶ }
017⫶
014⫶    {
015⫶ return $criterion instanceof CameraManufacturerCriterion;
016⫶ }
017⫶
018⫶    public function visit(CriterionVisitor $dispatcher, Criterion $criterion, LanguageFilter $languageFilter): array
018⫶    public function visit(CriterionVisitor $dispatcher, CriterionInterface $criterion, LanguageFilter $languageFilter): array
019⫶    {
019⫶    {
020⫶        return [
021⫶ 'terms' => [
022⫶ 'exif_camera_manufacturer_id' => (array)$criterion->value,
023⫶ ],
024⫶ ];
025⫶ }
026⫶}
020⫶        /** @var \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion $criterion */
021⫶ return [
022⫶ 'terms' => [
023⫶ 'exif_camera_manufacturer_id' => property_exists($criterion, 'value') ? (array)$criterion->value : [],
024⫶ ],
025⫶ ];
026⫶ }
027⫶}


code_samples/search/solr/src/Query/Criterion/Solr/CameraManufacturerVisitor.php

docs/search/extensibility/create_custom_search_criterion.md@35: ``` php
docs/search/extensibility/create_custom_search_criterion.md@36: --8<--
docs/search/extensibility/create_custom_search_criterion.md@37: code_samples/search/solr/src/Query/Criterion/Solr/CameraManufacturerVisitor.php
docs/search/extensibility/create_custom_search_criterion.md@38: --8<--
docs/search/extensibility/create_custom_search_criterion.md@39: ```

001⫶<?php
002⫶
003⫶declare(strict_types=1);
004⫶
005⫶namespace App\Query\Criterion\Solr;
006⫶


code_samples/search/solr/src/Query/Criterion/Solr/CameraManufacturerVisitor.php

docs/search/extensibility/create_custom_search_criterion.md@35: ``` php
docs/search/extensibility/create_custom_search_criterion.md@36: --8<--
docs/search/extensibility/create_custom_search_criterion.md@37: code_samples/search/solr/src/Query/Criterion/Solr/CameraManufacturerVisitor.php
docs/search/extensibility/create_custom_search_criterion.md@38: --8<--
docs/search/extensibility/create_custom_search_criterion.md@39: ```

001⫶<?php
002⫶
003⫶declare(strict_types=1);
004⫶
005⫶namespace App\Query\Criterion\Solr;
006⫶
007⫶use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion;
007⫶use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface;
008⫶use Ibexa\Contracts\Solr\Query\CriterionVisitor;
009⫶
010⫶final class CameraManufacturerVisitor extends CriterionVisitor
011⫶{
008⫶use Ibexa\Contracts\Solr\Query\CriterionVisitor;
009⫶
010⫶final class CameraManufacturerVisitor extends CriterionVisitor
011⫶{
012⫶    public function canVisit(Criterion $criterion)
012⫶    public function canVisit(CriterionInterface $criterion)
013⫶    {
014⫶ return $criterion instanceof CameraManufacturerCriterion;
015⫶ }
016⫶
013⫶    {
014⫶ return $criterion instanceof CameraManufacturerCriterion;
015⫶ }
016⫶
017⫶    public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null)
017⫶    public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null)
018⫶    {
018⫶    {
019⫶        $expressions = array_map(
020⫶ function ($value): string {
021⫶ return 'exif_camera_manufacturer_id:"' . $this->escapeQuote((string) $value) . '"';
022⫶ },
023⫶ $criterion->value
024⫶ );
025⫶
026⫶ return '(' . implode(' OR ', $expressions) . ')';
027⫶ }
028⫶}
019⫶        /** @var \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion $criterion */
020⫶ $expressions = array_map(
021⫶ function ($value): string {
022⫶ return 'exif_camera_manufacturer_id:"' . $this->escapeQuote((string) $value) . '"';
023⫶ },
024⫶ property_exists($criterion, 'value') ? (array)$criterion->value : []
025⫶ );
026⫶
027⫶ return '(' . implode(' OR ', $expressions) . ')';
028⫶ }
029⫶}


Download colorized diff

@adriendupuis
Copy link
Contributor Author

adriendupuis commented Dec 11, 2024

Less interesting duplicate of #2576
--8<-- handling moved to #2578

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant