Mantis Bugtracker
  

Viewing Issue Advanced Details Jump to Notes ] View Simple ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0001180 [Quercus] minor always 06-05-06 18:09 06-09-06 15:57
Reporter koreth View Status public  
Assigned To ferg
Priority normal Resolution fixed Platform
Status closed   OS
Projection none   OS Version
ETA none Fixed in Version 3.0.20 Product Version 3.0.20
  Product Build
Summary 0001180: Need is_subclass_of()
Description PHP:

<?php
if (is_subclass_of('a', 'b')) { print "yep\n"; }
?>

This fails under Quercus:

Users/sgrimm/resin/resin/webapps/test/test.php:2: Fatal Error: Users/sgrimm/resin/resin/webapps/test/test.php:2: 'is_subclass_of' is an unknown function.
Steps To Reproduce
Additional Information
Attached Files

- Relationships

- Notes
(0001267)
koreth
06-05-06 18:58

Here's an implementation (which I put in ClassesModule) that seems to work.

  /**
   * Returns true if one class is a subclass of another.
   */
  public static boolean is_subclass_of(Env env,
                             @ReadOnly Value value,
                             @ReadOnly String className)
  {
    QuercusClass clazz;
    if (value instanceof Var) {
      Var var = (Var) value;
      value = var.getRawValue();
    }
    if (value instanceof StringValue) {
      StringValue str = (StringValue) value;
      clazz = env.findClass(str.toString());
    }
    else if (value instanceof ObjectValue) {
      ObjectValue obj = (ObjectValue) value;
      clazz = obj.getQuercusClass();
    }
    else {
      return false;
    }
    while ((clazz = clazz.getParent()) != null) {
      if (clazz.getName().equals(className))
    return true;
    }
    return false;
  }
 
(0001278)
ferg
06-09-06 15:57

php/1j0c
 

- Issue History
Date Modified Username Field Change
06-05-06 18:09 koreth New Issue
06-05-06 18:58 koreth Note Added: 0001267
06-09-06 15:57 ferg Note Added: 0001278
06-09-06 15:57 ferg Assigned To  => ferg
06-09-06 15:57 ferg Status new => closed
06-09-06 15:57 ferg Resolution open => fixed
06-09-06 15:57 ferg Fixed in Version  => 3.0.20


Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
31 total queries executed.
27 unique queries executed.
Powered by Mantis Bugtracker