updated-packages

This commit is contained in:
RafficMohammed
2023-01-08 00:13:22 +05:30
parent 3ff7df7487
commit da241bacb6
12659 changed files with 563377 additions and 510538 deletions

View File

@@ -4,6 +4,7 @@ namespace Illuminate\View\Compilers;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use InvalidArgumentException;
class BladeCompiler extends Compiler implements CompilerInterface
{
@@ -12,6 +13,7 @@ class BladeCompiler extends Compiler implements CompilerInterface
Concerns\CompilesComponents,
Concerns\CompilesConditionals,
Concerns\CompilesEchos,
Concerns\CompilesErrors,
Concerns\CompilesHelpers,
Concerns\CompilesIncludes,
Concerns\CompilesInjections,
@@ -107,7 +109,7 @@ class BladeCompiler extends Compiler implements CompilerInterface
/**
* Compile the view at the given path.
*
* @param string $path
* @param string|null $path
* @return void
*/
public function compile($path = null)
@@ -117,12 +119,44 @@ class BladeCompiler extends Compiler implements CompilerInterface
}
if (! is_null($this->cachePath)) {
$contents = $this->compileString($this->files->get($this->getPath()));
$contents = $this->compileString(
$this->files->get($this->getPath())
);
$this->files->put($this->getCompiledPath($this->getPath()), $contents);
if (! empty($this->getPath())) {
$tokens = $this->getOpenAndClosingPhpTokens($contents);
// If the tokens we retrieved from the compiled contents have at least
// one opening tag and if that last token isn't the closing tag, we
// need to close the statement before adding the path at the end.
if ($tokens->isNotEmpty() && $tokens->last() !== T_CLOSE_TAG) {
$contents .= ' ?>';
}
$contents .= "<?php /**PATH {$this->getPath()} ENDPATH**/ ?>";
}
$this->files->put(
$this->getCompiledPath($this->getPath()), $contents
);
}
}
/**
* Get the open and closing PHP tag tokens from the given string.
*
* @param string $contents
* @return \Illuminate\Support\Collection
*/
protected function getOpenAndClosingPhpTokens($contents)
{
return collect(token_get_all($contents))
->pluck($tokenNumber = 0)
->filter(function ($token) {
return in_array($token, [T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO, T_CLOSE_TAG]);
});
}
/**
* Get the path currently being compiled.
*
@@ -272,7 +306,7 @@ class BladeCompiler extends Compiler implements CompilerInterface
*/
protected function parseToken($token)
{
list($id, $content) = $token;
[$id, $content] = $token;
if ($id == T_INLINE_HTML) {
foreach ($this->compilers as $type) {
@@ -428,12 +462,12 @@ class BladeCompiler extends Compiler implements CompilerInterface
* Register a component alias directive.
*
* @param string $path
* @param string $alias
* @param string|null $alias
* @return void
*/
public function component($path, $alias = null)
{
$alias = $alias ?: array_last(explode('.', $path));
$alias = $alias ?: Arr::last(explode('.', $path));
$this->directive($alias, function ($expression) use ($path) {
return $expression
@@ -450,17 +484,17 @@ class BladeCompiler extends Compiler implements CompilerInterface
* Register an include alias directive.
*
* @param string $path
* @param string $alias
* @param string|null $alias
* @return void
*/
public function include($path, $alias = null)
{
$alias = $alias ?: array_last(explode('.', $path));
$alias = $alias ?: Arr::last(explode('.', $path));
$this->directive($alias, function ($expression) use ($path) {
$expression = $this->stripParentheses($expression) ?: '[]';
return "<?php echo \$__env->make('{$path}', {$expression}, array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>";
return "<?php echo \$__env->make('{$path}', {$expression}, \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>";
});
}
@@ -473,6 +507,10 @@ class BladeCompiler extends Compiler implements CompilerInterface
*/
public function directive($name, callable $handler)
{
if (! preg_match('/^\w+(?:::\w+)?$/x', $name)) {
throw new InvalidArgumentException("The directive name [{$name}] is not valid. Directive names must only contain alphanumeric characters and underscores.");
}
$this->customDirectives[$name] = $handler;
}

View File

@@ -45,4 +45,25 @@ trait CompilesComponents
{
return '<?php $__env->endSlot(); ?>';
}
/**
* Compile the component-first statements into valid PHP.
*
* @param string $expression
* @return string
*/
protected function compileComponentFirst($expression)
{
return "<?php \$__env->startComponentFirst{$expression}; ?>";
}
/**
* Compile the end-component-first statements into valid PHP.
*
* @return string
*/
protected function compileEndComponentFirst()
{
return $this->compileEndComponent();
}
}

View File

@@ -46,7 +46,7 @@ trait CompilesEchos
$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 {$matches[2]}; ?>{$whitespace}";
};
return preg_replace_callback($pattern, $callback, $value);
@@ -65,7 +65,7 @@ trait CompilesEchos
$callback = function ($matches) {
$whitespace = empty($matches[3]) ? '' : $matches[3].$matches[3];
$wrapped = sprintf($this->echoFormat, $this->compileEchoDefaults($matches[2]));
$wrapped = sprintf($this->echoFormat, $matches[2]);
return $matches[1] ? substr($matches[0], 1) : "<?php echo {$wrapped}; ?>{$whitespace}";
};
@@ -86,20 +86,9 @@ trait CompilesEchos
$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({$matches[2]}); ?>{$whitespace}";
};
return preg_replace_callback($pattern, $callback, $value);
}
/**
* Compile the default values for the echo statement.
*
* @param string $value
* @return string
*/
public function compileEchoDefaults($value)
{
return preg_replace('/^(?=\$)(.+?)(?:\s+or\s+)(.+?)$/si', 'isset($1) ? $1 : $2', $value);
}
}

View File

@@ -0,0 +1,34 @@
<?php
namespace Illuminate\View\Compilers\Concerns;
trait CompilesErrors
{
/**
* Compile the error statements into valid PHP.
*
* @param string $expression
* @return string
*/
protected function compileError($expression)
{
$expression = $this->stripParentheses($expression);
return '<?php if ($errors->has('.$expression.')) :
if (isset($message)) { $messageCache = $message; }
$message = $errors->first('.$expression.'); ?>';
}
/**
* Compile the enderror statements into valid PHP.
*
* @param string $expression
* @return string
*/
protected function compileEnderror($expression)
{
return '<?php unset($message);
if (isset($messageCache)) { $message = $messageCache; }
endif; ?>';
}
}

View File

@@ -25,7 +25,7 @@ trait CompilesIncludes
{
$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}, \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>";
}
/**
@@ -38,7 +38,7 @@ trait CompilesIncludes
{
$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}, \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>";
}
/**
@@ -51,7 +51,7 @@ trait CompilesIncludes
{
$expression = $this->stripParentheses($expression);
return "<?php echo \$__env->renderWhen($expression, array_except(get_defined_vars(), array('__data', '__path'))); ?>";
return "<?php echo \$__env->renderWhen($expression, \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path'])); ?>";
}
/**
@@ -64,6 +64,6 @@ trait CompilesIncludes
{
$expression = $this->stripParentheses($expression);
return "<?php echo \$__env->first({$expression}, array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>";
return "<?php echo \$__env->first({$expression}, \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>";
}
}

View File

@@ -23,7 +23,7 @@ trait CompilesLayouts
{
$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}, \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>";
$this->footer[] = $echo;

View File

@@ -2,6 +2,7 @@
namespace Illuminate\View\Concerns;
use Illuminate\Support\Arr;
use Illuminate\Support\HtmlString;
trait ManagesComponents
@@ -52,6 +53,22 @@ trait ManagesComponents
}
}
/**
* Get the first view that actually exists from the given list, and start a component.
*
* @param array $names
* @param array $data
* @return void
*/
public function startComponentFirst(array $names, array $data = [])
{
$name = Arr::first($names, function ($item) {
return $this->exists($item);
});
$this->startComponent($name, $data);
}
/**
* Render the current component.
*

View File

@@ -115,7 +115,7 @@ trait ManagesEvents
*/
protected function buildClassEventCallback($class, $prefix)
{
list($class, $method) = $this->parseClassEvent($class, $prefix);
[$class, $method] = $this->parseClassEvent($class, $prefix);
// Once we have the class and method name, we can build the Closure to resolve
// the instance out of the IoC container and call the method on it with the

View File

@@ -77,6 +77,7 @@ trait ManagesLayouts
*
* @param bool $overwrite
* @return string
*
* @throws \InvalidArgumentException
*/
public function stopSection($overwrite = false)
@@ -100,6 +101,7 @@ trait ManagesLayouts
* Stop injecting content into a section and append it.
*
* @return string
*
* @throws \InvalidArgumentException
*/
public function appendSection()
@@ -187,7 +189,7 @@ trait ManagesLayouts
* Get the contents of a section.
*
* @param string $name
* @param string $default
* @param string|null $default
* @return mixed
*/
public function getSection($name, $default = null)

View File

@@ -33,6 +33,8 @@ trait ManagesLoops
'count' => $length,
'first' => true,
'last' => isset($length) ? $length == 1 : null,
'odd' => false,
'even' => true,
'depth' => count($this->loopsStack) + 1,
'parent' => $parent ? (object) $parent : null,
];
@@ -51,6 +53,8 @@ trait ManagesLoops
'iteration' => $loop['iteration'] + 1,
'index' => $loop['iteration'],
'first' => $loop['iteration'] == 0,
'odd' => ! $loop['odd'],
'even' => ! $loop['even'],
'remaining' => isset($loop['count']) ? $loop['remaining'] - 1 : null,
'last' => isset($loop['count']) ? $loop['iteration'] == $loop['count'] - 1 : null,
]);

