Repository navigation
feat: allow extensions to supply their own phpstan config #1577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package verifier | ||
|
|
||
| import ( | ||
| "path/filepath" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
|
|
||
| "github.com/shopware/shopware-cli/internal/extension" | ||
| "github.com/shopware/shopware-cli/internal/testhelper" | ||
| ) | ||
|
|
||
| func TestConvertExtensionToToolConfigCopiesPhpstanConfig(t *testing.T) { | ||
| pluginDir := filepath.Join(t.TempDir(), "SwagExample") | ||
| testhelper.WriteFile(t, filepath.Join(pluginDir, "composer.json"), testhelper.PluginComposer("test/swag-example", "1.0.0", `SwagExample\SwagExample`).String()) | ||
| testhelper.WriteFile(t, filepath.Join(pluginDir, ".shopware-extension.yml"), "validation:\n phpstan_config: phpstan-verifier.neon\n") | ||
| testhelper.WriteFile(t, filepath.Join(pluginDir, "phpstan-verifier.neon"), "parameters:\n") | ||
|
|
||
| ext, err := extension.GetExtensionByFolder(t.Context(), pluginDir) | ||
| require.NoError(t, err) | ||
|
|
||
| cfg := newToolConfig(ext) | ||
|
|
||
| assert.Equal(t, "phpstan-verifier.neon", cfg.PhpstanConfig) | ||
| assert.Equal(t, ext.GetPath(), cfg.RootDir) | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -39,6 +39,8 @@ type ToolConfig struct { | |||||||||||
| SourceDirectories []string | ||||||||||||
| // Contains a list of identifiers that are ignored | ||||||||||||
| ValidationIgnores []validation.ToolConfigIgnore | ||||||||||||
| // Path to an extension-supplied PHPStan config, relative to RootDir. Empty means the bundled config is used. | ||||||||||||
| PhpstanConfig string | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: not sure if this struct should contain a PHPStan specific field, as it's part of the One other idea with a much smaller changeset could also be adjusting: shopware-cli/internal/verifier/phpstan.go Lines 18 to 22 in 8209286
to auto discover a "custom / SW CLI specific" phpstan config first (e.g. your I think all the other tools currently all rely on either auto discovery of their specific config or use a bundled one, so this use case would be new and we might want to consider allowing overriding the used config files for all tools then, having it as a proper feature (I guess we have to discuss that team internally if we want to support that) 🤔 |
||||||||||||
| // Contains a list of directories that are considered as admin code | ||||||||||||
| AdminDirectories []string | ||||||||||||
| // Contains a list of directories that are considered as storefront code | ||||||||||||
|
|
||||||||||||
Uh oh!
There was an error while loading. Please reload this page.