Skip to content

Commit 53d14df

Browse files
authored
Merge pull request #26 from shopwareLabs/fix/create-cli-context-rule
fix: typo in method name
2 parents fa58b21 + f81e214 commit 53d14df

4 files changed

Lines changed: 11 additions & 4 deletions

File tree

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
"allow-plugins": {
3434
"phpstan/extension-installer": true,
3535
"symfony/runtime": false
36+
},
37+
"audit": {
38+
"block-insecure": false
3639
}
3740
},
3841
"extra": {

src/Rule/DisallowDefaultContextCreation.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,19 @@ public function processNode(Node $node, Scope $scope): array
4343
return [];
4444
}
4545

46+
if (!$this->reflectionProvider->hasClass('Shopware\Core\Framework\Context')) {
47+
return [];
48+
}
49+
4650
$class = $this->reflectionProvider->getClass('Shopware\Core\Framework\Context');
4751

48-
if (!$class->hasMethod('createCliContext')) {
52+
if (!$class->hasMethod('createCLIContext')) {
4953
return [];
5054
}
5155

5256
return [
5357
RuleErrorBuilder::message(sprintf('Do not use %s::createDefaultContext() function in code.', $node->class->toString()))
54-
->addTip('If you are in a CLI context, use %s::createCliContext() instead.')
58+
->addTip('If you are in a CLI context, use %s::createCLIContext() instead.')
5559
->addTip('If you are in a web context, pass down the context from the controller.')
5660
->identifier('shopware.disallow.default.context.creation')
5761
->build(),

tests/Rule/DisallowDefaultContextCreationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function testAnalyse(): void
2121
[
2222
<<<EOF
2323
Do not use Shopware\Core\Framework\Context::createDefaultContext() function in code.
24-
💡 • If you are in a CLI context, use %s::createCliContext() instead.
24+
💡 • If you are in a CLI context, use %s::createCLIContext() instead.
2525
• If you are in a web context, pass down the context from the controller.
2626
EOF,
2727
5,

tests/Rule/fixtures/DisallowDefaultContextCreation/context.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
$context = \Shopware\Core\Framework\Context::createDefaultContext();
66

7-
$context = \Shopware\Core\Framework\Context::createCliContext();
7+
$context = \Shopware\Core\Framework\Context::createCLIContext();

0 commit comments

Comments
 (0)