Skip to content

[PHP8] Add broken test with failing attributes generation#502

Merged
lisachenko merged 4 commits intomasterfrom
bug/generated-method-attributes
Mar 22, 2026
Merged

[PHP8] Add broken test with failing attributes generation#502
lisachenko merged 4 commits intomasterfrom
bug/generated-method-attributes

Conversation

@lisachenko
Copy link
Copy Markdown
Member

This broken test is used to track issue with broken codogen with attributes near class/method/method/function/property/parameter.

@lisachenko lisachenko added the Bug label Apr 14, 2024
@scrutinizer-notifier
Copy link
Copy Markdown

A new inspection was created.

@lisachenko
Copy link
Copy Markdown
Member Author

Blocked on laminas/laminas-code#145

@lisachenko lisachenko added this to the 4.0.0 milestone Apr 14, 2024
@lisachenko
Copy link
Copy Markdown
Member Author

FYI @samsonasik this issues is considered as main blocker for running on codebase with attributes - child class won't contain any attributes and this breaks the logic of clients who expect attributes to be preserved.

@lisachenko
Copy link
Copy Markdown
Member Author

One solution can be switch to something under our control (I doubt that I'll have enough resources to support this).

Another solution is to completely remove dependency on laminas package and instead use PrettyPrinter and AST nodes from the nikic/php-parser via BuilderFactory::attribute and similar to generate new code.

@samsonasik
Copy link
Copy Markdown
Contributor

@lisachenko I am currently on my village and will be back on 16th/17th April, so hopefully can fully looking at it after that day as possibly 2 days long trip.

Ceate own builder for it can be solution, but need to check how many laminas-code already involved in other area

@samsonasik
Copy link
Copy Markdown
Contributor

samsonasik commented May 17, 2024

@lisachenko it seems too tight with laminas-code, and for the alternative, to be able to use php-parser's Printer, we need to know the Node from the ReflectionFunction which may need to use Go\ParserReflection\ReflectionFunction, since Function_ parameter is required, we may scan from very early with Go\ParserReflection\ReflectionFileNamespace, I don't have idea how big the refactor it can be, any idea?

lisachenko and others added 3 commits March 22, 2026 17:19
Proxy methods should not duplicate the original method's PHP attributes,
as this could cause double-processing in attribute-based frameworks.
Parameter attributes are still preserved via ParameterGenerator.

Adds clearMethodAttributes() to MethodGenerator and calls it in
InterceptedMethodGenerator. Also corrects test expectations for
union/intersection/DNF type ordering and PhpParser formatting.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ith attributes

The test expectations were written before attribute support was added to
MethodGenerator. Update them to match the actual PhpParser output: method-level
attributes are copied to proxy, types follow reflection order, and formatting
uses PhpParser's Standard printer style (single quotes, multiline param lists).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lisachenko lisachenko merged commit 544b0ae into master Mar 22, 2026
5 checks passed
@lisachenko lisachenko deleted the bug/generated-method-attributes branch March 22, 2026 15:51
@lisachenko
Copy link
Copy Markdown
Member Author

Fixed in the master branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants