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

Factories #3722

Merged
merged 27 commits into from
Oct 10, 2020
Merged

Factories #3722

merged 27 commits into from
Oct 10, 2020

Conversation

MGatner
Copy link
Member

@MGatner MGatner commented Oct 4, 2020

Description
Defines a new dynamic lookup class, Factories, for returning shared instances of named components.

Supersedes #3712 (but still read about the ModelFactory bug there, which also applies to the previous Config).

Checklist:

  • Securely signed commits
  • Component(s) with PHPdocs
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@MGatner
Copy link
Member Author

MGatner commented Oct 4, 2020

See what you all think of this. I will obviously add tests and docs but I want us to iron out the core class first. I would also like to see about implementing it for Config, though might need to tweak how it loads its own configuration if we do so they don't loop.

Also, should this move to system/ root instead of being part of system/Config? Or even be part of system/Autoload?

@michalsn
Copy link
Member

michalsn commented Oct 4, 2020

I like how it looks. You added some nice config options so it's even better. I am very much into using this wherever it will bring some benefits.

I think it fits good to system/Config - alongside the Services class.

@MGatner
Copy link
Member Author

MGatner commented Oct 5, 2020

@michalsn Thanks for the feedback! I have some improvements in the works I'm excited about - I think this will becomes a very versatile core aspect of the framework when it is ready.

@lonnieezell
Copy link
Member

@MGatner Looking great! Those methods definitely multiplied over time. Will be great to have this pulled out into a central class.

@MGatner
Copy link
Member Author

MGatner commented Oct 5, 2020

Thanks! I keep going back and forth on the names... @michalsn @lonnieezell have any input?

  1. (current) Factory class to generate instances that uses a Factories config file.
  2. Factories class that uses a Factory config file

IMO (1) is easier to type and makes more sense logically, but (2) is consistent with Services and sets up a nice parallel between the two.

@michalsn
Copy link
Member

michalsn commented Oct 5, 2020

@MGatner I think I like option 2 more, but I don't mind 1 either. Glad I could help 😅

@MGatner MGatner changed the title Factory Factories Oct 5, 2020
@lonnieezell
Copy link
Member

@MGatner I'm ok with either, but do agree that option 2 parallels existing stuff in the framework better, keeping a nice consistency. And a decent IDE makes typing lots of things even easier than the naming itself. :)

@MGatner
Copy link
Member Author

MGatner commented Oct 5, 2020

Glad to hear support from both of you because I already changed it :) Got some test failures to work through and working on the User Guide, then this should be set for review.

system/Config/Factories.php Outdated Show resolved Hide resolved
system/Config/Factory.php Outdated Show resolved Hide resolved
@MGatner
Copy link
Member Author

MGatner commented Oct 5, 2020

Failing tests again :/ I don't have more time to work on this now - if anyone can figure out why the failures and post back I can take another shot at it later in the week.

@MGatner
Copy link
Member Author

MGatner commented Oct 6, 2020

Okay I see the problem: App\Config\Whatever is not a namespace path because we use Config\Whatever - I will have to add some special handling for that.

@MGatner
Copy link
Member Author

MGatner commented Oct 6, 2020

Down to what appears to be a discrepancy with ReflectionClass::getStaticPropertyValue() between PHP versions. I might need to find a way around using that.

@MGatner
Copy link
Member Author

MGatner commented Oct 7, 2020

Test failure is unrelated.

Copy link
Member

@paulbalandan paulbalandan left a comment

Choose a reason for hiding this comment

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

User guide syntax check still fails. Other than the phpstan ignored message, I approve. ;)

phpstan.neon.dist Outdated Show resolved Hide resolved
@michalsn michalsn mentioned this pull request Oct 8, 2020
5 tasks
Copy link
Member

@michalsn michalsn left a comment

Choose a reason for hiding this comment

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

I think it looks really good.

We should only mention about ModelFactory depreciation in the changelog.

@MGatner
Copy link
Member Author

MGatner commented Oct 9, 2020

User guide syntax check still fails.

@paulbalandan Any ideas on what is still wrong?

@MGatner
Copy link
Member Author

MGatner commented Oct 9, 2020

We should only mention about ModelFactory depreciation in the changelog.

I added a note for both ModelFactory and Config

@MGatner MGatner requested a review from michalsn October 9, 2020 15:44
Copy link
Member

@michalsn michalsn left a comment

Choose a reason for hiding this comment

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

Could you also add this to the changelog in the user guide? I think this is the main one, and the changelog.md is always generated semi-automatically before release.

@MGatner
Copy link
Member Author

MGatner commented Oct 9, 2020

Oops! Sorry, will do. I haven't touched the changelogs before, good for me to learn this :D

@paulbalandan
Copy link
Member

User guide syntax check still fails.

@paulbalandan Any ideas on what is still wrong?

Found the fault. After the preferApp row, you should add the bottom table borders that matches above borders.

@MGatner
Copy link
Member Author

MGatner commented Oct 9, 2020

@paulbalandan @michalsn

Copy link
Member

@paulbalandan paulbalandan left a comment

Choose a reason for hiding this comment

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

Last two. :)

CHANGELOG.md Outdated Show resolved Hide resolved
user_guide_src/source/changelogs/v4.0.5.rst Outdated Show resolved Hide resolved
MGatner and others added 2 commits October 9, 2020 12:23
Co-authored-by: John Paul E. Balandan, CPA <51850998+paulbalandan@users.noreply.github.com>
Co-authored-by: John Paul E. Balandan, CPA <51850998+paulbalandan@users.noreply.github.com>
@paulbalandan paulbalandan mentioned this pull request Oct 9, 2020
4 tasks
@paulbalandan
Copy link
Member

I believe this is mergeable already. @MGatner any last additions?

@MGatner
Copy link
Member Author

MGatner commented Oct 10, 2020

I think it's ready, I'm just scared. 😳

@paulbalandan
Copy link
Member

I see this as a useful addition. 🎉

@paulbalandan paulbalandan merged commit 9a91196 into codeigniter4:develop Oct 10, 2020
@MGatner MGatner deleted the factory branch October 11, 2020 12:32
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.

5 participants