/**
  * Execute the command
  * @param  array  $args Arguments gived to the command
  * @return array Response
  */
 public function execute($args = array())
 {
     $class = $args[0];
     $name = $args[1];
     if (strpos($class, '\\') == 0) {
         $class = substr($class, 1);
     }
     $parser = new DocParser();
     return $parser->get($class, 'method', $name, array(DocParser::PARAM_TYPE));
 }
Example #2
0
 public function bindRoutes($controller, $route)
 {
     $reflector = new ReflectionClass($controller);
     $classDoc = new DocParser($reflector->getDocComment());
     foreach ($reflector->getMethods(ReflectionMethod::IS_PUBLIC) as $methods) {
         if (strpos($methods->name, '__') === 0) {
             continue;
         }
         $methodDoc = new DocParser($method->getDocComment());
         $methods = $methodDoc->getMethods() ?: $classDoc->getMethods() ?: ['GET'];
         $pattern = implode('/', array_filter([$route, $classDoc->getRoute(), $methodDoc->getRoute()]));
         $router = $this->map($methods, $pattern, "{$controller}:{$meth}");
         $this->addMiddleware($router, $classDoc, $methodDoc);
     }
 }
Example #3
0
function parse_doc($php_doc_comment)
{
    $p = new DocParser();
    return $p->parse($php_doc_comment);
    $p = new Parser($php_doc_comment);
    return $p;
    $php_doc_comment = preg_replace("/(^[\\s]*\\/\\*\\*)\n        |(^[\\s]\\*\\/)\n        |(^[\\s]*\\*?\\s)\n        |(^[\\s]*)\n        |(^[\\t]*)/ixm", "", $php_doc_comment);
    $php_doc_comment = str_replace("\r", "", $php_doc_comment);
    $php_doc_comment = preg_replace("/([\\t])+/", "\t", $php_doc_comment);
    return explode("\n", $php_doc_comment);
    $php_doc_comment = trim(preg_replace('/\\r?\\n *\\* */', ' ', $php_doc_comment));
    return $php_doc_comment;
    preg_match_all('/@([a-z]+)\\s+(.*?)\\s*(?=$|@[a-z]+\\s)/s', $php_doc_comment, $matches);
    return array_combine($matches[1], $matches[2]);
}
 /**
  * {@inheritDoc}
  */
 public function getPropertyAnnotations(\ReflectionProperty $property)
 {
     return $this->parser->parse($property->getDocComment(), 'property ' . $property->getDeclaringClass()->name . '::$' . $property->getName());
 }
