Changeset 703

Show
Ignore:
Timestamp:
06/02/07 14:04:46 (1 year ago)
Author:
mikey
Message:

Only clone instances of net.stubbles.stubObject, prevents cloning of reflection classes which are not clonable and result in a fatal error (fixes ticket #54). However this is more sort of a hack because PHP does not offer a possibility to check whether an object can be cloned or not.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/reflection/annotations/stubAbstractAnnotation.php

    r522 r703  
    2222     */ 
    2323    protected $annotationName; 
    24      
     24 
    2525    /** 
    2626     * Sets the name under which the annotation is stored. 
     
    2828     * @param  string  $name 
    2929     */ 
    30     public function setAnnotationName($name) { 
     30    public function setAnnotationName($name) 
     31    { 
    3132        $this->annotationName = $name; 
    3233    } 
    33      
     34 
    3435    /** 
    3536     * Returns the name under which the annotation is stored. 
     
    3738     * @return  string 
    3839     */ 
    39     public function getAnnotationName() { 
     40    public function getAnnotationName() 
     41    { 
    4042        return $this->annotationName; 
    4143    } 
    42      
     44 
    4345    /** 
    44      * assure that a clone clones all properties og type object as well 
     46     * assure that a clone clones all properties of type object as well 
    4547     */ 
    4648    public function __clone() 
    4749    { 
    4850        foreach (get_object_vars($this) as $name => $value) { 
    49             if (is_object($value) == true) { 
     51            // FIXME: stubObject is not a really good indication of whether the 
     52            //        object is clonable or not. Probably think about a new 
     53            //        interface net.stubbles.stubClonable. 
     54            if (is_object($value) == true && $value instanceof stubObject) { 
    5055                $this->$name = clone $this->$name; 
    5156            }