public function createContextFromFilename($filename) { $tokens = $this->getFileTokens($filename); $class = $this->getNamespaceFromToken($tokens); $reader = new SimpleAnnotationReader(); $reflClass = new \ReflectionClass($class); $entityAnnotation = $reader->getClassAnnotation($reflClass, Entity::class); if (!$entityAnnotation) { return; } $context = new Context(); $context->setFile($filename); $context->setEntity($entityAnnotation); $propertyAnnotations = []; foreach ($reflClass->getProperties() as $property) { $annotation = $reader->getPropertyAnnotation($property, Property::class); if ($annotation && !$annotation->name) { $annotation->name = $property->getName(); $context->addProperty($annotation); } } return $context; }