Example #5
0
        $objs[$fileinfo['filename']] = $class;
    }
}
if (empty($className)) {
    foreach ($objs as $className) {
        $class = new \ReflectionClass($className);
        $json['path'] = strtolower("/resources/" . $class->getShortName() . ".{format}");
        $json['description'] = "";
        $config['apis'][] = $json;
    }
    echo json_encode($config, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
} else {
    if (array_key_exists($className, $objs)) {
        $class = new \ReflectionClass($objs[$className]);
        $methods = $class->getMethods();
        $DocParser = new DocParser();
        foreach ($methods as $method) {
            //公共方法才生成文档
            if ($method->isPublic()) {
                $info = $DocParser->parse($method->getDocComment());
                $json = array();
                $json['path'] = strtolower('/' . $class->getShortName() . '/' . $method->getName() . ".{format}");
                $json['description'] = $info['description'];
                $operation['nickname'] = $method->getName();
                $operation['summary'] = $info['description'];
                foreach ($method->getParameters() as $key => $parameter) {
                    $temp = explode('$' . $parameter->getName(), $info['param'][$key]);
                    $dataType = str_replace('(', '', $temp[0]);
                    $dataType = str_replace(')', '', $dataType);
                    $params = ["name" => $parameter->getName(), "description" => $info['param'][$key], "paramType" => "query", "required" => true, "defaultValue" => 0, "allowMultiple" => false, "dataType" => $dataType];
                    try {
Example #6
0
        $returnTypeBlock = $dom->find('//ref:refsect1[@role="returnvalues"]/ref:para');
        foreach ($returnTypeBlock as $returnTypeElement) {
            /** @var DOMElement $term */
            $manualEntry->setReturnType($returnTypeElement->textContent);
        }
        $this->manualEntries[] = $manualEntry;
        return $manualEntry;
    }
}
$urlList = ['imagickpixel' => ['clear.xml', 'construct.xml', 'destroy.xml', 'getcolor.xml', 'getcolorasstring.xml', 'getcolorcount.xml', 'getcolorvalue.xml', 'gethsl.xml', 'ispixelsimilar.xml', 'issimilar.xml', 'setcolor.xml', 'setcolorvalue.xml', 'sethsl.xml'], 'imagickpixeliterator' => ['clear.xml', 'construct.xml', 'destroy.xml', 'getcurrentiteratorrow.xml', 'getiteratorrow.xml', 'getnextiteratorrow.xml', 'getpreviousiteratorrow.xml', 'newpixeliterator.xml', 'newpixelregioniterator.xml', 'resetiterator.xml', 'setiteratorfirstrow.xml', 'setiteratorlastrow.xml', 'setiteratorrow.xml', 'synciterator.xml'], 'imagickdraw' => ['affine.xml', 'annotation.xml', 'arc.xml', 'bezier.xml', 'circle.xml', 'clear.xml', 'clone.xml', 'color.xml', 'comment.xml', 'composite.xml', 'construct.xml', 'destroy.xml', 'ellipse.xml', 'getclippath.xml', 'getcliprule.xml', 'getclipunits.xml', 'getfillcolor.xml', 'getfillopacity.xml', 'getfillrule.xml', 'getfont.xml', 'getfontfamily.xml', 'getfontsize.xml', 'getfontstyle.xml', 'getfontweight.xml', 'getgravity.xml', 'getstrokeantialias.xml', 'getstrokecolor.xml', 'getstrokedasharray.xml', 'getstrokedashoffset.xml', 'getstrokelinecap.xml', 'getstrokelinejoin.xml', 'getstrokemiterlimit.xml', 'getstrokeopacity.xml', 'getstrokewidth.xml', 'gettextalignment.xml', 'gettextantialias.xml', 'gettextdecoration.xml', 'gettextencoding.xml', 'gettextundercolor.xml', 'getvectorgraphics.xml', 'line.xml', 'matte.xml', 'pathclose.xml', 'pathcurvetoabsolute.xml', 'pathcurvetoquadraticbezierabsolute.xml', 'pathcurvetoquadraticbezierrelative.xml', 'pathcurvetoquadraticbeziersmoothabsolute.xml', 'pathcurvetoquadraticbeziersmoothrelative.xml', 'pathcurvetorelative.xml', 'pathcurvetosmoothabsolute.xml', 'pathcurvetosmoothrelative.xml', 'pathellipticarcabsolute.xml', 'pathellipticarcrelative.xml', 'pathfinish.xml', 'pathlinetoabsolute.xml', 'pathlinetohorizontalabsolute.xml', 'pathlinetohorizontalrelative.xml', 'pathlinetorelative.xml', 'pathlinetoverticalabsolute.xml', 'pathlinetoverticalrelative.xml', 'pathmovetoabsolute.xml', 'pathmovetorelative.xml', 'pathstart.xml', 'point.xml', 'polygon.xml', 'polyline.xml', 'pop.xml', 'popclippath.xml', 'popdefs.xml', 'poppattern.xml', 'push.xml', 'pushclippath.xml', 'pushdefs.xml', 'pushpattern.xml', 'rectangle.xml', 'render.xml', 'rotate.xml', 'roundrectangle.xml', 'scale.xml', 'setclippath.xml', 'setcliprule.xml', 'setclipunits.xml', 'setfillalpha.xml', 'setfillcolor.xml', 'setfillopacity.xml', 'setfillpatternurl.xml', 'setfillrule.xml', 'setfont.xml', 'setfontfamily.xml', 'setfontsize.xml', 'setfontstretch.xml', 'setfontstyle.xml', 'setfontweight.xml', 'setgravity.xml', 'setstrokealpha.xml', 'setstrokeantialias.xml', 'setstrokecolor.xml', 'setstrokedasharray.xml', 'setstrokedashoffset.xml', 'setstrokelinecap.xml', 'setstrokelinejoin.xml', 'setstrokemiterlimit.xml', 'setstrokeopacity.xml', 'setstrokepatternurl.xml', 'setstrokewidth.xml', 'settextalignment.xml', 'settextantialias.xml', 'settextdecoration.xml', 'settextencoding.xml', 'settextundercolor.xml', 'setvectorgraphics.xml', 'setviewbox.xml', 'skewx.xml', 'skewy.xml', 'translate.xml'], 'imagick' => ['adaptiveblurimage.xml', 'adaptiveresizeimage.xml', 'adaptivesharpenimage.xml', 'adaptivethresholdimage.xml', 'addimage.xml', 'addnoiseimage.xml', 'affinetransformimage.xml', 'animateimages.xml', 'annotateimage.xml', 'appendimages.xml', 'averageimages.xml', 'blackthresholdimage.xml', 'blurimage.xml', 'borderimage.xml', 'charcoalimage.xml', 'chopimage.xml', 'clear.xml', 'clipimage.xml', 'clippathimage.xml', 'clone.xml', 'clutimage.xml', 'coalesceimages.xml', 'colorfloodfillimage.xml', 'colorizeimage.xml', 'combineimages.xml', 'commentimage.xml', 'compareimagechannels.xml', 'compareimagelayers.xml', 'compareimages.xml', 'compositeimage.xml', 'construct.xml', 'contrastimage.xml', 'contraststretchimage.xml', 'convolveimage.xml', 'cropimage.xml', 'cropthumbnailimage.xml', 'current.xml', 'cyclecolormapimage.xml', 'decipherimage.xml', 'deconstructimages.xml', 'deleteimageartifact.xml', 'deskewimage.xml', 'despeckleimage.xml', 'destroy.xml', 'displayimage.xml', 'displayimages.xml', 'distortimage.xml', 'drawimage.xml', 'edgeimage.xml', 'embossimage.xml', 'encipherimage.xml', 'enhanceimage.xml', 'equalizeimage.xml', 'evaluateimage.xml', 'exportimagepixels.xml', 'extentimage.xml', 'flattenimages.xml', 'flipimage.xml', 'floodfillpaintimage.xml', 'flopimage.xml', 'frameimage.xml', 'functionimage.xml', 'fximage.xml', 'gammaimage.xml', 'gaussianblurimage.xml', 'getcolorspace.xml', 'getcompression.xml', 'getcompressionquality.xml', 'getcopyright.xml', 'getfilename.xml', 'getfont.xml', 'getformat.xml', 'getgravity.xml', 'gethomeurl.xml', 'getimage.xml', 'getimagealphachannel.xml', 'getimageartifact.xml', 'getimagebackgroundcolor.xml', 'getimageblob.xml', 'getimageblueprimary.xml', 'getimagebordercolor.xml', 'getimagechanneldepth.xml', 'getimagechanneldistortion.xml', 'getimagechanneldistortions.xml', 'getimagechannelextrema.xml', 'getimagechannelkurtosis.xml', 'getimagechannelmean.xml', 'getimagechannelrange.xml', 'getimagechannelstatistics.xml', 'getimageclipmask.xml', 'getimagecolormapcolor.xml', 'getimagecolors.xml', 'getimagecolorspace.xml', 'getimagecompose.xml', 'getimagecompression.xml', 'getimagecompressionquality.xml', 'getimagedelay.xml', 'getimagedepth.xml', 'getimagedispose.xml', 'getimagedistortion.xml', 'getimageextrema.xml', 'getimagefilename.xml', 'getimageformat.xml', 'getimagegamma.xml', 'getimagegeometry.xml', 'getimagegravity.xml', 'getimagegreenprimary.xml', 'getimageheight.xml', 'getimagehistogram.xml', 'getimageindex.xml', 'getimageinterlacescheme.xml', 'getimageinterpolatemethod.xml', 'getimageiterations.xml', 'getimagelength.xml', 'getimagemagicklicense.xml', 'getimagematte.xml', 'getimagemattecolor.xml', 'getimageorientation.xml', 'getimagepage.xml', 'getimagepixelcolor.xml', 'getimageprofile.xml', 'getimageprofiles.xml', 'getimageproperties.xml', 'getimageproperty.xml', 'getimageredprimary.xml', 'getimageregion.xml', 'getimagerenderingintent.xml', 'getimageresolution.xml', 'getimagesblob.xml', 'getimagescene.xml', 'getimagesignature.xml', 'getimagesize.xml', 'getimagetickspersecond.xml', 'getimagetotalinkdensity.xml', 'getimagetype.xml', 'getimageunits.xml', 'getimagevirtualpixelmethod.xml', 'getimagewhitepoint.xml', 'getimagewidth.xml', 'getinterlacescheme.xml', 'getiteratorindex.xml', 'getnumberimages.xml', 'getoption.xml', 'getpackagename.xml', 'getpage.xml', 'getpixeliterator.xml', 'getpixelregioniterator.xml', 'getpointsize.xml', 'getquantumdepth.xml', 'getquantumrange.xml', 'getreleasedate.xml', 'getresource.xml', 'getresourcelimit.xml', 'getsamplingfactors.xml', 'getsize.xml', 'getsizeoffset.xml', 'getversion.xml', 'haldclutimage.xml', 'hasnextimage.xml', 'haspreviousimage.xml', 'identifyimage.xml', 'implodeimage.xml', 'importimagepixels.xml', 'labelimage.xml', 'levelimage.xml', 'linearstretchimage.xml', 'liquidrescaleimage.xml', 'magnifyimage.xml', 'mapimage.xml', 'mattefloodfillimage.xml', 'medianfilterimage.xml', 'mergeimagelayers.xml', 'minifyimage.xml', 'modulateimage.xml', 'montageimage.xml', 'morphimages.xml', 'mosaicimages.xml', 'motionblurimage.xml', 'negateimage.xml', 'newimage.xml', 'newpseudoimage.xml', 'nextimage.xml', 'normalizeimage.xml', 'oilpaintimage.xml', 'opaquepaintimage.xml', 'optimizeimagelayers.xml', 'orderedposterizeimage.xml', 'paintfloodfillimage.xml', 'paintopaqueimage.xml', 'painttransparentimage.xml', 'pingimage.xml', 'pingimageblob.xml', 'pingimagefile.xml', 'polaroidimage.xml', 'posterizeimage.xml', 'previewimages.xml', 'previousimage.xml', 'profileimage.xml', 'quantizeimage.xml', 'quantizeimages.xml', 'queryfontmetrics.xml', 'queryfonts.xml', 'queryformats.xml', 'radialblurimage.xml', 'raiseimage.xml', 'randomthresholdimage.xml', 'readimage.xml', 'readimageblob.xml', 'readimagefile.xml', 'recolorimage.xml', 'reducenoiseimage.xml', 'remapimage.xml', 'removeimage.xml', 'removeimageprofile.xml', 'render.xml', 'resampleimage.xml', 'resetimagepage.xml', 'resizeimage.xml', 'rollimage.xml', 'rotateimage.xml', 'roundcorners.xml', 'sampleimage.xml', 'scaleimage.xml', 'segmentimage.xml', 'separateimagechannel.xml', 'sepiatoneimage.xml', 'setbackgroundcolor.xml', 'setcolorspace.xml', 'setcompression.xml', 'setcompressionquality.xml', 'setfilename.xml', 'setfirstiterator.xml', 'setfont.xml', 'setformat.xml', 'setgravity.xml', 'setimage.xml', 'setimagealphachannel.xml', 'setimageartifact.xml', 'setimagebackgroundcolor.xml', 'setimagebias.xml', 'setimageblueprimary.xml', 'setimagebordercolor.xml', 'setimagechanneldepth.xml', 'setimageclipmask.xml', 'setimagecolormapcolor.xml', 'setimagecolorspace.xml', 'setimagecompose.xml', 'setimagecompression.xml', 'setimagecompressionquality.xml', 'setimagedelay.xml', 'setimagedepth.xml', 'setimagedispose.xml', 'setimageextent.xml', 'setimagefilename.xml', 'setimageformat.xml', 'setimagegamma.xml', 'setimagegravity.xml', 'setimagegreenprimary.xml', 'setimageindex.xml', 'setimageinterlacescheme.xml', 'setimageinterpolatemethod.xml', 'setimageiterations.xml', 'setimagematte.xml', 'setimagemattecolor.xml', 'setimageopacity.xml', 'setimageorientation.xml', 'setimagepage.xml', 'setimageprofile.xml', 'setimageproperty.xml', 'setimageredprimary.xml', 'setimagerenderingintent.xml', 'setimageresolution.xml', 'setimagescene.xml', 'setimagetickspersecond.xml', 'setimagetype.xml', 'setimageunits.xml', 'setimagevirtualpixelmethod.xml', 'setimagewhitepoint.xml', 'setinterlacescheme.xml', 'setiteratorindex.xml', 'setlastiterator.xml', 'setoption.xml', 'setpage.xml', 'setpointsize.xml', 'setresolution.xml', 'setresourcelimit.xml', 'setsamplingfactors.xml', 'setsize.xml', 'setsizeoffset.xml', 'settype.xml', 'shadeimage.xml', 'shadowimage.xml', 'sharpenimage.xml', 'shaveimage.xml', 'shearimage.xml', 'sigmoidalcontrastimage.xml', 'sketchimage.xml', 'solarizeimage.xml', 'sparsecolorimage.xml', 'spliceimage.xml', 'spreadimage.xml', 'steganoimage.xml', 'stereoimage.xml', 'stripimage.xml', 'swirlimage.xml', 'textureimage.xml', 'thresholdimage.xml', 'thumbnailimage.xml', 'tintimage.xml', 'transformimage.xml', 'transparentpaintimage.xml', 'transposeimage.xml', 'transverseimage.xml', 'trimimage.xml', 'uniqueimagecolors.xml', 'unsharpmaskimage.xml', 'valid.xml', 'vignetteimage.xml', 'waveimage.xml', 'whitethresholdimage.xml', 'writeimage.xml', 'writeimagefile.xml', 'writeimages.xml', 'writeimagesfile.xml']];
function writeManualEntry(ManualEntry $manualEntry, $filename)
{
    $output = var_export($manualEntry->toArray(), true);
    file_put_contents($filename, $output);
}
$docParser = new DocParser();
$baseURL = "http://svn.php.net/repository/phpdoc/en/trunk/reference/imagick/";
foreach ($urlList as $subdir => $entries) {
    foreach ($entries as $entry) {
        $filename = "./man/" . $subdir . $entry . ".txt";
        if (file_exists($filename) == false) {
            $manualEntry = $docParser->getDoc($baseURL . "/{$subdir}/{$entry}", $subdir, $entry);
            if ($manualEntry) {
                writeManualEntry($manualEntry, $filename);
            }
        }
    }
}
function normalizeString($string)
{
    if (is_array($string)) {
Example #7
0
<?php

include "vendor/autoload.php";
$files = array();
if (empty($argv) || count($argv) < 2) {
    $files = glob(__DIR__ . "/examples/*.php");
} else {
    // cli
    $own = array_shift($argv);
    $files = array_merge($files, $argv);
}
$dock = new DocParser();
foreach ($files as $key => $value) {
    $data = file_get_contents($value);
    preg_match_all("/\\/\\*\\*(.*?)\\*?\\*(\\/)/is", $data, $matches, PREG_SET_ORDER);
    $dock->nextFile($value);
    foreach ($matches as $key => $doc) {
        $dock->nextDoc($doc, array("file" => $value));
    }
}
$a = new DocShowApi($dock->getStorage());
echo $a->render();