framework/behaviors/AttributeTypecastBehavior.php
public function typecastAttributes($attributeNames = null)
    {
        $attributeTypes = [];

        if ($attributeNames === null) {
            $attributeTypes = $this->attributeTypes;
        } else {
            foreach ($attributeNames as $attribute) {
                if (!isset($this->attributeTypes[$attribute])) {
                    throw new InvalidArgumentException("There is no type mapping for '{$attribute}'.");
                }
                $attributeTypes[$attribute] = $this->attributeTypes[$attribute];
            }
        }

        foreach ($attributeTypes as $attribute => $type) {
            $value = $this->owner->{$attribute};
            if ($this->skipOnNull && $value === null) {
                continue;
            }
            $this->owner->{$attribute} = $this->typecastValue($value, $type);
        }
    }
public function typecastAttributes($attributeNames = null)
    {
        $attributeTypes = [];

        if ($attributeNames === null) {
            $attributeTypes = $this->attributeTypes;
        } else {
            foreach ($attributeNames as $attribute) {
                if (!isset($this->attributeTypes[$attribute])) {
                    throw new InvalidArgumentException("There is no type mapping for '{$attribute}'.");
                }
                $attributeTypes[$attribute] = $this->attributeTypes[$attribute];
            }
        }

        foreach ($attributeTypes as $attribute => $type) {
            $value = $this->owner->{$attribute};
            if ($this->skipOnNull && $value === null) {
                continue;
            }
            $this->owner->{$attribute} = $this->typecastValue($value, $type);
        }
    }
public function typecastAttributes ( $ attributeNames = null ) { $ attributeTypes = [ ] ; if ( $ attributeNames === null ) { $ attributeTypes = $ this -> attributeTypes ; } else { foreach ( $ attributeNames as $ attribute ) { if ( ! isset ( $ this -> attributeTypes [ $ attribute ] ) ) { throw new InvalidArgumentException ( "There is no type mapping for '{$attribute}'." ) ; } $ attributeTypes [ $ attribute ] = $ this -> attributeTypes [ $ attribute ] ; } } foreach ( $ attributeTypes as $ attribute => $ type ) { $ value = $ this -> owner -> { $ attribute } ; if ( $ this -> skipOnNull && $ value === null ) { continue ; } $ this -> owner -> { $ attribute } = $ this -> typecastValue ( $ value , $ type ) ; } }
Typecast owner attributes according to [[attributeTypes]].
@param array $attributeNames list of attribute names that should be type-casted.
If this parameter is empty, it means any attribute listed in the [[attributeTypes]]
should be type-casted.
Typecast owner attributes according to [[ attributeTypes ]] .