Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Having trouble creating PDO object #195

Open
garrettw opened this issue Sep 16, 2021 · 3 comments
Open

Having trouble creating PDO object #195

garrettw opened this issue Sep 16, 2021 · 3 comments

Comments

@garrettw
Copy link

For a job interview today, I had to try to make a Twitter clone, getting as far as I could in 8 hours. Aside from the fact that I should have chosen Laravel instead of doing it from scratch, and thus I didn't get nearly far enough... I ran into a problem near the end where I couldn't get an instance of PDO going with Dice.

Here's the relevant config:
https://github.com/garrettw/screamer/blob/main/dic-config.php#L39

The problem I was running into was that somehow, the PDO constructor was being sent 5 params: my 3 followed by two NULLs -- so it was complaining that it could only take 4 params. I tried to work around it in a few ways but I didn't get any different outcome.

Can you see anything I might be doing wrong in the config? Or is this an actual bug?

@TRPB
Copy link
Member

TRPB commented Sep 17, 2021

I've just tested this and it is an actual bug, it looks like it was introduced when scalar type hints were added. Multiple variables of the same type would be counted twice when there were also matching values of those types in constructParams this should now be fixed. I hope this didn't impact your chances of getting the job.

@garrettw
Copy link
Author

garrettw commented Sep 20, 2021

Truthfully I don't think it did. Even if PDO had been working, I still didn't get far enough in 8 hours to show them the things they were really looking for, due to my choosing to roll my own framework. Thanks for the fix - I'll try it out.

cseufert added a commit to moddengine/Dice that referenced this issue Oct 3, 2022
* Support nullable class type hints (Level-2#182)

* Remove PHP 8 deprecation warning

* Level-2#195 - stop some parameters getting counted twice

* Fix issue where 'shareInstances' resolve but fail to propagate (Level-2#201)

* Level-2#200 - Expand shareInstances test to replicate propagation issue

* Level-2#200 - Fix issue where 'shareInstances' resolve but fail to propagate

Because `$share` is passed by reference to `matchParam()`, and
`matchParam()` removes matching objects from its `$search` array,
instances may be removed from `$share` before it is passed to `expand()`
or `create()`. Depending on the order of constructor parameters and the
relative placement of `shareInstances` dependencies in the object tree,
this may result in multiple instances of these dependencies being
created.

Fixed by passing a copy of the `$share` array to `matchParam()`.

- Updated CI to use github actions

Co-authored-by: thisispiers <[email protected]>
Co-authored-by: Tom Butler <[email protected]>
Co-authored-by: Luke Arms <[email protected]>
@jtojnar
Copy link

jtojnar commented Nov 13, 2022

This is the same as #181

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

No branches or pull requests

3 participants