Skip to content

Conversation

OskarStark
Copy link
Contributor

Q A
Bug fix? no
New feature? no
Docs? no
Issues --
License MIT

To make Fabbot (and @nicolas-grekas) happy 😃

@chr-hertel
Copy link
Member

I really feel like this is only a symfony/symfony concern 😞

@OskarStark
Copy link
Contributor Author

OskarStark commented Jul 29, 2025

But the used Fabbot action is now shared across all repos, or shall we make this configurable @nicolas-grekas ?

See

@OskarStark
Copy link
Contributor Author

@nicolas-grekas any clue regarding?
CleanShot 2025-07-29 at 12 43 31@2x

@nicolas-grekas
Copy link
Member

This is a general Symfony policy. Adding return types to test cases is just visual debt (TM)

@chr-hertel
Copy link
Member

ah okay, i thought it's more about avoiding git conflict between different versions - which does not apply here.

is it that you opt in whenever there is a more meaningful return type for tests depending on each other or just avoid that in general? not that i see depending test scenarios a lot, but that's the difference to void tests i guess

anyhow no hard feelings - just curious :D

@derrabus
Copy link
Member

derrabus commented Jul 29, 2025

I would not enforce this rule in a brand new code repository, tbh. I understand that this rule has historic reasons in symfony/symfony, but those don't apply here. Let's use types everywhere. The less exceptions to the rule, the better.

@OskarStark
Copy link
Contributor Author

I agree ☝🏻

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

The search-n-replace has been a bit too broad ;)

This still makes sense to me. It's not about historical practices, it's about thinking about what one is doing. Each method needs careful thinking at its boundaries, to provide a clear API.
Test case methods are not part of any API. They're entry points. Specifying a return type for them is just more syntax soup IMHO.
A rule like "all methods must have a return type" applies in a context. Ignoring this context (designing APIs) and making the rule a generic one prevents people from thinking about what they're doing.
I wouldn't call the "no-void" policy an exception to the rule, but more like a domain where the above rule doesn't apply.

}

private function assertToolConfiguration(Tool $metadata, string $className, string $name, string $description, string $method, array $parameters): void
private function assertToolConfiguration(Tool $metadata, string $className, string $name, string $description, string $method, array $parameters)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
private function assertToolConfiguration(Tool $metadata, string $className, string $name, string $description, string $method, array $parameters)
private function assertToolConfiguration(Tool $metadata, string $className, string $name, string $description, string $method, array $parameters): void
@nicolas-grekas
Copy link
Member

The "/home/runner/work/ai/ai/b/examples" directory does not exist.

That's because the .php-cs-fixer.dist.php needs to account for missing directories, since we check only patched files and the others are not checked-out. Using glob does the job:

--- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -43,7 +43,7 @@ return (new PhpCsFixer\Config()) ->setRiskyAllowed(true) ->setFinder( (new PhpCsFixer\Finder()) - ->in([__DIR__.'/demo', __DIR__.'/examples', __DIR__.'/fixtures', __DIR__.'/src']) + ->in(__DIR__.'/{demo,examples,fixtures,src}') ->append([__FILE__])
@nicolas-grekas
Copy link
Member

For phpstan to be happy, I'd suggest going with this, which matches what fabbot does (we could further restrict to **/tests/**.php files):

	ignoreErrors: +- +message: "#^Method .*::test.*\\(\\) has no return type specified\\.$#" +
@OskarStark
Copy link
Contributor Author

Will tackle that topic tomorrow

@chr-hertel
Copy link
Member

Yea, i guess it's rather subjective how you read these methods, but I get your point - and I also don't want to be bothered to define a complex array shape for a normalize(...): array method by phpstan if only framework code consumes it - fair.
I guess my hard limit is when it comes to #[Depends] scenarios, but i feel like those are rare. not sure why it is different for setUp() tho. anyhow, i for sure can live with that - especially if there's automation to remind me about it

@OskarStark
Copy link
Contributor Author

@nicolas-grekas if I get it right, we don't have a convenient link to fix CS for the contributors anymore, this is a step back IMHO

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Jul 30, 2025

You're right, that's not something supported by GHA.
Instead, I made generated patch copy/pasteable.

@nicolas-grekas
Copy link
Member

See #226 for exception messages

@nicolas-grekas nicolas-grekas force-pushed the remove-void-return-types-from-tests branch 3 times, most recently from 3ebdd14 to 3f93cca Compare July 30, 2025 07:12
@OskarStark
Copy link
Contributor Author

See #226 for exception messages

Lets go with yours first, and then rebase mine on top

@nicolas-grekas nicolas-grekas force-pushed the remove-void-return-types-from-tests branch 2 times, most recently from 5739c7c to 3f0231e Compare July 30, 2025 07:20
@nicolas-grekas nicolas-grekas force-pushed the remove-void-return-types-from-tests branch from 3f0231e to 2f97be9 Compare July 30, 2025 08:55
@nicolas-grekas
Copy link
Member

Thank you @OskarStark.

@nicolas-grekas
Copy link
Member

Thank you @OskarStark.

@nicolas-grekas nicolas-grekas merged commit 6651405 into symfony:main Jul 30, 2025
17 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants