Skip to content

Commit

Permalink
configure checkDynamicProperties in test
Browse files Browse the repository at this point in the history
  • Loading branch information
rajyan committed Apr 21, 2022
1 parent f12c7ca commit 0f5a31c
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions tests/PHPStan/Rules/Properties/AccessPropertiesRuleTest.php
Expand Up @@ -17,16 +17,19 @@ class AccessPropertiesRuleTest extends RuleTestCase

private bool $checkUnionTypes;

private bool $checkDynamicProperties;

protected function getRule(): Rule
{
$reflectionProvider = $this->createReflectionProvider();
return new AccessPropertiesRule($reflectionProvider, new RuleLevelHelper($reflectionProvider, true, $this->checkThisOnly, $this->checkUnionTypes, false), true, true);
return new AccessPropertiesRule($reflectionProvider, new RuleLevelHelper($reflectionProvider, true, $this->checkThisOnly, $this->checkUnionTypes, false), true, $this->checkDynamicProperties);
}

public function testAccessProperties(): void
{
$this->checkThisOnly = false;
$this->checkUnionTypes = true;
$this->checkDynamicProperties = false;
$this->analyse(
[__DIR__ . '/data/access-properties.php'],
[
Expand Down Expand Up @@ -157,6 +160,7 @@ public function testAccessPropertiesWithoutUnionTypes(): void
{
$this->checkThisOnly = false;
$this->checkUnionTypes = false;
$this->checkDynamicProperties = false;
$this->analyse(
[__DIR__ . '/data/access-properties.php'],
[
Expand Down Expand Up @@ -270,6 +274,7 @@ public function testRuleAssignOp(): void
}
$this->checkThisOnly = false;
$this->checkUnionTypes = true;
$this->checkDynamicProperties = false;
$this->analyse([__DIR__ . '/data/access-properties-assign-op.php'], [
[
'Access to an undefined property TestAccessProperties\AssignOpNonexistentProperty::$flags.',
Expand All @@ -282,6 +287,7 @@ public function testAccessPropertiesOnThisOnly(): void
{
$this->checkThisOnly = true;
$this->checkUnionTypes = true;
$this->checkDynamicProperties = false;
$this->analyse(
[__DIR__ . '/data/access-properties.php'],
[
Expand All @@ -301,6 +307,7 @@ public function testAccessPropertiesAfterIsNullInBooleanOr(): void
{
$this->checkThisOnly = false;
$this->checkUnionTypes = true;
$this->checkDynamicProperties = false;
$this->analyse([__DIR__ . '/data/access-properties-after-isnull.php'], [
[
'Cannot access property $fooProperty on null.',
Expand Down Expand Up @@ -341,6 +348,7 @@ public function testDateIntervalChildProperties(): void
{
$this->checkThisOnly = false;
$this->checkUnionTypes = true;
$this->checkDynamicProperties = false;
$this->analyse([__DIR__ . '/data/date-interval-child-properties.php'], [
[
'Access to an undefined property AccessPropertiesDateIntervalChild\DateIntervalChild::$nonexistent.',
Expand All @@ -353,6 +361,7 @@ public function testClassExists(): void
{
$this->checkThisOnly = false;
$this->checkUnionTypes = true;
$this->checkDynamicProperties = false;

$this->analyse([__DIR__ . '/data/access-properties-class-exists.php'], [
[
Expand Down Expand Up @@ -382,6 +391,7 @@ public function testMixin(): void
{
$this->checkThisOnly = false;
$this->checkUnionTypes = true;
$this->checkDynamicProperties = false;
$this->analyse([__DIR__ . '/data/mixin.php'], [
[
'Access to an undefined property MixinProperties\GenericFoo<ReflectionClass>::$namee.',
Expand All @@ -394,6 +404,7 @@ public function testBug3947(): void
{
$this->checkThisOnly = false;
$this->checkUnionTypes = true;
$this->checkDynamicProperties = false;
$this->analyse([__DIR__ . '/data/bug-3947.php'], []);
}

Expand All @@ -405,6 +416,7 @@ public function testNullSafe(): void

$this->checkThisOnly = false;
$this->checkUnionTypes = true;
$this->checkDynamicProperties = false;

$this->analyse([__DIR__ . '/data/nullsafe-property-fetch.php'], [
[
Expand Down Expand Up @@ -434,6 +446,7 @@ public function testBug3371(): void
{
$this->checkThisOnly = false;
$this->checkUnionTypes = true;
$this->checkDynamicProperties = false;
$this->analyse([__DIR__ . '/data/bug-3371.php'], []);
}

Expand All @@ -445,13 +458,15 @@ public function testBug4527(): void

$this->checkThisOnly = false;
$this->checkUnionTypes = true;
$this->checkDynamicProperties = false;
$this->analyse([__DIR__ . '/data/bug-4527.php'], []);
}

public function testBug4808(): void
{
$this->checkThisOnly = false;
$this->checkUnionTypes = true;
$this->checkDynamicProperties = false;
$this->analyse([__DIR__ . '/data/bug-4808.php'], []);
}

Expand All @@ -463,6 +478,7 @@ public function testBug5868(): void
}
$this->checkThisOnly = false;
$this->checkUnionTypes = true;
$this->checkDynamicProperties = false;
$this->analyse([__DIR__ . '/data/bug-5868.php'], [
[
'Cannot access property $child on Bug5868PropertyFetch\Foo|null.',
Expand Down Expand Up @@ -491,6 +507,7 @@ public function testBug6385(): void

$this->checkThisOnly = false;
$this->checkUnionTypes = true;
$this->checkDynamicProperties = false;
$this->analyse([__DIR__ . '/data/bug-6385.php'], [
[
'Access to an undefined property UnitEnum::$value.',
Expand All @@ -510,13 +527,15 @@ public function testBug6566(): void
}
$this->checkThisOnly = false;
$this->checkUnionTypes = true;
$this->checkDynamicProperties = false;
$this->analyse([__DIR__ . '/data/bug-6566.php'], []);
}

public function testBug6899(): void
{
$this->checkThisOnly = false;
$this->checkUnionTypes = true;
$this->checkDynamicProperties = false;
$this->analyse([__DIR__ . '/data/bug-6899.php'], [
[
'Cannot access property $prop on string.',
Expand All @@ -537,35 +556,39 @@ public function testBug6026(): void
{
$this->checkThisOnly = false;
$this->checkUnionTypes = true;
$this->checkDynamicProperties = false;
$this->analyse([__DIR__ . '/data/bug-6026.php'], []);
}

public function testBug3659(): void
{
$this->checkThisOnly = false;
$this->checkUnionTypes = true;
$this->checkDynamicProperties = false;
$this->analyse([__DIR__ . '/data/bug-3659.php'], []);
}

public function testDynamicProperties(): void
{
$this->checkThisOnly = false;
$this->checkUnionTypes = true;
$this->checkDynamicProperties = false;
$this->analyse([__DIR__ . '/data/dynamic-properties.php'], []);
}


public function testBug4559(): void
{
$this->checkThisOnly = false;
$this->checkUnionTypes = true;
$this->checkDynamicProperties = false;
$this->analyse([__DIR__ . '/data/bug-4559.php'], []);
}

public function testBug3171(): void
{
$this->checkThisOnly = false;
$this->checkUnionTypes = true;
$this->checkDynamicProperties = false;
$this->analyse([__DIR__ . '/data/bug-3171.php'], []);
}

Expand Down

0 comments on commit 0f5a31c

Please sign in to comment.