Skip to content

Commit

Permalink
Avoid namespace-clashing of test helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
herndlm committed May 2, 2022
1 parent 00fb9ff commit de542a7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 20 deletions.
22 changes: 11 additions & 11 deletions tests/HookDocsRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,43 +38,43 @@ public function testRule(): void
[
[
'Expected 2 @param tags, found 1.',
22,
19,
],
[
'Expected 2 @param tags, found 3.',
31,
28,
],
[
'@param string $one does not accept actual type of parameter: int|string.',
43,
40,
],
[
'@param string $one does not accept actual type of parameter: int.',
53,
50,
],
[
'@param tag must not be named $this. Choose a descriptive alias, for example $instance.',
82,
79,
],
[
'Expected 2 @param tags, found 1.',
97,
94,
],
[
'@param ChildTestClass $one does not accept actual type of parameter: ParentTestClass.',
134,
'@param SzepeViktor\PHPStan\WordPress\Tests\ChildTestClass $one does not accept actual type of parameter: SzepeViktor\PHPStan\WordPress\Tests\ParentTestClass.',
131,
],
[
'@param string $one does not accept actual type of parameter: string|null.',
155,
152,
],
[
'One or more @param tags has an invalid name or invalid syntax.',
170,
167,
],
[
'One or more @param tags has an invalid name or invalid syntax.',
206,
203,
],
]
);
Expand Down
1 change: 0 additions & 1 deletion tests/data/apply_filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

use function PHPStan\Testing\assertType;
use function apply_filters;
use function returnValue;

$value = apply_filters('filter', 'Hello, World');
assertType('mixed', $value);
Expand Down
9 changes: 3 additions & 6 deletions tests/data/hook-docs.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

namespace SzepeViktor\PHPStan\WordPress\Tests;

use ChildTestClass;
use ParentTestClass;

// phpcs:disable Squiz.NamingConventions.ValidFunctionName.NotCamelCaps,Squiz.NamingConventions.ValidVariableName.NotCamelCaps,Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps

$one = 1;
Expand Down Expand Up @@ -109,7 +106,7 @@ function correct_inherited_param_type(ChildTestClass $one)
/**
* This param tag is for a super class of the variable, which is fine.
*
* @param \ParentTestClass $one First parameter.
* @param ParentTestClass $one First parameter.
*/
$args = apply_filters('filter', $one);
}
Expand All @@ -119,7 +116,7 @@ function correct_interface_param_type(ChildTestClass $one)
/**
* This param tag is for the interface of the variable, which is fine.
*
* @param \TestInterface $one First parameter.
* @param TestInterface $one First parameter.
*/
$args = apply_filters('filter', $one);
}
Expand All @@ -129,7 +126,7 @@ function incorrect_inherited_param_type(ParentTestClass $one)
/**
* This param tag is for a child class of the variable. Oh no.
*
* @param \ChildTestClass $one First parameter.
* @param ChildTestClass $one First parameter.
*/
$args = apply_filters('filter', $one);
}
Expand Down
6 changes: 4 additions & 2 deletions tests/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

declare(strict_types=1);

namespace SzepeViktor\PHPStan\WordPress\Tests;

/**
* Returns the passed value.
*
Expand All @@ -18,10 +20,10 @@ interface TestInterface
{
}

class ParentTestClass implements \TestInterface
class ParentTestClass implements TestInterface
{
}

class ChildTestClass extends \ParentTestClass
class ChildTestClass extends ParentTestClass
{
}

0 comments on commit de542a7

Please sign in to comment.