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

Create instance in loop issue #1673

Closed
navisoft opened this issue Sep 15, 2018 · 3 comments
Closed

Create instance in loop issue #1673

navisoft opened this issue Sep 15, 2018 · 3 comments

Comments

@navisoft
Copy link

navisoft commented Sep 15, 2018

Example:

var instance, className;
for className in ["A", "B"] {
	let instance = new {className}();
	//or
	if className == "A" {
		let instance = new A();
	} else {
		let instance = new B();
	}
	instance->execute();
	instance->another();
}

class A {
	public function execute() {
		echo "A";
	}
	public function another() {
		echo "Aa";
	}
}
class B {
	public function execute() {
		echo "B";
	}
	public function another() {
		echo "Bb";
	}
}

Both A and B have the "execute" and "another" method.
Result: The function execute of A instance run twice times.
The function execute of B doesn't runs.

@danhunsaker
Copy link
Contributor

We only see part of the implementation of A, and none of B, so it's difficult to say where the problem is being introduced. Can you provide a more complete example?

@navisoft
Copy link
Author

navisoft commented Oct 4, 2018

The class B is same the class A. I just updated the question.

sergeyklay added a commit that referenced this issue Oct 30, 2018
sergeyklay added a commit that referenced this issue Oct 30, 2018
@sergeyklay
Copy link
Member

As you can see there is no issue at all #1700

I'm closing this issue but if I have made an oversight, please do get back in touch. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants