Skip to content

Commit

Permalink
Added rector rule to replace ContentType::isContainer property to met…
Browse files Browse the repository at this point in the history
…hod (#25)
  • Loading branch information
wiewiurdp authored Mar 1, 2025
1 parent 1257477 commit 0f0bc5b
Show file tree
Hide file tree
Showing 10 changed files with 295 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/contracts/Sets/ibexa-50.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,22 @@
'replace_with' => 'Ibexa\Contracts\Core\Variation\VariationPathGenerator',
]
);

$rectorConfig->ruleWithConfiguration(PropertyToGetterRector::class, [
'Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType' => [
'isContainer' => 'isContainer',
],
]);

$rectorConfig->ruleWithConfiguration(PropertyToGetterRector::class, [
'Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeDraft' => [
'isContainer' => 'isContainer',
],
]);

$rectorConfig->ruleWithConfiguration(PropertyToGetterRector::class, [
'Ibexa\Core\Repository\Values\ContentType\ContentTypeDraft' => [
'isContainer' => 'isContainer',
],
]);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Rector\Tests\TypeDeclaration\Rector\ReplaceCartMoneyFactoryRector\Fixture;

use Ibexa\Core\Repository\Values\ContentType\ContentTypeDraft;

readonly class Foo
{
public function foo(ContentTypeDraft $contentTypeDraft): array
{
return [$contentTypeDraft->isContainer];
}
}

?>
-----
<?php

namespace Rector\Tests\TypeDeclaration\Rector\ReplaceCartMoneyFactoryRector\Fixture;

use Ibexa\Core\Repository\Values\ContentType\ContentTypeDraft;

readonly class Foo
{
public function foo(ContentTypeDraft $contentTypeDraft): array
{
return [$contentTypeDraft->isContainer()];
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Rector\Tests\TypeDeclaration\Rector\ReplaceCartMoneyFactoryRector\Fixture;

use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType;

readonly class Foo
{
public function foo(ContentType $contentType): array
{
return [$contentType->isContainer];
}
}

?>
-----
<?php

namespace Rector\Tests\TypeDeclaration\Rector\ReplaceCartMoneyFactoryRector\Fixture;

use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType;

readonly class Foo
{
public function foo(ContentType $contentType): array
{
return [$contentType->isContainer()];
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Rector\Tests\TypeDeclaration\Rector\ReplaceCartMoneyFactoryRector\Fixture;

use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeDraft;

readonly class Foo
{
public function foo(ContentTypeDraft $contentTypeDraft): array
{
return [$contentTypeDraft->isContainer];
}
}

?>
-----
<?php

namespace Rector\Tests\TypeDeclaration\Rector\ReplaceCartMoneyFactoryRector\Fixture;

use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeDraft;

readonly class Foo
{
public function foo(ContentTypeDraft $contentTypeDraft): array
{
return [$contentTypeDraft->isContainer()];
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Rector\Tests\TypeDeclaration\Rector\ReplaceCartMoneyFactoryRector\Fixture;

use Ibexa\Solr\Gateway\UpdateSerializer;

readonly class Foo
{
public function __construct(UpdateSerializer $updateSerializer)
{
}
}

?>
-----
<?php

namespace Rector\Tests\TypeDeclaration\Rector\ReplaceCartMoneyFactoryRector\Fixture;

use Ibexa\Solr\Gateway\UpdateSerializer\XmlUpdateSerializer;

readonly class Foo
{
public function __construct(XmlUpdateSerializer $updateSerializer)
{
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Rector\Tests\TypeDeclaration\Rector\ReplaceCartMoneyFactoryRector\Fixture;

use Ibexa\Migration\ValueObject\ContentType\Matcher;

readonly class Foo
{
public function fooBar(): string
{
return Matcher::CONTENT_TYPE_IDENTIFIER;
}
}

?>
-----
<?php

namespace Rector\Tests\TypeDeclaration\Rector\ReplaceCartMoneyFactoryRector\Fixture;

use Ibexa\Migration\StepExecutor\ContentType\IdentifierFinder;
use Ibexa\Migration\ValueObject\ContentType\Matcher;

readonly class Foo
{
public function fooBar(): string
{
return IdentifierFinder::CONTENT_TYPE_IDENTIFIER;
}
}

?>
32 changes: 32 additions & 0 deletions tests/lib/Sets/Ibexa50/Fixture/rename_const_tree_root.php.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Rector\Tests\TypeDeclaration\Rector\ReplaceCartMoneyFactoryRector\Fixture;

use Ibexa\Bundle\FormBuilder\DependencyInjection\Configuration;

readonly class Foo
{
public function fooBar(): string
{
return Configuration::TREE_ROOT;
}
}

?>
-----
<?php

namespace Rector\Tests\TypeDeclaration\Rector\ReplaceCartMoneyFactoryRector\Fixture;

use Ibexa\Bundle\FormBuilder\DependencyInjection\IbexaFormBuilderExtension;
use Ibexa\Bundle\FormBuilder\DependencyInjection\Configuration;

readonly class Foo
{
public function fooBar(): string
{
return IbexaFormBuilderExtension::EXTENSION_NAME;
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Rector\Tests\TypeDeclaration\Rector\ReplaceCartMoneyFactoryRector\Fixture;

use Ibexa\Solr\Query\Content\CriterionVisitor\Field;

readonly class Foo
{
public function __construct(Field $field)
{
}
}

?>
-----
<?php

namespace Rector\Tests\TypeDeclaration\Rector\ReplaceCartMoneyFactoryRector\Fixture;

use Ibexa\Solr\Query\Common\CriterionVisitor\Field;

readonly class Foo
{
public function __construct(Field $field)
{
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Rector\Tests\TypeDeclaration\Rector\ReplaceCartMoneyFactoryRector\Fixture;

use Ibexa\Contracts\Core\Repository\Values\Content\Trash\SearchResult;

readonly class Foo
{
public function foo(SearchResult $searchResult): string
{
return $searchResult->count;
}
}

?>
-----
<?php

namespace Rector\Tests\TypeDeclaration\Rector\ReplaceCartMoneyFactoryRector\Fixture;

use Ibexa\Contracts\Core\Repository\Values\Content\Trash\SearchResult;

readonly class Foo
{
public function foo(SearchResult $searchResult): string
{
return $searchResult->totalCount;
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Rector\Tests\TypeDeclaration\Rector\ReplaceCartMoneyFactoryRector\Fixture;

use Ibexa\Contracts\Core\Repository\Values\Content\Search\SearchResult;

readonly class Foo
{
public function foo(SearchResult $searchResult): array
{
return [$searchResult->spellSuggestion];
}
}

?>
-----
<?php

namespace Rector\Tests\TypeDeclaration\Rector\ReplaceCartMoneyFactoryRector\Fixture;

use Ibexa\Contracts\Core\Repository\Values\Content\Search\SearchResult;

readonly class Foo
{
public function foo(SearchResult $searchResult): array
{
return [$searchResult->spellcheck];
}
}

?>

0 comments on commit 0f0bc5b

Please sign in to comment.