Get the properties for this class.
public getProperties ( ) : |
||
return |
/** * {@inheritDoc} */ public function getProperties($filter = null) { $properties = $this->betterReflectionClass->getProperties(); $wrappedProperties = []; foreach ($properties as $key => $property) { $wrappedProperties[$key] = new ReflectionProperty($property); } return $wrappedProperties; }
public function properties() : Properties { return new Properties($this->name(), array_map(function (ReflectionProperty $property) { return new Property($property, $this->typeFactory->create($this->reflector, new Mixed(), $property->getDocBlockTypeStrings(), false), $this->annotations->scanForAnnotations($property->getDocComment(), $this->fileName(), $this->imports)); }, $this->reflectionClass->getProperties())); }
/** * collects all properties for current class (only self defined ones). * * @param ReflectionClass $class * @param string $public * @param string $private * * @return array */ protected function buildProperties(ReflectionClass $class, $public = '+', $private = '-') { $props = []; if (!$this->config['withProperties'] || $class->isInterface()) { return $props; } foreach ($class->getProperties() as $property) { /* @var ReflectionProperty $property */ $props[] = ($property->isPublic() ? $public : $private) . $property->getName(); } natcasesort($props); return $props; }
function it_has_properties(ReflectionClass $reflectionClass, ReflectionProperty $property, AnnotationScanner $annotations, TypeFactory $typeFactory) { $reflectionClass->getName()->willReturn('MyClass'); $property->getName()->willReturn('id'); $property->getDocBlockTypeStrings()->willReturn(['string']); $property->getDocComment()->willReturn('/** @Target("CLASS") */'); $typeFactory->create(Argument::any(), Argument::type(Mixed::class), ['string'], false)->willReturn(new StringType()); $reflectionClass->getProperties()->willReturn([$property]); $annotations->scanForAnnotations('/** @Target("CLASS") */', '/var/www/MyClass.php', $this->imports)->willReturn(new Annotations([new Target(['value' => "CLASS"])])); $this->properties()->shouldHaveSize(1); }