Skip to content

Conversation

@LioTree
Copy link
Contributor

@LioTree LioTree commented Apr 6, 2022

Hi,I add the feature to support trait use.

@ircmaxell
Copy link
Owner

Added a few comments inline. The structure of the overall layout of classes is one thing i'd love feedback on, as the current implementation feels a bit too ad-hoc...

Copy link
Owner

@ircmaxell ircmaxell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few action items here to discuss...

foreach($node->adaptations as $adaptation) {
if($adaptation instanceof Stmt\TraitUseAdaptation\Alias) {
$adaptations[] = new Alias(
new Literal($adaptation->trait != null ? $adaptation->trait->toCodeString() : null),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the null be inside the Literal? Or should it be on the outside? As in $adaptation->trait !== null ? new Literal($adaptation->trait->toCodeString()) : null?

$adaptations[] = new Alias(
new Literal($adaptation->trait != null ? $adaptation->trait->toCodeString() : null),
new Literal($adaptation->method->name),
new Literal($adaptation->newName != null ? $adaptation->newName->name : null),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question here, should the null be on the outside?

* @license MIT See LICENSE at the root of the project for more info
*/

namespace PHPCfg;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be an Op class? Considering it will always have a line-number associated with it...

Perhaps structure like:

  • Op\TraitUse
  • Op\Statement\TraitUse
  • Op\TraitUse\Adaptation
  • Op\TraitUse\Alias
  • Op\TraitUse\Precedence

Thoughts?

@LioTree
Copy link
Contributor Author

LioTree commented May 2, 2022

I modified it according to your comment, the current structure is

  • Op\Stmt\TraitUse
  • Op\TraitUseAdaptation
  • Op\TraitUseAdaptation\Alias
  • Op\TraitUseAdaptation\Precedence

@ircmaxell ircmaxell merged commit b50789a into ircmaxell:master May 2, 2022
@ircmaxell
Copy link
Owner

Thanks!

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.

2 participants