fasano/typedocs 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

fasano/typedocs

最新稳定版本:v1.0.0

Composer 安装命令:

composer require fasano/typedocs

包简介

Standard attributes for documenting types.

README 文档

README

Standard attributes for documenting types in PHP.

Overview

Typedocs provides a set of PHP attributes that allow you to add human-readable documentation directly to your custom types. These attributes can be reflected at runtime to generate documentation, validate schemas, or provide metadata for API documentation.

Installation

composer require foundation/typedocs

Available Attributes

#[Name]

A human-readable name for the type.

#[Example]

Example(s) of valid value(s) for the type.

#[Description]

A detailed description of what the type represents.

Usage

<?php

use Fasano\Typedocs as Doc;
use Fasano\PHPrimitives\AbstractString;

#[Doc\Name('Email')]
#[Doc\Example('john.doe@example.com')]
#[Doc\Description('The user\'s email address.')]
readonly class UserEmail extends AbstractString
{
    protected static function validate(string $value): void
    {
        if (!filter_var($value, FILTER_VALIDATE_EMAIL)) {
            throw new InvalidArgumentException(
                sprintf('Invalid email: %s', $value)
            );
        }
    }
}

Reading Attributes

Use PHP's reflection API to read the documentation attributes:

<?php

use ReflectionClass;
use Fasano\Typedocs\Name;
use Fasano\Typedocs\Example;
use Fasano\Typedocs\Description;

$reflection = new ReflectionClass(UserEmail::class);

$name = $reflection->getAttributes(Name::class)[0]->newInstance();
$example = $reflection->getAttributes(Example::class)[0]->newInstance();
$description = $reflection->getAttributes(Description::class)[0]->newInstance();

echo $name->value;        // "Email"
echo $example->value;     // "john.doe@example.com"
echo $description->value; // "The user's email address."

统计信息

  • 总下载量: 24
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固