Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
{

}