2017 © Pedro Peláez
 

library lib-api

API library of the Ride framework.

image

ride/lib-api

API library of the Ride framework.

  • Tuesday, October 11, 2016
  • by ride-user
  • Repository
  • 8 Watchers
  • 0 Stars
  • 2,219 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 2 % Grown

The README.md

Ride: API Library

Library to browse the API of your PHP code through reflection., (*1)

What's In This Library

DocParser

The DocParser class parses a doc comment string into a Doc instance., (*2)

An example of a doc comment string:, (*3)

    /**
     * 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., (*4)

DocParameter

The DocParameter class is a data container for the doc comment information of an argument of a function or method., (*5)

TagParser

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

Tag

The Tag interface is used to implement a specific doc comment tag., (*7)

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., (*8)

ReflectionMethod

The ReflectionClass class extends from the PHP core class and adds methods to access the parsed Doc instances and the source code., (*9)

ReflectionProperty

The ReflectionProperty class extends from the PHP core class and adds methods to access the parsed Doc instances., (*10)

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., (*11)

Code Sample

Check the following code sample to see some of the possibilities of this library., (*12)

<?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) {

    }
}

Installation

You can use Composer to install this library., (*13)

composer require ride/lib-api

The Versions

11/10 2016

dev-master

9999999-dev

API library of the Ride framework.

  Sources   Download

MIT

The Requires

 

by Joris Vandeweerd

11/10 2016

dev-develop

dev-develop

API library of the Ride framework.

  Sources   Download

MIT

The Requires

 

by Joris Vandeweerd

11/10 2016

1.0.0

1.0.0.0

API library of the Ride framework.

  Sources   Download

MIT

The Requires

 

by Joris Vandeweerd

28/03 2014

0.1.1

0.1.1.0

API library of the Ride framework.

  Sources   Download

MIT

The Requires

 

by Joris Vandeweerd

23/02 2014

0.1.0

0.1.0.0

API library of the Ride framework.

  Sources   Download

MIT

The Requires

 

by Joris Vandeweerd