Skip to content

Support @method static int foo() syntax for magic methods #1855

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

TysonAndre
Copy link
Contributor

After this change, phpdoc API documentation generated from @method tags will indicate that the method is static the phpdoc tag was of the form @method static Type foo()

Do this by reading isStatic() from ReflectionDocBlock

  • This was added to ReflectionDocBlock before the docblock 2.0.0 release,
    so it should be safe to assume that it's available (excluding beta versions of ReflectionDocBlock)

This was tested locally with the following snippet
(verified generated HTML API documentation was correct and static):

/** 
 * @method static int fooStatic() implicitly a void
 */  
class MyClass{}

Add a draft of updating the docs for static method support.

  • Not sure how to indicate the first version where phpdocumentor supports static method
  • Feel free to suggest the exact wording and layout, or fix it after this PR

For issue #822

Do this reading isStatic() from ReflectionDocBlock

This was added to ReflectionDocBlock before the docblock 2.0.0 release,
so it should be safe to assume that it's available (excluding beta versions)

For issue phpDocumentor#822

This was tested locally with the following snippet:

    /**
     * @method static int fooStatic() implicitly a void
     */
    class MyClass{}
Not sure how to indicate the first version where phpdocumentor supports
it.
Copy link
Member

@jaapio jaapio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this contribution! Only a small update is required before merging this. When done we can release this with the next release!

@@ -377,6 +377,7 @@ public function testGetMagicMethods()
$methodMock->shouldReceive('getDescription')->andReturn($description);
$methodMock->shouldReceive('getResponse')->andReturn($response);
$methodMock->shouldReceive('getArguments')->andReturn($arguments);
$methodMock->shouldReceive('isStatic')->andReturn(true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do add this to a new test. It is unclear to me now if the original behavior was not changed unintended.
It looks like is't ok, but I want to be sure.

@@ -101,6 +101,7 @@ public function testMagicMethodsReturnsExpectedCollectionWithTags()
{
$mockMethodDescriptor = m::mock('phpDocumentor\Descriptor\Tag\MethodDescriptor');
$mockMethodDescriptor->shouldReceive('getMethodName')->andReturn('Sample');
$mockMethodDescriptor->shouldReceive('isStatic')->andReturn(false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same applies here, please add a new testcase.

@jaapio jaapio self-assigned this Jun 4, 2017
@jaapio jaapio merged commit 4557a44 into phpDocumentor:develop Jun 4, 2017
@jaapio
Copy link
Member

jaapio commented Jun 4, 2017

Thanks for the quick response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants