Skip to content

Commit

Permalink
Merge pull request #1563 from sergeyklay/development
Browse files Browse the repository at this point in the history
Minor cleanup
  • Loading branch information
sergeyklay authored Jul 24, 2017
2 parents 60ab252 + 6fd42cf commit 0161027
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 20 deletions.
4 changes: 3 additions & 1 deletion Library/Backends/ZendEngine2/Backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,14 @@ public function getBoolCode(Variable $variable, CompilationContext $context, $us
return $output;
}

/**
* {@inheritdoc}
*/
public function getStringsManager()
{
return new StringsManager();
}


public function getFcallManager()
{
if (!$this->fcallManager) {
Expand Down
19 changes: 15 additions & 4 deletions Library/Backends/ZendEngine3/Backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public function getBoolCode(Variable $variable, CompilationContext $context, $us
return $code;
}

/**
* {@inheritdoc}
*/
public function getStringsManager()
{
return new StringsManager();
Expand Down Expand Up @@ -421,7 +424,7 @@ public function addArrayEntry(Variable $variable, $key, $value, CompilationConte
break;
}

if (!$type) {
if ($type === null) {
throw new CompilerException("Unknown type mapping: " . $value->getType());
}

Expand Down Expand Up @@ -495,7 +498,8 @@ public function arrayUnset(Variable $variable, $exprIndex, $flags, CompilationCo
$context->codePrinter->output('zephir_array_unset_string(' . $variableCode . ', SL("' . $exprIndex->getCode() . '"), ' . $flags . ');');
return;
}
return parent::arrayUnset($variable, $exprIndex, $flags, $context);

parent::arrayUnset($variable, $exprIndex, $flags, $context);
}

public function fetchGlobal(Variable $globalVar, CompilationContext $compilationContext, $useCodePrinter = true)
Expand Down Expand Up @@ -552,6 +556,7 @@ public function fetchProperty(Variable $symbolVariable, Variable $variableVariab
*/
public function fetchStaticProperty(Variable $symbolVariable, $classDefinition, $property, $readOnly, CompilationContext $context)
{
// TODO: maybe optimizations as well as above
$context->codePrinter->output(
sprintf(
'zephir_read_static_property_ce(%s%s, %s, SL("%s"), PH_NOISY_CC%s);',
Expand All @@ -565,7 +570,11 @@ public function fetchStaticProperty(Variable $symbolVariable, $classDefinition,
}

/**
* @return Variable
* @param $value
* @param CompilationContext $context
* @param bool $usePointer
* @return bool|string|Variable
* @throws CompilerException
*/
public function resolveValue($value, CompilationContext $context, $usePointer = false)
{
Expand All @@ -581,7 +590,9 @@ public function resolveValue($value, CompilationContext $context, $usePointer =
$value = 'false';
break;
default:
throw new CompilerException('ZE3: Unknown constant '.$value->getName());
throw new CompilerException(
$this->name . ': Unknown constant ' . $value->getName()
);
}
}

Expand Down
8 changes: 8 additions & 0 deletions Library/BaseBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

namespace Zephir;

use Zephir\StringsManager;

abstract class BaseBackend
{
/**
Expand Down Expand Up @@ -68,6 +70,8 @@ public function getInternalTemplatePath()

/**
* Resolves the path to the source template file of the backend
*
* @param string $filename
* @return string Absolute path to template file
*/
public function getTemplateFileContents($filename)
Expand All @@ -79,7 +83,11 @@ public function getTemplateFileContents($filename)
return file_get_contents($filepath);
}

/**
* @return StringsManager
*/
abstract public function getStringsManager();

abstract public function getTypeDefinition($type);
abstract public function getTypeofCondition(Variable $variableVariable, $operator, $value, CompilationContext $context);
abstract public function generateInitCode(&$groupVariables, $type, $pointer, Variable $variable);
Expand Down
12 changes: 6 additions & 6 deletions Library/ClassDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

namespace Zephir;

use Zephir\HeadersManager;
use Zephir\Documentation\Docblock;
use Zephir\Documentation\DocblockParser;

Expand Down Expand Up @@ -101,7 +100,7 @@ class ClassDefinition
protected $methods = array();

/**
* @var array
* @var string
*/
protected $docBlock;

Expand Down Expand Up @@ -492,7 +491,7 @@ public function getDependencyRank()
/**
* Sets the class/interface docBlock
*
* @param array $docBlock
* @param string $docBlock
*/
public function setDocBlock($docBlock)
{
Expand All @@ -502,7 +501,7 @@ public function setDocBlock($docBlock)
/**
* Returns the class/interface docBlock
*
* @return array
* @return string
*/
public function getDocBlock()
{
Expand All @@ -512,18 +511,19 @@ public function getDocBlock()
/**
* Returns the parsed docBlock
*
* @return DocBlock
* @return DocBlock|null
*/
public function getParsedDocBlock()
{
if (!$this->parsedDocblock) {
if (strlen($this->docBlock) > 0) {
$parser = new DocblockParser("/" . $this->docBlock ."/");
$parser = new DocblockParser("/" . $this->docBlock . "/");
$this->parsedDocblock = $parser->parse();
} else {
return null;
}
}

return $this->parsedDocblock;
}

Expand Down
2 changes: 2 additions & 0 deletions Library/Statements/Let/ObjectPropertyArrayIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ protected function _assignPropertyArrayMultipleIndex($variable, ZephirVariable $
* @param CompiledExpression $resolvedExpr
* @param CompilationContext $compilationContext,
* @param array $statement
*
* @throws CompilerException
*/
public function assign($variable, ZephirVariable $symbolVariable, CompiledExpression $resolvedExpr, CompilationContext $compilationContext, $statement)
{
Expand Down
7 changes: 1 addition & 6 deletions kernels/ZendEngine2/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ static zephir_debug_entry *active = NULL;
*/
int zephir_start_debug(){
if(!zephir_log){
/*//zephir_log = fopen("/home/gutierrezandresfelipe/phalcon-debug.a", "w");
zephir_log = fopen("/tmp/phalcon-debug.a", "w");
if(!zephir_log){
fprintf(stderr, "Can't open debug log\n");
}*/
zephir_log = stderr;
}
return SUCCESS;
Expand All @@ -60,7 +55,7 @@ int zephir_stop_debug(){
ptr = ptr->prev;
efree(this_entry);
}
//fclose(zephir_log);

zephir_log = NULL;
return SUCCESS;
}
Expand Down
2 changes: 1 addition & 1 deletion kernels/ZendEngine2/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ int zephir_fetch_parameters(int num_args TSRMLS_DC, int required_args, int optio
}

/** Get current hash key copying the iterator if needed */

// TODO: Deprecated. Will be removed in future
#if PHP_VERSION_ID < 50500

#define ZEPHIR_GET_IMKEY(var, it) \
Expand Down
4 changes: 2 additions & 2 deletions kernels/ZendEngine3/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ int zephir_fast_count_int(zval *value)
/**
* Check if a function exists using explicit function length
*
* @todo Deprecated. Will be removed in future
* TODO: Deprecated. Will be removed in future
*/
int zephir_function_quick_exists_ex(const char *function_name, size_t function_len)
{
Expand Down Expand Up @@ -285,7 +285,7 @@ int zephir_function_exists(const zval *function_name)
/**
* Check if a function exists using explicit function length
*
* @todo Deprecated. Will be removed in future
* TODO: Deprecated. Will be removed in future
* @param function_name
* @param function_len strlen(function_name) + 1
*/
Expand Down
3 changes: 3 additions & 0 deletions templates/ZendEngine2/project.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <php.h>

// TODO: Deprecated. Will be removed in future
#if PHP_VERSION_ID < 50500
#include <locale.h>
#endif
Expand Down Expand Up @@ -37,6 +38,7 @@ PHP_INI_END()

static PHP_MINIT_FUNCTION(%PROJECT_LOWER%)
{
// TODO: Deprecated. Will be removed in future
#if PHP_VERSION_ID < 50500
char* old_lc_all = setlocale(LC_ALL, NULL);
if (old_lc_all) {
Expand All @@ -55,6 +57,7 @@ static PHP_MINIT_FUNCTION(%PROJECT_LOWER%)
REGISTER_INI_ENTRIES();
%CLASS_INITS%

// TODO: Deprecated. Will be removed in future
#if PHP_VERSION_ID < 50500
setlocale(LC_ALL, old_lc_all);
free(old_lc_all);
Expand Down

0 comments on commit 0161027

Please sign in to comment.