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

[5.4] Remove unused parameters and improve variable interpolation #17554

Merged
merged 3 commits into from
Jan 26, 2017
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
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,19 @@ protected function compileElsecannot($expression)
/**
* Compile the end-can statements into valid PHP.
*
* @param string $expression
* @return string
*/
protected function compileEndcan($expression)
protected function compileEndcan()
{
return '<?php endif; ?>';
}

/**
* Compile the end-cannot statements into valid PHP.
*
* @param string $expression
* @return string
*/
protected function compileEndcannot($expression)
protected function compileEndcannot()
{
return '<?php endif; ?>';
}
Expand Down
6 changes: 2 additions & 4 deletions src/Illuminate/View/Compilers/Concerns/CompilesComponents.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ protected function compileComponent($expression)
/**
* Compile the end-component statements into valid PHP.
*
* @param string $expression
* @return string
*/
protected function compileEndComponent($expression)
protected function compileEndComponent()
{
return '<?php echo $__env->renderComponent(); ?>';
}
Expand All @@ -40,10 +39,9 @@ protected function compileSlot($expression)
/**
* Compile the end-slot statements into valid PHP.
*
* @param string $expression
* @return string
*/
protected function compileEndSlot($expression)
protected function compileEndSlot()
{
return '<?php $__env->endSlot(); ?>';
}
Expand Down
11 changes: 4 additions & 7 deletions src/Illuminate/View/Compilers/Concerns/CompilesConditionals.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected function compileIf($expression)
*/
protected function compileUnless($expression)
{
return "<?php if (! $expression): ?>";
return "<?php if (! {$expression}): ?>";
}

/**
Expand All @@ -51,32 +51,29 @@ protected function compileElseif($expression)
/**
* Compile the else statements into valid PHP.
*
* @param string $expression
* @return string
*/
protected function compileElse($expression)
protected function compileElse()
{
return '<?php else: ?>';
}

/**
* Compile the end-if statements into valid PHP.
*
* @param string $expression
* @return string
*/
protected function compileEndif($expression)
protected function compileEndif()
{
return '<?php endif; ?>';
}

/**
* Compile the end-unless statements into valid PHP.
*
* @param string $expression
* @return string
*/
protected function compileEndunless($expression)
protected function compileEndunless()
{
return '<?php endif; ?>';
}
Expand Down
6 changes: 3 additions & 3 deletions src/Illuminate/View/Compilers/Concerns/CompilesEchos.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected function compileRawEchos($value)
$callback = function ($matches) {
$whitespace = empty($matches[3]) ? '' : $matches[3].$matches[3];

return $matches[1] ? substr($matches[0], 1) : '<?php echo '.$this->compileEchoDefaults($matches[2]).'; ?>'.$whitespace;
return $matches[1] ? substr($matches[0], 1) : "<?php echo {$this->compileEchoDefaults($matches[2])}; ?>{$whitespace}";
};

return preg_replace_callback($pattern, $callback, $value);
Expand All @@ -67,7 +67,7 @@ protected function compileRegularEchos($value)

$wrapped = sprintf($this->echoFormat, $this->compileEchoDefaults($matches[2]));

return $matches[1] ? substr($matches[0], 1) : '<?php echo '.$wrapped.'; ?>'.$whitespace;
return $matches[1] ? substr($matches[0], 1) : "<?php echo {$wrapped}; ?>{$whitespace}";
};

return preg_replace_callback($pattern, $callback, $value);
Expand All @@ -86,7 +86,7 @@ protected function compileEscapedEchos($value)
$callback = function ($matches) {
$whitespace = empty($matches[3]) ? '' : $matches[3].$matches[3];

return $matches[1] ? $matches[0] : '<?php echo e('.$this->compileEchoDefaults($matches[2]).'); ?>'.$whitespace;
return $matches[1] ? $matches[0] : "<?php echo e({$this->compileEchoDefaults($matches[2])}); ?>{$whitespace}";
};

return preg_replace_callback($pattern, $callback, $value);
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/View/Compilers/Concerns/CompilesIncludes.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected function compileInclude($expression)
{
$expression = $this->stripParentheses($expression);

return "<?php echo \$__env->make($expression, array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>";
return "<?php echo \$__env->make({$expression}, array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>";
}

