public function testReturnsAllProperties() { $reflClassA = new \ReflectionClass($this->testSubjectA); $reflClassB = new \ReflectionClass($this->testSubjectB); $this->assertCount(1, ReflectionUtils::getProperties($reflClassA)); $this->assertCount(2, ReflectionUtils::getProperties($reflClassB)); }
private function getAnnotatedTargetValue($annotationName, CommandMessageInterface $command, AnnotationReader $reader, \ReflectionClass $reflClass) { foreach (ReflectionUtils::getProperties($reflClass) as $property) { if (null !== ($annot = $reader->getPropertyAnnotation($property, $annotationName))) { $property->setAccessible(true); return $property->getValue($command->getPayload()); } } foreach (ReflectionUtils::getMethods($reflClass) as $method) { if (null !== ($annot = $reader->getMethodAnnotation($method, $annotationName))) { $method->setAccessible(true); return $method->invoke($command->getPayload()); } } return null; }
private function fieldsMatch($aClass, $expectedValue, $actual) { $match = true; $reflClass = new \ReflectionClass($aClass); foreach (ReflectionUtils::getProperties($reflClass) as $property) { $property->setAccessible(true); $expectedFieldValue = $property->getValue($expectedValue); $actualFieldValue = $property->getValue($actual); if ($expectedFieldValue != $actualFieldValue) { $this->failedField = $property->name; $this->failedFieldExpectedValue = $expectedFieldValue; $this->failedFieldActualValue = $actualFieldValue; return false; } } return $match; }
/** * @return array */ public function getChildEntities() { $entities = array(); foreach (ReflectionUtils::getProperties($this->reflectionClass) as $property) { $annotation = $this->reader->getPropertyAnnotation($property, EventSourcedMember::class); if (null !== $annotation) { $property->setAccessible(true); $child = $property->getValue($this->targetObject); if (is_array($child)) { $entities = array_merge($entities, $child); } else { if ($child instanceof \IteratorAggregate) { foreach ($child as $element) { $entities[] = $element; } } else { $entities[] = $child; } } } } return $entities; }