EzDevInfo.com

phpDocumentor2

Documentation Generator for PHP phpDocumentor

Generate PDF in PHPDocumentor2?

phpdoc -d lib/model -t /var/www/html/docs/ --template responsive

generates html docs fine.

I have upgraded to PHPDocumentor2 and cannot find the command for outputing to PDF. The old way for 1.x doesn't not work in the new version.

Can someone tell me how to do this or point me to the documentation.

Thank you in advance.


Source: (StackOverflow)

Documentation of dereferenced closure in PHP

How should I document the final_nums constant using doxygen or phpdocumentor markup? The closure was not documentable in older phpdocumentor but as of phpdocumentor2 they should have full php 5.3 support. To complicate documentation just a little more, the closure is short lived by the dereferencing.

I believe the resultant documentation should explain that the constant is composed of the results of an anonymous function that takes arguements of (int)prefix and (string)input and returns a (int)result.

$prefix = 1234;
$input = $_GET['input'];
define( 'final_nums', call_user_func(function() use ( $prefix, $input ) {       
    $no_str = preg_replace( '/[^0-9]/', '', $input );
    $output = $prefix . $no_str;
    return $output;
}));

Source: (StackOverflow)

Advertisements

Documenting inherited functions/variables in subclasses with phpdoc

Lets say I have parent class with some variable, which has phpdoc:

class Parent
{
    /**
     * This variable stores some important value that
     * is going to be changed in child classes
     * @var integer
     */
    public $variable = 0;
}

Now I am writing child class, which has this variable overriden:

class Child extends Parent
{
    public $variable = 10;
}

So my question is: what phpdoc should I write for $variable in Child class, so I do not have to copy and paste variable description? Same question goes for methods. Help is much appreciated.

Update: I've asked this question after I've seen errors after creating phpdoc, like "No summary for property $variable" in Child class. If I add this summary - error disappears, but phpdoc shows description from Parent class anyway, no matter what I write in Child class. What am I doing wrong?


Source: (StackOverflow)

Symfony2 install phpDocumentor

I want to install phpdocumentor to my Symfony 2.4 project, so I added this two lines to my composer.json:

"require": {
   //my old requires
   "phpdocumentor/template-abstract": "~1.2",
   "phpdocumentor/phpdocumentor": "2.1.*@dev"
}

whene I execut php composer.phar update, i have these errors:

 Problem 1
- phpdocumentor/template-abstract 1.2.1 requires ext-xsl * -> the requested PHP extension xsl is missing from your system.
- phpdocumentor/template-abstract 1.2 requires ext-xsl * -> the requested PHP extension xsl is missing from your system.
- Installation request for phpdocumentor/template-abstract ~1.2 -> satisfiable by phpdocumentor/template-abstract[1.2, 1.2.1].

although I installed php_xsl in my php extensions?!! Thank you.


Source: (StackOverflow)

How to dynamically change the @version field from the phpdocumentor

I use phpdocumentor tags to document my php codes classes and function, as shown below

/**
* Module for Car 
* @category Vehicle
* @version  2.0
* @since    1.0
* @link     http://api.abc.example.com/v2.0/docs/#!/car
*/

My question is that, is there way to dynamically change @version and @link values. As if the version change, I do not want to go to every class and function to update the @version ad @link fields. If my system version change from v2.0 to 3.0 I would have to change documentation for all my classes and functions

/**
* Module for Car 
* @category Vehicle
* @version  3.0
* @since    1.0
* @link     http://api.abc.example.com/v3.0/docs/#!/car
*/

Its a tedious works to do so :-).

Any suggestions?


Source: (StackOverflow)

PhpStorm 7 @method bug or I'm wrongly using phpDocumentor annotations?

I don't know if this is my bad (wrong phpDocumentor annotations) or it's a bug. Anyone experiencing this issue?

namespace Bar\Baz;

/**
 * @method Foo baz(boolean $baz)
 */
class Foo
{

}

As you can see there is no code completion for chaining (i.e. $f->baz()->baz()) and boolean type is namespaced:

Problem 1 Problem 2


Source: (StackOverflow)

PhpDocumentor on Laravel framework