/**
Expand All @@ -38,6 +38,6 @@ protected function compileIncludeIf($expression)
{
$expression = $this->stripParentheses($expression);

return "<?php if (\$__env->exists($expression)) echo \$__env->make($expression, array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>";
return "<?php if (\$__env->exists({$expression})) echo \$__env->make({$expression}, array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ protected function compileInject($expression)
{
$segments = explode(',', preg_replace("/[\(\)\\\"\']/", '', $expression));

return '<?php $'.trim($segments[0])." = app('".trim($segments[1])."'); ?>";
$variable = trim($segments[0]);

$service = trim($segments[1]);

return "<?php \${$variable} = app('{$service}'); ?>";
}
}
17 changes: 6 additions & 11 deletions src/Illuminate/View/Compilers/Concerns/CompilesLayouts.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected function compileExtends($expression)
{
$expression = $this->stripParentheses($expression);

$echo = "<?php echo \$__env->make($expression, array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>";
$echo = "<?php echo \$__env->make({$expression}, array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>";

$this->footer[] = $echo;

Expand Down Expand Up @@ -67,54 +67,49 @@ protected function compileYield($expression)
/**
* Compile the show statements into valid PHP.
*
* @param string $expression
* @return string
*/
protected function compileShow($expression)
protected function compileShow()
{
return '<?php echo $__env->yieldSection(); ?>';
}

/**
* Compile the append statements into valid PHP.
*
* @param string $expression
* @return string
*/
protected function compileAppend($expression)
protected function compileAppend()
{
return '<?php $__env->appendSection(); ?>';
}

/**
* Compile the overwrite statements into valid PHP.
*
* @param string $expression
* @return string
*/
protected function compileOverwrite($expression)
protected function compileOverwrite()
{
return '<?php $__env->stopSection(true); ?>';
}

/**
* Compile the stop statements into valid PHP.
*
* @param string $expression
* @return string
*/
protected function compileStop($expression)
protected function compileStop()
{
return '<?php $__env->stopSection(); ?>';
}

/**
* Compile the end-section statements into valid PHP.
*
* @param string $expression
* @return string
*/
protected function compileEndsection($expression)
protected function compileEndsection()
{
return '<?php $__env->stopSection(); ?>';
}
Expand Down
15 changes: 5 additions & 10 deletions src/Illuminate/View/Compilers/Concerns/CompilesLoops.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ protected function compileForelse($expression)
/**
* Compile the for-else-empty statements into valid PHP.
*
* @param string $expression
* @return string
*/
protected function compileEmpty($expression)
protected function compileEmpty()
{
$empty = '$__empty_'.$this->forElseCounter--;

Expand All @@ -50,10 +49,9 @@ protected function compileEmpty($expression)
/**
* Compile the end-for-else statements into valid PHP.
*
* @param string $expression
* @return string
*/
protected function compileEndforelse($expression)
protected function compileEndforelse()
{
return '<?php endif; ?>';
}
Expand Down Expand Up @@ -115,21 +113,19 @@ protected function compileContinue($expression)
/**
* Compile the end-for statements into valid PHP.
*
* @param string $expression
* @return string
*/
protected function compileEndfor($expression)
protected function compileEndfor()
{
return '<?php endfor; ?>';
}

/**
* Compile the end-for-each statements into valid PHP.
*
* @param string $expression
* @return string
*/
protected function compileEndforeach($expression)
protected function compileEndforeach()
{
return '<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>';
}
Expand All @@ -148,10 +144,9 @@ protected function compileWhile($expression)
/**
* Compile the end-while statements into valid PHP.
*
* @param string $expression
* @return string
*/
protected function compileEndwhile($expression)
protected function compileEndwhile()
{
return '<?php endwhile; ?>';
}
Expand Down
3 changes: 1 addition & 2 deletions src/Illuminate/View/Compilers/Concerns/CompilesRawPhp.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ protected function compilePhp($expression)
/**
* Compile end-php statements into valid PHP.
*
* @param string $expression
* @return string
*/
protected function compileEndphp($expression)
protected function compileEndphp()
{
return ' ?>';
}
Expand Down
3 changes: 1 addition & 2 deletions src/Illuminate/View/Compilers/Concerns/CompilesStacks.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ protected function compilePush($expression)
/**
* Compile the end-push statements into valid PHP.
*
* @param string $expression
* @return string
*/
protected function compileEndpush($expression)
protected function compileEndpush()
{
return '<?php $__env->stopPush(); ?>';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ protected function compileLang($expression)
} elseif ($expression[1] === '[') {
return "<?php \$__env->startTranslation{$expression}; ?>";
} else {
return "<?php echo app('translator')->get$expression; ?>";
return "<?php echo app('translator')->get{$expression}; ?>";
}
}

Expand All @@ -39,6 +39,6 @@ protected function compileEndlang()
*/
protected function compileChoice($expression)
{
return "<?php echo app('translator')->choice$expression; ?>";
return "<?php echo app('translator')->choice{$expression}; ?>";
}
}