Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed pointless property and variables from Volt compiler #13925

Merged
merged 3 commits into from
Apr 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG-4.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
## Fixed
- Fixed `Mvc\Collection::isInitialized()` now works as intended.

## Removed
- Removed `arrayHelpers` property from the Volt compiler. [#13925](https://github.com/phalcon/cphalcon/pull/13925)

# [4.0.0-alpha.4](https://github.com/phalcon/cphalcon/releases/tag/v4.0.0-alpha.4) (2019-03-31)
## Added
- Added `delimiter` and `enclosure` options to *Phalcon\Translate\Adapter\Csv* constructor
Expand Down
149 changes: 68 additions & 81 deletions phalcon/Mvc/View/Engine/Volt/Compiler.zep
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ use Phalcon\Mvc\View\Engine\Volt\Exception;
*/
class Compiler implements InjectionAwareInterface
{
protected arrayHelpers;
protected autoescape = false;
protected blockLevel = 0;
protected blocks;
Expand Down Expand Up @@ -107,8 +106,7 @@ class Compiler implements InjectionAwareInterface
*/
public function attributeReader(array! expr) -> string
{
var exprCode, left, leftType, variable,
level, container, leftCode, right;
var exprCode, left, leftType, variable, level, leftCode, right;

let exprCode = null;

Expand All @@ -130,8 +128,7 @@ class Compiler implements InjectionAwareInterface
/**
* Services registered in the dependency injector container are available always
*/
let container = this->container;
if typeof container == "object" && container->has(variable) {
if typeof this->container == "object" && this->container->has(variable) {
let exprCode .= "$this->" . variable;
} else {
let exprCode .= "$" . variable;
Expand Down Expand Up @@ -1525,7 +1522,7 @@ class Compiler implements InjectionAwareInterface
var code, funcArguments, arguments, nameExpr,
nameType, name, extensions, functions, definition,
extendedBlocks, block, currentBlock, exprLevel, escapedCode,
method, arrayHelpers, className;
method, arrayHelpers;

let code = null;

Expand Down Expand Up @@ -1642,98 +1639,88 @@ class Compiler implements InjectionAwareInterface
return "''";
}

let method = lcfirst(camelize(name)),
className = "Phalcon\\Tag";
let method = lcfirst(camelize(name));

let arrayHelpers = [
"link_to": true,
"image": true,
"form": true,
"submit_button": true,
"radio_field": true,
"check_field": true,
"file_field": true,
"hidden_field": true,
"password_field": true,
"text_area": true,
"text_field": true,
"email_field": true,
"date_field": true,
"tel_field": true,
"numeric_field": true,
"image_input": true
];

/**
* Check if it's a method in Phalcon\Tag
*/
if method_exists(className, method) {

let arrayHelpers = this->arrayHelpers;
if typeof arrayHelpers != "array" {
let arrayHelpers = [
"link_to": true,
"image": true,
"form": true,
"submit_button": true,
"radio_field": true,
"check_field": true,
"file_field": true,
"hidden_field": true,
"password_field": true,
"text_area": true,
"text_field": true,
"email_field": true,
"date_field": true,
"tel_field": true,
"numeric_field": true,
"image_input": true
];
let this->arrayHelpers = arrayHelpers;
}

if method_exists("Phalcon\\Tag", method) {
if isset arrayHelpers[name] {
return "$this->tag->" . method . "([" . arguments . "])";
}

return "$this->tag->" . method . "(" . arguments . ")";
}

/**
* The code below will be activated when Html\Tag is enabled
*/
/**
let className = "Phalcon\\Html\\Tag";

if method_exists(className, method) {
let arrayHelpers = this->arrayHelpers;
if typeof arrayHelpers != "array" {
let arrayHelpers = [
"button_submit" : true.
"element" : true.
"element_close" : true.
"end_form" : true.
"form" : true.
"friendly_title" : true.
"get_doc_type" : true.
"get_title" : true.
"get_title_separator" : true.
"image" : true.
"input_checkbox" : true.
"input_color" : true.
"input_date" : true.
"input_date_time" : true.
"input_date_time_local" : true.
"input_email" : true.
"input_file" : true.
"input_hidden" : true.
"input_image" : true.
"input_month" : true.
"input_numeric" : true.
"input_password" : true.
"input_radio" : true.
"input_range" : true.
"input_search" : true.
"input_tel" : true.
"input_text" : true.
"input_time" : true.
"input_url" : true.
"input_week" : true.
"javascript" : true.
"link" : true.
"prepend_title" : true.
"render_title" : true.
"select" : true.
"stylesheet" : true.
"submit" : true.
"text_area" : true.
];
let this->arrayHelpers = arrayHelpers;
}

let arrayHelpers = [
"button_submit" : true.
"element" : true.
"element_close" : true.
"end_form" : true.
"form" : true.
"friendly_title" : true.
"get_doc_type" : true.
"get_title" : true.
"get_title_separator" : true.
"image" : true.
"input_checkbox" : true.
"input_color" : true.
"input_date" : true.
"input_date_time" : true.
"input_date_time_local" : true.
"input_email" : true.
"input_file" : true.
"input_hidden" : true.
"input_image" : true.
"input_month" : true.
"input_numeric" : true.
"input_password" : true.
"input_radio" : true.
"input_range" : true.
"input_search" : true.
"input_tel" : true.
"input_text" : true.
"input_time" : true.
"input_url" : true.
"input_week" : true.
"javascript" : true.
"link" : true.
"prepend_title" : true.
"render_title" : true.
"select" : true.
"stylesheet" : true.
"submit" : true.
"text_area" : true.
];

if method_exists("Phalcon\\Html\\Tag", method) {
if isset arrayHelpers[name] {
return "$this->tag->" . method . "([" . arguments . "])";
}

return "$this->tag->" . method . "(" . arguments . ")";
}
*/
Expand Down