#41137 [Bgs]: is_a() for interfaces

2007-04-29 Thread amadeusz dot jasak at gmail dot com
 ID:   41137
 User updated by:  amadeusz dot jasak at gmail dot com
 Reported By:  amadeusz dot jasak at gmail dot com
 Status:   Bogus
 Bug Type: Feature/Change Request
 Operating System: -
 PHP Version:  5.2.1
 New Comment:

Yes, I know, but not everyone has Reflection API, reflection slow...


Previous Comments:


[2007-04-29 12:38:19] [EMAIL PROTECTED]

I think reflection extension allows to do such checks.



[2007-04-19 15:18:18] amadeusz dot jasak at gmail dot com

So, maybe new function for checking interface implementation for
classes?? Like bool is_implementing(mixed $class_or_object, string
$interface)



[2007-04-19 15:01:33] [EMAIL PROTECTED]

quoting the manual (http://php.net/is_a):

bool is_a ( object $object, string $class_name )

Checks if the given object is of this class or has this class as one 
of its parents.

'foo' is not an object (it is a string), and therefore is_a() 
returns false.

is_a('foo', 'foo')

is also false for the same reason.



[2007-04-19 06:31:39] amadeusz dot jasak at gmail dot com

Description:

is_a function will be works if first argument is class name and next
argument is interface name. Currently it isn't working... I can't check
for class (not object) is implementing some interface

Reproduce code:
---
?php

inteface factory
{
  public static function _factory($params);
}

class foo implements factory
{
  public static function _factory($params)
  {
$t = new foo();
return $t; // Sweet use of factory ;)
  }
}

var_dump
(
  is_a('foo', 'factory'), // Currently return false, but true is
expected
  is_a($foo = new foo(), 'factory') // It is working but it isn't
practicly
);
?

Expected result:

bool(true)
bool(true)

Actual result:
--
bool(false)
bool(true)





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



#41137 [NEW]: is_a() for interfaces

2007-04-19 Thread amadeusz dot jasak at gmail dot com
From: amadeusz dot jasak at gmail dot com
Operating system: -
PHP version:  5.2.1
PHP Bug Type: Feature/Change Request
Bug description:  is_a() for interfaces

Description:

is_a function will be works if first argument is class name and next
argument is interface name. Currently it isn't working... I can't check for
class (not object) is implementing some interface

Reproduce code:
---
?php

inteface factory
{
  public static function _factory($params);
}

class foo implements factory
{
  public static function _factory($params)
  {
$t = new foo();
return $t; // Sweet use of factory ;)
  }
}

var_dump
(
  is_a('foo', 'factory'), // Currently return false, but true is expected
  is_a($foo = new foo(), 'factory') // It is working but it isn't
practicly
);
?

Expected result:

bool(true)
bool(true)

Actual result:
--
bool(false)
bool(true)

-- 
Edit bug report at http://bugs.php.net/?id=41137edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=41137r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=41137r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=41137r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=41137r=fixedcvs
Fixed in release: 
http://bugs.php.net/fix.php?id=41137r=alreadyfixed
Need backtrace:   http://bugs.php.net/fix.php?id=41137r=needtrace
Need Reproduce Script:http://bugs.php.net/fix.php?id=41137r=needscript
Try newer version:http://bugs.php.net/fix.php?id=41137r=oldversion
Not developer issue:  http://bugs.php.net/fix.php?id=41137r=support
Expected behavior:http://bugs.php.net/fix.php?id=41137r=notwrong
Not enough info:  
http://bugs.php.net/fix.php?id=41137r=notenoughinfo
Submitted twice:  
http://bugs.php.net/fix.php?id=41137r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=41137r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=41137r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=41137r=dst
IIS Stability:http://bugs.php.net/fix.php?id=41137r=isapi
Install GNU Sed:  http://bugs.php.net/fix.php?id=41137r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=41137r=float
No Zend Extensions:   http://bugs.php.net/fix.php?id=41137r=nozend
MySQL Configuration Error:http://bugs.php.net/fix.php?id=41137r=mysqlcfg


#41137 [Bgs]: is_a() for interfaces

2007-04-19 Thread amadeusz dot jasak at gmail dot com
 ID:   41137
 User updated by:  amadeusz dot jasak at gmail dot com
 Reported By:  amadeusz dot jasak at gmail dot com
 Status:   Bogus
 Bug Type: Feature/Change Request
 Operating System: -
 PHP Version:  5.2.1
 New Comment:

So, maybe new function for checking interface implementation for
classes?? Like bool is_implementing(mixed $class_or_object, string
$interface)


Previous Comments:


[2007-04-19 15:01:33] [EMAIL PROTECTED]

quoting the manual (http://php.net/is_a):

bool is_a ( object $object, string $class_name )

Checks if the given object is of this class or has this class as one 
of its parents.

'foo' is not an object (it is a string), and therefore is_a() 
returns false.

is_a('foo', 'foo')

is also false for the same reason.



[2007-04-19 06:31:39] amadeusz dot jasak at gmail dot com

Description:

is_a function will be works if first argument is class name and next
argument is interface name. Currently it isn't working... I can't check
for class (not object) is implementing some interface

Reproduce code:
---
?php

inteface factory
{
  public static function _factory($params);
}

class foo implements factory
{
  public static function _factory($params)
  {
$t = new foo();
return $t; // Sweet use of factory ;)
  }
}

var_dump
(
  is_a('foo', 'factory'), // Currently return false, but true is
expected
  is_a($foo = new foo(), 'factory') // It is working but it isn't
practicly
);
?

Expected result:

bool(true)
bool(true)

Actual result:
--
bool(false)
bool(true)





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