Skip to content

Commit aa45e59

Browse files
authored
NamedArgumentConstructor: load polyfill explicitly (#8)
1 parent 3d3aab1 commit aa45e59

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/NamedArgumentConstructorAttribute.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@
66

77
use Doctrine\Common\Annotations\NamedArgumentConstructorAnnotation;
88

9+
//
10+
// In some cases, the polyfill may not load. For example, if this class is
11+
// loaded from the composer plugin (plugins do not load the files defined in
12+
// the "require.classmap" and "require.files" section of the "composer.json"
13+
// file).
14+
//
15+
// In this case, it should be loaded explicitly.
16+
//
17+
if (!\class_exists(NamedArgumentConstructorAnnotation::class, false)) {
18+
require_once __DIR__ . '/polyfill.php';
19+
}
20+
921
/**
1022
* Marker interface for PHP7/PHP8 compatible support for named arguments
1123
* (and constructor property promotion).

0 commit comments

Comments
 (0)