Skip to content

Commit

Permalink
Merge pull request #9 from phalcon/4.0.x
Browse files Browse the repository at this point in the history
4.0.x
  • Loading branch information
zsilbi authored May 2, 2019
2 parents 376b359 + 8a568e6 commit ba010c9
Show file tree
Hide file tree
Showing 604 changed files with 16,582 additions and 6,401 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-4.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
- Fixed the exception message in `Phalcon\Security::computeHmac()` by removing `"%s"` from output.
- `Phalcon\Mvc\Model\Relation::isForeignKey()` now returns false if the `foreignKey` option is set to `false`.
- Fixed `Phalcon\Flash\Session::output()` not to throw an exception when there are no messages stored in session. [#14023](https://github.com/phalcon/cphalcon/issues/14023)
- Fixed `Phalcon\Config\Adapter\Ini()` to handle arrays correctly in .ini files. [#14025](https://github.com/phalcon/cphalcon/issues/14025)

## Removed
- Removed `arrayHelpers` property from the Volt compiler. [#13925](https://github.com/phalcon/cphalcon/pull/13925)
Expand Down
28 changes: 23 additions & 5 deletions optimizers/PhalconCssminOptimizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ public function optimize(array $expression, Call $call, CompilationContext $cont
}

if (count($expression['parameters']) != 1) {
throw new CompilerException("phalcon_cssmin only accepts one parameter", $expression);
throw new CompilerException(
"phalcon_cssmin only accepts one parameter",
$expression
);
}

/**
Expand All @@ -44,21 +47,36 @@ public function optimize(array $expression, Call $call, CompilationContext $cont
$call->processExpectedReturn($context);

$symbolVariable = $call->getSymbolVariable();

if ($symbolVariable->getType() != 'variable') {
throw new CompilerException("Returned values by functions can only be assigned to variant variables", $expression);
throw new CompilerException(
"Returned values by functions can only be assigned to variant variables",
$expression
);
}

if ($call->mustInitSymbolVariable()) {
$symbolVariable->initVariant($context);
}

$context->headersManager->add('phalcon/assets/filters/cssminifier');

$symbolVariable->setDynamicTypes('string');

$resolvedParams = $call->getResolvedParams($expression['parameters'], $context, $expression);
$resolvedParams = $call->getResolvedParams(
$expression['parameters'],
$context,
$expression
);

$context->codePrinter->output('phalcon_cssmin(' . $symbolVariable->getName() . ', ' . $resolvedParams[0] . ' TSRMLS_CC);');
$context->codePrinter->output(
'phalcon_cssmin(' . $symbolVariable->getName() . ', ' . $resolvedParams[0] . ' TSRMLS_CC);'
);

return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression);
return new CompiledExpression(
'variable',
$symbolVariable->getRealName(),
$expression
);
}
}
25 changes: 20 additions & 5 deletions optimizers/PhalconEscapeCssOptimizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ public function optimize(array $expression, Call $call, CompilationContext $cont
}

if (count($expression['parameters']) != 1) {
throw new CompilerException("phalcon_escape_css only accepts one parameter", $expression);
throw new CompilerException(
"phalcon_escape_css only accepts one parameter",
$expression
);
}

/**
Expand All @@ -50,6 +53,7 @@ public function optimize(array $expression, Call $call, CompilationContext $cont
$call->processExpectedReturn($context);

$symbolVariable = $call->getSymbolVariable();

if ($symbolVariable->getType() != 'variable') {
throw new CompilerException(
"Returned values by functions can only be assigned to variant variables",
Expand All @@ -63,9 +67,20 @@ public function optimize(array $expression, Call $call, CompilationContext $cont

$context->headersManager->add('kernel/filter');

$resolvedParams = $call->getResolvedParams($expression['parameters'], $context, $expression);
$context->codePrinter->output('zephir_escape_css(' . $symbolVariable->getName() . ', ' . $resolvedParams[0] . ');');
return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression);
}
$resolvedParams = $call->getResolvedParams(
$expression['parameters'],
$context,
$expression
);

$context->codePrinter->output(
'zephir_escape_css(' . $symbolVariable->getName() . ', ' . $resolvedParams[0] . ');'
);

return new CompiledExpression(
'variable',
$symbolVariable->getRealName(),
$expression
);
}
}
30 changes: 23 additions & 7 deletions optimizers/PhalconEscapeJsOptimizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ class PhalconEscapeJsOptimizer extends OptimizerAbstract
*/
public function optimize(array $expression, Call $call, CompilationContext $context)
{

if (!isset($expression['parameters'])) {
return false;
}

if (count($expression['parameters']) != 1) {
throw new CompilerException("phalcon_escape_js only accepts one parameter", $expression);
throw new CompilerException(
"phalcon_escape_js only accepts one parameter",
$expression
);
}

/**
Expand All @@ -51,8 +53,12 @@ public function optimize(array $expression, Call $call, CompilationContext $cont
$call->processExpectedReturn($context);

$symbolVariable = $call->getSymbolVariable();

if ($symbolVariable->getType() != 'variable') {
throw new CompilerException("Returned values by functions can only be assigned to variant variables", $expression);
throw new CompilerException(
"Returned values by functions can only be assigned to variant variables",
$expression
);
}

if ($call->mustInitSymbolVariable()) {
Expand All @@ -61,12 +67,22 @@ public function optimize(array $expression, Call $call, CompilationContext $cont

$context->headersManager->add('kernel/filter');

$resolvedParams = $call->getResolvedParams($expression['parameters'], $context, $expression);
$resolvedParams = $call->getResolvedParams(
$expression['parameters'],
$context,
$expression
);

$symbol = $context->backend->getVariableCode($symbolVariable);
$context->codePrinter->output('zephir_escape_js(' . $symbol . ', ' . $resolvedParams[0] . ');');

return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression);
}
$context->codePrinter->output(
'zephir_escape_js(' . $symbol . ', ' . $resolvedParams[0] . ');'
);

return new CompiledExpression(
'variable',
$symbolVariable->getRealName(),
$expression
);
}
}
29 changes: 23 additions & 6 deletions optimizers/PhalconFilterAlphanumOptimizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ class PhalconFilterAlphanumOptimizer extends OptimizerAbstract
*/
public function optimize(array $expression, Call $call, CompilationContext $context)
{

if (!isset($expression['parameters'])) {
return false;
}

if (count($expression['parameters']) != 1) {
throw new CompilerException("phalcon_filter_alphanum only accepts one parameter", $expression);
throw new CompilerException(
"phalcon_filter_alphanum only accepts one parameter",
$expression
);
}

/**
Expand All @@ -45,8 +47,12 @@ public function optimize(array $expression, Call $call, CompilationContext $cont
$call->processExpectedReturn($context);

$symbolVariable = $call->getSymbolVariable();

if ($symbolVariable->getType() != 'variable') {
throw new CompilerException("Returned values by functions can only be assigned to variant variables", $expression);
throw new CompilerException(
"Returned values by functions can only be assigned to variant variables",
$expression
);
}

if ($call->mustInitSymbolVariable()) {
Expand All @@ -55,11 +61,22 @@ public function optimize(array $expression, Call $call, CompilationContext $cont

$context->headersManager->add('kernel/filter');

$resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression);
$resolvedParams = $call->getReadOnlyResolvedParams(
$expression['parameters'],
$context,
$expression
);

$symbol = $context->backend->getVariableCode($symbolVariable);
$context->codePrinter->output('zephir_filter_alphanum(' . $symbol . ', ' . $resolvedParams[0] . ');');

return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression);
$context->codePrinter->output(
'zephir_filter_alphanum(' . $symbol . ', ' . $resolvedParams[0] . ');'
);

return new CompiledExpression(
'variable',
$symbolVariable->getRealName(),
$expression
);
}
}
21 changes: 17 additions & 4 deletions optimizers/PhalconFixPathOptimizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@ public function optimize(array $expression, Call $call, CompilationContext $cont
$call->processExpectedReturn($context);

$symbolVariable = $call->getSymbolVariable();

if ($symbolVariable->getType() != 'variable') {
throw new CompilerException("Returned values by functions can only be assigned to variant variables", $expression);
throw new CompilerException(
"Returned values by functions can only be assigned to variant variables",
$expression
);
}

if ($call->mustInitSymbolVariable()) {
Expand All @@ -56,9 +60,18 @@ public function optimize(array $expression, Call $call, CompilationContext $cont

$symbolVariable->setDynamicTypes('array');

$resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression);
$resolvedParams = $call->getReadOnlyResolvedParams(
$expression['parameters'],
$context,
$expression
);

//$context->codePrinter->output('zephir_fast_array_merge(' . $symbolVariable->getName() . ', &(' . $resolvedParams[0] . '), &(' . $resolvedParams[1] . ') TSRMLS_CC);');
return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression);
}

return new CompiledExpression(
'variable',
$symbolVariable->getRealName(),
$expression
);
}
}
36 changes: 27 additions & 9 deletions optimizers/PhalconGetUriOptimizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

class PhalconGetUriOptimizer extends OptimizerAbstract
{

/**
* @param array $expression
* @param Call $call
Expand All @@ -32,13 +31,15 @@ class PhalconGetUriOptimizer extends OptimizerAbstract
*/
public function optimize(array $expression, Call $call, CompilationContext $context)
{

if (!isset($expression['parameters'])) {
return false;
}

if (count($expression['parameters']) != 1) {
throw new CompilerException("phalcon_get_uri only accepts three parameter", $expression);
throw new CompilerException(
"phalcon_get_uri only accepts three parameter",
$expression
);
}

/**
Expand All @@ -47,22 +48,39 @@ public function optimize(array $expression, Call $call, CompilationContext $cont
$call->processExpectedReturn($context);

$symbolVariable = $call->getSymbolVariable();

if ($symbolVariable->getType() != 'variable') {
throw new CompilerException("Returned values by functions can only be assigned to variant variables", $expression);
throw new CompilerException(
"Returned values by functions can only be assigned to variant variables",
$expression
);
}

if ($call->mustInitSymbolVariable()) {
$symbolVariable->initVariant($context);
}

$context->headersManager->add('phalcon/url/utils', HeadersManager::POSITION_LAST);
$context->headersManager->add(
'phalcon/url/utils',
HeadersManager::POSITION_LAST
);

$resolvedParams = $call->getResolvedParams($expression['parameters'], $context, $expression);
$resolvedParams = $call->getResolvedParams(
$expression['parameters'],
$context,
$expression
);

$symbol = $context->backend->getVariableCode($symbolVariable);
$context->codePrinter->output('phalcon_get_uri(' . $symbol . ', ' . $resolvedParams[0] . ');');

return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression);
}
$context->codePrinter->output(
'phalcon_get_uri(' . $symbol . ', ' . $resolvedParams[0] . ');'
);

return new CompiledExpression(
'variable',
$symbolVariable->getRealName(),
$expression
);
}
}
31 changes: 23 additions & 8 deletions optimizers/PhalconIsBasicCharsetOptimizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

class PhalconIsBasicCharsetOptimizer extends OptimizerAbstract
{

/**
* @param array $expression
* @param Call $call
Expand All @@ -31,13 +30,15 @@ class PhalconIsBasicCharsetOptimizer extends OptimizerAbstract
*/
public function optimize(array $expression, Call $call, CompilationContext $context)
{

if (!isset($expression['parameters'])) {
return false;
}

if (count($expression['parameters']) != 1) {
throw new CompilerException("phalcon_is_basic_charset only accepts one parameter", $expression);
throw new CompilerException(
"phalcon_is_basic_charset only accepts one parameter",
$expression
);
}

/**
Expand All @@ -46,8 +47,12 @@ public function optimize(array $expression, Call $call, CompilationContext $cont
$call->processExpectedReturn($context);

$symbolVariable = $call->getSymbolVariable();

if ($symbolVariable->getType() != 'variable') {
throw new CompilerException("Returned values by functions can only be assigned to variant variables", $expression);
throw new CompilerException(
"Returned values by functions can only be assigned to variant variables",
$expression
);
}

if ($call->mustInitSymbolVariable()) {
Expand All @@ -56,12 +61,22 @@ public function optimize(array $expression, Call $call, CompilationContext $cont

$context->headersManager->add('kernel/filter');

$resolvedParams = $call->getResolvedParams($expression['parameters'], $context, $expression);
$resolvedParams = $call->getResolvedParams(
$expression['parameters'],
$context,
$expression
);

$symbol = $context->backend->getVariableCode($symbolVariable);
$context->codePrinter->output('zephir_is_basic_charset(' . $symbol . ', ' . $resolvedParams[0] . ');');

return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression);
}
$context->codePrinter->output(
'zephir_is_basic_charset(' . $symbol . ', ' . $resolvedParams[0] . ');'
);

return new CompiledExpression(
'variable',
$symbolVariable->getRealName(),
$expression
);
}
}
Loading

0 comments on commit ba010c9

Please sign in to comment.