Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AllowDynamicProperties stub #1478

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions stubs/runtime/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,10 @@ final class ReturnTypeWillChange
{
}
}

if (\PHP_VERSION_ID < 80200 && !class_exists('AllowDynamicProperties', false)) {
#[Attribute(Attribute::TARGET_CLASS)]
final class AllowDynamicProperties
{
}
}
9 changes: 9 additions & 0 deletions tests/PHPStan/Rules/Classes/ClassAttributesRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,13 @@ public function testBug7171(): void
]);
}

public function testAllowDynamicPropertiesAttribute(): void
{
if (PHP_VERSION_ID >= 80200) {
$this->markTestSkipped('Test requires PHP < 8.2.');
}

$this->analyse([__DIR__ . '/data/allow-dynamic-properties-attribute.php'], []);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace AllowDynamicPropertiesAttribute;

#[\AllowDynamicProperties]
class Foo
{

}