Annotation.php 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /*
  3. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  4. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  5. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  6. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  7. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  8. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  9. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  10. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  12. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  13. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14. *
  15. * This software consists of voluntary contributions made by many individuals
  16. * and is licensed under the LGPL. For more information, see
  17. * <http://www.doctrine-project.org>.
  18. */
  19. namespace Doctrine\Common\Annotations;
  20. /**
  21. * Annotations class
  22. *
  23. * @author Benjamin Eberlei <kontakt@beberlei.de>
  24. * @author Guilherme Blanco <guilhermeblanco@hotmail.com>
  25. * @author Jonathan Wage <jonwage@gmail.com>
  26. * @author Roman Borschel <roman@code-factory.org>
  27. */
  28. class Annotation
  29. {
  30. /**
  31. * Value property. Common among all derived classes.
  32. *
  33. * @var string
  34. */
  35. public $value;
  36. /**
  37. * Constructor
  38. *
  39. * @param array $data Key-value for properties to be defined in this class
  40. */
  41. public final function __construct(array $data)
  42. {
  43. foreach ($data as $key => $value) {
  44. $this->$key = $value;
  45. }
  46. }
  47. /**
  48. * Error handler for unknown property accessor in Annotation class.
  49. *
  50. * @param string $name Unknown property name
  51. */
  52. public function __get($name)
  53. {
  54. throw new \BadMethodCallException(
  55. sprintf("Unknown property '%s' on annotation '%s'.", $name, get_class($this))
  56. );
  57. }
  58. /**
  59. * Error handler for unknown property mutator in Annotation class.
  60. *
  61. * @param string $name Unkown property name
  62. * @param mixed $value Property value
  63. */
  64. public function __set($name, $value)
  65. {
  66. throw new \BadMethodCallException(
  67. sprintf("Unknown property '%s' on annotation '%s'.", $name, get_class($this))
  68. );
  69. }
  70. }