Skip to content

Adding override attribute to override code action - #3057

Merged
dantleech merged 1 commit into
phpactor:masterfrom
mamazu:override-php-attribute
Aug 22, 2026
Merged

Adding override attribute to override code action#3057
dantleech merged 1 commit into
phpactor:masterfrom
mamazu:override-php-attribute

Conversation

@mamazu

@mamazu mamazu commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

When generating method overrides with phpactor it should also include the Override attribute for those methods.

refs #3056

Comment on lines +9 to +11
{% if prototype.override %}
#[\Override]
{% endif %}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't know what the best way is to scope this only to modern php projects.

);

$methodBuilder = $builder->class($method->declaringClass()->name()->short())->method($method->name());
$methodBuilder->override();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@mamazu
mamazu force-pushed the override-php-attribute branch from c644c0b to 2ed389b Compare July 22, 2026 00:43
$reflector = $this->reflectorForWorkspace($source);
$factory = new WorseBuilderFactory($reflector);
$override = new WorseOverrideMethod($reflector, $factory, $this->updater());
$override = new WorseOverrideMethod($reflector, $factory, $this->updater(), '8.5');

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Do we also want to test both versions like run the override Method Test for php 8.0 (as an example for a version that should not have the override feature) and for 8.3 again with the Override or is just testing the "newer" version enough?

@mamazu
mamazu force-pushed the override-php-attribute branch from 2ed389b to cf0a707 Compare July 22, 2026 12:10

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Phpactor Benchmarks'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: cf0a707 Previous: b327eec Ratio
ConfigLoaderBench::benchJsonPlainPhp 0.015611506849314892 ms (± 1.88%) 0.007483600782778811 ms (± 3.67%) 2.09

This comment was automatically generated by workflow using github-action-benchmark.


protected bool $abstract = false;

protected bool $override = false;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

as a code "builder" this would be better implemented as a list of "attribute" prototypes otherwise the precedent here means having a property for every type of attribute.

@mamazu mamazu Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What kind of datastructure would you suggest? Another bit field like with the modifiers? An Array of Attribute Builders (might be overblown)?

@mamazu
mamazu force-pushed the override-php-attribute branch from cf0a707 to a2fb7fc Compare August 13, 2026 21:32
@dantleech
dantleech merged commit cc377db into phpactor:master Aug 22, 2026
13 checks passed
@dantleech

Copy link
Copy Markdown
Collaborator

thanks, i'll see if I can add the attribute builder.

@mamazu
mamazu deleted the override-php-attribute branch August 22, 2026 12:39
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