/**
* Compiles obj->x++
*
* @param string $variable
* @param string $property
* @param ZephirVariable $symbolVariable
* @param CompilationContext $compilationContext
* @param array $statement
*/
public function assign($variable, $property, ZephirVariable $symbolVariable, CompilationContext $compilationContext, $statement)
{
if (!$symbolVariable->isInitialized()) {
throw new CompilerException("Cannot mutate variable '" . $variable . "' because it is not initialized", $statement);
}
/**
* Arrays must be stored in the HEAP
*/
if ($symbolVariable->isLocalOnly()) {
throw new CompilerException("Cannot mutate variable '" . $variable . "' because it is local only", $statement);
}
if (!$symbolVariable->isInitialized()) {
throw new CompilerException("Cannot mutate variable '" . $variable . "' because it is not initialized", $statement);
}
/**
* Only dynamic variables can be used as arrays
*/
if ($symbolVariable->getType() != 'variable') {
throw new CompilerException("Cannot use variable type: '" . $symbolVariable->getType() . "' as array", $statement);
}
if ($symbolVariable->hasAnyDynamicType('unknown')) {
throw new CompilerException("Cannot use non-initialized variable as an object", $statement);
}
/**
* Trying to use a non-object dynamic variable as object
*/
if ($symbolVariable->hasDifferentDynamicType(array('undefined', 'object', 'null'))) {
$compilationContext->logger->warning('Possible attempt to increment non-object dynamic variable', 'non-object-update', $statement);
}
$compilationContext->headersManager->add('kernel/object');
$compilationContext->codePrinter->output('RETURN_ON_FAILURE(zephir_property_incr(' . $symbolVariable->getName() . ', SL("' . $property . '") TSRMLS_CC));');
}