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

code improvements, readability enhancements, type safety, modern syntax adaptation #108

Merged
merged 31 commits into from
Jun 3, 2023

Conversation

xHeaven
Copy link
Contributor

@xHeaven xHeaven commented May 27, 2023

See commit messages. As far as I know, there are no breaking changes.

Copy link
Sponsor Collaborator

@NicolasCARPi NicolasCARPi left a comment

Choose a reason for hiding this comment

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

So I went over the code changes. This is not a refactor like the title implies, but rather a set of changes to make the code use modern syntax. Use match instead of switch, use null coalescing operator, etc... I didn't test it but it should indeed not have any impact on code behavior.

lib/Providers/Qr/QRicketProvider.php Outdated Show resolved Hide resolved
lib/Providers/Time/HttpTimeProvider.php Outdated Show resolved Hide resolved
@xHeaven
Copy link
Contributor Author

xHeaven commented May 27, 2023

So I went over the code changes. This is not a refactor like the title implies, but rather a set of changes to make the code use modern syntax. Use match instead of switch, use null coalescing operator, etc... I didn't test it but it should indeed not have any impact on code behavior.

As far as I'm aware, refactoring means introducing changes in an existing codebase in a way that doesn't change the software's behavior but improves some aspects of it, such as readability, performance, etc.
If you've got a different definition, I'm all ears, I'm also open to changing the title if you've got something more descriptive. Let me know.

@NicolasCARPi
Copy link
Sponsor Collaborator

As far as I'm aware, refactoring means introducing changes in an existing codebase in a way that doesn't change the software's behavior but improves some aspects of it, such as readability, performance, etc. If you've got a different definition

To me, refactoring means having an impact on the private API, and maybe public, by splitting/merging classes, and mainly doing refactoring of functions, in the algebraic/mathematical sense of the term.

But honestly your definition works too and nobody really care. It's just that reading "massive refactoring" I was a bit scared, but in fact it's more like "many small code improvements with no effective changes" ;)

@xHeaven xHeaven changed the title massive refactor code improvements: readability enhancements, type safety, modern syntax adaptation May 27, 2023
@xHeaven xHeaven changed the title code improvements: readability enhancements, type safety, modern syntax adaptation code improvements, readability enhancements, type safety, modern syntax adaptation May 27, 2023
Copy link
Collaborator

@willpower232 willpower232 left a comment

Choose a reason for hiding this comment

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

Thanks for your work, always good to have fresh eyes on something.

I've left a few points for discussion (mostly duplicated) so I look forward to your replies.

lib/Providers/Qr/BaconQrCodeProvider.php Show resolved Hide resolved
lib/Providers/Qr/BaconQrCodeProvider.php Show resolved Hide resolved
lib/Providers/Qr/BaconQrCodeProvider.php Outdated Show resolved Hide resolved
lib/Providers/Qr/BaconQrCodeProvider.php Show resolved Hide resolved
lib/Providers/Time/HttpTimeProvider.php Outdated Show resolved Hide resolved
lib/TwoFactorAuth.php Show resolved Hide resolved
lib/TwoFactorAuth.php Show resolved Hide resolved
tests/Providers/Rng/TestRNGProvider.php Show resolved Hide resolved
lib/Providers/Rng/OpenSSLRNGProvider.php Show resolved Hide resolved
lib/Providers/Rng/HashRNGProvider.php Show resolved Hide resolved
@RobThree
Copy link
Owner

Generally such 'huge' PR's aren't very helpful, this is so much that it's hard to see what has changed and what hasn't. Next time, please do one thing, make it into a PR and then make a new PR for the next thing.

I agree with most, if not all, of @willpower232's 'criticisms' above. I've just returned home from a weekend away; I'll go over it myself soon.

That's not to say the PR and your work isn't appreciated, just to be clear!

@xHeaven
Copy link
Contributor Author

xHeaven commented May 28, 2023

Appreciate the replies and reviews. I've answered some of them, I'll answer all of them a bit later today.

Generally such 'huge' PR's aren't very helpful, this is so much that it's hard to see what has changed and what hasn't. Next time, please do one thing, make it into a PR and then make a new PR for the next thing.

Absolutely understandable, I wasn't sure if I should put all of these things into a single PR as some kind of all-in-one improvement bundle or open a bunch of PRs instead, and I went with this after all. I'll open more PRs next time.

@xHeaven
Copy link
Contributor Author

xHeaven commented May 28, 2023

I've answered all of your reviews and marked most of them as resolved. If you've got a spare 5 minutes sometimes, could you take a look at it? @willpower232 Thanks!

@willpower232
Copy link
Collaborator

I wasn't aware the PHP CS Fixer config was so extra compared to just the bare standard, I usually just choose to run phpcs --standard=PSR12 app/ and fix as necessary 😅

I think this PR size is fine since its all overlapping stuff and the codebase has aged differently in different places with the evolution of PHP since it was first done. I don't think another PR of this size would exist in this repo for some time!

Thanks for all the explanations and indulging my many duplicates, I think I'm happy once the camelCase has happened.

@xHeaven
Copy link
Contributor Author

xHeaven commented May 28, 2023

Yeah, the Fixer config has quite a few different rules other than just PSR12, haha.
I've committed the camelCase changes as well in e554a9b.

@xHeaven xHeaven requested a review from willpower232 May 28, 2023 18:10
Copy link
Collaborator

@willpower232 willpower232 left a comment

Choose a reason for hiding this comment

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

happy with this if @RobThree is

@RobThree
Copy link
Owner

RobThree commented Jun 3, 2023

happy with this if @RobThree is

I am. Not sure I agree on the whitespace, but that's not worth a discussion.

Thanks @xHeaven! I'll merge.

@RobThree RobThree merged commit 63b49ce into RobThree:master Jun 3, 2023
6 checks passed
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.

None yet

4 participants