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

Resolving deep mixins #11082

Draft
wants to merge 20 commits into
base: 5.x
Choose a base branch
from
Draft

Commits on Sep 9, 2024

  1. Part 1. Fail tests of named mixins with object methods

    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
    ```
    issidorov committed Sep 9, 2024
    Configuration menu
    Copy the full SHA
    d8bea79 View commit details
    Browse the repository at this point in the history
  2. Part 1. Moving code into the handleMixins method

    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.
    issidorov committed Sep 9, 2024
    Configuration menu
    Copy the full SHA
    a1992a7 View commit details
    Browse the repository at this point in the history
  3. Part 1. Add variable method_exists

    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).
    issidorov committed Sep 9, 2024
    Configuration menu
    Copy the full SHA
    8cf6dbf View commit details
    Browse the repository at this point in the history
  4. Part 1. Extracting variables in the handleRegularMixins method

    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
    }
    ```
    issidorov committed Sep 9, 2024
    Configuration menu
    Copy the full SHA
    0e665e5 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    72817c1 View commit details
    Browse the repository at this point in the history
  6. Part 2. Fail tests of templated mixins with object methods

    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
    ```
    issidorov committed Sep 9, 2024
    Configuration menu
    Copy the full SHA
    bfd2937 View commit details
    Browse the repository at this point in the history
  7. Part 2. Refactoring the handleTemplatedMixins method

    Extracting code from:
    ```
    if ($codebase->methods->methodExists(...)) {
        // here extracted
    } elseif (...) {
        // here extracted
    }
    ```
    issidorov committed Sep 9, 2024
    Configuration menu
    Copy the full SHA
    fecae81 View commit details
    Browse the repository at this point in the history
  8. Part 2. Overriding the fq_class_name variable

    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.
    issidorov committed Sep 9, 2024
    Configuration menu
    Copy the full SHA
    229c072 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    95e2e54 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    cd71295 View commit details
    Browse the repository at this point in the history
  11. Part 4. Fail tests of named mixins with static methods

    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
    ```
    issidorov committed Sep 9, 2024
    Configuration menu
    Copy the full SHA
    c5ea30e View commit details
    Browse the repository at this point in the history
  12. Part 4. Moving code into the handleRegularMixins method

    Creating this method is necessary to be able to
    make recursive calls using this method in the
    next step.
    issidorov committed Sep 9, 2024
    Configuration menu
    Copy the full SHA
    ecbb340 View commit details
    Browse the repository at this point in the history
  13. Part 4. Resolve tests of named mixins with static methods

    Added recursive call
    issidorov committed Sep 9, 2024
    Configuration menu
    Copy the full SHA
    0d0a8b5 View commit details
    Browse the repository at this point in the history
  14. Part 5. Fail tests of mixins with properties

    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
    ```
    issidorov committed Sep 9, 2024
    Configuration menu
    Copy the full SHA
    08b50d6 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    d681ca3 View commit details
    Browse the repository at this point in the history
  16. Part 5. Resolve test of mixins with properties

    Added recurcive call
    issidorov committed Sep 9, 2024
    Configuration menu
    Copy the full SHA
    0ce8418 View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    635d38e View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    83b437a View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    b206f1a View commit details
    Browse the repository at this point in the history

Commits on Sep 12, 2024

  1. Configuration menu
    Copy the full SHA
    021c77b View commit details
    Browse the repository at this point in the history