★ wanayoo — archive 1999 https://github.com/phpDocumentor/ReflectionDocBlock/pull/250Nouvelle recherche | Portail wanayoo
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

Fix issue with modified backtrace #250

Merged
merged 1 commit into from Aug 15, 2020
Merged

Conversation

@jaapio
Copy link
Member

@jaapio jaapio commented Aug 12, 2020

php allows the backtrace arguments to be modified via the
backtrace. By using array_map we make sure that we do not overwrite
references.

fixes #249

php allows the backtrace arguments to be modified via the
backtrace. By using array_map we make sure that we do not overwrite
references.
@@ -15,4 +15,8 @@
<rule ref="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming.SuperfluousPrefix">
<exclude-pattern>*/src/*/Abstract*.php</exclude-pattern>
</rule>

<rule ref="SlevomatCodingStandard.Classes.UnusedPrivateElements.UnusedMethod">

This comment has been minimized.

@williamdes

williamdes Aug 12, 2020

this could be moved to the source file, but it depends on your code policy.

This comment has been minimized.

@williamdes

williamdes Aug 12, 2020

My proposed change would avoid this error

static function (array $call) use ($flatten) : array {
array_walk_recursive($call['args'], $flatten);
function (array $call) : array {
$call['args'] = array_map([$this, 'flattenArguments'], $call['args']);

This comment has been minimized.

@williamdes

williamdes Aug 12, 2020

Give the php version requirements I would recommend (not tested):
https://github.com/phpDocumentor/ReflectionDocBlock/blob/master/composer.json#L17

Suggested change
$call['args'] = array_map([$this, 'flattenArguments'], $call['args']);
$call['args'] = array_map(function($value) { return $this->flattenArguments($value); }, $call['args']);

This comment has been minimized.

@GrahamCampbell

GrahamCampbell Aug 12, 2020
Contributor

👎 for changing this. The array-callable syntax is much shorter and clearer?

This comment has been minimized.

@williamdes

williamdes Aug 12, 2020

Nope, for me this syntax is "compilation" compatible and explicit for any code searcher or analyser :)
Don't you agree?

This comment has been minimized.

@williamdes

williamdes Aug 12, 2020

And that would remove the need of ref="SlevomatCodingStandard.Classes.UnusedPrivateElements.UnusedMethod">

This comment has been minimized.

@GrahamCampbell

GrahamCampbell Aug 12, 2020
Contributor

Both can be formally detected. I guess it just hasn't been implemented by that code style package. psalm itself certainly recognises uses like that, in it's core stuff.

@jaapio
Copy link
Member Author

@jaapio jaapio commented Aug 12, 2020

@williamdes thanks for the review, are you able to test this with doctum?

@williamdes
Copy link

@williamdes williamdes commented Aug 12, 2020

@williamdes thanks for the review, are you able to test this with doctum?

Not yet, it will take me some time to test it because I can not reproduce it locally..
I will need to hack a phar and try on Travis CI phpMyAdmin

@jaapio
Copy link
Member Author

@jaapio jaapio commented Aug 13, 2020

If you can provide a phar I can reproduce the issue in docker😁

@williamdes
Copy link

@williamdes williamdes commented Aug 13, 2020

If you can provide a phar I can reproduce the issue in docker😁

Well if you succeed that would help me because I could not replicate this on my workstation or docker instances

Follow nikic/PHP-Parser#687 (comment) to replicate the issue, @nikic seems to have reproduced it

@jaapio
Copy link
Member Author

@jaapio jaapio commented Aug 13, 2020

That's what I already did, but can you provide me a phar with the fix included?

@williamdes
Copy link

@williamdes williamdes commented Aug 13, 2020

That's what I already did, but can you provide me a phar with the fix included?

Sure, here it is: https://doctum.long-term.support/releases/5.0.2-dev/doctum.phar

You can see on my manifest diff that I applied your patch code-lts/doctum@d2695c0#diff-d313403d9a8ddaf7d325ee4001bd3fb6

@williamdes
Copy link

@williamdes williamdes commented Aug 13, 2020

@jaapio jaapio merged commit d870572 into master Aug 15, 2020
19 checks passed
19 checks passed
setup
Details
Unit tests
Details
Unit tests for PHP version 7.2 on ubuntu-latest
Details
Unit tests for PHP version 7.3 on ubuntu-latest
Details
Unit tests for PHP version 7.4 on ubuntu-latest
Details
Unit tests for PHP version 8.0 on ubuntu-latest Unit tests for PHP version 8.0 on ubuntu-latest
Details
Unit tests for PHP version 7.2 on windows-latest Unit tests for PHP version 7.2 on windows-latest
Details
Unit tests for PHP version 7.3 on windows-latest Unit tests for PHP version 7.3 on windows-latest
Details
Unit tests for PHP version 7.4 on windows-latest Unit tests for PHP version 7.4 on windows-latest
Details
Unit tests for PHP version 8.0 on windows-latest Unit tests for PHP version 8.0 on windows-latest
Details
Unit tests for PHP version 7.2 on macOS-latest
Details
Unit tests for PHP version 7.3 on macOS-latest
Details
Unit tests for PHP version 7.4 on macOS-latest
Details
Unit tests for PHP version 8.0 on macOS-latest Unit tests for PHP version 8.0 on macOS-latest
Details
codestyle
Details
phpstan
Details
Psalm (ubuntu-latest, 7.2)
Details
BC Check
Details
Scrutinizer 10 updated code elements
Details
@jaapio jaapio deleted the fix/modified-backtrace-arguments branch Aug 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

3 participants
You can’t perform that action at this time.