-
Notifications
You must be signed in to change notification settings - Fork 660
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
Resolving deep mixins #11082
Closed
Closed
Resolving deep mixins #11082
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
issidorov
force-pushed
the
resolving-deep-mixins
branch
from
August 26, 2024 20:59
2621ae4
to
4f14562
Compare
Problems: ``` 1) Psalm\Tests\MixinsDeepTest::testValidCode with data set "NamedMixinsWithoutT_WithObjectMethods" Psalm\Exception\CodeException: MixedAssignment - src/somefile.php:22:1 - Unable to determine the type that $a is being assigned to 2) Psalm\Tests\MixinsDeepTest::testValidCode with data set "NamedMixinsWithT_WithObjectMethods" Psalm\Exception\CodeException: MixedAssignment - src/somefile.php:37:1 - Unable to determine the type that $a is being assigned to ```
Creating the `handleMixins` method is necessary so that it can be used in the future for recursive calls from the `handleTemplatedMixins` and `handleRegularMixins` methods. A recursive call to this method will allow us to search the depth of the mixins.
Deep processing of mixins is planned to be done through recursive calls to the `handleMixins` method. To realise this, we need this method to return information that it has managed to find the desired method. Therefore, the `method_exists` variable was declared to make it clear that the method was found. The existing `naive_method_exists` variable is not suitable for us, because it is not set to `true` if the method is magic (pseudo).
Extracting variables defined in the "if" statement block to the upper lines. All this is necessary to use these variables for further searching at the next deeper level of mixins, passing them to the `handleMixins` method, performing recursion in this way. Extracting code from: ``` if ($codebase->methods->methodExists(...)) { // here extracted } ```
Problems: ``` 1) Psalm\Tests\MixinsDeepTest::testValidCode with data set "TemplatedMixins_WithObjectMethods" Psalm\Exception\CodeException: MixedAssignment - src/somefile.php:25:1 - Unable to determine the type that $a is being assigned to ```
Extracting code from: ``` if ($codebase->methods->methodExists(...)) { // here extracted } elseif (...) { // here extracted } ```
Comparing the `handleTemplatedMixins` and `handleRegularMixins` methods, we can notice that in the `handleRegularMixins` method the `fq_class_name` variable is overridden if the sought method is found in the mixin. Whereas in the `handleTemplatedMixins` method this does not happen. And I think therein lies the error. Since the `class_storage` variable can be overridden in the `handleTemplatedMixins` method, the `fq_class_name` variable should also be overridden.
Problems: ``` 1) Psalm\Tests\MixinsDeepTest::testValidCode with data set "NamedMixinsWithoutT_WithStaticMethods" Psalm\Exception\CodeException: MixedAssignment - src/somefile.php:25:1 - Unable to determine the type that $a is being assigned to 2) Psalm\Tests\MixinsDeepTest::testValidCode with data set "NamedMixinsWithT_WithStaticMethods" Psalm\Exception\CodeException: MixedAssignment - src/somefile.php:39:1 - Unable to determine the type that $a is being assigned to ```
Creating this method is necessary to be able to make recursive calls using this method in the next step.
Added recursive call
Problems: ``` 1) Psalm\Tests\MixinsDeepTest::testValidCode with data set "NamedMixinsWithoutT_WithObjectProperties" Psalm\Exception\CodeException: MixedAssignment - src/somefile.php:23:1 - Unable to determine the type that $a is being assigned to ```
Added recurcive call
issidorov
force-pushed
the
resolving-deep-mixins
branch
from
September 9, 2024 17:57
4f14562
to
b206f1a
Compare
issidorov
force-pushed
the
resolving-deep-mixins
branch
from
September 12, 2024 04:44
b095dfa
to
021c77b
Compare
Pull request is closed. This problem has to be solved architecturally in a different way. |
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.
No description provided.