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

Cannot support different handling for the same named method in different classes #43

Closed
chasepeeler opened this issue Jun 12, 2015 · 6 comments

Comments

@chasepeeler
Copy link

Given the following:

{
  "class": "\\ESP\\Model\\Factory",
  "method": "get",
  "position": 0,
  "fileReturnTypeReplacementCall": [
    "ESPReturnTypes.js",
    "replaceModelFactory"
   ]
},
{
  "class": "\\ESP\\Container",
  "method": "get",
  "position": 0,
  "fileReturnTypeReplacementCall": [
    "ESPReturnTypes.js",
    "replaceContainerGet"
  ]
}

Calls to both \ESP\Container::get and \ESP\Model\Factory::get are processed by the replaceModelFactory method. However, if I switch the order in which the two items appear, so that the one for \ESP\Container is first, then calls to both methods are processed by replaceContainerGet.

@pbyrne84
Copy link
Owner

pbyrne84 commented Sep 8, 2015

Can I have the js file?
Cheers

@dmeybohm
Copy link

@pbyrne84 This happens also for masked methods:

namespace Namespace1 {
    class Controller {
        public function model($name) {
            $name = '\Namespace1\Model\\' . $name
            return new $name;
        }
    }
}
namespace Namespace1\Model {
    class Model1 {
        public function insideModel1() {

        }
    }
}
namespace Namespace2 {
    class Controller {
        public function model($name) {
            $name = '\Namespace2\Model\\' . $name;
            return new $name;
        }
    }
}
namespace Namespace2\Model {
    class Model1 {
        public $model2;
        public function insideModel2() {

        }
    }
}
namespace Namespace2 {
    $controllerOne = new \Namespace1\Controller();
    $controllerOne->model('Model1')->insideModel1();
    $controllerTwo = new \Namespace2\Controller();
    // this references the first model instead of the second:
    $controllerTwo->model('Model1')->
}

with config:

{
    "methodCalls"  : [
        {
            "class"   : "\\Namespace1\\Controller",
            "method"  : "model",
            "position": 0,
            "mask"    : "\\Namespace1\\Model\\%s"
        },
        {
            "class"   : "\\Namespace2\\Controller",
            "method"  : "model",
            "position": 0,
            "mask"    : "\\Namespace2\\Model\\%s"
        },
    ],
    "functionCalls": []
}

@pbyrne84
Copy link
Owner

pbyrne84 commented Mar 3, 2016

Many thanks for the example. I have started looking into it.

On 27 February 2016 at 22:43, David Meybohm notifications@github.com
wrote:

@pbyrne84 https://github.com/pbyrne84 This happens also for masked
methods:

namespace Namespace1 { class Controller { public function model($name) { $name = '\Namespace1\Model' . $name return new $name; } }}namespace Namespace1\Model { class Model1 { public function insideModel1() { } }}namespace Namespace2 { class Controller { public function model($name) { $name = '\Namespace2\Model' . $name; return new $name; } }}namespace Namespace2\Model { class Model1 { public $model2; public function insideModel2() { } }}namespace Namespace2 { $controllerOne = new \Namespace1\Controller(); $controllerOne->model('Model1')->insideModel1(); $controllerTwo = new \Namespace2\Controller(); // this references the first model instead of the second: $controllerTwo->model('Model1')->}

with config:

{
"methodCalls" : [
{
"class" : "\Namespace1\Controller",
"method" : "model",
"position": 0,
"mask" : "\Namespace1\Model%s"
},
{
"class" : "\Namespace2\Controller",
"method" : "model",
"position": 0,
"mask" : "\Namespace2\Model%s"
},
],
"functionCalls": []
}


Reply to this email directly or view it on GitHub
#43 (comment)
.

pbyrne84 added a commit to pbyrne84/DynamicReturnTypePluginTestEnvironment that referenced this issue Mar 4, 2016
pbyrne84 added a commit that referenced this issue Mar 4, 2016
Cannot support different handling for the same named method in different classes
#43
@pbyrne84
Copy link
Owner

pbyrne84 commented Mar 4, 2016

In theory the deployable here https://github.com/pbyrne84/DynamicReturnTypePlugin/raw/master/deploy/DynamicReturnTypePlugin.zip fixes the problem

locate your current DynamicReturnTypePlugin folder under plugins dir, delete and replace with the unzipped contents of this one and let me know if it works.

@dmeybohm
Copy link

dmeybohm commented Mar 5, 2016

It works. Thanks.

@pbyrne84
Copy link
Owner

pbyrne84 commented Mar 7, 2016

Thanks for the confirmation

@pbyrne84 pbyrne84 closed this as completed Mar 7, 2016
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

No branches or pull requests

3 participants