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

Extract type cast behaviour #5

Merged

Conversation

zluiten
Copy link
Contributor

@zluiten zluiten commented Jan 22, 2020

This is follow up on zfcampus/zf-doctrine-querybuilder#57

Q A
Bugfix no
BC Break no
New Feature yes
RFC no

Description

By extracting the type casting to its own class it can be easily replaced when needed. Preferring composition over inheritance etc.

It becomes better testable as well.

I kept BC by proxying to the TypeCaster and instantiating the TypeCaster in the AbstractFilter::getTypeCaster() method when not set in case FilterManager::filter() method is overridden.

@michalbundyra michalbundyra added the Enhancement New feature or request label Jan 22, 2020
@zluiten zluiten force-pushed the feature/extract-type-casting branch 3 times, most recently from 3f56d4d to 777d1c0 Compare January 22, 2020 13:39
@zluiten zluiten changed the title Feature/extract type casting Extract type cast behaviour Jan 22, 2020
@zluiten
Copy link
Contributor Author

zluiten commented Apr 30, 2020

Any idea what's needed to get this in?

@zluiten zluiten force-pushed the feature/extract-type-casting branch 2 times, most recently from bbaef20 to 12cef70 Compare August 5, 2020 06:58
@weierophinney weierophinney added this to the 1.9.0 milestone Sep 10, 2020
@weierophinney weierophinney changed the base branch from develop to 1.9.x September 10, 2020 19:15
weierophinney added a commit to zluiten/api-tools-doctrine-querybuilder that referenced this pull request Sep 10, 2020
Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
weierophinney added a commit to zluiten/api-tools-doctrine-querybuilder that referenced this pull request Sep 11, 2020
Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
@weierophinney weierophinney force-pushed the feature/extract-type-casting branch 2 times, most recently from 40a6572 to 3ad862d Compare September 11, 2020 15:57
@weierophinney
Copy link
Contributor

@Netiul I've rebased against the new "1.9.x" branch; you'll need to pull from your own remote to get your local checkout up-to-date.

However, tests are failing.

I tried a number of different approaches to fix them, but it seems like there's something fundamentally broken in the testing suite or with the existing dependencies, and after a few hours trying to figure it all out, I need to leave that to others to resolve. Hopefully, if they get resolved, your tests will pass again, and we can merge and release.

@zluiten
Copy link
Contributor Author

zluiten commented Sep 15, 2020

@weierophinney Thanks for the work you do and have done! About the tests, it looks like they passed on travis?

@weierophinney
Copy link
Contributor

You're right! They hadn't been when I was testing before, but they clearly do now! The only issue is CS, which is not your problem to fix in this case (it's a line-length issue with our copyright lines). I'll get that fixed shortly.

Copy link
Contributor

@weierophinney weierophinney left a comment

Choose a reason for hiding this comment

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

I love that you've extracted this, and I think it will add a lot of flexibility!

I've provided some notes on improvements you should make before we merge. Please bump the minimum supported PHP version to 7.2 as part of your changes (update composer.json, and remove job configuration from .travis.yml), and add typehints whereever possible on new signatures only.

Finally, I didn't note it, but your tests should import classes used such as stdClass and DateTime.

src/Filter/ODM/AbstractFilter.php Outdated Show resolved Hide resolved
src/Filter/ODM/AbstractFilter.php Outdated Show resolved Hide resolved
src/Filter/ORM/AbstractFilter.php Outdated Show resolved Hide resolved
src/Filter/ORM/TypeCaster.php Show resolved Hide resolved
src/Filter/ORM/TypeCaster.php Show resolved Hide resolved
src/Filter/ORM/TypeCaster.php Show resolved Hide resolved
src/Filter/TypeCastInterface.php Outdated Show resolved Hide resolved
src/Filter/ODM/TypeCaster.php Show resolved Hide resolved
src/Filter/ODM/TypeCaster.php Show resolved Hide resolved
src/Filter/ODM/TypeCaster.php Show resolved Hide resolved
@zluiten
Copy link
Contributor Author

zluiten commented Oct 6, 2020

@weierophinney Apologies, I somehow completed missed you having reviewed this. Thanks though, I'll soon process your remarks.

@zluiten zluiten force-pushed the feature/extract-type-casting branch 8 times, most recently from 0582423 to ae38f92 Compare October 27, 2020 20:29
@zluiten
Copy link
Contributor Author

zluiten commented Oct 27, 2020

@weierophinney Thanks again for the review and apologies for the late reply. Incorporated your suggestions and meanwhile fixed a bug as noted here.

The Travis builds with lowest composer dependencies (--prefer-lowest) for 7.3 and 7.4 are (still) disabled. I'm not familiar with reason why those are disabled (I tested, builds do fail). I think it's out of scope of this PR to fix that.

I've also added support for immutable date doctrine field variants. That was actually the reason I wanted to extract the type casting behavior so I could replace the TypeCaster with one that supported the immutable date types.

@zluiten
Copy link
Contributor Author

zluiten commented Jan 2, 2021

Hey @weierophinney, can you have another look?

zluiten and others added 5 commits January 4, 2021 15:52
Signed-off-by: Zacharias Luiten <zach@xzachly.com>
Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
Fixes issues flagged by phpcs that could not be autocorrected with phpcbf.

Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
Copy link
Contributor

@weierophinney weierophinney left a comment

Choose a reason for hiding this comment

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

Hi, @Netiul !

I merged another PR earlier today that prepares the package for PHP 8... and solves the testing issues you were observing as well (mainly by updating a few key dependencies). Since I merged that, I rebased for you... and then discovered issues in that previous patch's phpcs updates, which meant I was fixing phpcs issues... anyways, it looks good; you incorporated all the feedback I had, and we now have running tests.

The only last think I need from you: could you write-up an example for the README.md file demonstrating substituting an alternative type caster implementation? (Or is that even necessary?)

…g custom mapping types.

Signed-off-by: Zacharias Luiten <zach@xzachly.com>
@zluiten zluiten force-pushed the feature/extract-type-casting branch from f908072 to 159a20f Compare January 6, 2021 20:14
@zluiten
Copy link
Contributor Author

zluiten commented Jan 6, 2021

@weierophinney Thanks again. I've put something in the README.

Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
@weierophinney weierophinney linked an issue Jan 7, 2021 that may be closed by this pull request
@weierophinney weierophinney merged commit 02793df into laminas-api-tools:1.9.x Jan 7, 2021
@zluiten zluiten deleted the feature/extract-type-casting branch January 7, 2021 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extract type cast behaviour
3 participants