protected function getAnnotatedFields(ReflectionClass $class, array $field_validators)
    {
        $properties = $class->getProperties(ReflectionProperty::IS_PUBLIC);
        $fields = [];
        
        foreach ($properties as $prop)
        {
            $name = $prop->getName();
            $comment = $prop->getDocComment();
            if ($comment === false)
                continue;

            $annotations = new DocComment($comment);
            if (!empty($annotations->getAnnotations("ignore")))
                continue;

            $var = $annotations->getAnnotationTokens("var");
            if (count($var) === 0 || empty($var[0]))
                throw new BinderException("No type defined for $prop");

            $base_tp = reset($var);
            $element_tp = $base_tp === "array" ? $annotations->getAnnotationTokens("element") : [];
            $element_tp = reset($element_tp);
            $search_type = $element_tp ?: $base_tp;

            $const_name = Type::class . '::' . strtoupper($search_type);
            $transformer = null;
            if (defined($const_name))
            {
                $type = new Type(constant($const_name), ['unstrict' => true]);
            }
            else
            {
                $type = new Validator(Type::OBJECT, ['instanceof' => $search_type]);
                $transformer = TransformStore::getInstance()->getTransformer($search_type);
            }

            $fieldname = !empty($element_tp) ? $name . '[]' : $name;
            $field = new FormField($fieldname, $type, 'text', '');

            if ($transformer)
                $field->setTransformer($transformer);

            foreach ($annotations->getAnnotations('validator') as $valtype)
            {
                $instance = $this->getValidatorInstance($valtype);
                $field->addValidator($instance);
            }

            $additional = $field_validators[$name] ?? [];
            foreach ($additional as $validator)
                $field->addValidator($validator);

            $error_override = $annotations->getAnnotation('error', true);
            if (!empty($error_override))
                $field->setFixedError(['msg' => $error_override]);

            $fields[$name] = $field;
        }
        return $fields;
    }
protected function getAnnotatedFields(ReflectionClass $class, array $field_validators)
    {
        $properties = $class->getProperties(ReflectionProperty::IS_PUBLIC);
        $fields = [];
        
        foreach ($properties as $prop)
        {
            $name = $prop->getName();
            $comment = $prop->getDocComment();
            if ($comment === false)
                continue;

            $annotations = new DocComment($comment);
            if (!empty($annotations->getAnnotations("ignore")))
                continue;

            $var = $annotations->getAnnotationTokens("var");
            if (count($var) === 0 || empty($var[0]))
                throw new BinderException("No type defined for $prop");

            $base_tp = reset($var);
            $element_tp = $base_tp === "array" ? $annotations->getAnnotationTokens("element") : [];
            $element_tp = reset($element_tp);
            $search_type = $element_tp ?: $base_tp;

            $const_name = Type::class . '::' . strtoupper($search_type);
            $transformer = null;
            if (defined($const_name))
            {
                $type = new Type(constant($const_name), ['unstrict' => true]);
            }
            else
            {
                $type = new Validator(Type::OBJECT, ['instanceof' => $search_type]);
                $transformer = TransformStore::getInstance()->getTransformer($search_type);
            }

            $fieldname = !empty($element_tp) ? $name . '[]' : $name;
            $field = new FormField($fieldname, $type, 'text', '');

            if ($transformer)
                $field->setTransformer($transformer);

            foreach ($annotations->getAnnotations('validator') as $valtype)
            {
                $instance = $this->getValidatorInstance($valtype);
                $field->addValidator($instance);
            }

            $additional = $field_validators[$name] ?? [];
            foreach ($additional as $validator)
                $field->addValidator($validator);

            $error_override = $annotations->getAnnotation('error', true);
            if (!empty($error_override))
                $field->setFixedError(['msg' => $error_override]);

            $fields[$name] = $field;
        }
        return $fields;
    }
protected function getAnnotatedFields ( ReflectionClass $ class , array $ field_validators ) { $ properties = $ class -> getProperties ( ReflectionProperty :: IS_PUBLIC ) ; $ fields = [ ] ; foreach ( $ properties as $ prop ) { $ name = $ prop -> getName ( ) ; $ comment = $ prop -> getDocComment ( ) ; if ( $ comment === false ) continue ; $ annotations = new DocComment ( $ comment ) ; if ( ! empty ( $ annotations -> getAnnotations ( "ignore" ) ) ) continue ; $ var = $ annotations -> getAnnotationTokens ( "var" ) ; if ( count ( $ var ) === 0 || empty ( $ var [ 0 ] ) ) throw new BinderException ( "No type defined for $prop" ) ; $ base_tp = reset ( $ var ) ; $ element_tp = $ base_tp === "array" ? $ annotations -> getAnnotationTokens ( "element" ) : [ ] ; $ element_tp = reset ( $ element_tp ) ; $ search_type = $ element_tp ? : $ base_tp ; $ const_name = Type :: class . '::' . strtoupper ( $ search_type ) ; $ transformer = null ; if ( defined ( $ const_name ) ) { $ type = new Type ( constant ( $ const_name ) , [ 'unstrict' => true ] ) ; } else { $ type = new Validator ( Type :: OBJECT , [ 'instanceof' => $ search_type ] ) ; $ transformer = TransformStore :: getInstance ( ) -> getTransformer ( $ search_type ) ; } $ fieldname = ! empty ( $ element_tp ) ? $ name . '[]' : $ name ; $ field = new FormField ( $ fieldname , $ type , 'text' , '' ) ; if ( $ transformer ) $ field -> setTransformer ( $ transformer ) ; foreach ( $ annotations -> getAnnotations ( 'validator' ) as $ valtype ) { $ instance = $ this -> getValidatorInstance ( $ valtype ) ; $ field -> addValidator ( $ instance ) ; } $ additional = $ field_validators [ $ name ] ?? [ ] ; foreach ( $ additional as $ validator ) $ field -> addValidator ( $ validator ) ; $ error_override = $ annotations -> getAnnotation ( 'error' , true ) ; if ( ! empty ( $ error_override ) ) $ field -> setFixedError ( [ 'msg' => $ error_override ] ) ; $ fields [ $ name ] = $ field ; } return $ fields ; }
Iterate over all properties and add their values to the form

@param ReflectionClass $class The class to extract properties from
@param array $field_validator Additional validators
Iterate over all properties and add their values to the form