View File

@@ -49,6 +49,7 @@ trait ManagesStacks
* Stop injecting content into a push section.
*
* @return string
*
* @throws \InvalidArgumentException
*/
public function stopPush()
@@ -104,6 +105,7 @@ trait ManagesStacks
* Stop prepending content into a push section.
*
* @return string
*
* @throws \InvalidArgumentException
*/
public function stopPrepend()

View File

@@ -42,6 +42,7 @@ class EngineResolver
*
* @param string $engine
* @return \Illuminate\Contracts\View\Engine
*
* @throws \InvalidArgumentException
*/
public function resolve($engine)

View File

@@ -5,6 +5,7 @@ namespace Illuminate\View;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use InvalidArgumentException;
use Illuminate\Support\Traits\Macroable;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\View\Engines\EngineResolver;
@@ -13,7 +14,8 @@ use Illuminate\Contracts\View\Factory as FactoryContract;
class Factory implements FactoryContract
{
use Concerns\ManagesComponents,
use Macroable,
Concerns\ManagesComponents,
Concerns\ManagesEvents,
Concerns\ManagesLayouts,
Concerns\ManagesLoops,
@@ -64,6 +66,7 @@ class Factory implements FactoryContract
'blade.php' => 'blade',
'php' => 'php',
'css' => 'file',
'html' => 'file',
];
/**
@@ -101,7 +104,7 @@ class Factory implements FactoryContract
* Get the evaluated view contents for the given view.
*
* @param string $path
* @param array $data
* @param \Illuminate\Contracts\Support\Arrayable|array $data
* @param array $mergeData
* @return \Illuminate\Contracts\View\View
*/
@@ -118,7 +121,7 @@ class Factory implements FactoryContract
* Get the evaluated view contents for the given view.
*
* @param string $view
* @param array $data
* @param \Illuminate\Contracts\Support\Arrayable|array $data
* @param array $mergeData
* @return \Illuminate\Contracts\View\View
*/
@@ -142,7 +145,7 @@ class Factory implements FactoryContract
* Get the first view that actually exists from the given list.
*
* @param array $views
* @param array $data
* @param \Illuminate\Contracts\Support\Arrayable|array $data
* @param array $mergeData
* @return \Illuminate\Contracts\View\View
*
@@ -166,7 +169,7 @@ class Factory implements FactoryContract
*
* @param bool $condition
* @param string $view
* @param array $data
* @param \Illuminate\Contracts\Support\Arrayable|array $data
* @param array $mergeData
* @return string
*/
@@ -242,7 +245,7 @@ class Factory implements FactoryContract
*
* @param string $view
* @param string $path
* @param array $data
* @param \Illuminate\Contracts\Support\Arrayable|array $data
* @return \Illuminate\Contracts\View\View
*/
protected function viewInstance($view, $path, $data)
@@ -305,7 +308,7 @@ class Factory implements FactoryContract
* Add a piece of shared data to the environment.
*
* @param array|string $key
* @param mixed $value
* @param mixed|null $value
* @return mixed
*/
public function share($key, $value = null)
@@ -407,7 +410,7 @@ class Factory implements FactoryContract
*
* @param string $extension
* @param string $engine
* @param \Closure $resolver
* @param \Closure|null $resolver
* @return void
*/
public function addExtension($extension, $engine, $resolver = null)

View File

@@ -40,20 +40,20 @@ class FileViewFinder implements ViewFinderInterface
*
* @var array
*/
protected $extensions = ['blade.php', 'php', 'css'];
protected $extensions = ['blade.php', 'php', 'css', 'html'];
/**
* Create a new file view loader instance.
*
* @param \Illuminate\Filesystem\Filesystem $files
* @param array $paths
* @param array $extensions
* @param array|null $extensions
* @return void
*/
public function __construct(Filesystem $files, array $paths, array $extensions = null)
{
$this->files = $files;
$this->paths = $paths;
$this->paths = array_map([$this, 'resolvePath'], $paths);
if (isset($extensions)) {
$this->extensions = $extensions;
@@ -87,7 +87,7 @@ class FileViewFinder implements ViewFinderInterface
*/
protected function findNamespacedView($name)
{
list($namespace, $view) = $this->parseNamespaceSegments($name);
[$namespace, $view] = $this->parseNamespaceSegments($name);
return $this->findInPaths($view, $this->hints[$namespace]);
}
@@ -158,7 +158,7 @@ class FileViewFinder implements ViewFinderInterface
*/
public function addLocation($location)
{
$this->paths[] = $location;
$this->paths[] = $this->resolvePath($location);
}
/**
@@ -169,7 +169,18 @@ class FileViewFinder implements ViewFinderInterface
*/
public function prependLocation($location)
{
array_unshift($this->paths, $location);
array_unshift($this->paths, $this->resolvePath($location));
}
/**
* Resolve the path.
*
* @param string $path
* @return string
*/
protected function resolvePath($path)
{
return realpath($path) ?: $path;
}
/**
@@ -266,6 +277,19 @@ class FileViewFinder implements ViewFinderInterface
return $this->files;
}
/**
* Set the active view paths.
*
* @param array $paths
* @return $this
*/
public function setPaths($paths)
{
$this->paths = $paths;
return $this;
}
/**
* Get the active view paths.
*
@@ -276,6 +300,16 @@ class FileViewFinder implements ViewFinderInterface
return $this->paths;
}
/**
* Get the views that have been located.
*
* @return array
*/
public function getViews()
{
return $this->views;
}
/**
* Get the namespace to file path hints.
*

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Taylor Otwell
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -80,7 +80,7 @@ class View implements ArrayAccess, ViewContract
* Get the string contents of the view.
*
* @param callable|null $callback
* @return string
* @return array|string
*
* @throws \Throwable
*/
@@ -147,7 +147,7 @@ class View implements ArrayAccess, ViewContract
*
* @return array
*/
protected function gatherData()
public function gatherData()
{
$data = array_merge($this->factory->getShared(), $this->data);
@@ -163,7 +163,9 @@ class View implements ArrayAccess, ViewContract
/**
* Get the sections of the rendered view.
*
* @return string
* @return array
*
* @throws \Throwable
*/
public function renderSections()
{
@@ -382,7 +384,7 @@ class View implements ArrayAccess, ViewContract
* Remove a piece of bound data from the view.
*
* @param string $key
* @return bool
* @return void
*/
public function __unset($key)
{
@@ -417,6 +419,8 @@ class View implements ArrayAccess, ViewContract
* Get the string contents of the view.
*
* @return string
*
* @throws \Throwable
*/
public function __toString()
{

View File

@@ -50,7 +50,7 @@ interface ViewFinderInterface
*
* @param string $namespace
* @param string|array $hints
* @return $this
* @return void
*/
public function replaceNamespace($namespace, $hints);

View File

@@ -18,7 +18,7 @@ class ViewName
return str_replace('/', '.', $name);
}
list($namespace, $name) = explode($delimiter, $name);
[$namespace, $name] = explode($delimiter, $name);
return $namespace.$delimiter.str_replace('/', '.', $name);
}

View File

@@ -15,12 +15,13 @@
],
"require": {
"php": "^7.1.3",
"illuminate/container": "5.6.*",
"illuminate/contracts": "5.6.*",
"illuminate/events": "5.6.*",
"illuminate/filesystem": "5.6.*",
"illuminate/support": "5.6.*",
"symfony/debug": "~4.0"
"ext-json": "*",
"illuminate/container": "5.8.*",
"illuminate/contracts": "5.8.*",
"illuminate/events": "5.8.*",
"illuminate/filesystem": "5.8.*",
"illuminate/support": "5.8.*",
"symfony/debug": "^4.2"
},
"autoload": {
"psr-4": {
@@ -29,7 +30,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "5.6-dev"
"dev-master": "5.8-dev"
}
},
"config": {