From 04a4b2b8ed99ff49a609fced4fb9325c74ab8cad Mon Sep 17 00:00:00 2001 From: Leon Helmus Date: Wed, 13 Apr 2022 00:41:03 +0200 Subject: [PATCH 1/4] Added a project resolver to decide which project is installed. Also added a config to overwrite the type used. - A project resolver to decide which project is installed. Also added a config to overwrite the type used. - Composer requirement which should have already been there. - Make patches independent on project type. - Files mapping to make clear which platforms the files are used for. --- CHANGELOG.md | 12 +++ composer.json | 1 + files/default/codeStyleSettings.xml | 100 ++++++++++++++++++ files/default/emptyConfig.xml | 3 + .../fileTemplates/code/PHP Constructor.php | 0 .../code/PHP Fluent Setter Method.php | 0 .../fileTemplates/code/PHP Getter Method.php | 0 .../code/PHP Implemented Method Body.php | 0 .../code/PHP Overridden Method Body.php | 0 .../fileTemplates/code/PHP Setter Method.php | 0 .../code/PHPUnit Test Method.php | 0 .../includes/Company Settings.php | 0 .../includes/PHP Class Doc Comment.php | 0 .../includes/PHP Field Doc Comment.php | 0 .../includes/PHP File Header.php | 0 .../includes/PHP Function Doc Comment.php | 0 .../includes/PHP Interface Doc Comment.php | 0 .../includes/PHP Property Doc Comment.php | 0 .../includes/PHP Trait Doc Comment.php | 0 .../fileTemplates/internal/JavaScript File.js | 0 .../fileTemplates/internal/PHP Class.php | 0 .../fileTemplates/internal/PHP File.php | 0 .../fileTemplates/internal/PHP Interface.php | 0 .../fileTemplates/internal/PHP Trait.php | 0 .../fileTemplates/internal/PHPUnit 6 Test.php | 0 .../fileTemplates/internal/PHPUnit Test.php | 0 .../inspectionProfiles/MediaCT.xml | 0 .../inspectionProfiles/profiles_settings.xml | 0 .../{ => magento2}/file.template.settings.xml | 0 .../fileTemplates/M2-Acl-XML.xml | 0 .../M2-Class-Backend-Controller.php | 0 .../fileTemplates/M2-Class-Block.php | 0 .../fileTemplates/M2-Class-Helper.php | 0 .../fileTemplates/M2-Class-Observer.php | 0 .../fileTemplates/M2-Class-ViewModel.php | 0 .../{ => magento2}/fileTemplates/M2-Class.php | 0 .../fileTemplates/M2-Config-XML.xml | 0 files/{ => magento2}/fileTemplates/M2-DI.xml | 0 .../fileTemplates/M2-Db-schema-XML.xml | 0 .../fileTemplates/M2-Events.xml | 0 .../M2-Extension-Attributes-XML.xml | 0 .../fileTemplates/M2-Layout-XML.xml | 0 .../{ => magento2}/fileTemplates/M2-Menu.xml | 0 .../fileTemplates/M2-Module-XML.xml | 0 .../fileTemplates/M2-Registration.php | 0 .../fileTemplates/M2-Routes.xml | 0 .../fileTemplates/M2-Sales-XML.xml | 0 .../fileTemplates/M2-System-XML.xml | 0 .../fileTemplates/M2-System-include-XML.xml | 0 .../includes/M2-PHP-File-Header.php | 0 files/{ => magento2}/includes/M2-Settings.php | 0 .../includes/M2-XML-File-Header.xml | 0 files/{ => magento2}/templates/M2-acl.xml | 0 .../{ => magento2}/templates/M2-db_schema.xml | 0 files/{ => magento2}/templates/M2-di.xml | 0 files/{ => magento2}/templates/M2-events.xml | 0 files/{ => magento2}/templates/M2-menu.xml | 0 files/{ => magento2}/templates/M2-module.xml | 0 files/{ => magento2}/templates/M2-phtml.xml | 0 .../templates/M2-registration.xml | 0 files/{ => magento2}/templates/M2-system.xml | 0 src/Environment.php | 16 ++- src/EnvironmentInterface.php | 7 ++ src/InstallerPlugin.php | 3 +- src/Patcher/ConfigPatcher.php | 30 ++++-- src/Patcher/FileTemplatesPatcher.php | 2 +- src/Patcher/InspectionsPatcher.php | 2 +- src/Patcher/Magento2/FileTemplatesPatcher.php | 36 +++++++ .../{ => Magento2}/LiveTemplatesPatcher.php | 10 +- .../TemplateSettingsPatcher.php | 18 ++-- src/ProjectTypeResolver.php | 78 ++++++++++++++ 71 files changed, 296 insertions(+), 22 deletions(-) create mode 100644 files/default/codeStyleSettings.xml create mode 100644 files/default/emptyConfig.xml rename files/{ => default}/fileTemplates/code/PHP Constructor.php (100%) rename files/{ => default}/fileTemplates/code/PHP Fluent Setter Method.php (100%) rename files/{ => default}/fileTemplates/code/PHP Getter Method.php (100%) rename files/{ => default}/fileTemplates/code/PHP Implemented Method Body.php (100%) rename files/{ => default}/fileTemplates/code/PHP Overridden Method Body.php (100%) rename files/{ => default}/fileTemplates/code/PHP Setter Method.php (100%) rename files/{ => default}/fileTemplates/code/PHPUnit Test Method.php (100%) rename files/{ => default}/fileTemplates/includes/Company Settings.php (100%) rename files/{ => default}/fileTemplates/includes/PHP Class Doc Comment.php (100%) rename files/{ => default}/fileTemplates/includes/PHP Field Doc Comment.php (100%) rename files/{ => default}/fileTemplates/includes/PHP File Header.php (100%) rename files/{ => default}/fileTemplates/includes/PHP Function Doc Comment.php (100%) rename files/{ => default}/fileTemplates/includes/PHP Interface Doc Comment.php (100%) rename files/{ => default}/fileTemplates/includes/PHP Property Doc Comment.php (100%) rename files/{ => default}/fileTemplates/includes/PHP Trait Doc Comment.php (100%) rename files/{ => default}/fileTemplates/internal/JavaScript File.js (100%) rename files/{ => default}/fileTemplates/internal/PHP Class.php (100%) rename files/{ => default}/fileTemplates/internal/PHP File.php (100%) rename files/{ => default}/fileTemplates/internal/PHP Interface.php (100%) rename files/{ => default}/fileTemplates/internal/PHP Trait.php (100%) rename files/{ => default}/fileTemplates/internal/PHPUnit 6 Test.php (100%) rename files/{ => default}/fileTemplates/internal/PHPUnit Test.php (100%) rename files/{ => default}/inspectionProfiles/MediaCT.xml (100%) rename files/{ => default}/inspectionProfiles/profiles_settings.xml (100%) rename files/{ => magento2}/file.template.settings.xml (100%) rename files/{ => magento2}/fileTemplates/M2-Acl-XML.xml (100%) rename files/{ => magento2}/fileTemplates/M2-Class-Backend-Controller.php (100%) rename files/{ => magento2}/fileTemplates/M2-Class-Block.php (100%) rename files/{ => magento2}/fileTemplates/M2-Class-Helper.php (100%) rename files/{ => magento2}/fileTemplates/M2-Class-Observer.php (100%) rename files/{ => magento2}/fileTemplates/M2-Class-ViewModel.php (100%) rename files/{ => magento2}/fileTemplates/M2-Class.php (100%) rename files/{ => magento2}/fileTemplates/M2-Config-XML.xml (100%) rename files/{ => magento2}/fileTemplates/M2-DI.xml (100%) rename files/{ => magento2}/fileTemplates/M2-Db-schema-XML.xml (100%) rename files/{ => magento2}/fileTemplates/M2-Events.xml (100%) rename files/{ => magento2}/fileTemplates/M2-Extension-Attributes-XML.xml (100%) rename files/{ => magento2}/fileTemplates/M2-Layout-XML.xml (100%) rename files/{ => magento2}/fileTemplates/M2-Menu.xml (100%) rename files/{ => magento2}/fileTemplates/M2-Module-XML.xml (100%) rename files/{ => magento2}/fileTemplates/M2-Registration.php (100%) rename files/{ => magento2}/fileTemplates/M2-Routes.xml (100%) rename files/{ => magento2}/fileTemplates/M2-Sales-XML.xml (100%) rename files/{ => magento2}/fileTemplates/M2-System-XML.xml (100%) rename files/{ => magento2}/fileTemplates/M2-System-include-XML.xml (100%) rename files/{ => magento2}/includes/M2-PHP-File-Header.php (100%) rename files/{ => magento2}/includes/M2-Settings.php (100%) rename files/{ => magento2}/includes/M2-XML-File-Header.xml (100%) rename files/{ => magento2}/templates/M2-acl.xml (100%) rename files/{ => magento2}/templates/M2-db_schema.xml (100%) rename files/{ => magento2}/templates/M2-di.xml (100%) rename files/{ => magento2}/templates/M2-events.xml (100%) rename files/{ => magento2}/templates/M2-menu.xml (100%) rename files/{ => magento2}/templates/M2-module.xml (100%) rename files/{ => magento2}/templates/M2-phtml.xml (100%) rename files/{ => magento2}/templates/M2-registration.xml (100%) rename files/{ => magento2}/templates/M2-system.xml (100%) create mode 100644 src/Patcher/Magento2/FileTemplatesPatcher.php rename src/Patcher/{ => Magento2}/LiveTemplatesPatcher.php (64%) rename src/Patcher/{ => Magento2}/TemplateSettingsPatcher.php (87%) create mode 100644 src/ProjectTypeResolver.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c5708c..8cff12b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 2.4.0 - 2022-04-13 +### Added +- A project resolver to decide which project is installed. Also added a config to overwrite the type used. +- Composer requirement which should have already been there. + +### Changed +- Make patches independent on project type. +- Files mapping to make clear which platforms the files are used for. + +### Fixed +- Issue where magento 2 IDE files are installed in different projects like `Alumio` or `Laravel`. + ## 2.3.0 - 2021-03-10 ### Added - Copyright. diff --git a/composer.json b/composer.json index 788237c..aabdf13 100644 --- a/composer.json +++ b/composer.json @@ -16,6 +16,7 @@ "composer-plugin-api": "^1.0 || ^2.0" }, "require-dev": { + "composer/composer": "@stable", "ext-simplexml": "*", "kint-php/kint": "@stable", "mikey179/vfsstream": "^1.6" diff --git a/files/default/codeStyleSettings.xml b/files/default/codeStyleSettings.xml new file mode 100644 index 0000000..22ccc84 --- /dev/null +++ b/files/default/codeStyleSettings.xml @@ -0,0 +1,100 @@ + + + + + + diff --git a/files/default/emptyConfig.xml b/files/default/emptyConfig.xml new file mode 100644 index 0000000..db93c94 --- /dev/null +++ b/files/default/emptyConfig.xml @@ -0,0 +1,3 @@ + + + diff --git a/files/fileTemplates/code/PHP Constructor.php b/files/default/fileTemplates/code/PHP Constructor.php similarity index 100% rename from files/fileTemplates/code/PHP Constructor.php rename to files/default/fileTemplates/code/PHP Constructor.php diff --git a/files/fileTemplates/code/PHP Fluent Setter Method.php b/files/default/fileTemplates/code/PHP Fluent Setter Method.php similarity index 100% rename from files/fileTemplates/code/PHP Fluent Setter Method.php rename to files/default/fileTemplates/code/PHP Fluent Setter Method.php diff --git a/files/fileTemplates/code/PHP Getter Method.php b/files/default/fileTemplates/code/PHP Getter Method.php similarity index 100% rename from files/fileTemplates/code/PHP Getter Method.php rename to files/default/fileTemplates/code/PHP Getter Method.php diff --git a/files/fileTemplates/code/PHP Implemented Method Body.php b/files/default/fileTemplates/code/PHP Implemented Method Body.php similarity index 100% rename from files/fileTemplates/code/PHP Implemented Method Body.php rename to files/default/fileTemplates/code/PHP Implemented Method Body.php diff --git a/files/fileTemplates/code/PHP Overridden Method Body.php b/files/default/fileTemplates/code/PHP Overridden Method Body.php similarity index 100% rename from files/fileTemplates/code/PHP Overridden Method Body.php rename to files/default/fileTemplates/code/PHP Overridden Method Body.php diff --git a/files/fileTemplates/code/PHP Setter Method.php b/files/default/fileTemplates/code/PHP Setter Method.php similarity index 100% rename from files/fileTemplates/code/PHP Setter Method.php rename to files/default/fileTemplates/code/PHP Setter Method.php diff --git a/files/fileTemplates/code/PHPUnit Test Method.php b/files/default/fileTemplates/code/PHPUnit Test Method.php similarity index 100% rename from files/fileTemplates/code/PHPUnit Test Method.php rename to files/default/fileTemplates/code/PHPUnit Test Method.php diff --git a/files/fileTemplates/includes/Company Settings.php b/files/default/fileTemplates/includes/Company Settings.php similarity index 100% rename from files/fileTemplates/includes/Company Settings.php rename to files/default/fileTemplates/includes/Company Settings.php diff --git a/files/fileTemplates/includes/PHP Class Doc Comment.php b/files/default/fileTemplates/includes/PHP Class Doc Comment.php similarity index 100% rename from files/fileTemplates/includes/PHP Class Doc Comment.php rename to files/default/fileTemplates/includes/PHP Class Doc Comment.php diff --git a/files/fileTemplates/includes/PHP Field Doc Comment.php b/files/default/fileTemplates/includes/PHP Field Doc Comment.php similarity index 100% rename from files/fileTemplates/includes/PHP Field Doc Comment.php rename to files/default/fileTemplates/includes/PHP Field Doc Comment.php diff --git a/files/fileTemplates/includes/PHP File Header.php b/files/default/fileTemplates/includes/PHP File Header.php similarity index 100% rename from files/fileTemplates/includes/PHP File Header.php rename to files/default/fileTemplates/includes/PHP File Header.php diff --git a/files/fileTemplates/includes/PHP Function Doc Comment.php b/files/default/fileTemplates/includes/PHP Function Doc Comment.php similarity index 100% rename from files/fileTemplates/includes/PHP Function Doc Comment.php rename to files/default/fileTemplates/includes/PHP Function Doc Comment.php diff --git a/files/fileTemplates/includes/PHP Interface Doc Comment.php b/files/default/fileTemplates/includes/PHP Interface Doc Comment.php similarity index 100% rename from files/fileTemplates/includes/PHP Interface Doc Comment.php rename to files/default/fileTemplates/includes/PHP Interface Doc Comment.php diff --git a/files/fileTemplates/includes/PHP Property Doc Comment.php b/files/default/fileTemplates/includes/PHP Property Doc Comment.php similarity index 100% rename from files/fileTemplates/includes/PHP Property Doc Comment.php rename to files/default/fileTemplates/includes/PHP Property Doc Comment.php diff --git a/files/fileTemplates/includes/PHP Trait Doc Comment.php b/files/default/fileTemplates/includes/PHP Trait Doc Comment.php similarity index 100% rename from files/fileTemplates/includes/PHP Trait Doc Comment.php rename to files/default/fileTemplates/includes/PHP Trait Doc Comment.php diff --git a/files/fileTemplates/internal/JavaScript File.js b/files/default/fileTemplates/internal/JavaScript File.js similarity index 100% rename from files/fileTemplates/internal/JavaScript File.js rename to files/default/fileTemplates/internal/JavaScript File.js diff --git a/files/fileTemplates/internal/PHP Class.php b/files/default/fileTemplates/internal/PHP Class.php similarity index 100% rename from files/fileTemplates/internal/PHP Class.php rename to files/default/fileTemplates/internal/PHP Class.php diff --git a/files/fileTemplates/internal/PHP File.php b/files/default/fileTemplates/internal/PHP File.php similarity index 100% rename from files/fileTemplates/internal/PHP File.php rename to files/default/fileTemplates/internal/PHP File.php diff --git a/files/fileTemplates/internal/PHP Interface.php b/files/default/fileTemplates/internal/PHP Interface.php similarity index 100% rename from files/fileTemplates/internal/PHP Interface.php rename to files/default/fileTemplates/internal/PHP Interface.php diff --git a/files/fileTemplates/internal/PHP Trait.php b/files/default/fileTemplates/internal/PHP Trait.php similarity index 100% rename from files/fileTemplates/internal/PHP Trait.php rename to files/default/fileTemplates/internal/PHP Trait.php diff --git a/files/fileTemplates/internal/PHPUnit 6 Test.php b/files/default/fileTemplates/internal/PHPUnit 6 Test.php similarity index 100% rename from files/fileTemplates/internal/PHPUnit 6 Test.php rename to files/default/fileTemplates/internal/PHPUnit 6 Test.php diff --git a/files/fileTemplates/internal/PHPUnit Test.php b/files/default/fileTemplates/internal/PHPUnit Test.php similarity index 100% rename from files/fileTemplates/internal/PHPUnit Test.php rename to files/default/fileTemplates/internal/PHPUnit Test.php diff --git a/files/inspectionProfiles/MediaCT.xml b/files/default/inspectionProfiles/MediaCT.xml similarity index 100% rename from files/inspectionProfiles/MediaCT.xml rename to files/default/inspectionProfiles/MediaCT.xml diff --git a/files/inspectionProfiles/profiles_settings.xml b/files/default/inspectionProfiles/profiles_settings.xml similarity index 100% rename from files/inspectionProfiles/profiles_settings.xml rename to files/default/inspectionProfiles/profiles_settings.xml diff --git a/files/file.template.settings.xml b/files/magento2/file.template.settings.xml similarity index 100% rename from files/file.template.settings.xml rename to files/magento2/file.template.settings.xml diff --git a/files/fileTemplates/M2-Acl-XML.xml b/files/magento2/fileTemplates/M2-Acl-XML.xml similarity index 100% rename from files/fileTemplates/M2-Acl-XML.xml rename to files/magento2/fileTemplates/M2-Acl-XML.xml diff --git a/files/fileTemplates/M2-Class-Backend-Controller.php b/files/magento2/fileTemplates/M2-Class-Backend-Controller.php similarity index 100% rename from files/fileTemplates/M2-Class-Backend-Controller.php rename to files/magento2/fileTemplates/M2-Class-Backend-Controller.php diff --git a/files/fileTemplates/M2-Class-Block.php b/files/magento2/fileTemplates/M2-Class-Block.php similarity index 100% rename from files/fileTemplates/M2-Class-Block.php rename to files/magento2/fileTemplates/M2-Class-Block.php diff --git a/files/fileTemplates/M2-Class-Helper.php b/files/magento2/fileTemplates/M2-Class-Helper.php similarity index 100% rename from files/fileTemplates/M2-Class-Helper.php rename to files/magento2/fileTemplates/M2-Class-Helper.php diff --git a/files/fileTemplates/M2-Class-Observer.php b/files/magento2/fileTemplates/M2-Class-Observer.php similarity index 100% rename from files/fileTemplates/M2-Class-Observer.php rename to files/magento2/fileTemplates/M2-Class-Observer.php diff --git a/files/fileTemplates/M2-Class-ViewModel.php b/files/magento2/fileTemplates/M2-Class-ViewModel.php similarity index 100% rename from files/fileTemplates/M2-Class-ViewModel.php rename to files/magento2/fileTemplates/M2-Class-ViewModel.php diff --git a/files/fileTemplates/M2-Class.php b/files/magento2/fileTemplates/M2-Class.php similarity index 100% rename from files/fileTemplates/M2-Class.php rename to files/magento2/fileTemplates/M2-Class.php diff --git a/files/fileTemplates/M2-Config-XML.xml b/files/magento2/fileTemplates/M2-Config-XML.xml similarity index 100% rename from files/fileTemplates/M2-Config-XML.xml rename to files/magento2/fileTemplates/M2-Config-XML.xml diff --git a/files/fileTemplates/M2-DI.xml b/files/magento2/fileTemplates/M2-DI.xml similarity index 100% rename from files/fileTemplates/M2-DI.xml rename to files/magento2/fileTemplates/M2-DI.xml diff --git a/files/fileTemplates/M2-Db-schema-XML.xml b/files/magento2/fileTemplates/M2-Db-schema-XML.xml similarity index 100% rename from files/fileTemplates/M2-Db-schema-XML.xml rename to files/magento2/fileTemplates/M2-Db-schema-XML.xml diff --git a/files/fileTemplates/M2-Events.xml b/files/magento2/fileTemplates/M2-Events.xml similarity index 100% rename from files/fileTemplates/M2-Events.xml rename to files/magento2/fileTemplates/M2-Events.xml diff --git a/files/fileTemplates/M2-Extension-Attributes-XML.xml b/files/magento2/fileTemplates/M2-Extension-Attributes-XML.xml similarity index 100% rename from files/fileTemplates/M2-Extension-Attributes-XML.xml rename to files/magento2/fileTemplates/M2-Extension-Attributes-XML.xml diff --git a/files/fileTemplates/M2-Layout-XML.xml b/files/magento2/fileTemplates/M2-Layout-XML.xml similarity index 100% rename from files/fileTemplates/M2-Layout-XML.xml rename to files/magento2/fileTemplates/M2-Layout-XML.xml diff --git a/files/fileTemplates/M2-Menu.xml b/files/magento2/fileTemplates/M2-Menu.xml similarity index 100% rename from files/fileTemplates/M2-Menu.xml rename to files/magento2/fileTemplates/M2-Menu.xml diff --git a/files/fileTemplates/M2-Module-XML.xml b/files/magento2/fileTemplates/M2-Module-XML.xml similarity index 100% rename from files/fileTemplates/M2-Module-XML.xml rename to files/magento2/fileTemplates/M2-Module-XML.xml diff --git a/files/fileTemplates/M2-Registration.php b/files/magento2/fileTemplates/M2-Registration.php similarity index 100% rename from files/fileTemplates/M2-Registration.php rename to files/magento2/fileTemplates/M2-Registration.php diff --git a/files/fileTemplates/M2-Routes.xml b/files/magento2/fileTemplates/M2-Routes.xml similarity index 100% rename from files/fileTemplates/M2-Routes.xml rename to files/magento2/fileTemplates/M2-Routes.xml diff --git a/files/fileTemplates/M2-Sales-XML.xml b/files/magento2/fileTemplates/M2-Sales-XML.xml similarity index 100% rename from files/fileTemplates/M2-Sales-XML.xml rename to files/magento2/fileTemplates/M2-Sales-XML.xml diff --git a/files/fileTemplates/M2-System-XML.xml b/files/magento2/fileTemplates/M2-System-XML.xml similarity index 100% rename from files/fileTemplates/M2-System-XML.xml rename to files/magento2/fileTemplates/M2-System-XML.xml diff --git a/files/fileTemplates/M2-System-include-XML.xml b/files/magento2/fileTemplates/M2-System-include-XML.xml similarity index 100% rename from files/fileTemplates/M2-System-include-XML.xml rename to files/magento2/fileTemplates/M2-System-include-XML.xml diff --git a/files/includes/M2-PHP-File-Header.php b/files/magento2/includes/M2-PHP-File-Header.php similarity index 100% rename from files/includes/M2-PHP-File-Header.php rename to files/magento2/includes/M2-PHP-File-Header.php diff --git a/files/includes/M2-Settings.php b/files/magento2/includes/M2-Settings.php similarity index 100% rename from files/includes/M2-Settings.php rename to files/magento2/includes/M2-Settings.php diff --git a/files/includes/M2-XML-File-Header.xml b/files/magento2/includes/M2-XML-File-Header.xml similarity index 100% rename from files/includes/M2-XML-File-Header.xml rename to files/magento2/includes/M2-XML-File-Header.xml diff --git a/files/templates/M2-acl.xml b/files/magento2/templates/M2-acl.xml similarity index 100% rename from files/templates/M2-acl.xml rename to files/magento2/templates/M2-acl.xml diff --git a/files/templates/M2-db_schema.xml b/files/magento2/templates/M2-db_schema.xml similarity index 100% rename from files/templates/M2-db_schema.xml rename to files/magento2/templates/M2-db_schema.xml diff --git a/files/templates/M2-di.xml b/files/magento2/templates/M2-di.xml similarity index 100% rename from files/templates/M2-di.xml rename to files/magento2/templates/M2-di.xml diff --git a/files/templates/M2-events.xml b/files/magento2/templates/M2-events.xml similarity index 100% rename from files/templates/M2-events.xml rename to files/magento2/templates/M2-events.xml diff --git a/files/templates/M2-menu.xml b/files/magento2/templates/M2-menu.xml similarity index 100% rename from files/templates/M2-menu.xml rename to files/magento2/templates/M2-menu.xml diff --git a/files/templates/M2-module.xml b/files/magento2/templates/M2-module.xml similarity index 100% rename from files/templates/M2-module.xml rename to files/magento2/templates/M2-module.xml diff --git a/files/templates/M2-phtml.xml b/files/magento2/templates/M2-phtml.xml similarity index 100% rename from files/templates/M2-phtml.xml rename to files/magento2/templates/M2-phtml.xml diff --git a/files/templates/M2-registration.xml b/files/magento2/templates/M2-registration.xml similarity index 100% rename from files/templates/M2-registration.xml rename to files/magento2/templates/M2-registration.xml diff --git a/files/templates/M2-system.xml b/files/magento2/templates/M2-system.xml similarity index 100% rename from files/templates/M2-system.xml rename to files/magento2/templates/M2-system.xml diff --git a/src/Environment.php b/src/Environment.php index 7393307..5d742fd 100644 --- a/src/Environment.php +++ b/src/Environment.php @@ -38,6 +38,8 @@ class Environment implements EnvironmentInterface * @var Composer */ private $composer; + /** @var ProjectTypeResolver */ + private $projectTypeResolver; /** * Constructor. @@ -55,7 +57,8 @@ public function __construct( FilesystemInterface $defaultsFilesystem, FilesystemInterface $projectFilesystem, IOInterface $inputOutput, - Composer $composer + Composer $composer, + ProjectTypeResolver $projectTypeResolver ) { $this->ideConfigFilesystem = $ideConfigFilesystem; $this->ideDefaultFilesystem = $ideDefaultFileSystem; @@ -63,6 +66,7 @@ public function __construct( $this->projectFilesystem = $projectFilesystem; $this->inputOutput = $inputOutput; $this->composer = $composer; + $this->projectTypeResolver = $projectTypeResolver; } /** @@ -124,4 +128,14 @@ public function getComposer(): Composer { return $this->composer; } + + /** + * Get project type resolver. + * + * @return ProjectTypeResolver + */ + public function getProjectTypeResolver(): ProjectTypeResolver + { + return $this->projectTypeResolver; + } } diff --git a/src/EnvironmentInterface.php b/src/EnvironmentInterface.php index 9d84eae..7ff1b8f 100644 --- a/src/EnvironmentInterface.php +++ b/src/EnvironmentInterface.php @@ -55,4 +55,11 @@ public function getInputOutput(): IOInterface; * @return Composer */ public function getComposer(): Composer; + + /** + * Get composer project type resolver. + * + * @return ProjectTypeResolver + */ + public function getProjectTypeResolver(): ProjectTypeResolver; } diff --git a/src/InstallerPlugin.php b/src/InstallerPlugin.php index 8c1e13a..b3daf72 100644 --- a/src/InstallerPlugin.php +++ b/src/InstallerPlugin.php @@ -110,7 +110,8 @@ public function onNewCodeEvent(Event $event): void new Filesystem($filesDir), new Filesystem($projectDir), $event->getIO(), - $event->getComposer() + $event->getComposer(), + new ProjectTypeResolver($event->getComposer()) ) ); diff --git a/src/Patcher/ConfigPatcher.php b/src/Patcher/ConfigPatcher.php index 26a739e..315a83f 100644 --- a/src/Patcher/ConfigPatcher.php +++ b/src/Patcher/ConfigPatcher.php @@ -10,6 +10,9 @@ namespace Youwe\CodingStandard\PhpStorm\Patcher; use Youwe\CodingStandard\PhpStorm\EnvironmentInterface; +use Youwe\CodingStandard\PhpStorm\Patcher\Magento2\FileTemplatesPatcher as FileTemplatesPatcherMagento2; +use Youwe\CodingStandard\PhpStorm\Patcher\Magento2\LiveTemplatesPatcher; +use Youwe\CodingStandard\PhpStorm\Patcher\Magento2\TemplateSettingsPatcher; use Youwe\CodingStandard\PhpStorm\XmlAccessor; class ConfigPatcher implements ConfigPatcherInterface @@ -31,11 +34,16 @@ public function __construct(array $patchers = null) $this->patchers = $patchers !== null ? $patchers : [ - new CodeStylePatcher(), - new FileTemplatesPatcher($xmlAccessor), - new InspectionsPatcher($xmlAccessor), - new TemplateSettingsPatcher($xmlAccessor), - new LiveTemplatesPatcher() + 'default' => [ + new CodeStylePatcher(), + new FileTemplatesPatcher($xmlAccessor), + new InspectionsPatcher($xmlAccessor) + ], + 'magento2' => [ + new FileTemplatesPatcherMagento2(), + new TemplateSettingsPatcher($xmlAccessor), + new LiveTemplatesPatcher() + ] ]; } @@ -49,8 +57,16 @@ public function __construct(array $patchers = null) public function patch( EnvironmentInterface $environment ): void { - foreach ($this->patchers as $patcher) { - $patcher->patch($environment); + foreach ($this->patchers as $projectType => $patcher) { + if ($environment->getProjectTypeResolver()->resolve() === $projectType) { + $patcher->patch($environment); + } elseif ($projectType === 'default') { + /** + * Patches that are default are configured for all projects. + * TODO:: Add function to overwrite default patches. + **/ + $patcher->patch($environment); + } } } } diff --git a/src/Patcher/FileTemplatesPatcher.php b/src/Patcher/FileTemplatesPatcher.php index ea2d7f9..c19b586 100644 --- a/src/Patcher/FileTemplatesPatcher.php +++ b/src/Patcher/FileTemplatesPatcher.php @@ -45,7 +45,7 @@ public function patch( $this->copyDirectory( $environment->getDefaultsFilesystem(), $environment->getIdeConfigFilesystem(), - 'fileTemplates' + 'default/fileTemplates' ); $this->patchWorkspaceConfig( diff --git a/src/Patcher/InspectionsPatcher.php b/src/Patcher/InspectionsPatcher.php index f23949a..8f25dde 100644 --- a/src/Patcher/InspectionsPatcher.php +++ b/src/Patcher/InspectionsPatcher.php @@ -48,7 +48,7 @@ public function patch( $this->copyDirectory( $environment->getDefaultsFilesystem(), $environment->getIdeConfigFilesystem(), - 'inspectionProfiles' + 'default/inspectionProfiles' ); $this->setProjectProfiles($environment); diff --git a/src/Patcher/Magento2/FileTemplatesPatcher.php b/src/Patcher/Magento2/FileTemplatesPatcher.php new file mode 100644 index 0000000..83435bf --- /dev/null +++ b/src/Patcher/Magento2/FileTemplatesPatcher.php @@ -0,0 +1,36 @@ +copyDirectory( + $environment->getDefaultsFilesystem(), + $environment->getIdeConfigFilesystem(), + $environment->getProjectTypeResolver()->resolve() . DIRECTORY_SEPARATOR . 'fileTemplates' + ); + } +} diff --git a/src/Patcher/LiveTemplatesPatcher.php b/src/Patcher/Magento2/LiveTemplatesPatcher.php similarity index 64% rename from src/Patcher/LiveTemplatesPatcher.php rename to src/Patcher/Magento2/LiveTemplatesPatcher.php index 8566cda..34b47f2 100644 --- a/src/Patcher/LiveTemplatesPatcher.php +++ b/src/Patcher/Magento2/LiveTemplatesPatcher.php @@ -7,10 +7,11 @@ declare(strict_types=1); -namespace Youwe\CodingStandard\PhpStorm\Patcher; +namespace Youwe\CodingStandard\PhpStorm\Patcher\Magento2; use Youwe\CodingStandard\PhpStorm\EnvironmentInterface; -use Youwe\CodingStandard\PhpStorm\FilesystemInterface; +use Youwe\CodingStandard\PhpStorm\Patcher\ConfigPatcherInterface; +use Youwe\CodingStandard\PhpStorm\Patcher\CopyFilesTrait; class LiveTemplatesPatcher implements ConfigPatcherInterface { @@ -26,11 +27,12 @@ class LiveTemplatesPatcher implements ConfigPatcherInterface public function patch( EnvironmentInterface $environment ): void { - if (! empty($environment->getIdeDefaultConfigFilesystem()->getRoot())) { + + if (!empty($environment->getIdeDefaultConfigFilesystem()->getRoot())) { $this->copyDirectory( $environment->getDefaultsFilesystem(), $environment->getIdeDefaultConfigFilesystem(), - 'templates' + $environment->getProjectTypeResolver()->resolve() . DIRECTORY_SEPARATOR . 'templates' ); } } diff --git a/src/Patcher/TemplateSettingsPatcher.php b/src/Patcher/Magento2/TemplateSettingsPatcher.php similarity index 87% rename from src/Patcher/TemplateSettingsPatcher.php rename to src/Patcher/Magento2/TemplateSettingsPatcher.php index 63a20bc..bc5be5b 100644 --- a/src/Patcher/TemplateSettingsPatcher.php +++ b/src/Patcher/Magento2/TemplateSettingsPatcher.php @@ -7,10 +7,11 @@ declare(strict_types=1); -namespace Youwe\CodingStandard\PhpStorm\Patcher; +namespace Youwe\CodingStandard\PhpStorm\Patcher\Magento2; use Youwe\CodingStandard\PhpStorm\EnvironmentInterface; -use Youwe\CodingStandard\PhpStorm\FilesystemInterface; +use Youwe\CodingStandard\PhpStorm\Patcher\ConfigPatcherInterface; +use Youwe\CodingStandard\PhpStorm\Patcher\CopyFilesTrait; use Youwe\CodingStandard\PhpStorm\XmlAccessorInterface; class TemplateSettingsPatcher implements ConfigPatcherInterface @@ -70,15 +71,16 @@ public function patch( public function patchFileTemplateSettings( EnvironmentInterface $environment ): void { - if (!$environment->getIdeConfigFilesystem()->has('file.template.settings.xml')) { + $path = $environment->getProjectTypeResolver()->resolve() . DIRECTORY_SEPARATOR . 'file.template.settings.xml'; + if (!$environment->getIdeConfigFilesystem()->has($path)) { $this->copyFile( $environment->getDefaultsFilesystem(), $environment->getIdeConfigFilesystem(), - 'file.template.settings.xml' + $path ); } else { $xml = simplexml_load_string( - $environment->getIdeConfigFilesystem()->read('file.template.settings.xml') + $environment->getIdeConfigFilesystem()->read($path) ); foreach ($this->getFileTemplates() as $xmlTag => $fileTemplateNames) { @@ -101,7 +103,7 @@ public function patchFileTemplateSettings( 'live-template-enabled' => 'true' ] ); - $environment->getIdeConfigFilesystem()->put('file.template.settings.xml', $xml->asXML()); + $environment->getIdeConfigFilesystem()->put($path, $xml->asXML()); } } } @@ -120,7 +122,9 @@ public function patchIncludes(EnvironmentInterface $environment): void if (!$environment->getIdeConfigFilesystem()->has("fileTemplates/includes/$fileName")) { $environment->getIdeConfigFilesystem()->put( "fileTemplates/includes/$fileName", - $environment->getDefaultsFilesystem()->read("includes/$fileName") + $environment->getDefaultsFilesystem()->read( + $environment->getProjectTypeResolver()->resolve(). DIRECTORY_SEPARATOR ."includes/$fileName" + ) ); } } diff --git a/src/ProjectTypeResolver.php b/src/ProjectTypeResolver.php new file mode 100644 index 0000000..67f124a --- /dev/null +++ b/src/ProjectTypeResolver.php @@ -0,0 +1,78 @@ + 'magento2', + 'magento-module' => 'magento1', + 'magento2-project' => 'magento2', + 'magento-project' => 'magento2', + 'alumio-project' => 'alumio', + 'laravel-project' => 'laravel', + ]; + + public const DEFAULT_PROJECT_TYPE = 'default'; + + /** + * Constructor. + * + * @param Composer $composer + * @param array|null $mapping + */ + public function __construct(Composer $composer) + { + $this->composer = $composer; + $this->mapping = $mapping ?? $this->mapping; + } + + /** + * Get the type. + * + * @return string + */ + public function resolve(): string + { + $config = $this->composer->getConfig(); + + if ($config->has(static::COMPOSER_CONFIG_KEY)) { + $configNode = $config->get(static::COMPOSER_CONFIG_KEY); + if (isset($configNode[static::COMPOSER_CONFIG_TYPE_KEY])) { + return $configNode[static::COMPOSER_CONFIG_TYPE_KEY]; + } + } + + $packageType = $this->composer->getPackage()->getType(); + + return array_key_exists($packageType, $this->mapping) + ? $this->mapping[$packageType] + : self::DEFAULT_PROJECT_TYPE; + } +} From 2514b64babd433dd8d5f923d108a0ad2433fcc0e Mon Sep 17 00:00:00 2001 From: Leon Helmus Date: Wed, 13 Apr 2022 08:58:57 +0200 Subject: [PATCH 2/4] Update phpstorm to fix errors. --- CHANGELOG.md | 2 +- composer.json | 8 ++- files/codeStyleSettings.xml | 100 ---------------------------- files/emptyConfig.xml | 3 - src/Patcher/ConfigPatcher.php | 22 +++--- src/Patcher/InspectionsPatcher.php | 2 +- tests/EnvironmentTest.php | 6 +- tests/InstallerPluginTest.php | 2 +- tests/Patcher/ConfigPatcherTest.php | 2 +- 9 files changed, 27 insertions(+), 120 deletions(-) delete mode 100644 files/codeStyleSettings.xml delete mode 100644 files/emptyConfig.xml diff --git a/CHANGELOG.md b/CHANGELOG.md index 8cff12b..9845fea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,4 +22,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Declare strict type. ### Changed -- Vendor name from Mediact to Youwe \ No newline at end of file +- Vendor name from Mediact to Youwe diff --git a/composer.json b/composer.json index aabdf13..a6c27b1 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "type": "composer-plugin", "license": "MIT", "prefer-stable": true, - "minimum-stability": "stable", + "minimum-stability": "dev", "authors": [ { "name": "Youwe B.V.", @@ -19,13 +19,17 @@ "composer/composer": "@stable", "ext-simplexml": "*", "kint-php/kint": "@stable", - "mikey179/vfsstream": "^1.6" + "mikey179/vfsstream": "^1.6", + "phpunit/phpunit": "@stable" }, "autoload": { "psr-4": { "Youwe\\CodingStandard\\PhpStorm\\": "src" } }, + "replace": { + "youwe/coding-standard-phpstorm": "*" + }, "autoload-dev": { "psr-4": { "Youwe\\CodingStandard\\PhpStorm\\Tests\\": "tests" diff --git a/files/codeStyleSettings.xml b/files/codeStyleSettings.xml deleted file mode 100644 index 22ccc84..0000000 --- a/files/codeStyleSettings.xml +++ /dev/null @@ -1,100 +0,0 @@ - - - - - - diff --git a/files/emptyConfig.xml b/files/emptyConfig.xml deleted file mode 100644 index db93c94..0000000 --- a/files/emptyConfig.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/src/Patcher/ConfigPatcher.php b/src/Patcher/ConfigPatcher.php index 315a83f..ac8f7e8 100644 --- a/src/Patcher/ConfigPatcher.php +++ b/src/Patcher/ConfigPatcher.php @@ -18,7 +18,7 @@ class ConfigPatcher implements ConfigPatcherInterface { /** - * @var ConfigPatcherInterface[] + * @var array */ private $patchers; @@ -57,15 +57,17 @@ public function __construct(array $patchers = null) public function patch( EnvironmentInterface $environment ): void { - foreach ($this->patchers as $projectType => $patcher) { - if ($environment->getProjectTypeResolver()->resolve() === $projectType) { - $patcher->patch($environment); - } elseif ($projectType === 'default') { - /** - * Patches that are default are configured for all projects. - * TODO:: Add function to overwrite default patches. - **/ - $patcher->patch($environment); + foreach ($this->patchers as $projectType => $patchers) { + foreach ($patchers as $patcher) { + if ($environment->getProjectTypeResolver()->resolve() === $projectType) { + $patcher->patch($environment); + } elseif ($projectType === 'default') { + /** + * Patches that are default are configured for all projects. + * TODO:: Add function to overwrite default patches. + **/ + $patcher->patch($environment); + } } } } diff --git a/src/Patcher/InspectionsPatcher.php b/src/Patcher/InspectionsPatcher.php index 8f25dde..959fdaa 100644 --- a/src/Patcher/InspectionsPatcher.php +++ b/src/Patcher/InspectionsPatcher.php @@ -18,7 +18,7 @@ class InspectionsPatcher implements ConfigPatcherInterface use CopyFilesTrait; public const PROJECT_PHPCS = 'phpcs.xml'; - public const INSPECTION_PROFILE = 'inspectionProfiles/MediaCT.xml'; + public const INSPECTION_PROFILE = 'default/inspectionProfiles/Global.xml'; /** * @var XmlAccessorInterface diff --git a/tests/EnvironmentTest.php b/tests/EnvironmentTest.php index f357f22..4003199 100644 --- a/tests/EnvironmentTest.php +++ b/tests/EnvironmentTest.php @@ -14,6 +14,7 @@ use Youwe\CodingStandard\PhpStorm\FilesystemInterface; use PHPUnit\Framework\TestCase; use Youwe\CodingStandard\PhpStorm\Environment; +use Youwe\CodingStandard\PhpStorm\ProjectTypeResolver; /** * @coversDefaultClass \Youwe\CodingStandard\PhpStorm\Environment @@ -37,6 +38,7 @@ public function testAccess() $projectFs = $this->createMock(FilesystemInterface::class); $inputOutput = $this->createMock(IOInterface::class); $composer = $this->createMock(Composer::class); + $projectTypeResolver = $this->createMock(ProjectTypeResolver::class); $environment = new Environment( $ideConfigFs, @@ -44,7 +46,8 @@ public function testAccess() $defaultsFs, $projectFs, $inputOutput, - $composer + $composer, + $projectTypeResolver ); $this->assertSame($ideConfigFs, $environment->getIdeConfigFilesystem()); @@ -53,5 +56,6 @@ public function testAccess() $this->assertSame($projectFs, $environment->getProjectFilesystem()); $this->assertSame($inputOutput, $environment->getInputOutput()); $this->assertSame($composer, $environment->getComposer()); + $this->assertSame($projectTypeResolver, $environment->getProjectTypeResolver()); } } diff --git a/tests/InstallerPluginTest.php b/tests/InstallerPluginTest.php index 576530f..f753be1 100644 --- a/tests/InstallerPluginTest.php +++ b/tests/InstallerPluginTest.php @@ -70,7 +70,7 @@ public function testOnNewCodeEvent() $event = $this->createMock(Event::class); $event - ->expects($this->exactly(2)) + ->expects($this->atLeast(2)) ->method('getComposer') ->willReturn($composer); diff --git a/tests/Patcher/ConfigPatcherTest.php b/tests/Patcher/ConfigPatcherTest.php index 2a856b7..e13d92c 100644 --- a/tests/Patcher/ConfigPatcherTest.php +++ b/tests/Patcher/ConfigPatcherTest.php @@ -37,7 +37,7 @@ public function testPatch() foreach ($patchers as $patcher) { $patcher - ->expects($this->once()) + ->expects($this->exactly(0)) ->method('patch') ->with($environment); } From 53d23654ad313b047608709e16109b75811d530a Mon Sep 17 00:00:00 2001 From: Leon Helmus Date: Fri, 22 Apr 2022 11:36:58 +0200 Subject: [PATCH 3/4] Update stability and remove replace. --- composer.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/composer.json b/composer.json index a6c27b1..7aa1150 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "type": "composer-plugin", "license": "MIT", "prefer-stable": true, - "minimum-stability": "dev", + "minimum-stability": "stable", "authors": [ { "name": "Youwe B.V.", @@ -27,9 +27,6 @@ "Youwe\\CodingStandard\\PhpStorm\\": "src" } }, - "replace": { - "youwe/coding-standard-phpstorm": "*" - }, "autoload-dev": { "psr-4": { "Youwe\\CodingStandard\\PhpStorm\\Tests\\": "tests" From b6dc18e061da6c8f6ef3301d458279b64e5997e8 Mon Sep 17 00:00:00 2001 From: Leon Helmus Date: Fri, 22 Apr 2022 12:10:55 +0200 Subject: [PATCH 4/4] Update how to get project types. --- .../{MediaCT.xml => Global.xml} | 2 +- .../inspectionProfiles/profiles_settings.xml | 6 +++--- src/Patcher/CodeStylePatcher.php | 2 +- src/Patcher/CopyFilesTrait.php | 17 ++++++++++++----- src/Patcher/FileTemplatesPatcher.php | 2 +- src/Patcher/InspectionsPatcher.php | 2 +- src/Patcher/Magento2/FileTemplatesPatcher.php | 3 ++- src/Patcher/Magento2/LiveTemplatesPatcher.php | 3 ++- .../Magento2/TemplateSettingsPatcher.php | 5 +++-- tests/Patcher/CodeStylePatcherTest.php | 4 ++-- tests/Patcher/CopyFilesTraitTest.php | 10 +++++----- 11 files changed, 33 insertions(+), 23 deletions(-) rename files/default/inspectionProfiles/{MediaCT.xml => Global.xml} (99%) diff --git a/files/default/inspectionProfiles/MediaCT.xml b/files/default/inspectionProfiles/Global.xml similarity index 99% rename from files/default/inspectionProfiles/MediaCT.xml rename to files/default/inspectionProfiles/Global.xml index a0c773c..2a38f9f 100644 --- a/files/default/inspectionProfiles/MediaCT.xml +++ b/files/default/inspectionProfiles/Global.xml @@ -1,6 +1,6 @@ - diff --git a/src/Patcher/CodeStylePatcher.php b/src/Patcher/CodeStylePatcher.php index db828e1..2b705b2 100644 --- a/src/Patcher/CodeStylePatcher.php +++ b/src/Patcher/CodeStylePatcher.php @@ -28,7 +28,7 @@ public function patch( $this->copyFile( $environment->getDefaultsFilesystem(), $environment->getIdeConfigFilesystem(), - 'codeStyleSettings.xml' + 'codeStyleSettings.xml' ); } } diff --git a/src/Patcher/CopyFilesTrait.php b/src/Patcher/CopyFilesTrait.php index 5ee7208..4583ea0 100644 --- a/src/Patcher/CopyFilesTrait.php +++ b/src/Patcher/CopyFilesTrait.php @@ -10,6 +10,7 @@ namespace Youwe\CodingStandard\PhpStorm\Patcher; use Youwe\CodingStandard\PhpStorm\FilesystemInterface; +use Youwe\CodingStandard\PhpStorm\ProjectTypeResolver; trait CopyFilesTrait { @@ -19,15 +20,17 @@ trait CopyFilesTrait * @param FilesystemInterface $source * @param FilesystemInterface $destination * @param string $path + * @param string $type * * @return void */ private function copyDirectory( FilesystemInterface $source, FilesystemInterface $destination, - string $path + string $path, + string $type = ProjectTypeResolver::DEFAULT_PROJECT_TYPE ): void { - foreach ($source->listFiles($path) as $filePath) { + foreach ($source->listFiles($type . DIRECTORY_SEPARATOR . $path) as $filePath) { $this->copyFile($source, $destination, $filePath); } } @@ -38,17 +41,21 @@ private function copyDirectory( * @param FilesystemInterface $source * @param FilesystemInterface $destination * @param string $path + * @param string $type * * @return void */ private function copyFile( FilesystemInterface $source, FilesystemInterface $destination, - string $path + string $path, + string $type = ProjectTypeResolver::DEFAULT_PROJECT_TYPE ): void { + $projectPath = $type . DIRECTORY_SEPARATOR . $path; + $destination->put( - $path, - $source->read($path) + $projectPath, + $source->read($projectPath) ); } } diff --git a/src/Patcher/FileTemplatesPatcher.php b/src/Patcher/FileTemplatesPatcher.php index c19b586..ea2d7f9 100644 --- a/src/Patcher/FileTemplatesPatcher.php +++ b/src/Patcher/FileTemplatesPatcher.php @@ -45,7 +45,7 @@ public function patch( $this->copyDirectory( $environment->getDefaultsFilesystem(), $environment->getIdeConfigFilesystem(), - 'default/fileTemplates' + 'fileTemplates' ); $this->patchWorkspaceConfig( diff --git a/src/Patcher/InspectionsPatcher.php b/src/Patcher/InspectionsPatcher.php index 959fdaa..e014e78 100644 --- a/src/Patcher/InspectionsPatcher.php +++ b/src/Patcher/InspectionsPatcher.php @@ -18,7 +18,7 @@ class InspectionsPatcher implements ConfigPatcherInterface use CopyFilesTrait; public const PROJECT_PHPCS = 'phpcs.xml'; - public const INSPECTION_PROFILE = 'default/inspectionProfiles/Global.xml'; + public const INSPECTION_PROFILE = 'inspectionProfiles/Global.xml'; /** * @var XmlAccessorInterface diff --git a/src/Patcher/Magento2/FileTemplatesPatcher.php b/src/Patcher/Magento2/FileTemplatesPatcher.php index 83435bf..9793984 100644 --- a/src/Patcher/Magento2/FileTemplatesPatcher.php +++ b/src/Patcher/Magento2/FileTemplatesPatcher.php @@ -30,7 +30,8 @@ public function patch( $this->copyDirectory( $environment->getDefaultsFilesystem(), $environment->getIdeConfigFilesystem(), - $environment->getProjectTypeResolver()->resolve() . DIRECTORY_SEPARATOR . 'fileTemplates' + DIRECTORY_SEPARATOR . 'fileTemplates', + $environment->getProjectTypeResolver()->resolve() ); } } diff --git a/src/Patcher/Magento2/LiveTemplatesPatcher.php b/src/Patcher/Magento2/LiveTemplatesPatcher.php index 34b47f2..64c706b 100644 --- a/src/Patcher/Magento2/LiveTemplatesPatcher.php +++ b/src/Patcher/Magento2/LiveTemplatesPatcher.php @@ -32,7 +32,8 @@ public function patch( $this->copyDirectory( $environment->getDefaultsFilesystem(), $environment->getIdeDefaultConfigFilesystem(), - $environment->getProjectTypeResolver()->resolve() . DIRECTORY_SEPARATOR . 'templates' + 'templates', + $environment->getProjectTypeResolver()->resolve() ); } } diff --git a/src/Patcher/Magento2/TemplateSettingsPatcher.php b/src/Patcher/Magento2/TemplateSettingsPatcher.php index bc5be5b..3de8619 100644 --- a/src/Patcher/Magento2/TemplateSettingsPatcher.php +++ b/src/Patcher/Magento2/TemplateSettingsPatcher.php @@ -71,12 +71,13 @@ public function patch( public function patchFileTemplateSettings( EnvironmentInterface $environment ): void { - $path = $environment->getProjectTypeResolver()->resolve() . DIRECTORY_SEPARATOR . 'file.template.settings.xml'; + $path = 'file.template.settings.xml'; if (!$environment->getIdeConfigFilesystem()->has($path)) { $this->copyFile( $environment->getDefaultsFilesystem(), $environment->getIdeConfigFilesystem(), - $path + $path, + $environment->getProjectTypeResolver()->resolve() ); } else { $xml = simplexml_load_string( diff --git a/tests/Patcher/CodeStylePatcherTest.php b/tests/Patcher/CodeStylePatcherTest.php index 9a5e118..1fbe378 100644 --- a/tests/Patcher/CodeStylePatcherTest.php +++ b/tests/Patcher/CodeStylePatcherTest.php @@ -31,13 +31,13 @@ public function testPatch() $ideConfigFs ->expects($this->once()) ->method('put') - ->with('codeStyleSettings.xml', ''); + ->with('default/codeStyleSettings.xml', ''); $defaultsFs = $this->createMock(FilesystemInterface::class); $defaultsFs ->expects($this->once()) ->method('read') - ->with('codeStyleSettings.xml') + ->with('default/codeStyleSettings.xml') ->willReturn(''); $environment = $this->createConfiguredMock( diff --git a/tests/Patcher/CopyFilesTraitTest.php b/tests/Patcher/CopyFilesTraitTest.php index 5469ee6..2f945a3 100644 --- a/tests/Patcher/CopyFilesTraitTest.php +++ b/tests/Patcher/CopyFilesTraitTest.php @@ -33,15 +33,15 @@ public function testPatch() ->expects($this->exactly(2)) ->method('put') ->withConsecutive( - ['foo/foo.xml', ''], - ['foo/bar.xml', ''] + ['default/foo/foo.xml', ''], + ['default/foo/bar.xml', ''] ); $source = $this->createMock(FilesystemInterface::class); $source ->expects($this->once()) ->method('listFiles') - ->with('foo') + ->with('default/foo') ->willReturn( [ 'foo/foo.xml', @@ -54,8 +54,8 @@ public function testPatch() ->method('read') ->willReturnMap( [ - ['foo/foo.xml', ''], - ['foo/bar.xml', ''] + ['default/foo/foo.xml', ''], + ['default/foo/bar.xml', ''] ] );