-
-
Notifications
You must be signed in to change notification settings - Fork 468
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' into #2255-php8.1
- Loading branch information
Showing
23 changed files
with
333 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ on: | |
- development | ||
|
||
env: | ||
ZEPHIR_PARSER_VERSION: v1.3.6 | ||
ZEPHIR_PARSER_VERSION: v1.3.8 | ||
|
||
jobs: | ||
linux: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Zephir. | ||
* | ||
* (c) Phalcon Team <team@zephir-lang.com> | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Zephir\Operators\Other; | ||
|
||
use Zephir\CompilationContext; | ||
use Zephir\CompiledExpression; | ||
use Zephir\Exception; | ||
use Zephir\Expression; | ||
use Zephir\Operators\BaseOperator; | ||
|
||
/** | ||
* Require once. | ||
* | ||
* Includes once a plain PHP file | ||
*/ | ||
class RequireOnceOperator extends BaseOperator | ||
{ | ||
/** | ||
* @param array $expression | ||
* @param CompilationContext $compilationContext | ||
* | ||
* @return CompiledExpression | ||
* @throws Exception | ||
*/ | ||
public function compile(array $expression, CompilationContext $compilationContext): CompiledExpression | ||
{ | ||
$expr = new Expression($expression['left']); | ||
$expr->setReadOnly(true); | ||
$expr->setExpectReturn(true); | ||
|
||
$exprPath = $expr->compile($compilationContext); | ||
if ('variable' === $exprPath->getType()) { | ||
$exprVariable = $compilationContext->symbolTable->getVariableForRead($exprPath->getCode(), $compilationContext, $expression); | ||
$exprVar = $compilationContext->backend->getVariableCode($exprVariable); | ||
if ('variable' === $exprVariable->getType()) { | ||
if ($exprVariable->hasDifferentDynamicType(['undefined', 'string'])) { | ||
$compilationContext->logger->warning( | ||
'Possible attempt to use invalid type as path in "require_once" operator', | ||
['non-valid-require-once', $expression] | ||
); | ||
} | ||
} | ||
} else { | ||
$exprVar = $compilationContext->symbolTable->getTempVariableForWrite('variable', $compilationContext, $expression); | ||
$compilationContext->backend->assignString($exprVar, $exprPath->getCode(), $compilationContext); | ||
$exprVar = $compilationContext->backend->getVariableCode($exprVar); | ||
} | ||
|
||
$symbolVariable = false; | ||
if ($this->isExpecting()) { | ||
$symbolVariable = $compilationContext->symbolTable->getTempVariableForObserveOrNullify('variable', $compilationContext); | ||
} | ||
|
||
$compilationContext->headersManager->add('kernel/memory'); | ||
$compilationContext->headersManager->add('kernel/require'); | ||
|
||
$codePrinter = $compilationContext->codePrinter; | ||
|
||
if ($symbolVariable) { | ||
$codePrinter->output('ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(&'.$symbolVariable->getName().');'); | ||
$symbol = $compilationContext->backend->getVariableCodePointer($symbolVariable); | ||
$codePrinter->output('if (zephir_require_once_zval_ret('.$symbol.', '.$exprVar.') == FAILURE) {'); | ||
} else { | ||
$codePrinter->output('if (zephir_require_once_zval('.$exprVar.') == FAILURE) {'); | ||
} | ||
$codePrinter->output("\t".'RETURN_MM_NULL();'); | ||
$codePrinter->output('}'); | ||
|
||
if ($symbolVariable) { | ||
return new CompiledExpression('variable', $symbolVariable->getName(), $expression); | ||
} | ||
|
||
return new CompiledExpression('null', null, $expression); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Zephir. | ||
* | ||
* (c) Phalcon Team <team@zephir-lang.com> | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Zephir\Statements; | ||
|
||
use Zephir\CompilationContext; | ||
use Zephir\Exception; | ||
use Zephir\Expression; | ||
|
||
/** | ||
* RequireOnceStatement. | ||
* | ||
* Require once statement is used to execute PHP scripts in a given path | ||
*/ | ||
class RequireOnceStatement extends StatementAbstract | ||
{ | ||
/** | ||
* @param CompilationContext $compilationContext | ||
* | ||
* @throws Exception | ||
*/ | ||
public function compile(CompilationContext $compilationContext) | ||
{ | ||
$expression = [ | ||
'type' => 'require_once', | ||
'left' => $this->statement['expr'], | ||
'file' => $this->statement['file'], | ||
'line' => $this->statement['line'], | ||
'char' => $this->statement['char'], | ||
]; | ||
|
||
$expr = new Expression($expression); | ||
$expr->setExpectReturn(false, null); | ||
$expr->compile($compilationContext); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.