Req #60573 [PATCH]: type hinting with self keyword causes weird errors

2011-12-20 Thread larue...@php.net
Edit report at https://bugs.php.net/bug.php?id=60573edit=1

 ID: 60573
 Patch added by: larue...@php.net
 Reported by:jpa...@php.net
 Summary:type hinting with self keyword causes weird errors
 Status: Assigned
 Type:   Feature/Change Request
 Package:Scripting Engine problem
 Operating System:   *nix
 PHP Version:5.3.8
 Assigned To:laruence
 Block user comment: N
 Private report: N

 New Comment:

The following patch has been added/updated:

Patch Name: bug60573.patch
Revision:   1324396875
URL:
https://bugs.php.net/patch-display.php?bug=60573patch=bug60573.patchrevision=1324396875


Previous Comments:

[2011-12-20 12:53:38] larue...@php.net

I have a patch now, will apply it after do careful testings


[2011-12-20 12:31:44] larue...@php.net

This is really a tough one,  think about following:

?php
class Foo {

public function setSelf(self $s) { }

}

class Bar extends Foo {

public function setSelf(parent $s) { }

}
?
-
?php
class Foo {

public function setSelf(Foo $s) { }

}

class Bar extends Foo {

public function setSelf(parent $s) { }

}
---
?php
class Base {
}

class Foo extends Base{

public function setSelf(parent $s) { }

}

class Bar extends Foo {

public function setSelf(Base $s) { }

}


and more...


[2011-12-20 10:56:31] jpa...@php.net

Description:

self should be thought as the class where the keyword is written in.

Here is then a strange behavior using inheritance :

Test script:
---
class Foo {

public function setSelf(self $s) { }

}

class Bar extends Foo {

public function setSelf(self $s) { }

}


Expected result:

Strict Standards as Bar::setself() signature doesn't respect Foo::setSelf() 
signature.
Foo's one has a type hint on Foo (using self keyword), but Bar's one on Bar 
(still using self keyword) : the methods then have a signature mismatch, and 
PHP 
should complain about that

Actual result:
--
Nothing happens.

Trying this gives the correct E_STRICT error, correct behavior :

class Foo {

public function setSelf(Foo $s) { }

}

class Bar extends Foo {

public function setSelf(Bar $s) { }

}







-- 
Edit this bug report at https://bugs.php.net/bug.php?id=60573edit=1


Req #60573 [PATCH]: type hinting with self keyword causes weird errors

2011-12-20 Thread larue...@php.net
Edit report at https://bugs.php.net/bug.php?id=60573edit=1

 ID: 60573
 Patch added by: larue...@php.net
 Reported by:jpa...@php.net
 Summary:type hinting with self keyword causes weird errors
 Status: Assigned
 Type:   Feature/Change Request
 Package:Scripting Engine problem
 Operating System:   *nix
 PHP Version:5.3.8
 Assigned To:laruence
 Block user comment: N
 Private report: N

 New Comment:

The following patch has been added/updated:

Patch Name: bug60573.phpt
Revision:   1324396902
URL:
https://bugs.php.net/patch-display.php?bug=60573patch=bug60573.phptrevision=1324396902


Previous Comments:

[2011-12-20 16:01:15] larue...@php.net

The following patch has been added/updated:

Patch Name: bug60573.patch
Revision:   1324396875
URL:
https://bugs.php.net/patch-display.php?bug=60573patch=bug60573.patchrevision=1324396875


[2011-12-20 12:53:38] larue...@php.net

I have a patch now, will apply it after do careful testings


[2011-12-20 12:31:44] larue...@php.net

This is really a tough one,  think about following:

?php
class Foo {

public function setSelf(self $s) { }

}

class Bar extends Foo {

public function setSelf(parent $s) { }

}
?
-
?php
class Foo {

public function setSelf(Foo $s) { }

}

class Bar extends Foo {

public function setSelf(parent $s) { }

}
---
?php
class Base {
}

class Foo extends Base{

public function setSelf(parent $s) { }

}

class Bar extends Foo {

public function setSelf(Base $s) { }

}


and more...


[2011-12-20 10:56:31] jpa...@php.net

Description:

self should be thought as the class where the keyword is written in.

Here is then a strange behavior using inheritance :

Test script:
---
class Foo {

public function setSelf(self $s) { }

}

class Bar extends Foo {

public function setSelf(self $s) { }

}


Expected result:

Strict Standards as Bar::setself() signature doesn't respect Foo::setSelf() 
signature.
Foo's one has a type hint on Foo (using self keyword), but Bar's one on Bar 
(still using self keyword) : the methods then have a signature mismatch, and 
PHP 
should complain about that

Actual result:
--
Nothing happens.

Trying this gives the correct E_STRICT error, correct behavior :

class Foo {

public function setSelf(Foo $s) { }

}

class Bar extends Foo {

public function setSelf(Bar $s) { }

}







-- 
Edit this bug report at https://bugs.php.net/bug.php?id=60573edit=1