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

Can't use this or self in instanceof. #776

Closed
kse300489 opened this issue Feb 26, 2015 · 5 comments
Closed

Can't use this or self in instanceof. #776

kse300489 opened this issue Feb 26, 2015 · 5 comments
Labels
nfr New Feature Request

Comments

@kse300489
Copy link

Php

class SimpleClass{
  public function testInstanceOfThis($var){
    return $var instanceof $this;
  }

  public function testInstanceOfSelf($var){
    return $var instanceof $this;
  }
}

$simpleClass = new SimpleClass();

var_dump($simpleClass->testInstanceOfThis($simpleClass));
var_dump($simpleClass->testInstanceOfSelf($simpleClass));

Output:

bool(true)
bool(true)

Zephir:

DOMElement instanceof this

not compiled, get compile error:

element.zep.c: In function 'zim_It_Utils_Xml_DOM_Element_removeAttributes':
element.zep.c:153:42: error: 'this' undeclared (first use in this function)
element.zep.c:153:42: note: each undeclared identifier is reported only once for each function it appears in
make: *** [it/utils/xml/dom/element.lo] Error 1
element.zep.c: In function 'zim_It_Utils_Xml_DOM_Element_removeAttributes':
element.zep.c:153:42: error: 'this' undeclared (first use in this function)
element.zep.c:153:42: note: each undeclared identifier is reported only once for each function it appears in
make: *** [element.lo] Error 1

Generated C code:

zephir_is_instance_of(DOMElement, Z_STRVAL_P(this), Z_STRLEN_P(this) TSRMLS_CC))

If i use self:

DOMElement instanceof this

Compile, but generated invalid class name in C code:

zephir_is_instance_of(DOMElement, SL("It\\Utils\\Xml\\DOM\\self") TSRMLS_CC)
@kse300489 kse300489 changed the title Can't use this or self as instanceof. Can't use this or self in instanceof. Feb 26, 2015
@kse300489
Copy link
Author

Ping ?

@ovr
Copy link
Contributor

ovr commented Mar 17, 2015

Pong?

@ovr ovr added the nfr New Feature Request label Mar 17, 2015
@ovr
Copy link
Contributor

ovr commented Mar 17, 2015

I think it's not implemented, I will try

@ovr ovr self-assigned this Mar 17, 2015
@kse300489
Copy link
Author

Ty. This is a very useful feature.

ovr added a commit to ovr/zephir that referenced this issue Mar 17, 2015
ovr added a commit to ovr/zephir that referenced this issue Mar 17, 2015
@ovr
Copy link
Contributor

ovr commented Mar 17, 2015

Implemented, check latest master

@ovr ovr closed this as completed Mar 17, 2015
@phalcon phalcon unassigned ovr Aug 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
nfr New Feature Request
Projects
None yet
Development

No branches or pull requests

2 participants