Skip to content

Conversation

@gmponos
Copy link
Contributor

@gmponos gmponos commented Dec 5, 2018

Made all the parsers use the same code by using a trait..

At my initial commits I made all the parsers use the same code. And then later I replaced the code with a trait.

@frederikbosch made a comment here

I had also thought about the same idea but later on my plan was to submit a PR just like this one.

Marking this trait as internal will also not be inside the BC promise.

@gmponos gmponos force-pushed the proof_of_concept_use_trait branch from 7debca6 to 90d52eb Compare December 5, 2018 18:59
@Big-Shark
Copy link

@gmponos Any updates?

@gmponos
Copy link
Contributor Author

gmponos commented May 13, 2019

This could be my fault.. but I need some feedback in order to proceed and finalize this or not.

Neither on the current PR or here I got any feedback.

@Big-Shark
Copy link

@gmponos This is look very nice for me, but I am not scure, why we can not use number_format ?
Yasterday I created this class https://gist.github.com/Big-Shark/84434409e4f4cb6754645ea283e48c74
And all my tests passed.
Can you explorer this?


trait DecimalParserTrait
{
public static $decimalPattern = '/^(?P<sign>-)?(?P<digits>0|[1-9]\d*)?\.?(?P<fraction>\d+)?$/';
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be a const IMHO

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Traits can not have constants :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

In that case, I would make it protected.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

*/
final class DecimalMoneyParser implements MoneyParser
{
const DECIMAL_PATTERN = '/^(?P<sign>-)?(?P<digits>0|[1-9]\d*)?\.?(?P<fraction>\d+)?$/';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Note that removing this constant is probably a BC break.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

reverted

@sagikazarmark
Copy link
Collaborator

Like the idea! Can you please rebase the branch from master?

@gmponos gmponos mentioned this pull request Dec 28, 2019
@gmponos gmponos changed the title [WIP] Proof of concept: Use a trait for parsers Proof of concept: Use a trait for parsers Jun 22, 2020
@gmponos gmponos marked this pull request as draft June 22, 2020 11:39
@gmponos
Copy link
Contributor Author

gmponos commented Jun 22, 2020

Marked as WIP.. let's merge this first: #586

@frederikbosch
Copy link
Member

Sorry @gmponos, I think we are going to leave this as is. In my opinion traits are to be avoided.

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.

4 participants