Skip to content

Commit 6b72847

Browse files
committed
Set the registry private and add an accessor
1 parent 504bfac commit 6b72847

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/Annotations/AnnotationManager.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class AnnotationManager
6161
/**
6262
* @var array List of registered annotation aliases.
6363
*/
64-
public $registry = array(
64+
private $_registry = array(
6565
'api' => false,
6666
'abstract' => false,
6767
'access' => false,
@@ -232,7 +232,7 @@ protected function getAnnotationFile(string $path): AnnotationFile
232232
* @return string|bool The fully qualified annotation class-name, or false if the
233233
* requested annotation has been disabled (set to false) in the registry.
234234
*
235-
* @see $registry
235+
* @see $_registry
236236
*/
237237
public function resolveName(string $name)
238238
{
@@ -242,8 +242,8 @@ public function resolveName(string $name)
242242

243243
$type = \lcfirst($name);
244244

245-
if (isset($this->registry[$type])) {
246-
return $this->registry[$type]; // type-name is registered
245+
if (isset($this->_registry[$type])) {
246+
return $this->_registry[$type]; // type-name is registered
247247
}
248248

249249
$type = \ucfirst(\strtr($name, '-', '_')) . $this->suffix;
@@ -467,7 +467,7 @@ protected function filterAnnotations(array $annotations, string $type): array
467467
*/
468468
public function getUsage(string $class): UsageAnnotation
469469
{
470-
if ($class === $this->registry['usage']) {
470+
if ($class === $this->_registry['usage']) {
471471
return $this->_usageAnnotation;
472472
}
473473

@@ -611,4 +611,15 @@ public function getPropertyAnnotations($class, string $property = null, string $
611611
return $this->filterAnnotations($this->getAnnotations($class, self::MEMBER_PROPERTY, '$' . $property), $type);
612612
}
613613
}
614+
615+
/**
616+
* Adds an annotation in the registry.
617+
*
618+
* @param string $annotation The annotation to register.
619+
* @param string|bool $class The full name of the class.
620+
*/
621+
public function registerAnnotation(string $annotation, $class)
622+
{
623+
$this->_registry[$annotation] = $class;
624+
}
614625
}

0 commit comments

Comments
 (0)