acf-pro-stubs icon indicating copy to clipboard operation
acf-pro-stubs copied to clipboard

lncorrect PHPDoc tags for stubs (e.g. acf_get_field_types, acf_get_setting)

Open mundschenk-at opened this issue 2 years ago • 10 comments
trafficstars

Unfortunately the included PHPDoc tags for several functions are incorrect, for example @return void for acf_get_field_types and acf_get_setting).

mundschenk-at avatar Dec 25 '22 21:12 mundschenk-at

Yes. This is not a selling point of ACF Pro, so these tags are slowly improving. Please talk to Elliot as this is an automatically generated repo.

All I have is this. https://github.com/php-stubs/acf-pro-stubs/blob/3f029889ab95d7ed8baf16149e150bd4bb903227/generate.sh#L27-L43

Related #8 and many more.

What do you suggest?

szepeviktor avatar Dec 25 '22 21:12 szepeviktor

I don't really have a suggestion, I just noted that paulthewalton/acf-stubs was deprecated and it was advised to install php-stubs/acf-pro-stubs instead, but doing so resulted in invalid findings with PHPStan.

mundschenk-at avatar Dec 25 '22 21:12 mundschenk-at

Yes, Paul did it with his hands, line by line.

I would be very happy if you figure out a mechanism to fix the docblock of daily used functions.

szepeviktor avatar Dec 25 '22 21:12 szepeviktor

Yes, Paul did it with his hands, line by line.

No! My mistake. Paul also used giacocorsiglia/stubs-generator 3 years ago.

szepeviktor avatar Dec 25 '22 21:12 szepeviktor

...after a bit of thinking. Please try to talk to Elliot. Maybe he accepts a patch.

Last time I talked to him 🤣 he told me that applying my patch would fix all docblocks and he prefers fixing source code and docblocks at the same time, so he did not apply it.

szepeviktor avatar Dec 25 '22 22:12 szepeviktor

@mundschenk-at All right. Please provide me that one file (includes/fields.php) with fixed types in a secret gist and I figure out something.

szepeviktor avatar Mar 12 '23 12:03 szepeviktor

@mundschenk-at Did a series of releases but still no improvement on "your" front.

Many docblocks have improved in https://github.com/php-stubs/acf-pro-stubs/compare/v6.0.7...v6.1.0 but not in these reported functions.

szepeviktor avatar Jul 21 '23 09:07 szepeviktor

Using acf()->fields->get_field_type() was recommended (https://github.com/php-stubs/acf-pro-stubs/pull/8#issuecomment-1284553571), but that throws an undefined property error.

crstauf avatar Sep 07 '23 00:09 crstauf

You could download https://patch-diff.githubusercontent.com/raw/php-stubs/acf-pro-stubs/pull/8.patch and apply it as a patch.

szepeviktor avatar Sep 07 '23 02:09 szepeviktor

Ended up using composer-patches:~1.0 to apply a patch (on composer install/update) to fix the return type of acf_get_field_type().

Generated the patch with this command:

git diff --no-index vendor/php-stubs/acf-pro-stubs/acf-pro-stubs.php.old vendor/php-stubs/acf-pro-stubs/acf-pro-stubs.php > dev/patches/acf-pro-stubs.patch

I tried using symplify/vendor-patches, but couldn't get the patch to apply.

crstauf avatar Sep 08 '23 16:09 crstauf