Skip to content

Adding override attribute to override code action#3057

Open
mamazu wants to merge 1 commit into
phpactor:masterfrom
mamazu:override-php-attribute
Open

Adding override attribute to override code action#3057
mamazu wants to merge 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.

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