diff --git a/tests/Calls/FunctionCallsTest.php b/tests/Calls/FunctionCallsTest.php index c16613b..891b7cd 100644 --- a/tests/Calls/FunctionCallsTest.php +++ b/tests/Calls/FunctionCallsTest.php @@ -187,6 +187,16 @@ protected function getRule(): Rule 1 => Blade::class, ], ], + [ + 'function' => '\Foo\Bar\Waldo\config()', + 'allowIn' => [ + '../src/disallowed-allow/*.php', + '../src/*-allow/*.*', + ], + 'disallowParams' => [ + 1 => 'string-key', + ], + ], ] ); } @@ -287,6 +297,10 @@ public function testRule(): void 'Calling Foo\Bar\Waldo\mocky() is forbidden, mocking Blade is not allowed.', 83, ], + [ + 'Calling Foo\Bar\Waldo\config() is forbidden, because reasons', + 91, + ], ]); // Based on the configuration above, no errors in this file: $this->analyse([__DIR__ . '/../src/disallowed-allow/functionCalls.php'], [ diff --git a/tests/libs/Functions.php b/tests/libs/Functions.php index 289dc51..37110de 100644 --- a/tests/libs/Functions.php +++ b/tests/libs/Functions.php @@ -39,3 +39,11 @@ function waldo(string $name = '', string $value = '', int $expires = 0, string $ function mocky(string $className): void { } + + +/** + * @param array|string|null $key + */ +function config($key = null) +{ +} diff --git a/tests/src/disallowed-allow/functionCalls.php b/tests/src/disallowed-allow/functionCalls.php index 5d5151b..a2ae87f 100644 --- a/tests/src/disallowed-allow/functionCalls.php +++ b/tests/src/disallowed-allow/functionCalls.php @@ -84,3 +84,8 @@ // not disallowed hash((new stdClass())->property . 'foo', 'NAH'); + +// not disallowed param +\Foo\Bar\Waldo\config(['key' => 'string']); +// allowed by path +\Foo\Bar\Waldo\config('string-key'); diff --git a/tests/src/disallowed/functionCalls.php b/tests/src/disallowed/functionCalls.php index 13470de..cb8893c 100644 --- a/tests/src/disallowed/functionCalls.php +++ b/tests/src/disallowed/functionCalls.php @@ -84,3 +84,8 @@ // not disallowed hash((new stdClass())->property . 'foo', 'NAH'); + +// not disallowed param +\Foo\Bar\Waldo\config(['key' => 'string']); +// disallowed param +\Foo\Bar\Waldo\config('string-key');