Skip to content

Commit c31ce6b

Browse files
authored
Merge pull request #6 from fsylum/feature-wp65
Add support for WordPress 6.5
2 parents c46215f + 96250e6 commit c31ce6b

File tree

8 files changed

+111
-3
lines changed

8 files changed

+111
-3
lines changed

config/sets/level/up-to-wp-6.5.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
use Fsylum\RectorWordPress\Set\WordPressLevelSetList;
4+
use Fsylum\RectorWordPress\Set\WordPressSetList;
5+
use Rector\Config\RectorConfig;
6+
7+
return static function (RectorConfig $rectorConfig): void {
8+
$rectorConfig->sets([WordPressSetList::WP_6_5, WordPressLevelSetList::UP_TO_WP_6_4]);
9+
};

config/sets/wp-6.5.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
use Fsylum\RectorWordPress\Rules\MethodCall\ParameterAdderRector;
4+
use Fsylum\RectorWordPress\ValueObject\MethodParameterAdder;
5+
use Rector\Config\RectorConfig;
6+
use Rector\Transform\Rector\MethodCall\MethodCallToFuncCallRector;
7+
use Rector\Transform\ValueObject\MethodCallToFuncCall;
8+
9+
return static function (RectorConfig $rectorConfig): void {
10+
$rectorConfig->import(__DIR__ . '/../config.php');
11+
12+
$rectorConfig->ruleWithConfiguration(ParameterAdderRector::class, [
13+
new MethodParameterAdder('Custom_Image_Header', 'create_attachment_object', 2, 'custom-header'),
14+
new MethodParameterAdder('WP_Site_Icon', 'create_attachment_object', 2, 'site-icon'),
15+
]);
16+
17+
$rectorConfig->ruleWithConfiguration(MethodCallToFuncCallRector::class, [
18+
new MethodCallToFuncCall('Custom_Image_Header', 'create_attachment_object', 'wp_copy_parent_attachment_properties'),
19+
new MethodCallToFuncCall('WP_Site_Icon', 'create_attachment_object', 'wp_copy_parent_attachment_properties'),
20+
]);
21+
22+
/*
23+
* TODO: these are not handled currently
24+
*
25+
* FUNCTIONS
26+
* - block_core_query_ensure_interactivity_dependency
27+
* - block_core_file_ensure_interactivity_dependency
28+
* - block_core_image_ensure_interactivity_dependency
29+
*
30+
* METHODS
31+
* - Translations::parenthesize_plural_exression
32+
*/
33+
};

src/Set/WordPressLevelSetList.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,6 @@ final class WordPressLevelSetList implements SetListInterface
101101
public const UP_TO_WP_6_3 = __DIR__ . '/../../config/sets/level/up-to-wp-6.3.php';
102102

103103
public const UP_TO_WP_6_4 = __DIR__ . '/../../config/sets/level/up-to-wp-6.4.php';
104+
105+
public const UP_TO_WP_6_5 = __DIR__ . '/../../config/sets/level/up-to-wp-6.5.php';
104106
}

src/Set/WordPressSetList.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,6 @@ final class WordPressSetList implements SetListInterface
101101
public const WP_6_3 = __DIR__ . '/../../config/sets/wp-6.3.php';
102102

103103
public const WP_6_4 = __DIR__ . '/../../config/sets/wp-6.4.php';
104+
105+
public const WP_6_5 = __DIR__ . '/../../config/sets/wp-6.5.php';
104106
}

tests/Rector/Sets/Level/UpToWp64/UpToWp64Test.php renamed to tests/Rector/Sets/Level/UpToWp65/UpToWp65Test.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Fsylum\RectorWordPress\Tests\Rector\Sets\Level\UpToWp64;
3+
namespace Fsylum\RectorWordPress\Tests\Rector\Sets\Level\UpToWp65;
44

55
use Iterator;
66
use PHPUnit\Framework\Attributes\DataProvider;
@@ -9,7 +9,7 @@
99
/**
1010
* @internal
1111
*/
12-
final class UpToWp64Test extends AbstractRectorTestCase
12+
final class UpToWp65Test extends AbstractRectorTestCase
1313
{
1414
#[DataProvider('provideData')]
1515
public function test(string $filePath): void
@@ -24,6 +24,6 @@ public static function provideData(): Iterator
2424

2525
public function provideConfigFilePath(): string
2626
{
27-
return __DIR__ . '/../../../../../config/sets/level/up-to-wp-6.4.php';
27+
return __DIR__ . '/../../../../../config/sets/level/up-to-wp-6.5.php';
2828
}
2929
}

tests/Rector/Sets/Level/UpToWp64/test_fixture.php.inc renamed to tests/Rector/Sets/Level/UpToWp65/test_fixture.php.inc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,13 @@ wp_img_tag_add_decoding_attr('foo', 'bar');
361361
$foo = TEMPLATEPATH;
362362
$bar = STYLESHEETPATH;
363363

364+
// 6.5
365+
$class1 = new Custom_Image_Header;
366+
$class2 = new WP_Site_Icon;
367+
368+
$class1->create_attachment_object('foo', 1);
369+
$class2->create_attachment_object('foo', 1);
370+
364371
?>
365372
-----
366373
<?php
@@ -676,4 +683,11 @@ wp_img_tag_add_loading_optimization_attrs('foo', 'bar');
676683
$foo = \get_template_directory();
677684
$bar = \get_stylesheet_directory();
678685

686+
// 6.5
687+
$class1 = new Custom_Image_Header;
688+
$class2 = new WP_Site_Icon;
689+
690+
\wp_copy_parent_attachment_properties('foo', 1, 'custom-header');
691+
\wp_copy_parent_attachment_properties('foo', 1, 'site-icon');
692+
679693
?>

tests/Rector/Sets/Wp65/Wp65Test.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace Fsylum\RectorWordPress\Tests\Rector\Sets\Wp65;
4+
5+
use Iterator;
6+
use PHPUnit\Framework\Attributes\DataProvider;
7+
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
8+
9+
/**
10+
* @internal
11+
*/
12+
final class Wp65Test extends AbstractRectorTestCase
13+
{
14+
#[DataProvider('provideData')]
15+
public function test(string $filePath): void
16+
{
17+
$this->doTestFile($filePath);
18+
}
19+
20+
public static function provideData(): Iterator
21+
{
22+
return self::yieldFilesFromDirectory(__DIR__);
23+
}
24+
25+
public function provideConfigFilePath(): string
26+
{
27+
return __DIR__ . '/../../../../config/sets/wp-6.5.php';
28+
}
29+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
$class1 = new Custom_Image_Header;
4+
$class2 = new WP_Site_Icon;
5+
6+
$class1->create_attachment_object('foo', 1);
7+
$class2->create_attachment_object('foo', 1);
8+
9+
?>
10+
-----
11+
<?php
12+
13+
$class1 = new Custom_Image_Header;
14+
$class2 = new WP_Site_Icon;
15+
16+
\wp_copy_parent_attachment_properties('foo', 1, 'custom-header');
17+
\wp_copy_parent_attachment_properties('foo', 1, 'site-icon');
18+
19+
?>

0 commit comments

Comments
 (0)