Zephir\ClassProperty::declareProperty PHP Метод

declareProperty() защищенный Метод

Declare class property with default value
protected declareProperty ( zephir\CompilationContext $compilationContext, string $type, $value )
$compilationContext zephir\CompilationContext
$type string
$value
    protected function declareProperty(CompilationContext $compilationContext, $type, $value)
    {
        $codePrinter = $compilationContext->codePrinter;
        if (is_object($value)) {
            return;
        }
        $classEntry = $compilationContext->classDefinition->getClassEntry();
        switch ($type) {
            case 'long':
            case 'int':
                $codePrinter->output("zend_declare_property_long(" . $classEntry . ", SL(\"" . $this->getName() . "\"), " . $value . ", " . $this->getVisibilityAccessor() . " TSRMLS_CC);");
                break;
            case 'double':
                $codePrinter->output("zend_declare_property_double(" . $classEntry . ", SL(\"" . $this->getName() . "\"), " . $value . ", " . $this->getVisibilityAccessor() . " TSRMLS_CC);");
                break;
            case 'bool':
                $codePrinter->output("zend_declare_property_bool(" . $classEntry . ", SL(\"" . $this->getName() . "\"), " . $this->getBooleanCode($value) . ", " . $this->getVisibilityAccessor() . " TSRMLS_CC);");
                break;
            case Types::CHAR:
            case Types::STRING:
                $codePrinter->output("zend_declare_property_string(" . $classEntry . ", SL(\"" . $this->getName() . "\"), \"" . Utils::addSlashes($value, true, $type) . "\", " . $this->getVisibilityAccessor() . " TSRMLS_CC);");
                break;
            case 'array':
            case 'empty-array':
            case 'null':
                $codePrinter->output("zend_declare_property_null(" . $classEntry . ", SL(\"" . $this->getName() . "\"), " . $this->getVisibilityAccessor() . " TSRMLS_CC);");
                break;
            default:
                throw new CompilerException('Unknown default type: ' . $type, $this->original);
        }
    }