[Lunr.Locator] Core: Allow immutable class method usage

Review Request #867 — Created Sept. 12, 2022 and submitted

smillernl
Lunr.Locator
feature/methods/allow_immutable_class_methods
lunr
Core: Allow immutable class method usage

CI in https://github.com/M2mobi/lunr.locator/pull/4

  • 0
  • 0
  • 3
  • 0
  • 3
Description From Last Updated
smillernl
pprkut
  1. 
      
  2. src/Lunr/Core/Tests/ConfigServiceLocatorSupportTest.php (Diff revision 1)
     
     
     
     
     
     
     

    I think attaching this info to the method that is called makes it nicer. i.e. something like

    'methods' => [
        [
            'name' => 'test',
            'params' => [ '!param1' ],
            'replace_instance' => TRUE
        ]
    ]
    

    immutable as a keyword makes a bit less sense then, since the method is not immutable, that's why I picked replace_instance, but maybe you find something better :)

    1. How about return_self?

    2. I thought about that too, but it's not the same thing. If the class is immutable, then it's not returning self, but just an instance of the same class. And if it is returning self, the object wouldn't have to be immutable.

    3. returns_clone or returns_instance? I guess I'm mostly trying to make it clear that it's a method property, while replace_instance can be misunderstood as a goal.

    4. What we want to communicate essentially is "the value that's returned by this method replaces the object instance".

      How about return_replaces_instance? The shorter forms mostly stumble when it's about "but what's the effect of that now?"

  3. 
      
smillernl
smillernl
pprkut
smillernl
Review request changed

Status: Closed (submitted)

Loading...