Skip to content

Conversation

@yesdevnull
Copy link
Contributor

Codeception version: alpha1
PHP version: 8.1.2

I noticed the following error during seeding a class with a constructor which required no parameters (and the same on classes with no defined constructor):

[ReflectionException] Class App\Entity\User does not have a constructor, so you cannot pass any constructor arguments

Perhaps this is more an issue with ReflectionClass itself for complaining about an empty array for a constructor since one would expect it to skip the constructor parameters array if it's empty, however seemingly this is not the case (I haven't tested with other versions of PHP; only 8.1.2).

@TavoNiievez
Copy link
Member

TavoNiievez commented Feb 5, 2022

@yesdevnull $obj = $reflectionClass->newInstance(...$constructorParameters); does the trick.

I saw your PR after 1 hour looking for the problem and committed the solution :-) (which was present in the 4.1 branch of Codeception).
Anyway, I'll redo my commit as a co-authored commit.
It seems that we have been doing the same tasks concurrently.
Could you join the Codeception Slack?
If you write to me, it is possible that I will merge your PR more quickly or that I prevent you from doing a task that I have already done before.

I'm also going to review the PRs you currently have open.

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