Skip to content
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

Update prefixes in function document #111

Open
ravinderk opened this issue Jul 16, 2024 · 5 comments
Open

Update prefixes in function document #111

ravinderk opened this issue Jul 16, 2024 · 5 comments

Comments

@ravinderk
Copy link

I found that the function document does not update which creates a false flag with tools like PHPStan. I expect it to auto-update @param and @return in the function document.

image
@ravinderk ravinderk changed the title Update prefixes in function documents Update prefixes in function document Jul 16, 2024
@BrianHenryIE
Copy link
Owner

That makes sense. Please include an example composer.json and specific file lines that can be used in a test.

@ravinderk
Copy link
Author

That makes sense. Please include an example composer.json and specific file lines that can be used in a test.

I noticed PHP tags (@param, @return) in function description updates. The only issue I see when variable type is in <> like Collection<\Stripe\Payout>

@BrianHenryIE
Copy link
Owner

BrianHenryIE commented Jul 16, 2024

Please include an example composer.json and specific file lines that can be used in a test.

I don't know what the name of the package you're referring to is. I need to recreate this if I am to fix it.

The only issue I see when variable type is in <> like Collection<\Stripe\Payout>

File and line number would be hugely helpful here.

@ravinderk
Copy link
Author

Please include an example composer.json and specific file lines that can be used in a test.

I don't know what the name of the package you're referring to is. I need to recreate this if I am to fix it.

The only issue I see when variable type is in <> like Collection<\Stripe\Payout>

File and line number would be hugely helpful here.

@BrianHenryIE this is line: https://github.com/stripe/stripe-php/blob/dbcb2820703dd36f6375c7b3c5bf696bd0cff260/lib/Payout.php#L107

@BrianHenryIE
Copy link
Owner

BrianHenryIE commented Oct 13, 2024

I just wrote a test to try to address this but it is behaving as desired for me

    /**
     * Returns a list of existing payouts sent to third-party bank accounts or payouts
     * that Stripe sent to you. The payouts return in sorted order, with the most
     * recently created payouts appearing first.
     *
     * @param null|array $params
     * @param null|array|string $opts
     *
     * @throws \Strauss\Issue111\Stripe\Exception\ApiErrorException if the request fails
     *
     * @return \Strauss\Issue111\Stripe\Collection<\Stripe\Payout> of ApiResources
     */
    public static function all($params = null, $opts = null)
    {
        $url = static::classUrl();

        return static::_requestPage($url, \Strauss\Issue111\Stripe\Collection::class, $params, $opts);
    }

Is this maybe a case of PhpStorm's rendering of the PhpDoc hiding the full namespace?

Test:

<?php
/**
 * Should prefix modified classnames in phpdoc
 *
 * @see https://github.com/BrianHenryIE/strauss/pull/111
 */

namespace BrianHenryIE\Strauss\Tests\Issues;

use BrianHenryIE\Strauss\Tests\Integration\Util\IntegrationTestCase;

/**
 * @package BrianHenryIE\Strauss\Tests\Issues
 * @coversNothing
 */
class StraussIssue111Test extends IntegrationTestCase
{
    public function test_phpdoc()
    {
        $composerJsonString = <<<'EOD'
{
  "name": "strauss/issue111",
  "require": {
    "stripe/stripe-php": "16.1.0"
  },
  "extra": {
    "strauss": {
      "namespace_prefix": "Strauss\\Issue111\\"
    }
  }
}
EOD;

	    chdir($this->testsWorkingDir);

	    file_put_contents($this->testsWorkingDir . '/composer.json', $composerJsonString);

	    exec('composer install');

	    $this->runStrauss();

	    $php_string = file_get_contents($this->testsWorkingDir . '/vendor-prefixed/stripe/stripe-php/lib/Payout.php');

	    self::assertStringNotContainsString('@throws \Stripe\Exception\ApiErrorException', $php_string);
	    self::assertStringContainsString('@throws \Strauss\Issue111\Stripe\Exception\ApiErrorException', $php_string);
    }
}

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

No branches or pull requests

2 participants