Skip to content

Commit 4813e8e

Browse files
authored
Modernize TYPO3 Extension Metadata Handling (#214)
* Exclude var directory via .gitignore * Git ignore full var directory, not only contained files * Remove bin directory from .gitignore * Remove vendor directory from .gitignore on root * Remove index.php from .gitignore on root * Remove typo3/install.php from .gitignore on root * [TASK] Adjust directory path resolution in PHP-CS-Fixer config Ensure consistent path resolution by updating the `in()` definition in `.php-cs-fixer.dist.php`. * [TASK] Extend excluded directories in PHP-CS-Fixer config Add additional directories to the exclude list for clearer code analysis boundaries. * [TASK] Add strict type declarations to functional test fixtures Include `declare(strict_types=1);` in all relevant PHP files within the functional test fixtures to enforce strict typing and improve code reliability. * [TASK] Remove strict type declarations from functional test fixtures Omit `declare(strict_types=1);` in functional test fixture PHP files to simplify the test setup and align with the intended purpose of fixtures as non-strictly typed code. * [TASK] Filter null and empty values in site setting arrays Ensure settings arrays exclude null or empty values during conversion to arrays, enhancing data cleanliness and consistency. * [TASK] Skip SafeDeclareStrictTypesRector for specific fixture files Update Rector configuration to exclude fixture files and `ext_emconf.php` from `SafeDeclareStrictTypesRector`, ensuring flexible handling of strict types for test-related and configuration files. * [TASK] Remove ext_emconf.php handling from Extension Creator Remove generation and usage of `ext_emconf.php` files from the Extension Creator and functional test fixtures, reflecting their deprecation and ensuring alignment with modern TYPO3 standards. * [TASK] Enhance composer.json structure in test fixtures Extend the `composer.json` structure within functional test fixtures to include `Package` metadata and `version` information, ensuring better compatibility with TYPO3 standards. * [TASK] Remove ext_emconf.php and enhance composer.json structure Remove the deprecated `ext_emconf.php` file and migrate metadata to `composer.json`, including `Package` metadata and `version`, aligning with modern TYPO3 standards. * [TASK] Remove ext_emconf.php from Rector paths Exclude `ext_emconf.php` from Rector's analyzed paths to align with its deprecation and removal in favor of `composer.json`.
1 parent 53c478f commit 4813e8e

43 files changed

Lines changed: 107 additions & 390 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,7 @@ nbproject
5454
.tscache
5555
#
5656
# Ignore composer stuff
57-
/bin/*
58-
/vendor/*
59-
/index.php
60-
/typo3/install.php
57+
/var
6158
#
6259
# Ignore common TYPO3 CMS files/directories
6360
/typo3temp/*

Build/cgl/.php-cs-fixer.dist.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,14 @@
2222
->setFinder(
2323
(new PhpCsFixer\Finder())
2424
->ignoreVCSIgnored(true)
25-
->in(__DIR__.'/../'.'../')
26-
->exclude('.Build')
27-
->exclude('Fixtures')
25+
->in(__DIR__ . '/../../')
26+
->exclude([
27+
'.Build',
28+
'.github',
29+
'Build',
30+
'var',
31+
'Tests/Functional/Integration/Fixtures',
32+
])
2833
)
2934
->setRiskyAllowed(true)
3035
->setRules([

Build/rector/rector.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector;
1414
use Rector\Config\RectorConfig;
1515
use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector;
16+
use Rector\TypeDeclaration\Rector\StmtsAwareInterface\SafeDeclareStrictTypesRector;
1617
use Rector\ValueObject\PhpVersion;
1718
use Ssch\TYPO3Rector\CodeQuality\General\ExtEmConfRector;
1819
use Ssch\TYPO3Rector\Configuration\Typo3Option;
@@ -24,7 +25,6 @@
2425
__DIR__ . '/../../Classes',
2526
__DIR__ . '/../../Configuration',
2627
__DIR__ . '/../../Tests',
27-
__DIR__ . '/../../ext_emconf.php',
2828
])
2929
->withPreparedSets(
3030
deadCode: true,
@@ -53,8 +53,14 @@
5353
->withImportNames(importShortClasses: false, removeUnusedImports: true)
5454
->withSkip([
5555
NullToStrictStringFuncCallArgRector::class,
56+
SafeDeclareStrictTypesRector::class => [
57+
'*ext_emconf.php',
58+
'*/Tests/Functional/Integration/Fixtures/*/Configuration/TCA/*.php',
59+
'*/Tests/Functional/Integration/Fixtures/*/Configuration/TCA/Overrides/*.php',
60+
'*/Tests/Functional/Integration/Fixtures/*/Configuration/Backend/*.php',
61+
],
5662
FlipTypeControlToUseExclusiveTypeRector::class => [
57-
__DIR__ . '/../../Classes/PhpParser/Printer/PrettyTypo3Printer.php',
63+
'*/Classes/PhpParser/Printer/PrettyTypo3Printer.php',
5864
],
5965
'*Build/*',
6066
'*Resources/*',

Classes/Creator/Extension/ComposerJsonCreator.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ private function getFileContent(ExtensionInformation $extensionInformation): str
5959
],
6060
'extra' => [
6161
'typo3/cms' => [
62+
'Package' => [
63+
'providesPackages' => (object)[],
64+
],
6265
'extension-key' => $extensionInformation->getExtensionKey(),
66+
'version' => $extensionInformation->getVersion(),
6367
],
6468
],
6569
];

Classes/Creator/Extension/ExtEmconfCreator.php

Lines changed: 0 additions & 80 deletions
This file was deleted.

Classes/Creator/SiteSet/SiteSettingsDefinitionCreator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ private function getFileContent(SiteSettingsDefinitionInformation $siteSettingsD
6464
}
6565
$this->types->getProvidedServices();
6666
foreach ($siteSettingsDefinitionInformation->getSettings() as $setting) {
67-
$array = $setting->toArray();
67+
$array = array_filter(get_object_vars($setting), fn(mixed $value): bool => $value !== null && $value !== []);
6868

6969
unset($array['key']);
7070
if ($array['readonly'] === false) {

Classes/Creator/Test/Environment/ComposerJsonCreator.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ private function updateComposerJson(array $composerConfig): string
7070

7171
ksort($composerConfig['config']['allow-plugins']);
7272

73+
if (isset($composerConfig['extra']['typo3/cms']['Package']['providesPackages'])
74+
&& $composerConfig['extra']['typo3/cms']['Package']['providesPackages'] === []
75+
) {
76+
$composerConfig['extra']['typo3/cms']['Package']['providesPackages'] = (object)[];
77+
}
78+
7379
if (!isset($composerConfig['config']['bin-dir'])) {
7480
$composerConfig['config']['bin-dir'] = '.Build/bin';
7581
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# TYPO3 Extension Kickstarter
22

3-
`kickstarter` is a TYPO3 extension that simplifies and accelerates the creation of new TYPO3 extensions by automating file generation, controller setup, and plugin registration through easy-to-use CLI commands. With a few CLI commands, it generates essential files like `LICENSE`, `ext_emconf.php`,`composer.json`, and more. Whether starting from scratch or extending existing functionality, `kickstarter` helps streamline development.
3+
`kickstarter` is a TYPO3 extension that simplifies and accelerates the creation of new TYPO3 extensions by automating file generation, controller setup, and plugin registration through easy-to-use CLI commands. With a few CLI commands, it generates essential files like `LICENSE`, `composer.json`, and more. Whether starting from scratch or extending existing functionality, `kickstarter` helps streamline development.
44

55
---
66

Tests/Functional/Integration/ExtensionCreatorServiceTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ public static function extensionCreationProvider(): array
9898
'namespaceForAutoload' => 'Vendor\\MyExtension\\',
9999
'expectedDir' => __DIR__ . '/Fixtures/expected_extension',
100100
'expectedFiles' => [
101-
'ext_emconf.php',
102101
'README.md',
103102
],
104103
],
@@ -116,7 +115,6 @@ public static function extensionCreationProvider(): array
116115
'namespaceForAutoload' => 'Vendor\\MyExtension\\',
117116
'expectedDir' => __DIR__ . '/Fixtures/extension_with_folders',
118117
'expectedFiles' => [
119-
'ext_emconf.php',
120118
'README.md',
121119
],
122120
'createFolders' => true,

Tests/Functional/Integration/Fixtures/expected_extension/composer.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@
2626
},
2727
"extra": {
2828
"typo3/cms": {
29-
"extension-key": "my_extension"
29+
"Package": {
30+
"providesPackages": {}
31+
},
32+
"extension-key": "my_extension",
33+
"version": "1.0.0"
3034
}
3135
}
3236
}

0 commit comments

Comments
 (0)