Skip to content

Commit fd7975e

Browse files
authored
Make tests green when running with zend.assertions=1 (#321)
Close #320
2 parents eb57454 + 18457f2 commit fd7975e

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"phpcs": "vendor/bin/phpcs src/ tests/",
5050
"cs-fix": "vendor/bin/phpcbf src/ tests/",
5151
"phpstan": "vendor/bin/phpstan --ansi analyse --configuration phpstan.neon",
52-
"phpunit": "vendor/bin/phpunit --colors=always",
52+
"phpunit": "php -d zend.assertions=1 vendor/bin/phpunit --colors=always",
5353
"test": [
5454
"@lint",
5555
"@lint-neon",

src/RuleErrors/DisallowedCallsRuleErrors.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,12 @@ public function __construct(Allowed $allowed, Identifier $identifier, FilePath $
4949
*/
5050
public function get(?CallLike $node, Scope $scope, string $name, ?string $displayName, ?string $definedIn, array $disallowedCalls, string $identifier, ?string $message = null): array
5151
{
52+
$args = isset($node) && !$node->isFirstClassCallable() ? $node->getArgs() : null;
5253
foreach ($disallowedCalls as $disallowedCall) {
5354
if (
5455
$this->identifier->matches($disallowedCall->getCall(), $name, $disallowedCall->getExcludes())
5556
&& $this->definedInMatches($disallowedCall, $definedIn)
56-
&& !$this->allowed->isAllowed($node, $scope, isset($node) ? $node->getArgs() : null, $disallowedCall)
57+
&& !$this->allowed->isAllowed($node, $scope, $args, $disallowedCall)
5758
) {
5859
$errorBuilder = RuleErrorBuilder::message(sprintf(
5960
$message ?? 'Calling %s is forbidden%s%s',

0 commit comments

Comments
 (0)