Skip to content

Commit 0f0bc5b

Browse files
authored
Added rector rule to replace ContentType::isContainer property to method (#25)
1 parent 1257477 commit 0f0bc5b

10 files changed

+295
-0
lines changed

src/contracts/Sets/ibexa-50.php

+18
Original file line numberDiff line numberDiff line change
@@ -210,4 +210,22 @@
210210
'replace_with' => 'Ibexa\Contracts\Core\Variation\VariationPathGenerator',
211211
]
212212
);
213+
214+
$rectorConfig->ruleWithConfiguration(PropertyToGetterRector::class, [
215+
'Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType' => [
216+
'isContainer' => 'isContainer',
217+
],
218+
]);
219+
220+
$rectorConfig->ruleWithConfiguration(PropertyToGetterRector::class, [
221+
'Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeDraft' => [
222+
'isContainer' => 'isContainer',
223+
],
224+
]);
225+
226+
$rectorConfig->ruleWithConfiguration(PropertyToGetterRector::class, [
227+
'Ibexa\Core\Repository\Values\ContentType\ContentTypeDraft' => [
228+
'isContainer' => 'isContainer',
229+
],
230+
]);
213231
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace Rector\Tests\TypeDeclaration\Rector\ReplaceCartMoneyFactoryRector\Fixture;
4+
5+
use Ibexa\Core\Repository\Values\ContentType\ContentTypeDraft;
6+
7+
readonly class Foo
8+
{
9+
public function foo(ContentTypeDraft $contentTypeDraft): array
10+
{
11+
return [$contentTypeDraft->isContainer];
12+
}
13+
}
14+
15+
?>
16+
-----
17+
<?php
18+
19+
namespace Rector\Tests\TypeDeclaration\Rector\ReplaceCartMoneyFactoryRector\Fixture;
20+
21+
use Ibexa\Core\Repository\Values\ContentType\ContentTypeDraft;
22+
23+
readonly class Foo
24+
{
25+
public function foo(ContentTypeDraft $contentTypeDraft): array
26+
{
27+
return [$contentTypeDraft->isContainer()];
28+
}
29+
}
30+
31+
?>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace Rector\Tests\TypeDeclaration\Rector\ReplaceCartMoneyFactoryRector\Fixture;
4+
5+
use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType;
6+
7+
readonly class Foo
8+
{
9+
public function foo(ContentType $contentType): array
10+
{
11+
return [$contentType->isContainer];
12+
}
13+
}
14+
15+
?>
16+
-----
17+
<?php
18+
19+
namespace Rector\Tests\TypeDeclaration\Rector\ReplaceCartMoneyFactoryRector\Fixture;
20+
21+
use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType;
22+
23+
readonly class Foo
24+
{
25+
public function foo(ContentType $contentType): array
26+
{
27+
return [$contentType->isContainer()];
28+
}
29+
}
30+
31+
?>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace Rector\Tests\TypeDeclaration\Rector\ReplaceCartMoneyFactoryRector\Fixture;
4+
5+
use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeDraft;
6+
7+
readonly class Foo
8+
{
9+
public function foo(ContentTypeDraft $contentTypeDraft): array
10+
{
11+
return [$contentTypeDraft->isContainer];
12+
}
13+
}
14+
15+
?>
16+
-----
17+
<?php
18+
19+
namespace Rector\Tests\TypeDeclaration\Rector\ReplaceCartMoneyFactoryRector\Fixture;
20+
21+
use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeDraft;
22+
23+
readonly class Foo
24+
{
25+
public function foo(ContentTypeDraft $contentTypeDraft): array
26+
{
27+
return [$contentTypeDraft->isContainer()];
28+
}
29+
}
30+
31+
?>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace Rector\Tests\TypeDeclaration\Rector\ReplaceCartMoneyFactoryRector\Fixture;
4+
5+
use Ibexa\Solr\Gateway\UpdateSerializer;
6+
7+
readonly class Foo
8+
{
9+
public function __construct(UpdateSerializer $updateSerializer)
10+
{
11+
}
12+
}
13+
14+
?>
15+
-----
16+
<?php
17+
18+
namespace Rector\Tests\TypeDeclaration\Rector\ReplaceCartMoneyFactoryRector\Fixture;
19+
20+
use Ibexa\Solr\Gateway\UpdateSerializer\XmlUpdateSerializer;
21+
22+
readonly class Foo
23+
{
24+
public function __construct(XmlUpdateSerializer $updateSerializer)
25+
{
26+
}
27+
}
28+
29+
?>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace Rector\Tests\TypeDeclaration\Rector\ReplaceCartMoneyFactoryRector\Fixture;
4+
5+
use Ibexa\Migration\ValueObject\ContentType\Matcher;
6+
7+
readonly class Foo
8+
{
9+
public function fooBar(): string
10+
{
11+
return Matcher::CONTENT_TYPE_IDENTIFIER;
12+
}
13+
}
14+
15+
?>
16+
-----
17+
<?php
18+
19+
namespace Rector\Tests\TypeDeclaration\Rector\ReplaceCartMoneyFactoryRector\Fixture;
20+
21+
use Ibexa\Migration\StepExecutor\ContentType\IdentifierFinder;
22+
use Ibexa\Migration\ValueObject\ContentType\Matcher;
23+
24+
readonly class Foo
25+
{
26+
public function fooBar(): string
27+
{
28+
return IdentifierFinder::CONTENT_TYPE_IDENTIFIER;
29+
}
30+
}
31+
32+
?>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace Rector\Tests\TypeDeclaration\Rector\ReplaceCartMoneyFactoryRector\Fixture;
4+
5+
use Ibexa\Bundle\FormBuilder\DependencyInjection\Configuration;
6+
7+
readonly class Foo
8+
{
9+
public function fooBar(): string
10+
{
11+
return Configuration::TREE_ROOT;
12+
}
13+
}
14+
15+
?>
16+
-----
17+
<?php
18+
19+
namespace Rector\Tests\TypeDeclaration\Rector\ReplaceCartMoneyFactoryRector\Fixture;
20+
21+
use Ibexa\Bundle\FormBuilder\DependencyInjection\IbexaFormBuilderExtension;
22+
use Ibexa\Bundle\FormBuilder\DependencyInjection\Configuration;
23+
24+
readonly class Foo
25+
{
26+
public function fooBar(): string
27+
{
28+
return IbexaFormBuilderExtension::EXTENSION_NAME;
29+
}
30+
}
31+
32+
?>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace Rector\Tests\TypeDeclaration\Rector\ReplaceCartMoneyFactoryRector\Fixture;
4+
5+
use Ibexa\Solr\Query\Content\CriterionVisitor\Field;
6+
7+
readonly class Foo
8+
{
9+
public function __construct(Field $field)
10+
{
11+
}
12+
}
13+
14+
?>
15+
-----
16+
<?php
17+
18+
namespace Rector\Tests\TypeDeclaration\Rector\ReplaceCartMoneyFactoryRector\Fixture;
19+
20+
use Ibexa\Solr\Query\Common\CriterionVisitor\Field;
21+
22+
readonly class Foo
23+
{
24+
public function __construct(Field $field)
25+
{
26+
}
27+
}
28+
29+
?>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace Rector\Tests\TypeDeclaration\Rector\ReplaceCartMoneyFactoryRector\Fixture;
4+
5+
use Ibexa\Contracts\Core\Repository\Values\Content\Trash\SearchResult;
6+
7+
readonly class Foo
8+
{
9+
public function foo(SearchResult $searchResult): string
10+
{
11+
return $searchResult->count;
12+
}
13+
}
14+
15+
?>
16+
-----
17+
<?php
18+
19+
namespace Rector\Tests\TypeDeclaration\Rector\ReplaceCartMoneyFactoryRector\Fixture;
20+
21+
use Ibexa\Contracts\Core\Repository\Values\Content\Trash\SearchResult;
22+
23+
readonly class Foo
24+
{
25+
public function foo(SearchResult $searchResult): string
26+
{
27+
return $searchResult->totalCount;
28+
}
29+
}
30+
31+
?>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace Rector\Tests\TypeDeclaration\Rector\ReplaceCartMoneyFactoryRector\Fixture;
4+
5+
use Ibexa\Contracts\Core\Repository\Values\Content\Search\SearchResult;
6+
7+
readonly class Foo
8+
{
9+
public function foo(SearchResult $searchResult): array
10+
{
11+
return [$searchResult->spellSuggestion];
12+
}
13+
}
14+
15+
?>
16+
-----
17+
<?php
18+
19+
namespace Rector\Tests\TypeDeclaration\Rector\ReplaceCartMoneyFactoryRector\Fixture;
20+
21+
use Ibexa\Contracts\Core\Repository\Values\Content\Search\SearchResult;
22+
23+
readonly class Foo
24+
{
25+
public function foo(SearchResult $searchResult): array
26+
{
27+
return [$searchResult->spellcheck];
28+
}
29+
}
30+
31+
?>

0 commit comments

Comments
 (0)