How to use phpdocumentor in laravel 5 is there any simple way to generate documentation other than via CLI


Source: (StackOverflow)

phpDocumentor relative paths to css and javascript

It's my first time using phpDocumentor 2 and every file in the root folder of the documentation looks fine.

Unfortunately, anything in the subdirectories (classes, namespaces and packages) doesn't look right or function properly, because they don't reference "../css/template.css" but "css/template.css". (Same problem with the JS)

Am I missing some sort of configuration issue? The demo on the phpDoc site seems to include the reference to the parent directory.

Thanks in advance!


Source: (StackOverflow)

phpDocumentor does not override docs of parent class

So, basically I have the following setup:

class A {

    /**
     * This is some documentation
     */
    public function foo() {}

}

class B extends A {

    /**
     * This documentation is way more specific than in class A
     */
    public function foo() {}

}

When I try to document this with phpDocumentor2 it displays at method foo() for class B "This is some documentation", however I'd like it to say " This documentation is way more specific than in class A". In phpDocumenter 1, everything looks like expected. So, what is going on here? Is this the new default behavior of phpDocumentor2? And if so, is there a way to change it? Or is this simply a bug?

Note: while doing my research, I bumped frequently into {@inheritDoc}, but I'd like to have the exact opposite behavior.


Source: (StackOverflow)

PhpDocumentor 2 stucked while 'Transform analyzed project into artifacts'

I just started using PhpDocumentor 2. Everything seems to works and all the files are processed but when it reaches this 'Transform analyzed project into artifacts' it gets stucked for hours and never finishes it.

I was wondering if anybody had this issue before, it would be awesome if you can point me out to the right direction to fix it

Thanks!


Source: (StackOverflow)

PHPdoc for dynamic magic properties (or methods)

I recently created a class to create HTML elements. Instead of bothering by creating a method for every existing HTML element and attributes, I decided to use magic methods __get and __call. So with my code I can basically do this:

$signUpForm->insert->input->type('text')->name('firstName')->maxlength(100)->disabled
$signUpForm->insert->input->type('email')->name('emailAddress')->maxlength(100)

etc.

But since I decided to keep this "magic" and simple, I could also do this:

$signUpForm->insert->magic->trick('rabbit')->accessory('hat') which would result into:

<magic trick='rabbit' accessory='hat'>

This is all good since in my opinion it cuts down a lot of boilerplate code and does exactly what I need to do. I don't want a class to enforce HTML standards, I want a class to facilitate HTML, given you know how to use it (and honestly the code to do this is tiny)

So my question is, considering this class can accept any undefined property or methods, is there any way to specify this behavior in PHPDoc? I tried the following without any luck:

/**
 * @property HtmlElementAttribute *    Insert a new HTML element attribute
 * @method   HtmlElementAttribute *    Insert a new HTML element attribute
 */

I don't know if this is just a PHPStorm thing but I couldn't find any similar scenario anywhere...

Also if you are wondering why I would do such a thing, it is to keep track of certain HTML aspects in my PHP code (e.g. IDs declared in a form, or elements inside a form). This can allow me to have visibility in my HTML before its send to the end user.


Source: (StackOverflow)

Using @package instead of namespace in PhpDocumentor 2

I have a large code library for which I am trying to generate hierarchical documentation. The project does not use namespaces but uses @package instead.

I just tried generating docs as a test from the following file with phpDocumentor2:

<?php
/**
 * This is a file
 * @package JustAn\Example
 **/

 /**
 * Something class
 **/
 class Something{
    function try_this(){

    }
 }

Though according to the docs @package JustAn\Example should be the equivalent of namespace JustAn\Example, I found this not to be the case.

When I use namespaces the resulting documentation is like this:

namespace version

When I use the @package notation the result looks like this (even though it recognizes the package notation - this is shown on the full details page of the class):

package notation version

I am looking for a way to get the hierarchical result without having to rewrite the code to use 'real' namespaces.


Source: (StackOverflow)

phpDocumentor 2 tags not working

I installed phpDocumentor 2 using Pear as described on phpdoc.org. When doing so, I compiled my comments

 /**
  * Calls class1
  * @see class2
  * @access public
  */
 class class1 {

 }

 /**
  * Calls class2
  * you can {@link class1}
  */
 class class2 {

 }

