php-cs-fixer doing its thing.
This commit is contained in:
parent
229c98a91a
commit
74338e78a0
11 changed files with 36 additions and 18 deletions
|
|
@ -4,12 +4,13 @@ function detectAndLoadVendor($path = __DIR__): void
|
|||
{
|
||||
$path = realpath($path);
|
||||
if ('/' == $path) {
|
||||
die("Could not find a suitable /vendor directory! Maybe you need to run composer install!\n");
|
||||
exit("Could not find a suitable /vendor directory! Maybe you need to run composer install!\n");
|
||||
}
|
||||
|
||||
foreach (new DirectoryIterator($path) as $fileInfo) {
|
||||
if ($fileInfo->isDir() && 'vendor' == $fileInfo->getFilename()) {
|
||||
define('VENDOR_PATH', $fileInfo->getRealPath());
|
||||
|
||||
require_once VENDOR_PATH.'/autoload.php';
|
||||
|
||||
return;
|
||||
|
|
|
|||
18
src/App.php
18
src/App.php
|
|
@ -59,14 +59,14 @@ class App
|
|||
protected Router $router;
|
||||
protected bool $isSessionsEnabled = true;
|
||||
protected bool $interrogateControllersComplete = false;
|
||||
protected ?CachePoolChain $cachePoolChain = null;
|
||||
private array $viewPaths = [];
|
||||
private string $cachePath = APP_ROOT.'/cache';
|
||||
private string $logPath = APP_ROOT."/logs";
|
||||
private string $logPath = APP_ROOT.'/logs';
|
||||
private array $supportedLanguages = ['en_US'];
|
||||
private bool $debugMode = false;
|
||||
|
||||
private static bool $isInitialised = false;
|
||||
protected ?CachePoolChain $cachePoolChain = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
|
@ -134,11 +134,13 @@ class App
|
|||
|
||||
/**
|
||||
* @param array $viewPaths
|
||||
*
|
||||
* @return App
|
||||
*/
|
||||
public function setViewPaths(array $viewPaths): App
|
||||
{
|
||||
$this->viewPaths = $viewPaths;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -152,11 +154,13 @@ class App
|
|||
|
||||
/**
|
||||
* @param string $logPath
|
||||
*
|
||||
* @return App
|
||||
*/
|
||||
public function setLogPath(string $logPath): App
|
||||
{
|
||||
$this->logPath = $logPath;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -319,8 +323,8 @@ class App
|
|||
$caches[] = new ArrayCachePool();
|
||||
|
||||
$this->cachePoolChain = new CachePoolChain($caches);
|
||||
|
||||
}
|
||||
|
||||
return $this->cachePoolChain;
|
||||
});
|
||||
|
||||
|
|
@ -334,9 +338,9 @@ class App
|
|||
|
||||
$container->set(Logger::class, function (ConfigurationService $configurationService, EnvironmentService $environmentService) {
|
||||
$appName = $configurationService->get(ConfigurationService::KEY_APP_NAME);
|
||||
$logName = $environmentService->has("REQUEST_URI") ? sprintf("%s(%s)", $appName, $environmentService->get("REQUEST_URI")) : $appName;
|
||||
$logName = $environmentService->has('REQUEST_URI') ? sprintf('%s(%s)', $appName, $environmentService->get('REQUEST_URI')) : $appName;
|
||||
$monolog = new Logger($logName);
|
||||
$monolog->pushHandler(new StreamHandler(sprintf("%s/%s.log", $this->getLogPath(), strtolower($appName))));
|
||||
$monolog->pushHandler(new StreamHandler(sprintf('%s/%s.log', $this->getLogPath(), strtolower($appName))));
|
||||
$monolog->pushHandler(new ErrorLogHandler(), Logger::DEBUG);
|
||||
$monolog->pushProcessor(new PsrLogMessageProcessor());
|
||||
|
||||
|
|
@ -393,7 +397,7 @@ class App
|
|||
|
||||
$this->router = $container->get(Router::class);
|
||||
|
||||
#!\Kint::dump($this->environmentService->all());exit;
|
||||
//!\Kint::dump($this->environmentService->all());exit;
|
||||
return $container;
|
||||
}
|
||||
|
||||
|
|
@ -539,7 +543,7 @@ class App
|
|||
|
||||
$timeToBootstrapMs = (microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']) * 1000;
|
||||
$bootstrapTooLongThresholdMs = 300;
|
||||
if($timeToBootstrapMs >= $bootstrapTooLongThresholdMs) {
|
||||
if ($timeToBootstrapMs >= $bootstrapTooLongThresholdMs) {
|
||||
$this->logger->warning(sprintf('Bootstrap complete in %sms which is more than the threshold of %sms', number_format($timeToBootstrapMs, 2), $bootstrapTooLongThresholdMs));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ abstract class AbstractController
|
|||
public function __construct(Logger $logger, CacheProvider $cacheProvider)
|
||||
{
|
||||
$this->logger = $logger;
|
||||
#$this->logger->debug(sprintf('Entered Controller in %sms', number_format((microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']) * 1000, 2)));
|
||||
//$this->logger->debug(sprintf('Entered Controller in %sms', number_format((microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']) * 1000, 2)));
|
||||
$this->cacheProvider = $cacheProvider;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ abstract class AbstractHTMLController extends AbstractController
|
|||
$renderTimeLimitMs = 500;
|
||||
$renderTimeMs = (microtime(true) - $renderStart) * 1000;
|
||||
|
||||
if($renderTimeMs >= $renderTimeLimitMs) {
|
||||
if ($renderTimeMs >= $renderTimeLimitMs) {
|
||||
$this->logger->debug(sprintf(
|
||||
'Took %sms to render %s, which is over %sms limit',
|
||||
number_format($renderTimeMs, 2),
|
||||
|
|
|
|||
|
|
@ -46,18 +46,22 @@ class Filter
|
|||
$this->setLimit($value);
|
||||
|
||||
break;
|
||||
|
||||
case 'offset':
|
||||
$this->setOffset($value);
|
||||
|
||||
break;
|
||||
|
||||
case 'wheres':
|
||||
$this->setWheres($value);
|
||||
|
||||
break;
|
||||
|
||||
case 'order':
|
||||
$this->parseOrder($value);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new FilterDecodeException("Failed to decode Filter, unknown key: {$key}");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Benzine\Router;
|
||||
|
||||
use Monolog\Logger;
|
||||
use Slim\App;
|
||||
|
||||
class Route
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ class Router
|
|||
|
||||
$this->routes = $cacheItem->get();
|
||||
$timeToLoadFromCacheMs = (microtime(true) - $time) * 1000;
|
||||
if($timeToLoadFromCacheMs >= 500) {
|
||||
if ($timeToLoadFromCacheMs >= 500) {
|
||||
$this->logger->warning(sprintf('Loaded routes from Cache in %sms, which is slower than 500ms', number_format($timeToLoadFromCacheMs, 2)));
|
||||
}
|
||||
|
||||
|
|
@ -159,9 +159,9 @@ class Router
|
|||
|
||||
try {
|
||||
$this->cachePoolChain->save($routeItem);
|
||||
$this->logger->info("Cached router to cache pool");
|
||||
$this->logger->info('Cached router to cache pool');
|
||||
} catch (CachePoolException $cachePoolException) {
|
||||
$this->logger->critical("Cache Pool Exception: " . $cachePoolException->getMessage());
|
||||
$this->logger->critical('Cache Pool Exception: '.$cachePoolException->getMessage());
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
|
|
|||
|
|
@ -55,18 +55,23 @@ class TransformExtension extends AbstractExtension
|
|||
case 'camel':
|
||||
case 'camelcase':
|
||||
return new Format\CamelCase();
|
||||
|
||||
case 'screaming':
|
||||
case 'screamingsnake':
|
||||
case 'screamingsnakecase':
|
||||
return new Format\ScreamingSnakeCase();
|
||||
|
||||
case 'snake':
|
||||
case 'snakecase':
|
||||
return new Format\SnakeCase();
|
||||
|
||||
case 'spinal':
|
||||
case 'spinalcase':
|
||||
return new Format\SpinalCase();
|
||||
|
||||
case 'studly':
|
||||
return new Format\StudlyCaps();
|
||||
|
||||
default:
|
||||
throw new TransformExtensionException("Unknown transformer: \"{$name}\".");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,6 +108,7 @@ abstract class AbstractQueueWorker extends AbstractWorker
|
|||
|
||||
if ($this->stopOnZero && 0 == $queueLength) {
|
||||
$this->logger->warning('--stop-on-zero is set, and the queue length is zero! Stopping!');
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,18 +27,19 @@ abstract class AbstractWorker implements WorkerInterface
|
|||
);
|
||||
}
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $stopOnZero
|
||||
*/
|
||||
public function setStopOnZero(bool $stopOnZero): self
|
||||
{
|
||||
$this->stopOnZero = $stopOnZero;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function run(): void
|
||||
{
|
||||
|
|
|
|||
|
|
@ -13,13 +13,16 @@ class WorkerWorkItem implements \Serializable
|
|||
{
|
||||
$method = substr(strtolower($name), 0, 3);
|
||||
$field = substr(strtolower($name), 3);
|
||||
|
||||
switch ($method) {
|
||||
case 'set':
|
||||
$this->data[$field] = $arguments[0];
|
||||
|
||||
return $this;
|
||||
|
||||
case 'get':
|
||||
return $this->data[$field];
|
||||
|
||||
default:
|
||||
throw new WorkerException("Method {$name} doesn't exist");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue