1
0
mirror of https://github.com/laravel/valet.git synced 2026-02-07 01:00:09 +01:00

Apply fixes from StyleCI

This commit is contained in:
Taylor Otwell
2021-12-06 10:40:37 +00:00
committed by StyleCI Bot
parent 3a5d12e24d
commit 101abeae0e
35 changed files with 580 additions and 536 deletions

View File

@@ -12,7 +12,7 @@ class Typo3ValetDriver extends ValetDriver
| Document Root Subdirectory
|--------------------------------------------------------------------------
|
| This subdirectory contains the public server resources, such as the
| This subdirectory contains the public server resources, such as the
| index.php, the typo3 and fileadmin system directories. Change it
| to '', if you don't use a subdirectory but valet link directly.
|
@@ -48,7 +48,8 @@ class Typo3ValetDriver extends ValetDriver
*/
public function serves($sitePath, $siteName, $uri)
{
$typo3Dir = $sitePath . $this->documentRoot . '/typo3';
$typo3Dir = $sitePath.$this->documentRoot.'/typo3';
return file_exists($typo3Dir) && is_dir($typo3Dir);
}
@@ -66,17 +67,15 @@ public function isStaticFile($sitePath, $siteName, $uri)
{
// May the file contains a cache busting version string like filename.12345678.css
// If that is the case, the file cannot be found on disk, so remove the version
// identifier before retrying below.
if (!$this->isActualFile($filePath = $sitePath . $this->documentRoot . $uri))
{
$uri = preg_replace("@^(.+)\.(\d+)\.(js|css|png|jpg|gif|gzip)$@", "$1.$3", $uri);
// identifier before retrying below.
if (! $this->isActualFile($filePath = $sitePath.$this->documentRoot.$uri)) {
$uri = preg_replace("@^(.+)\.(\d+)\.(js|css|png|jpg|gif|gzip)$@", '$1.$3', $uri);
}
// Now that any possible version string is cleared from the filename, the resulting
// URI should be a valid file on disc. So assemble the absolut file name with the
// same schema as above and if it exists, authorize access and return its path.
if ($this->isActualFile($filePath = $sitePath . $this->documentRoot . $uri))
{
if ($this->isActualFile($filePath = $sitePath.$this->documentRoot.$uri)) {
return $this->isAccessAuthorized($uri) ? $filePath : false;
}
@@ -87,18 +86,17 @@ public function isStaticFile($sitePath, $siteName, $uri)
/**
* Determines if the given URI is blacklisted so that access is prevented.
*
* @param string $uri
* @return boolean
* @param string $uri
* @return bool
*/
private function isAccessAuthorized($uri)
{
foreach ($this->forbiddenUriPatterns as $forbiddenUriPattern)
{
if (preg_match("@$forbiddenUriPattern@", $uri))
{
foreach ($this->forbiddenUriPatterns as $forbiddenUriPattern) {
if (preg_match("@$forbiddenUriPattern@", $uri)) {
return false;
}
}
return true;
}
@@ -121,24 +119,18 @@ public function frontControllerPath($sitePath, $siteName, $uri)
$uri = rtrim($uri, '/');
// try to find the responsible script file for the requested folder / script URI
if (file_exists($absoluteFilePath = $sitePath . $this->documentRoot . $uri))
{
if (is_dir($absoluteFilePath))
{
if (file_exists($absoluteFilePath . '/index.php'))
{
if (file_exists($absoluteFilePath = $sitePath.$this->documentRoot.$uri)) {
if (is_dir($absoluteFilePath)) {
if (file_exists($absoluteFilePath.'/index.php')) {
// this folder can be served by index.php
return $this->serveScript($sitePath, $siteName, $uri . '/index.php');
return $this->serveScript($sitePath, $siteName, $uri.'/index.php');
}
if (file_exists($absoluteFilePath . '/index.html'))
{
if (file_exists($absoluteFilePath.'/index.html')) {
// this folder can be served by index.html
return $absoluteFilePath . '/index.html';
return $absoluteFilePath.'/index.html';
}
}
else if (pathinfo($absoluteFilePath, PATHINFO_EXTENSION) === 'php')
{
} elseif (pathinfo($absoluteFilePath, PATHINFO_EXTENSION) === 'php') {
// this file can be served directly
return $this->serveScript($sitePath, $siteName, $uri);
}
@@ -153,20 +145,18 @@ public function frontControllerPath($sitePath, $siteName, $uri)
* sysext install script. domain.dev/typo3 will be redirected to /typo3/, because
* the generated JavaScript URIs on the login screen would be broken on /typo3.
*
* @param string $uri
* @param string $uri
*/
private function handleRedirectBackendShorthandUris($uri)
{
if (rtrim($uri, '/') === '/typo3/install')
{
if (rtrim($uri, '/') === '/typo3/install') {
header('Location: /typo3/sysext/install/Start/Install.php');
die();
exit();
}
if ($uri === '/typo3')
{
if ($uri === '/typo3') {
header('Location: /typo3/');
die();
exit();
}
}
@@ -182,10 +172,10 @@ private function handleRedirectBackendShorthandUris($uri)
*/
private function serveScript($sitePath, $siteName, $uri)
{
$docroot = $sitePath . $this->documentRoot;
$abspath = $docroot . $uri;
$docroot = $sitePath.$this->documentRoot;
$abspath = $docroot.$uri;
$_SERVER['SERVER_NAME'] = $siteName . '.dev';
$_SERVER['SERVER_NAME'] = $siteName.'.dev';
$_SERVER['DOCUMENT_ROOT'] = $docroot;
$_SERVER['DOCUMENT_URI'] = $uri;
$_SERVER['SCRIPT_FILENAME'] = $abspath;