承接 ride/lib-api 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

ride/lib-api

最新稳定版本:1.0.0

Composer 安装命令:

composer require ride/lib-api

包简介

API library of the Ride framework.

README 文档

README

Library to browse the API of your PHP code through reflection.

What's In This Library

DocParser

The DocParser class parses a doc comment string into a Doc instance.

An example of a doc comment string:

    /**
     * Gets a list of namespaces
     * @param string $namespace Filter namespaces with the provided namespace
     * @return array Ordered array with the namespace as key and value
     */

Doc

The Doc class is a data container for the doc comment information as parsed by the DocParser.

DocParameter

The DocParameter class is a data container for the doc comment information of an argument of a function or method.

TagParser

The TagParser class is used by the DocParser to process the different tags (eg @param, @return, ...) of a doc comment.

Tag

The Tag interface is used to implement a specific doc comment tag.

ReflectionClass

The ReflectionClass extends from the PHP core class and adds methods to access the parsed Doc instances and other usefull things to generate an API doc.

ReflectionMethod

The ReflectionClass class extends from the PHP core class and adds methods to access the parsed Doc instances and the source code.

ReflectionProperty

The ReflectionProperty class extends from the PHP core class and adds methods to access the parsed Doc instances.

ApiBrowser

The ApiBrowser class is the facade to this library. Use this instance to check the available namespaces, the classes which reside therein or the full detail of an individual class.

Code Sample

Check the following code sample to see some of the possibilities of this library.

<?php

use ride\library\api\doc\DocParser;
use ride\library\api\ApiBrowser;
use ride\library\system\file\FileSystem;

function createApiBrowser(FileSystem $fileSystem) {
    $includePaths = array(
        '/path/to/source1',
        '/path/to/source2',
    );
    
    $tagParser = new TagParser();
    $docParser = new DocParser($tagParser);
    
    $apiBrowser = new ApiBrowser($docParser, $fileSystem, $includePaths);
    
    return $apiBrowser;
}

function useApiBrowser(ApiBrowser $apiBrowser) {
    // get all available namespaces
    $namespaces = $apiBrowser->getNamespaces();
    
    // get all namespaces in a specific namespace
    $subNamespaces = $apiBrowser->getNamespaces('ride\\library\\api');
    // array(
    //     'ride\\library\\api' => 'ride\\library\\api', 
    //     'ride\\library\\api\\doc' => 'ride\\library\\api\\doc', 
    //     'ride\\library\\api\\doc\\tag' => 'ride\\library\\api\\doc\\tag', 
    //     'ride\\library\\api\\io' => 'ride\\library\\api\\io', 
    //     'ride\\library\\api\\reflection' => 'ride\\library\\api\\reflection', 
    // );
    
    $classes = $apiBrowser->getClassesForNamespace('ride\\library\\api');
    // array(
    //     'ride\\library\\api\\ApiBrowser' => 'ApiBrowser',
    // );
    
    $class = $apiBrowser->getClass('ride\\library\\api\\ApiBrowser');
    
    $doc = $class->getDoc();
    $type = $class->getTypeAsString(); // abstract class, interface
    
    // an array with for each class, the methods it overrides or implements 
    $inheritance = $class->getInheritance();
    // array(
    //     'className' => array(
    //          'methodName' => 'ReflectionMethod',
    //     ), 
    // );
    
    // an array with all classes it extends or implements
    $parents = $class->getParentArray();
    // array(
    // );
    
    $methods = $class->getMethods();
    foreach ($methods as $methodName => $method) {
        $doc = $method->getDoc();
        $type = $method->getTypeAsString(); // abstract protected, ...
        $source = $method->getSource();
        
        $forInterface = $class->getMethodInterface($methodName);
        $false = $method->isInherited('ride\\library\\api\\ApiBrowser');
    }
    
    $properties = $class->getProperties();
    foreach ($properties as $propertyName => $property) {
        $doc = $property->getDoc();
        $type = $property->getTypeAsString();
    }
    
    $constants = $class->getConstants();
    foreach ($constants as $name => $value) {
        
    }
}

Related Modules

Installation

You can use Composer to install this library.

composer require ride/lib-api

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-02-23