Repository navigation
Expand file tree
/
Copy pathAnnotation.php
More file actions
66 lines (60 loc) · 1.67 KB
/
Copy pathAnnotation.php
File metadata and controls
66 lines (60 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/*
* This file is part of the php-annotation framework.
*
* (c) Rasmus Schultz <[email protected]>
*
* This software is licensed under the GNU LGPL license
* for more information, please see:
*
* <http://code.google.com/p/php-annotations>
*/
namespace Mindplay\Annotation;
/**
* A general-purpose base class for annotations.
*
* Annotations must implement IAnnotation, and may optionally derive
* from this base class.
*/
abstract class Annotation implements IAnnotation
{
/**
* @internal Insulation against read-access to undeclared properties
*/
public function __get($name)
{
throw new AnnotationException(get_class($this)."::\${$name} is not a valid property name");
}
/**
* @internal Insulation against write-access to undeclared properties
*/
public function __set($name, $value)
{
throw new AnnotationException(get_class($this)."::\${$name} is not a valid property name");
}
/**
* Helper method - initializes unnamed properties.
* @param array $properties Array of annotation properties, as passed into IAnnotation::initAnnotation()
* @param array $indexes Array of unnamed properties
*/
protected function _map(&$properties, $indexes)
{
foreach ($indexes as $index=>$name)
{
if (isset($properties[$index]))
{
$this->$name = $properties[$index];
unset($properties[$index]);
}
}
}
/**
* @internal Initializes this annotation instance.
* @see IAnnotation
*/
public function initAnnotation($properties)
{
foreach ($properties as $name => $value)
$this->$name = $value;
}
}