Skip to content

Commit

Permalink
NamedArgumentConstructor: load polyfill explicitly (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
msmakouz authored Jul 4, 2023
1 parent 3d3aab1 commit aa45e59
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/NamedArgumentConstructorAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@

use Doctrine\Common\Annotations\NamedArgumentConstructorAnnotation;

//
// In some cases, the polyfill may not load. For example, if this class is
// loaded from the composer plugin (plugins do not load the files defined in
// the "require.classmap" and "require.files" section of the "composer.json"
// file).
//
// In this case, it should be loaded explicitly.
//
if (!\class_exists(NamedArgumentConstructorAnnotation::class, false)) {
require_once __DIR__ . '/polyfill.php';
}

/**
* Marker interface for PHP7/PHP8 compatible support for named arguments
* (and constructor property promotion).
Expand Down

0 comments on commit aa45e59

Please sign in to comment.