php-stubs icon indicating copy to clipboard operation
php-stubs copied to clipboard

Fix for stomp parameter lists

Open vrnagy opened this issue 10 years ago • 8 comments

The code generates the stub with bad parameter list because of the OOP and functional style documentation and duplicates all parameter.

vrnagy avatar Nov 14 '13 10:11 vrnagy

Did you manually update these files, or did you use the generate command?

schmittjoh avatar Nov 14 '13 11:11 schmittjoh

Updated manually because the generator takes the argument list from OOP and procedural description from the docs. For example: readFrame has two approach

OOP: public stompframe Stomp::readFrame ([ string $class_name = "stompFrame" ] ) procedural: array stomp_read_frame ( resource $link )

and the generated code:

    /**
     * Reads the next frame
     *
     * @param string $class_name
     * @param resource $link
     *
     * @return array
     */
    public function readFrame($class_name = 'stompFrame', $link)
    {
    }

vrnagy avatar Nov 14 '13 11:11 vrnagy

Ah, I thought so.

Unfortunately, if we do not fix the generator, your changes are lost the next time generate is run.

schmittjoh avatar Nov 14 '13 11:11 schmittjoh

I know. Maybe we can filter the parameter list. In the SVN the stomp doc has the following format:

 <refsect1 role="description">
  &reftitle.description;
  <para>&style.oop; (method):</para>
   <methodsynopsis>
   <modifier>public</modifier> <type>bool</type><methodname>Stomp::send</methodname>
   <methodparam><type>string</type><parameter>destination</parameter></methodparam>
   <methodparam><type>mixed</type><parameter>msg</parameter></methodparam>
   <methodparam choice="opt"><type>array</type><parameter>headers</parameter></methodparam>
   </methodsynopsis>
  <para>&style.procedural;:</para>
  <methodsynopsis>
   <type>bool</type><methodname>stomp_send</methodname>
   <methodparam><type>resource</type><parameter>link</parameter></methodparam>
   <methodparam><type>string</type><parameter>destination</parameter></methodparam>
   <methodparam><type>mixed</type><parameter>msg</parameter></methodparam>
   <methodparam choice="opt"><type>array</type><parameter>headers</parameter></methodparam>
  </methodsynopsis>
  <para>
   Sends a message to the Message Broker.
  </para>
 </refsect1>

we only need the methodsynopsis right after "&style.oop; (method):" but i don't know if other documents maybe have two methodsynopsis block

vrnagy avatar Nov 14 '13 11:11 vrnagy

The logic is in this class: https://github.com/schmittjoh/php-stubs/blob/master/src/PHPStubs/DocumentationParser.php

We should probably extract both the OO version and the function. It's probably just a matter of updating where the method/function name is taken from.

schmittjoh avatar Nov 14 '13 11:11 schmittjoh

I just added a simple if to L#321 to check if method name is the referenced. But it only works for the OO version currently

vrnagy avatar Nov 14 '13 11:11 vrnagy

Did you run generate already?

schmittjoh avatar Nov 14 '13 11:11 schmittjoh

Yes, on my dev server an it's ok for stomp but not tested on other classes.

vrnagy avatar Nov 14 '13 12:11 vrnagy