Laravel 5.6 updates

Travis config update

Removed HHVM script as Laravel no longer support HHVM after releasing 5.3
This commit is contained in:
Manish Verma
2018-08-06 20:08:55 +05:30
parent 126fbb0255
commit 1ac0f42a58
2464 changed files with 65239 additions and 46734 deletions

View File

@@ -74,6 +74,8 @@ class JavascriptRenderer
protected $ajaxHandlerBindToXHR = false;
protected $ajaxHandlerAutoShow = true;
protected $openHandlerClass = 'PhpDebugBar.OpenHandler';
protected $openHandlerUrl;
@@ -117,6 +119,7 @@ class JavascriptRenderer
* - ignore_collectors
* - ajax_handler_classname
* - ajax_handler_bind_to_jquery
* - ajax_handler_auto_show
* - open_handler_classname
* - open_handler_url
*
@@ -169,6 +172,9 @@ class JavascriptRenderer
if (array_key_exists('ajax_handler_bind_to_jquery', $options)) {
$this->setBindAjaxHandlerToJquery($options['ajax_handler_bind_to_jquery']);
}
if (array_key_exists('ajax_handler_auto_show', $options)) {
$this->setAjaxHandlerAutoShow($options['ajax_handler_auto_show']);
}
if (array_key_exists('open_handler_classname', $options)) {
$this->setOpenHandlerClass($options['open_handler_classname']);
}
@@ -513,6 +519,28 @@ class JavascriptRenderer
return $this->ajaxHandlerBindToXHR;
}
/**
* Sets whether new ajax debug data will be immediately shown. Setting to false could be useful
* if there are a lot of tracking events cluttering things.
*
* @param boolean $autoShow
*/
public function setAjaxHandlerAutoShow($autoShow = true)
{
$this->ajaxHandlerAutoShow = $autoShow;
return $this;
}
/**
* Checks whether the ajax handler will immediately show new ajax requests.
*
* @return boolean
*/
public function isAjaxHandlerAutoShow()
{
return $this->ajaxHandlerAutoShow;
}
/**
* Sets the class name of the js open handler
*
@@ -556,12 +584,13 @@ class JavascriptRenderer
}
/**
* Add assets to render in the head
* Add assets stored in files to render in the head
*
* @param array $cssFiles An array of filenames
* @param array $jsFiles An array of filenames
* @param string $basePath Base path of those files
* @param string $baseUrl Base url of those files
* @return $this
*/
public function addAssets($cssFiles, $jsFiles, $basePath = null, $baseUrl = null)
{
@@ -574,10 +603,37 @@ class JavascriptRenderer
return $this;
}
/**
* Add inline assets to render inline in the head. Ideally, you should store static assets in
* files that you add with the addAssets function. However, adding inline assets is useful when
* integrating with 3rd-party libraries that require static assets that are only available in an
* inline format.
*
* The inline content arrays require special string array keys: they are used to deduplicate
* content. This is particularly useful if multiple instances of the same asset end up being
* added. Inline assets from all collectors are merged together into the same array, so these
* content IDs effectively deduplicate the inline assets.
*
* @param array $inlineCss An array map of content ID to inline CSS content (not including <style> tag)
* @param array $inlineJs An array map of content ID to inline JS content (not including <script> tag)
* @param array $inlineHead An array map of content ID to arbitrary inline HTML content (typically
* <style>/<script> tags); it must be embedded within the <head> element
* @return $this
*/
public function addInlineAssets($inlineCss, $inlineJs, $inlineHead)
{
$this->additionalAssets[] = array(
'inline_css' => (array) $inlineCss,
'inline_js' => (array) $inlineJs,
'inline_head' => (array) $inlineHead
);
return $this;
}
/**
* Returns the list of asset files
*
* @param string $type Only return css or js files
* @param string $type 'css', 'js', 'inline_css', 'inline_js', 'inline_head', or null for all
* @param string $relativeTo The type of path to which filenames must be relative (path, url or null)
* @return array
*/
@@ -585,6 +641,9 @@ class JavascriptRenderer
{
$cssFiles = $this->cssFiles;
$jsFiles = $this->jsFiles;
$inlineCss = array();
$inlineJs = array();
$inlineHead = array();
if ($this->includeVendors !== false) {
if ($this->includeVendors === true || in_array('css', $this->includeVendors)) {
@@ -615,11 +674,29 @@ class JavascriptRenderer
$root = $this->getRelativeRoot($relativeTo,
$this->makeUriRelativeTo($basePath, $this->basePath),
$this->makeUriRelativeTo($baseUrl, $this->baseUrl));
$cssFiles = array_merge($cssFiles, $this->makeUriRelativeTo((array) $assets['css'], $root));
$jsFiles = array_merge($jsFiles, $this->makeUriRelativeTo((array) $assets['js'], $root));
if (isset($assets['css'])) {
$cssFiles = array_merge($cssFiles, $this->makeUriRelativeTo((array) $assets['css'], $root));
}
if (isset($assets['js'])) {
$jsFiles = array_merge($jsFiles, $this->makeUriRelativeTo((array) $assets['js'], $root));
}
if (isset($assets['inline_css'])) {
$inlineCss = array_merge($inlineCss, (array) $assets['inline_css']);
}
if (isset($assets['inline_js'])) {
$inlineJs = array_merge($inlineJs, (array) $assets['inline_js']);
}
if (isset($assets['inline_head'])) {
$inlineHead = array_merge($inlineHead, (array) $assets['inline_head']);
}
}
return $this->filterAssetArray(array($cssFiles, $jsFiles), $type);
// Deduplicate files
$cssFiles = array_unique($cssFiles);
$jsFiles = array_unique($jsFiles);
return $this->filterAssetArray(array($cssFiles, $jsFiles, $inlineCss, $inlineJs, $inlineHead), $type);
}
/**
@@ -669,53 +746,64 @@ class JavascriptRenderer
}
/**
* Filters a tuple of (css, js) assets according to $type
* Filters a tuple of (css, js, inline_css, inline_js, inline_head) assets according to $type
*
* @param array $array
* @param string $type 'css', 'js' or null for both
* @param string $type 'css', 'js', 'inline_css', 'inline_js', 'inline_head', or null for all
* @return array
*/
protected function filterAssetArray($array, $type = null)
{
$type = strtolower($type);
if ($type === 'css') {
return $array[0];
}
if ($type === 'js') {
return $array[1];
}
return $array;
$types = array('css', 'js', 'inline_css', 'inline_js', 'inline_head');
$typeIndex = array_search(strtolower($type), $types);
return $typeIndex !== false ? $array[$typeIndex] : $array;
}
/**
* Returns a tuple where the both items are Assetic AssetCollection,
* the first one being css files and the second js files
* Returns an array where all items are Assetic AssetCollection:
* - The first one contains the CSS files
* - The second one contains the JS files
* - The third one contains arbitrary inline HTML (typically composed of <script>/<style>
* elements); it must be embedded within the <head> element
*
* @param string $type Only return css or js collection
* @return array or \Assetic\Asset\AssetCollection
* @param string $type Optionally return only 'css', 'js', or 'inline_head' collection
* @return array|\Assetic\Asset\AssetCollection
*/
public function getAsseticCollection($type = null)
{
list($cssFiles, $jsFiles) = $this->getAssets();
return $this->filterAssetArray(array(
$this->createAsseticCollection($cssFiles),
$this->createAsseticCollection($jsFiles)
), $type);
$types = array('css', 'js', 'inline_head');
$typeIndex = array_search(strtolower($type), $types);
list($cssFiles, $jsFiles, $inlineCss, $inlineJs, $inlineHead) = $this->getAssets();
$collections = array(
$this->createAsseticCollection($cssFiles, $inlineCss),
$this->createAsseticCollection($jsFiles, $inlineJs),
$this->createAsseticCollection(null, $inlineHead)
);
return $typeIndex !== false ? $collections[$typeIndex] : $collections;
}
/**
* Create an Assetic AssetCollection with the given files.
* Create an Assetic AssetCollection with the given content.
* Filenames will be converted to absolute path using
* the base path.
*
* @param array $files
* @param array|null $files Array of asset filenames.
* @param array|null $content Array of inline asset content.
* @return \Assetic\Asset\AssetCollection
*/
protected function createAsseticCollection($files)
protected function createAsseticCollection($files = null, $content = null)
{
$assets = array();
foreach ($files as $file) {
$assets[] = new \Assetic\Asset\FileAsset($file);
if ($files) {
foreach ($files as $file) {
$assets[] = new \Assetic\Asset\FileAsset($file);
}
}
if ($content) {
foreach ($content as $item) {
$assets[] = new \Assetic\Asset\StringAsset($item);
}
}
return new \Assetic\Asset\AssetCollection($assets);
}
@@ -727,7 +815,7 @@ class JavascriptRenderer
*/
public function dumpCssAssets($targetFilename = null)
{
$this->dumpAssets($this->getAssets('css'), $targetFilename);
$this->dumpAssets($this->getAssets('css'), $this->getAssets('inline_css'), $targetFilename);
}
/**
@@ -737,29 +825,48 @@ class JavascriptRenderer
*/
public function dumpJsAssets($targetFilename = null)
{
$this->dumpAssets($this->getAssets('js'), $targetFilename, $this->useRequireJs);
$this->dumpAssets($this->getAssets('js'), $this->getAssets('inline_js'), $targetFilename, $this->useRequireJs);
}
/**
* Write all inline HTML header assets to standard output or in a file (only returns assets not
* already returned by dumpCssAssets or dumpJsAssets)
*
* @param string $targetFilename
*/
public function dumpHeadAssets($targetFilename = null)
{
$this->dumpAssets(null, $this->getAssets('inline_head'), $targetFilename);
}
/**
* Write assets to standard output or in a file
*
* @param array $files
* @param array|null $files Filenames containing assets
* @param array|null $content Inline content to dump
* @param string $targetFilename
* @param bool $useRequireJs
*/
protected function dumpAssets($files, $targetFilename = null, $useRequireJs = false)
protected function dumpAssets($files = null, $content = null, $targetFilename = null, $useRequireJs = false)
{
$content = '';
foreach ($files as $file) {
$content .= file_get_contents($file) . "\n";
$dumpedContent = '';
if ($files) {
foreach ($files as $file) {
$dumpedContent .= file_get_contents($file) . "\n";
}
}
if ($content) {
foreach ($content as $item) {
$dumpedContent .= $item . "\n";
}
}
if ($useRequireJs) {
$content = "define('debugbar', ['jquery'], function($){\r\n" . $content . "\r\n return PhpDebugBar; \r\n});";
$dumpedContent = "define('debugbar', ['jquery'], function($){\r\n" . $dumpedContent . "\r\n return PhpDebugBar; \r\n});";
}
if ($targetFilename !== null) {
file_put_contents($targetFilename, $content);
file_put_contents($targetFilename, $dumpedContent);
} else {
echo $content;
echo $dumpedContent;
}
}
@@ -772,17 +879,29 @@ class JavascriptRenderer
*/
public function renderHead()
{
list($cssFiles, $jsFiles) = $this->getAssets(null, self::RELATIVE_URL);
list($cssFiles, $jsFiles, $inlineCss, $inlineJs, $inlineHead) = $this->getAssets(null, self::RELATIVE_URL);
$html = '';
foreach ($cssFiles as $file) {
$html .= sprintf('<link rel="stylesheet" type="text/css" href="%s">' . "\n", $file);
}
foreach ($inlineCss as $content) {
$html .= sprintf('<style type="text/css">%s</style>' . "\n", $content);
}
foreach ($jsFiles as $file) {
$html .= sprintf('<script type="text/javascript" src="%s"></script>' . "\n", $file);
}
foreach ($inlineJs as $content) {
$html .= sprintf('<script type="text/javascript">%s</script>' . "\n", $content);
}
foreach ($inlineHead as $content) {
$html .= $content . "\n";
}
if ($this->enableJqueryNoConflict && !$this->useRequireJs) {
$html .= '<script type="text/javascript">jQuery.noConflict(true);</script>' . "\n";
}
@@ -897,7 +1016,12 @@ class JavascriptRenderer
}
if ($this->ajaxHandlerClass) {
$js .= sprintf("%s.ajaxHandler = new %s(%s);\n", $this->variableName, $this->ajaxHandlerClass, $this->variableName);
$js .= sprintf("%s.ajaxHandler = new %s(%s, undefined, %s);\n",
$this->variableName,
$this->ajaxHandlerClass,
$this->variableName,
$this->ajaxHandlerAutoShow ? 'true' : 'false'
);
if ($this->ajaxHandlerBindToXHR) {
$js .= sprintf("%s.ajaxHandler.bindToXHR();\n", $this->variableName);
} elseif ($this->ajaxHandlerBindToJquery) {