The first one does not work unless you say @see class2 Class 2, and the second one would not work regardless. It just prints like it looks, not reading the curly brackets as inline tags. So, my question is - am I doing something wrong here? Is anyone else running into something similar? I downloaded phpDocs 1.x and did not have this problem, but I'd like phpDocs 2 if possible..

Thanks!


Source: (StackOverflow)

PHPDocumentor @example usage

I can not seem to understand how to get PHPCocumentor2 @example tags to work correctly.

I am attempting to parse a single file. My working directory is /home/developers/domains/example.com and I am trying to parse (relative to my working directory) simplesamlphp/modules/example/lib/Auth/Process/RoleTrigger.php. This class file has a DocBloc that looks like:

/**
 * Trigger Role on User from Configuration.
 *
 * @example "RoleManager.usage.example.php" Test Example
 */
public function process() { /* ... */ }

When I run the command to parse just this file in maximum verbosity (phpdoc -f simplesamlphp/modules/example/lib/Auth/Process/RoleTrigger.php -t httpdocs/test -vvv) PhpDoc indicates that the current project root is /home/developers/domains/example.com/simplesamlphp/modules/example/lib/Auth/Process/, so, according to the Documentation, this indicates that the example file RoleManager.usage.example.php should be located either at the same directory level of the parsed file, or in the examples directory of the current Project Root (which would be /home/developers/domains/example.com/simplesamlphp/modules/example/lib/Auth/Process/examples/).

However, try as I might, I can not seem to get the Example to show up in the generated documentation.

All I seem to get is, on the right-hand side of the generated page:

Tags
example     Test Example

With no hyper-link, or display of the file contents, or anything. Just the "Description" with nothing else.

I have attempted to use <code> but multiple lines with multiple levels render broken html that is also useless:

This:

/**
 * Test Doc
 *
 * <code>
 * <?php
 * $array = array(
 *     1 => 'one',
 *     2 => 'two',
 * );
 * print_r($array);
 * ?>
 * </code>
 */

Renders the following HTML:

<p><code>
&lt;?php
$array = array(</p>
<pre><code>1 =&gt; 'one',
2 =&gt; 'two',</code></pre>
<p>);
print_r($array);
?>
</code></p>

Multiple nested <code> and <pre> tags that render something awful. But that is a different issue.


Source: (StackOverflow)

Page-level docblocks and phpdocumentor templates

I'm having a really hard time to get phpDocumentor 2 working.

I have several files in procedural style, that must be documented. The only I found to do that is to use page-level docblocks, but it seems, that they don't work anymore correctly in phpDocumentor version 2.

A related question on stackoverflow shows that others run in the same problem. In this question there are two suggestions:

  1. Add a namespace to the files that should be documented
  2. As of phpDoc issue 910 use the template abstract or new-black

Unfortunately, I'm not able to get work either one.

  1. When I add the namespace, the namespace itself shows up in the doc, but not the content of the docblock.
  2. When I choose another template (I tried zend, abstract and new-black) whith the phar version of phpDoc 2, I get the error PHP Warning: XSLTProcessor::transformToUri(): No stylesheet associated to this object in phar. Apparently this is a known problem.

EDIT:

I'm a step further. I installed the PEAR version of phpDocumentor, and tried out each available template. But I'm still far from reaching the goal: page-level docblocks in the generated documentation.
The templates fall in two categories :

  • clean, responsive, responsive-twig and old-ocean: They do not output page-level docblocks in the generated documentation.
  • abstract, new-black and zend: They have a doc by file section, which show the expected file-level documentation. But they miss several ressources (.js files and images), therefore they look all the same, and do not work correctly (the navigation pane does not have expand-collapse behavior). I looked in their git repository, and the files seem to miss even there.

At this point I'm just wondering if I'm looking in the right direction: It seems inconceivable, that it is impossible to have a documentation showing file level docblocks, due to major regressions and bugs in phpDocumentor 2.

If I'm really on the wrong track, please suggest me how to get a valuable documentation out of my PHP project. If I'm on the right track, please help me to understand what important part in the puzzle I'm missing.


Source: (StackOverflow)