Annotation.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 MIT license. 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. * @throws \BadMethodCallException
  53. */
  54. public function __get($name)
  55. {
  56. throw new \BadMethodCallException(
  57. sprintf("Unknown property '%s' on annotation '%s'.", $name, get_class($this))
  58. );
  59. }
  60. /**
  61. * Error handler for unknown property mutator in Annotation class.
  62. *
  63. * @param string $name Unkown property name
  64. * @param mixed $value Property value
  65. *
  66. * @throws \BadMethodCallException
  67. */
  68. public function __set($name, $value)
  69. {
  70. throw new \BadMethodCallException(
  71. sprintf("Unknown property '%s' on annotation '%s'.", $name, get_class($this))
  72. );
  73. }
  74. }