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

Add @param-out for wp_parse_str() #204

Merged
merged 2 commits into from
Aug 25, 2024

Conversation

IanDelMar
Copy link
Contributor

Currently, no tests have been added as PHPStan requires bleeding edge to be enabled in order not to discard the type provided via @param-out.

Assertions might look like

// tests/data/wp_parse_str.php

declare(strict_types=1);

namespace PhpStubs\WordPress\Core\Tests;

use function wp_parse_str;
use function PHPStan\Testing\assertType;

// The type of `$result` cannot be narrowed further via stubs.
wp_parse_str('key=value');
assertType('array<int|string, array|string>', $result);
wp_parse_str('key1[key2]]=value');
assertType('array<int|string, array|string>', $result);

@szepeviktor
Copy link
Member

The docs say it needs a parameter name https://phpstan.org/writing-php-code/phpdocs-basics#setting-parameter-type-passed-by-reference

@IanDelMar
Copy link
Contributor Author

Of course.

@szepeviktor szepeviktor merged commit f9d99d5 into php-stubs:master Aug 25, 2024
5 checks passed
@johnbillion
Copy link
Contributor

I think it's worth using the phpstan- prefix on these tag names so it's clear what they are for. Especially as this is a new phpstan feature.

@johnbillion
Copy link
Contributor

Oh not that new actually. But still.

@IanDelMar IanDelMar deleted the wp_parse_str branch August 25, 2024 21:05
IanDelMar added a commit to IanDelMar/wordpress-stubs that referenced this pull request Aug 25, 2024
szepeviktor pushed a commit that referenced this pull request Aug 25, 2024
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.

3 participants