Skip to content

Large refactoring (ideas for v3?) #150

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

Closed
wants to merge 20 commits into from
Closed

Conversation

birkett
Copy link

@birkett birkett commented May 31, 2021

While building a tool for local server status listing and debugging - what started out as a minor code audit, turned into a refactor.

Lots of commits here, so maybe not merge-able - but there's a few things here which could be useful for the future (v3?).

Changes:

  • Introduced php-cs-fixer with all but 4 rules enabled.
  • Bumped PHPStan to max level.
  • Psalm now happily completes.
  • Removed some hard-coded goldsource / source differences. Extending rather than in-line logic.
  • Split up into smaller classes / interfaces / traits.
  • Introduced a simple factory class (just static functions for now) to help build a usable SourceQuery instance.

Breaking Changes:

  • Breaking API change - functions are now lowerCamelCase named.

@xPaw
Copy link
Owner

xPaw commented May 31, 2021

Changing all the styling makes this basically unreviewable, sorry. And things like factories are questionable at best.

Are there any actually interesting changes in this PR that could be split into separate pr?

@birkett
Copy link
Author

birkett commented Jun 2, 2021

Would you be open to bringing in cs-fixer as a start, with smaller commits? Adopting a known coding standard here will help with future contributions.
Consider PSR12 - https://www.php-fig.org/psr/psr-12/
The largest change here is the conversion of tabs to spaces, and no indent on lines after the opening php tag.

One of the changes here, is the splitting up of Source / GoldSource logic, see:
https://github.com/xPaw/PHP-Source-Query/pull/150/files#diff-1c6d6ad628e810f91b8d1a16a86a8a4b473b1ac89689d52b7d3ae74d13460251

https://github.com/xPaw/PHP-Source-Query/pull/150/files#diff-62800bacd4f0e5b3b1cc29c7859cfff921b4c3af36eeb0d7d27cd69d52a67807

This also includes the RCON code, now nicely interfaced:
https://github.com/xPaw/PHP-Source-Query/pull/150/files#diff-b96874cd9531f023bbf8797c6a950f84f88d38210e6c769d07579fa71e731649

Hidden in this PR are also changes to decouple the main SourceQuery class from the RCON code, we now pass in an instance of RconInterface via the constructor (this is why the factory was created, to ensure we are creating valid combinations of SourceQuery + Socket + Rcon).

Also hidden - we no longer pass around $engine - we simply use Socket::getType.

If you would prefer to not continue with any of the above changes, we can close this off, with work continuing on the fork.

@xPaw
Copy link
Owner

xPaw commented Jun 2, 2021

Yeah unfortunately I'm not seeing any changes here that aren't just simply a refactor. You are of course free to keep this as your own fork.

The breaking changes caused by the refactor are not really worth it, imo.

@xPaw xPaw closed this Jun 2, 2021
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.

2 participants