-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
Introduce a new Feature enum to improve the Features facade #1650
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
caendesilva
force-pushed
the
introduce-a-new-feature-enum
branch
from
April 9, 2024 12:35
54c881c
to
a43c18c
Compare
caendesilva
force-pushed
the
introduce-a-new-feature-enum
branch
from
April 9, 2024 12:49
6b1e4a8
to
c5adfa8
Compare
caendesilva
changed the title
Introduce a new feature enum
Introduce a new Feature enum to improve the Features facade
Apr 9, 2024
caendesilva
force-pushed
the
introduce-a-new-feature-enum
branch
from
April 9, 2024 14:06
87762b2
to
a1fac0b
Compare
This was referenced Apr 10, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Abstract
Cherry picks some changes from #1647 and #1649 in order to make the v2 upgrade path smoother. See https://twitter.com/CodeWithCaen/status/1777647925939593341
Using Enums for this improves the type safety and IDE support. For example if you use
Hyde::hasFeature()
which now takes an enum instead of a string, your IDE will provide autocomplete and warn if you use a feature that is not supported by Hyde. Due to these simplifications the old static feature flag methods have been removed. To upgrade, replace the following method usages (where the array key is the old syntax and the value is the new)Upgrade Path
To upgrade to use the enum cases instead of the now deprecated static features methods, simply replace the following usages:
PhpStorm Automatic Refactors
If you are using PhpStorm, you can follow these steps to do it automatically
Step 1: Put your caret on one of the deprecated method calls in the
features
array in theconfig/hyde.php
fileStep 2: Run Alt+Enter to open the context menu
Step 3: On the highlighted option, press right arrow to open the submenu and "Fix all deprecated problems in file"
Step 4: Move the cursor to the added
Feature
class and open the context menu againStep 5: Select the "Import class" option
Step 6: Done!