1010
1111namespace Go \Aop \Support ;
1212
13- use InvalidArgumentException ;
14- use ReflectionClass ;
15- use Go \Aop \Advice ;
16- use Go \Aop \PointFilter ;
17- use Go \Aop \IntroductionInfo ;
1813use Go \Aop \IntroductionAdvisor ;
14+ use Go \Aop \IntroductionInfo ;
15+ use Go \Aop \PointFilter ;
1916
2017/**
2118 * Introduction advisor delegating to the given object.
@@ -24,7 +21,9 @@ class DeclareParentsAdvisor implements IntroductionAdvisor
2421{
2522
2623 /**
27- * @var null|IntroductionInfo
24+ * Information about introduced interface/trait
25+ *
26+ * @var IntroductionInfo
2827 */
2928 private $ advice ;
3029
@@ -44,36 +43,10 @@ public function __construct(PointFilter $classFilter, IntroductionInfo $info)
4443 $ this ->advice = $ info ;
4544 }
4645
47- /**
48- * Can the advised interfaces be implemented by the introduction advice?
49- *
50- * Invoked before adding an IntroductionAdvisor.
51- *
52- * @return void
53- * @throws \InvalidArgumentException if the advised interfaces can't be implemented by the introduction advice
54- */
55- public function validateInterfaces ()
56- {
57- $ refInterface = new ReflectionClass (reset ($ this ->advice ->getInterfaces ()));
58- $ refImplementation = new ReflectionClass (reset ($ this ->advice ->getTraits ()));
59- if (!$ refInterface ->isInterface ()) {
60- throw new \InvalidArgumentException ("Only interface can be introduced " );
61- }
62- if (!$ refImplementation ->isTrait ()) {
63- throw new \InvalidArgumentException ("Only trait can be used as implementation " );
64- }
65-
66- foreach ($ refInterface ->getMethods () as $ interfaceMethod ) {
67- if (!$ refImplementation ->hasMethod ($ interfaceMethod ->name )) {
68- throw new \DomainException ("Implementation requires method {$ interfaceMethod ->name }" );
69- }
70- }
71- }
72-
7346 /**
7447 * Returns an advice to apply
7548 *
76- * @return Advice| IntroductionInfo|null
49+ * @return IntroductionInfo
7750 */
7851 public function getAdvice ()
7952 {
@@ -91,27 +64,4 @@ public function getClassFilter()
9164 {
9265 return $ this ->classFilter ;
9366 }
94-
95- /**
96- * Set the class filter for advisor
97- *
98- * @param PointFilter $classFilter Filter for classes
99- */
100- public function setClassFilter (PointFilter $ classFilter )
101- {
102- $ this ->classFilter = $ classFilter ;
103- }
104-
105- /**
106- * Return string representation of object
107- *
108- * @return string
109- */
110- public function __toString ()
111- {
112- $ adviceClass = get_class ($ this ->advice );
113- $ interfaceClasses = implode (', ' , $ this ->advice ->getInterfaces ());
114-
115- return get_called_class () . ": advice [ {$ adviceClass }]; interfaces [ {$ interfaceClasses }] " ;
116- }
11767}
0 commit comments