diff --git a/rector.php b/rector.php index 17204be..2abf5af 100644 --- a/rector.php +++ b/rector.php @@ -4,6 +4,7 @@ use Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector; use Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector; +use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector; use Rector\CodeQuality\Rector\Expression\InlineIfToExplicitIfRector; use Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector; use Rector\CodeQuality\Rector\FuncCall\ChangeArrayPushToArrayAssignRector; @@ -14,12 +15,12 @@ use Rector\CodeQuality\Rector\If_\ShortenElseIfRector; use Rector\CodeQuality\Rector\If_\SimplifyIfElseToTernaryRector; use Rector\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector; +use Rector\CodeQuality\Rector\Ternary\TernaryEmptyArrayArrayDimFetchToCoalesceRector; use Rector\CodeQuality\Rector\Ternary\UnnecessaryTernaryExpressionRector; use Rector\CodingStyle\Rector\ClassMethod\FuncGetArgsToVariadicParamRector; use Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector; use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector; use Rector\Config\RectorConfig; -use Rector\Core\ValueObject\PhpVersion; use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPromotedPropertyRector; use Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector; use Rector\EarlyReturn\Rector\If_\ChangeIfElseValueAssignToEarlyReturnRector; @@ -35,7 +36,10 @@ use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector; use Rector\Set\ValueObject\LevelSetList; use Rector\Set\ValueObject\SetList; +use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector; +use Rector\TypeDeclaration\Rector\Empty_\EmptyOnNullableObjectToInstanceOfRector; use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector; +use Rector\ValueObject\PhpVersion; return static function (RectorConfig $rectorConfig): void { $rectorConfig->sets([ @@ -112,10 +116,16 @@ $rectorConfig->rule(FuncGetArgsToVariadicParamRector::class); $rectorConfig->rule(MakeInheritedMethodVisibilitySameAsParentRector::class); $rectorConfig->rule(SimplifyEmptyArrayCheckRector::class); + $rectorConfig->rule(SimplifyEmptyCheckOnEmptyArrayRector::class); + $rectorConfig->rule(TernaryEmptyArrayArrayDimFetchToCoalesceRector::class); + $rectorConfig->rule(EmptyOnNullableObjectToInstanceOfRector::class); + $rectorConfig->rule(DisallowedEmptyRuleFixerRector::class); $rectorConfig ->ruleWithConfiguration(TypedPropertyFromAssignsRector::class, [ /** - * The INLINE_PUBLIC value is default to false to avoid BC break, if you use for libraries and want to preserve BC break, you don't need to configure it, as it included in LevelSetList::UP_TO_PHP_74 + * The INLINE_PUBLIC value is default to false to avoid BC break, + * if you use for libraries and want to preserve BC break, you don't + * need to configure it, as it included in LevelSetList::UP_TO_PHP_74 * Set to true for projects that allow BC break */ TypedPropertyFromAssignsRector::INLINE_PUBLIC => true, diff --git a/src/Bundles/DataTablesBundle.php b/src/Bundles/DataTablesBundle.php index f71cc8b..6443841 100644 --- a/src/Bundles/DataTablesBundle.php +++ b/src/Bundles/DataTablesBundle.php @@ -2,6 +2,7 @@ namespace Tatter\Frontend\Bundles; +use CodeIgniter\Files\Exceptions\FileNotFoundException; use Tatter\Frontend\FrontendBundle; class DataTablesBundle extends FrontendBundle @@ -11,8 +12,13 @@ class DataTablesBundle extends FrontendBundle */ protected function define(): void { + try { + $this->addPath('datatables/js/jquery.dataTables.min.js'); + } catch (FileNotFoundException) { + // this seems to have been removed in some DataTables release + } + $this - ->addPath('datatables/js/jquery.dataTables.min.js') ->addPath('datatables/js/dataTables.bootstrap4.min.js') ->addPath('datatables/css/dataTables.bootstrap4.min.css') ->merge(new BootstrapBundle()); diff --git a/src/Publishers/DataTablesStylePublisher.php b/src/Publishers/DataTablesStylePublisher.php index 228c2fb..676fa00 100644 --- a/src/Publishers/DataTablesStylePublisher.php +++ b/src/Publishers/DataTablesStylePublisher.php @@ -18,10 +18,10 @@ public function publish(): bool { return $this ->addPath('css') - ->addPath('images') ->addPath('js') ->addPath('types') ->removePattern('*.ts') + ->removePattern('*.mjs') ->merge(true); } } diff --git a/src/Test/PublishersTestCase.php b/src/Test/PublishersTestCase.php index 9dd2236..1d68f5f 100644 --- a/src/Test/PublishersTestCase.php +++ b/src/Test/PublishersTestCase.php @@ -14,7 +14,7 @@ abstract class PublishersTestCase extends CIUnitTestCase * @dataProvider publisherProvider * * @param class-string $class - * @param string[] $expected + * @param list $expected */ public function testPublishesFiles(string $class, array $expected): void { diff --git a/tests/BundlesTest.php b/tests/BundlesTest.php index 9a2b0c4..ea47aa9 100644 --- a/tests/BundlesTest.php +++ b/tests/BundlesTest.php @@ -42,7 +42,6 @@ public function bundleProvider(): array [ 'bootstrap.bundle.min.js', 'dataTables.bootstrap4.min.js', - 'jquery.dataTables.min.js', ], ], [ diff --git a/tests/PublishersTest.php b/tests/PublishersTest.php index 98530ef..96db4f0 100644 --- a/tests/PublishersTest.php +++ b/tests/PublishersTest.php @@ -33,14 +33,13 @@ public function publisherProvider(): array [ DataTablesPublisher::class, [ - 'datatables/js/jquery.dataTables.js', + 'datatables/js/dataTables.min.js', ], ], [ DataTablesStylePublisher::class, [ 'datatables/css/dataTables.bootstrap4.min.css', - 'datatables/images/sort_asc_disabled.png', 'datatables/js/dataTables.bootstrap4.js', ], ],