<?php $a = 2; ?> <?= $this->partial("path/view", ["a" => 1]) ?> <?= $a ?>
Surprisingly that prints 1, instead of 2, is this a feature? or a bug?
The local variables in the views behaves like globals
This in php7.0 and phalcon 3.x
Any solution other than preffixing the variables with the view name?
It adds a lot of work to name variables like
Why zephir is not executing the require as php does? (in the context of the method)
I am not sure if this is a bug in zephir or a "new feature"
This is not about require. This is about render:
As i told you, symbol tables where changed on php 7. There must be changes done to zephir in order to support what you want to achieve in php 7. On php 5.6 your code will work correctly. If you want you can create issue on zephir about this.
As I told you, it is a problem in the scopes (or the stack)
But https://github.com/phalcon/cphalcon/blob/master/phalcon/mvc/view/engine/php.zep#L49 is not setting them to the local scope.
2 possibles explanations: Zephir is setting locals as static locals or globals (because it is still referencing to the same value in memory, even if it is in a different function call.
Said this, this is a new not documented feature or a bug.
All of this, or
require doesn't execute in the function scope and execute in a global scope.
So, if a team member can confirm that indeed this is a bug, and not a feature, the bug can be created
As i already told you. This is because of PHP 7 and zephir. On PHP 5 it works fine. Just this https://github.com/phalcon/cphalcon/blob/master/phalcon/mvc/view.zep#L1073 is broken for php 7 and is not working correctly. Anyway, i will check it to be sure in home. But latest i was talking with some team member this symbol tables changes and not yet changed properly zephir is creating issue like yours.
Well btw anyway variables names like
$a is really bad :D
Yes, you are partially right. Like
view are bad names for a directory name and view name. But in the example context , those names are excellent ;) (Anyway, this is bikeshedding, I guess you were trolling)
Yes, I get the idea, it is creating the table. But in the zephir documentation is written this should happen anyway
All variables declared are locally scoped to the method where they were declared
or (the title refers to the local scope, but "current PHP symbol table", so aren't they the same?) https://docs.zephir-lang.com/en/latest/language.html#local-symbol-table