aboutsummaryrefslogtreecommitdiffhomepage
path: root/main/app/sprinkles/core/src
diff options
context:
space:
mode:
Diffstat (limited to 'main/app/sprinkles/core/src')
-rw-r--r--main/app/sprinkles/core/src/Alert/AlertStream.php28
-rw-r--r--main/app/sprinkles/core/src/Alert/CacheAlertStream.php43
-rw-r--r--main/app/sprinkles/core/src/Alert/SessionAlertStream.php31
-rw-r--r--main/app/sprinkles/core/src/Controller/SimpleController.php4
-rw-r--r--main/app/sprinkles/core/src/Core.php23
-rw-r--r--main/app/sprinkles/core/src/Database/Builder.php42
-rw-r--r--main/app/sprinkles/core/src/Database/DatabaseInvalidException.php1
-rw-r--r--main/app/sprinkles/core/src/Database/Migrations/v400/SessionsTable.php7
-rw-r--r--main/app/sprinkles/core/src/Database/Migrations/v400/ThrottlesTable.php7
-rw-r--r--main/app/sprinkles/core/src/Database/Models/Concerns/HasRelationships.php80
-rw-r--r--main/app/sprinkles/core/src/Database/Models/Model.php35
-rw-r--r--main/app/sprinkles/core/src/Database/Models/Throttle.php9
-rw-r--r--main/app/sprinkles/core/src/Database/Relations/BelongsToManyConstrained.php38
-rw-r--r--main/app/sprinkles/core/src/Database/Relations/BelongsToManyThrough.php65
-rw-r--r--main/app/sprinkles/core/src/Database/Relations/BelongsToManyUnique.php1
-rw-r--r--main/app/sprinkles/core/src/Database/Relations/Concerns/Syncable.php40
-rw-r--r--main/app/sprinkles/core/src/Database/Relations/Concerns/Unique.php140
-rw-r--r--main/app/sprinkles/core/src/Database/Relations/HasManySyncable.php1
-rw-r--r--main/app/sprinkles/core/src/Database/Relations/MorphManySyncable.php1
-rw-r--r--main/app/sprinkles/core/src/Database/Relations/MorphToManyUnique.php1
-rw-r--r--main/app/sprinkles/core/src/Error/ExceptionHandlerManager.php18
-rw-r--r--main/app/sprinkles/core/src/Error/Handler/ExceptionHandler.php44
-rw-r--r--main/app/sprinkles/core/src/Error/Handler/ExceptionHandlerInterface.php3
-rw-r--r--main/app/sprinkles/core/src/Error/Handler/HttpExceptionHandler.php12
-rw-r--r--main/app/sprinkles/core/src/Error/Handler/NotFoundExceptionHandler.php4
-rw-r--r--main/app/sprinkles/core/src/Error/Handler/PhpMailerExceptionHandler.php4
-rw-r--r--main/app/sprinkles/core/src/Error/Renderer/ErrorRenderer.php15
-rw-r--r--main/app/sprinkles/core/src/Error/Renderer/ErrorRendererInterface.php11
-rw-r--r--main/app/sprinkles/core/src/Error/Renderer/HtmlRenderer.php18
-rw-r--r--main/app/sprinkles/core/src/Error/Renderer/JsonRenderer.php10
-rw-r--r--main/app/sprinkles/core/src/Error/Renderer/PlainTextRenderer.php10
-rw-r--r--main/app/sprinkles/core/src/Error/Renderer/WhoopsRenderer.php220
-rw-r--r--main/app/sprinkles/core/src/Error/Renderer/XmlRenderer.php7
-rw-r--r--main/app/sprinkles/core/src/Facades/Debug.php4
-rw-r--r--main/app/sprinkles/core/src/Facades/Translator.php4
-rw-r--r--main/app/sprinkles/core/src/Http/Concerns/DeterminesContentType.php4
-rw-r--r--main/app/sprinkles/core/src/Log/DatabaseHandler.php9
-rw-r--r--main/app/sprinkles/core/src/Log/MixedFormatter.php15
-rw-r--r--main/app/sprinkles/core/src/Mail/EmailRecipient.php25
-rw-r--r--main/app/sprinkles/core/src/Mail/MailMessage.php49
-rw-r--r--main/app/sprinkles/core/src/Mail/Mailer.php58
-rw-r--r--main/app/sprinkles/core/src/Mail/StaticMailMessage.php16
-rw-r--r--main/app/sprinkles/core/src/Mail/TwigMailMessage.php18
-rw-r--r--main/app/sprinkles/core/src/Model/UFModel.php4
-rw-r--r--main/app/sprinkles/core/src/Router.php11
-rw-r--r--main/app/sprinkles/core/src/Sprunje/Sprunje.php91
-rw-r--r--main/app/sprinkles/core/src/Throttle/ThrottleRule.php25
-rw-r--r--main/app/sprinkles/core/src/Throttle/Throttler.php28
-rw-r--r--main/app/sprinkles/core/src/Throttle/ThrottlerException.php1
-rw-r--r--main/app/sprinkles/core/src/Twig/CacheHelper.php13
-rw-r--r--main/app/sprinkles/core/src/Twig/CoreExtension.php28
-rw-r--r--main/app/sprinkles/core/src/Util/BadClassNameException.php1
-rw-r--r--main/app/sprinkles/core/src/Util/Captcha.php53
-rw-r--r--main/app/sprinkles/core/src/Util/CheckEnvironment.php123
-rw-r--r--main/app/sprinkles/core/src/Util/ClassMapper.php14
-rw-r--r--main/app/sprinkles/core/src/Util/EnvironmentInfo.php11
-rw-r--r--main/app/sprinkles/core/src/Util/ShutdownHandler.php25
-rw-r--r--main/app/sprinkles/core/src/Util/Util.php47
58 files changed, 723 insertions, 927 deletions
diff --git a/main/app/sprinkles/core/src/Alert/AlertStream.php b/main/app/sprinkles/core/src/Alert/AlertStream.php
index 3946cbf..adb9b5b 100644
--- a/main/app/sprinkles/core/src/Alert/AlertStream.php
+++ b/main/app/sprinkles/core/src/Alert/AlertStream.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Alert;
use UserFrosting\Fortress\ServerSideValidator;
@@ -28,13 +29,12 @@ abstract class AlertStream
/**
* @var UserFrosting\I18n\MessageTranslator|null
*/
- protected $messageTranslator = null;
+ protected $messageTranslator = NULL;
/**
* Create a new message stream.
*/
- public function __construct($messagesKey, $translator = null)
- {
+ public function __construct($messagesKey, $translator = NULL) {
$this->messagesKey = $messagesKey;
$this->setTranslator($translator);
@@ -45,8 +45,7 @@ abstract class AlertStream
*
* @param UserFrosting\I18n\MessageTranslator $translator A MessageTranslator to be used to translate messages when added via `addMessageTranslated`.
*/
- public function setTranslator($translator)
- {
+ public function setTranslator($translator) {
$this->messageTranslator = $translator;
return $this;
}
@@ -58,8 +57,7 @@ abstract class AlertStream
* @param string $message The message to be added to the message stream.
* @return MessageStream this MessageStream object.
*/
- public function addMessage($type, $message)
- {
+ public function addMessage($type, $message) {
$messages = $this->messages();
$messages[] = array(
"type" => $type,
@@ -77,9 +75,8 @@ abstract class AlertStream
* @param array[string] $placeholders An optional hash of placeholder names => placeholder values to substitute into the translated message.
* @return MessageStream this MessageStream object.
*/
- public function addMessageTranslated($type, $messageId, $placeholders = array())
- {
- if (!$this->messageTranslator){
+ public function addMessageTranslated($type, $messageId, $placeholders = array()) {
+ if (!$this->messageTranslator) {
throw new \RuntimeException("No translator has been set! Please call MessageStream::setTranslator first.");
}
@@ -94,8 +91,7 @@ abstract class AlertStream
*
* @return array An array of messages, each of which is itself an array containing "type" and "message" fields.
*/
- public function getAndClearMessages()
- {
+ public function getAndClearMessages() {
$messages = $this->messages();
$this->resetMessageStream();
return $messages;
@@ -106,10 +102,9 @@ abstract class AlertStream
*
* @param ServerSideValidator $validator
*/
- public function addValidationErrors(ServerSideValidator $validator)
- {
+ public function addValidationErrors(ServerSideValidator $validator) {
foreach ($validator->errors() as $idx => $field) {
- foreach($field as $eidx => $error) {
+ foreach ($field as $eidx => $error) {
$this->addMessage("danger", $error);
}
}
@@ -120,8 +115,7 @@ abstract class AlertStream
*
* @return MessageTranslator The translator for this message stream.
*/
- public function translator()
- {
+ public function translator() {
return $this->messageTranslator;
}
diff --git a/main/app/sprinkles/core/src/Alert/CacheAlertStream.php b/main/app/sprinkles/core/src/Alert/CacheAlertStream.php
index 1fd5131..f3f6489 100644
--- a/main/app/sprinkles/core/src/Alert/CacheAlertStream.php
+++ b/main/app/sprinkles/core/src/Alert/CacheAlertStream.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Alert;
use Illuminate\Cache\Repository as Cache;
@@ -18,30 +19,29 @@ use UserFrosting\Support\Repository\Repository;
* the alerts. Note that the tags are added each time instead of the
* constructor since the session_id can change when the user logs in or out
*
- * @author Louis Charette
+ * @author Louis Charette
*/
class CacheAlertStream extends AlertStream
{
/**
- * @var Cache Object We use the cache object so that added messages will automatically appear in the cache.
+ * @var Cache Object We use the cache object so that added messages will automatically appear in the cache.
*/
protected $cache;
/**
- * @var Repository Object We use the cache object so that added messages will automatically appear in the cache.
+ * @var Repository Object We use the cache object so that added messages will automatically appear in the cache.
*/
protected $config;
/**
* Create a new message stream.
*
- * @param string $messagesKey Store the messages under this key
- * @param MessageTranslator|null $translator
- * @param Cache $cache
- * @param Repository $config
+ * @param string $messagesKey Store the messages under this key
+ * @param MessageTranslator|null $translator
+ * @param Cache $cache
+ * @param Repository $config
*/
- public function __construct($messagesKey, MessageTranslator $translator = null, Cache $cache, Repository $config)
- {
+ public function __construct($messagesKey, MessageTranslator $translator = NULL, Cache $cache, Repository $config) {
$this->cache = $cache;
$this->config = $config;
parent::__construct($messagesKey, $translator);
@@ -50,12 +50,11 @@ class CacheAlertStream extends AlertStream
/**
* Get the messages from this message stream.
*
- * @return array An array of messages, each of which is itself an array containing 'type' and 'message' fields.
+ * @return array An array of messages, each of which is itself an array containing 'type' and 'message' fields.
*/
- public function messages()
- {
- if ($this->cache->tags('_s'.session_id())->has($this->messagesKey)) {
- return $this->cache->tags('_s'.session_id())->get($this->messagesKey) ?: [];
+ public function messages() {
+ if ($this->cache->tags('_s' . session_id())->has($this->messagesKey)) {
+ return $this->cache->tags('_s' . session_id())->get($this->messagesKey) ?: [];
} else {
return [];
}
@@ -64,21 +63,19 @@ class CacheAlertStream extends AlertStream
/**
* Clear all messages from this message stream.
*
- * @return void
+ * @return void
*/
- public function resetMessageStream()
- {
- $this->cache->tags('_s'.session_id())->forget($this->messagesKey);
+ public function resetMessageStream() {
+ $this->cache->tags('_s' . session_id())->forget($this->messagesKey);
}
/**
* Save messages to the stream
*
- * @param string $messages The message
- * @return void
+ * @param string $messages The message
+ * @return void
*/
- protected function saveMessages($messages)
- {
- $this->cache->tags('_s'.session_id())->forever($this->messagesKey, $messages);
+ protected function saveMessages($messages) {
+ $this->cache->tags('_s' . session_id())->forever($this->messagesKey, $messages);
}
}
diff --git a/main/app/sprinkles/core/src/Alert/SessionAlertStream.php b/main/app/sprinkles/core/src/Alert/SessionAlertStream.php
index 8b4604b..fec0973 100644
--- a/main/app/sprinkles/core/src/Alert/SessionAlertStream.php
+++ b/main/app/sprinkles/core/src/Alert/SessionAlertStream.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Alert;
use UserFrosting\I18n\MessageTranslator;
@@ -15,24 +16,23 @@ use UserFrosting\Session\Session;
* Implements a message stream for use between HTTP requests, with i18n support via the MessageTranslator class
* Using the session storage to store the alerts
*
- * @author Alex Weissman (https://alexanderweissman.com)
+ * @author Alex Weissman (https://alexanderweissman.com)
*/
class SessionAlertStream extends AlertStream
{
/**
- * @var Session We use the session object so that added messages will automatically appear in the session.
+ * @var Session We use the session object so that added messages will automatically appear in the session.
*/
protected $session;
/**
* Create a new message stream.
*
- * @param string $messagesKey Store the messages under this key
- * @param MessageTranslator|null $translator
- * @param Session $session
+ * @param string $messagesKey Store the messages under this key
+ * @param MessageTranslator|null $translator
+ * @param Session $session
*/
- public function __construct($messagesKey, MessageTranslator $translator = null, Session $session)
- {
+ public function __construct($messagesKey, MessageTranslator $translator = NULL, Session $session) {
$this->session = $session;
parent::__construct($messagesKey, $translator);
}
@@ -40,31 +40,28 @@ class SessionAlertStream extends AlertStream
/**
* Get the messages from this message stream.
*
- * @return array An array of messages, each of which is itself an array containing "type" and "message" fields.
+ * @return array An array of messages, each of which is itself an array containing "type" and "message" fields.
*/
- public function messages()
- {
+ public function messages() {
return $this->session[$this->messagesKey] ?: [];
}
/**
* Clear all messages from this message stream.
*
- * @return void
+ * @return void
*/
- public function resetMessageStream()
- {
+ public function resetMessageStream() {
$this->session[$this->messagesKey] = [];
}
/**
* Save messages to the stream
*
- * @param string $messages The message
- * @return void
+ * @param string $messages The message
+ * @return void
*/
- protected function saveMessages($messages)
- {
+ protected function saveMessages($messages) {
$this->session[$this->messagesKey] = $messages;
}
}
diff --git a/main/app/sprinkles/core/src/Controller/SimpleController.php b/main/app/sprinkles/core/src/Controller/SimpleController.php
index b0fc152..1e3303a 100644
--- a/main/app/sprinkles/core/src/Controller/SimpleController.php
+++ b/main/app/sprinkles/core/src/Controller/SimpleController.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Controller;
use Interop\Container\ContainerInterface;
@@ -29,8 +30,7 @@ class SimpleController
*
* @param ContainerInterface $ci The global container object, which holds all your services.
*/
- public function __construct(ContainerInterface $ci)
- {
+ public function __construct(ContainerInterface $ci) {
$this->ci = $ci;
}
}
diff --git a/main/app/sprinkles/core/src/Core.php b/main/app/sprinkles/core/src/Core.php
index d7e1dcb..9518fe2 100644
--- a/main/app/sprinkles/core/src/Core.php
+++ b/main/app/sprinkles/core/src/Core.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core;
use RocketTheme\Toolbox\Event\Event;
@@ -23,8 +24,7 @@ class Core extends Sprinkle
/**
* Defines which events in the UF lifecycle our Sprinkle should hook into.
*/
- public static function getSubscribedEvents()
- {
+ public static function getSubscribedEvents() {
return [
'onSprinklesInitialized' => ['onSprinklesInitialized', 0],
'onSprinklesRegisterServices' => ['onSprinklesRegisterServices', 0],
@@ -35,8 +35,7 @@ class Core extends Sprinkle
/**
* Set static references to DI container in necessary classes.
*/
- public function onSprinklesInitialized()
- {
+ public function onSprinklesInitialized() {
// Set container for data model
Model::$ci = $this->ci;
@@ -47,8 +46,7 @@ class Core extends Sprinkle
/**
* Get shutdownHandler set up. This needs to be constructed explicitly because it's invoked natively by PHP.
*/
- public function onSprinklesRegisterServices()
- {
+ public function onSprinklesRegisterServices() {
// Set up any global PHP settings from the config service.
$config = $this->ci->config;
@@ -73,14 +71,14 @@ class Core extends Sprinkle
}
// Determine if error display is enabled in the shutdown handler.
- $displayErrors = false;
+ $displayErrors = FALSE;
if (in_array(strtolower($config['php.display_errors']), [
'1',
'on',
'true',
'yes'
])) {
- $displayErrors = true;
+ $displayErrors = TRUE;
}
$sh = new ShutdownHandler($this->ci, $displayErrors);
@@ -90,8 +88,7 @@ class Core extends Sprinkle
/**
* Add CSRF middleware.
*/
- public function onAddGlobalMiddleware(Event $event)
- {
+ public function onAddGlobalMiddleware(Event $event) {
$request = $this->ci->request;
$path = $request->getUri()->getPath();
$method = $request->getMethod();
@@ -102,13 +99,13 @@ class Core extends Sprinkle
$method = strtoupper($method);
$csrfBlacklist = $this->ci->config['csrf.blacklist'];
- $isBlacklisted = false;
+ $isBlacklisted = FALSE;
// Go through the blacklist and determine if the path and method match any of the blacklist entries.
foreach ($csrfBlacklist as $pattern => $methods) {
- $methods = array_map('strtoupper', (array) $methods);
+ $methods = array_map('strtoupper', (array)$methods);
if (in_array($method, $methods) && $pattern != '' && preg_match('~' . $pattern . '~', $path)) {
- $isBlacklisted = true;
+ $isBlacklisted = TRUE;
break;
}
}
diff --git a/main/app/sprinkles/core/src/Database/Builder.php b/main/app/sprinkles/core/src/Database/Builder.php
index 8e27b7c..cebc318 100644
--- a/main/app/sprinkles/core/src/Database/Builder.php
+++ b/main/app/sprinkles/core/src/Database/Builder.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Database;
use Illuminate\Database\Capsule\Manager as DB;
@@ -18,7 +19,7 @@ use Illuminate\Database\Query\Builder as LaravelBuilder;
*/
class Builder extends LaravelBuilder
{
- protected $excludedColumns = null;
+ protected $excludedColumns = NULL;
/**
* Perform a "begins with" pattern match on a specified column in a query.
@@ -27,8 +28,7 @@ class Builder extends LaravelBuilder
* @param $field string The column to match
* @param $value string The value to match
*/
- public function beginsWith($field, $value)
- {
+ public function beginsWith($field, $value) {
return $this->where($field, 'LIKE', "$value%");
}
@@ -39,8 +39,7 @@ class Builder extends LaravelBuilder
* @param $field string The column to match
* @param $value string The value to match
*/
- public function endsWith($field, $value)
- {
+ public function endsWith($field, $value) {
return $this->where($field, 'LIKE', "%$value");
}
@@ -50,11 +49,10 @@ class Builder extends LaravelBuilder
* @param $value array|string The column(s) to exclude
* @return $this
*/
- public function exclude($column)
- {
+ public function exclude($column) {
$column = is_array($column) ? $column : func_get_args();
- $this->excludedColumns = array_merge((array) $this->excludedColumns, $column);
+ $this->excludedColumns = array_merge((array)$this->excludedColumns, $column);
return $this;
}
@@ -65,8 +63,7 @@ class Builder extends LaravelBuilder
* @param $field string The column to match
* @param $value string The value to match
*/
- public function like($field, $value)
- {
+ public function like($field, $value) {
return $this->where($field, 'LIKE', "%$value%");
}
@@ -76,19 +73,17 @@ class Builder extends LaravelBuilder
* @param $field string The column to match
* @param $value string The value to match
*/
- public function orLike($field, $value)
- {
+ public function orLike($field, $value) {
return $this->orWhere($field, 'LIKE', "%$value%");
}
/**
* Execute the query as a "select" statement.
*
- * @param array $columns
+ * @param array $columns
* @return \Illuminate\Support\Collection
*/
- public function get($columns = ['*'])
- {
+ public function get($columns = ['*']) {
$original = $this->columns;
if (is_null($original)) {
@@ -110,8 +105,7 @@ class Builder extends LaravelBuilder
/**
* Remove excluded columns from the select column list.
*/
- protected function removeExcludedSelectColumns()
- {
+ protected function removeExcludedSelectColumns() {
// Convert current column list and excluded column list to fully-qualified list
$this->columns = $this->convertColumnsToFullyQualified($this->columns);
$excludedColumns = $this->convertColumnsToFullyQualified($this->excludedColumns);
@@ -132,8 +126,7 @@ class Builder extends LaravelBuilder
* @param array $columns
* @return array
*/
- protected function replaceWildcardColumns(array $columns)
- {
+ protected function replaceWildcardColumns(array $columns) {
$wildcardTables = $this->findWildcardTables($columns);
foreach ($wildcardTables as $wildColumn => $table) {
@@ -153,8 +146,7 @@ class Builder extends LaravelBuilder
* @param array $columns
* @return array
*/
- protected function findWildcardTables(array $columns)
- {
+ protected function findWildcardTables(array $columns) {
$tables = [];
foreach ($columns as $column) {
@@ -180,8 +172,7 @@ class Builder extends LaravelBuilder
* @param string $table
* @return array
*/
- protected function getQualifiedColumnNames($table = null)
- {
+ protected function getQualifiedColumnNames($table = NULL) {
$schema = $this->getConnection()->getSchemaBuilder();
return $this->convertColumnsToFullyQualified($schema->getColumnListing($table), $table);
@@ -193,14 +184,13 @@ class Builder extends LaravelBuilder
* @param array $columns
* @return array
*/
- protected function convertColumnsToFullyQualified($columns, $table = null)
- {
+ protected function convertColumnsToFullyQualified($columns, $table = NULL) {
if (is_null($table)) {
$table = $this->from;
}
array_walk($columns, function (&$item, $key) use ($table) {
- if (strpos($item, '.') === false) {
+ if (strpos($item, '.') === FALSE) {
$item = "$table.$item";
}
});
diff --git a/main/app/sprinkles/core/src/Database/DatabaseInvalidException.php b/main/app/sprinkles/core/src/Database/DatabaseInvalidException.php
index 08f8a31..0eba67b 100644
--- a/main/app/sprinkles/core/src/Database/DatabaseInvalidException.php
+++ b/main/app/sprinkles/core/src/Database/DatabaseInvalidException.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Database;
use UserFrosting\Support\Exception\ForbiddenException;
diff --git a/main/app/sprinkles/core/src/Database/Migrations/v400/SessionsTable.php b/main/app/sprinkles/core/src/Database/Migrations/v400/SessionsTable.php
index ac86ceb..82d6534 100644
--- a/main/app/sprinkles/core/src/Database/Migrations/v400/SessionsTable.php
+++ b/main/app/sprinkles/core/src/Database/Migrations/v400/SessionsTable.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Database\Migrations\v400;
use Illuminate\Database\Schema\Blueprint;
@@ -24,8 +25,7 @@ class SessionsTable extends Migration
/**
* {@inheritDoc}
*/
- public function up()
- {
+ public function up() {
if (!$this->schema->hasTable('sessions')) {
$this->schema->create('sessions', function (Blueprint $table) {
$table->string('id')->unique();
@@ -41,8 +41,7 @@ class SessionsTable extends Migration
/**
* {@inheritDoc}
*/
- public function down()
- {
+ public function down() {
$this->schema->drop('sessions');
}
}
diff --git a/main/app/sprinkles/core/src/Database/Migrations/v400/ThrottlesTable.php b/main/app/sprinkles/core/src/Database/Migrations/v400/ThrottlesTable.php
index 1c742f7..f74fee8 100644
--- a/main/app/sprinkles/core/src/Database/Migrations/v400/ThrottlesTable.php
+++ b/main/app/sprinkles/core/src/Database/Migrations/v400/ThrottlesTable.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Database\Migrations\v400;
use Illuminate\Database\Schema\Blueprint;
@@ -23,8 +24,7 @@ class ThrottlesTable extends Migration
/**
* {@inheritDoc}
*/
- public function up()
- {
+ public function up() {
if (!$this->schema->hasTable('throttles')) {
$this->schema->create('throttles', function (Blueprint $table) {
$table->increments('id');
@@ -45,8 +45,7 @@ class ThrottlesTable extends Migration
/**
* {@inheritDoc}
*/
- public function down()
- {
+ public function down() {
$this->schema->drop('throttles');
}
}
diff --git a/main/app/sprinkles/core/src/Database/Models/Concerns/HasRelationships.php b/main/app/sprinkles/core/src/Database/Models/Concerns/HasRelationships.php
index 4fe9a30..919c108 100644
--- a/main/app/sprinkles/core/src/Database/Models/Concerns/HasRelationships.php
+++ b/main/app/sprinkles/core/src/Database/Models/Concerns/HasRelationships.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Database\Models\Concerns;
use Illuminate\Support\Arr;
@@ -41,8 +42,7 @@ trait HasRelationships
* {@inheritDoc}
* @return \UserFrosting\Sprinkle\Core\Database\Relations\HasManySyncable
*/
- public function hasMany($related, $foreignKey = null, $localKey = null)
- {
+ public function hasMany($related, $foreignKey = NULL, $localKey = NULL) {
$instance = $this->newRelatedInstance($related);
$foreignKey = $foreignKey ?: $this->getForeignKey();
@@ -50,7 +50,7 @@ trait HasRelationships
$localKey = $localKey ?: $this->getKeyName();
return new HasManySyncable(
- $instance->newQuery(), $this, $instance->getTable().'.'.$foreignKey, $localKey
+ $instance->newQuery(), $this, $instance->getTable() . '.' . $foreignKey, $localKey
);
}
@@ -60,8 +60,7 @@ trait HasRelationships
* {@inheritDoc}
* @return \UserFrosting\Sprinkle\Core\Database\Relations\MorphManySyncable
*/
- public function morphMany($related, $name, $type = null, $id = null, $localKey = null)
- {
+ public function morphMany($related, $name, $type = NULL, $id = NULL, $localKey = NULL) {
$instance = $this->newRelatedInstance($related);
// Here we will gather up the morph type and ID for the relationship so that we
@@ -71,38 +70,37 @@ trait HasRelationships
$table = $instance->getTable();
$localKey = $localKey ?: $this->getKeyName();
- return new MorphManySyncable($instance->newQuery(), $this, $table.'.'.$type, $table.'.'.$id, $localKey);
+ return new MorphManySyncable($instance->newQuery(), $this, $table . '.' . $type, $table . '.' . $id, $localKey);
}
/**
* Define a many-to-many 'through' relationship.
* This is basically hasManyThrough for many-to-many relationships.
*
- * @param string $related
- * @param string $through
- * @param string $firstJoiningTable
- * @param string $firstForeignKey
- * @param string $firstRelatedKey
- * @param string $secondJoiningTable
- * @param string $secondForeignKey
- * @param string $secondRelatedKey
- * @param string $throughRelation
- * @param string $relation
+ * @param string $related
+ * @param string $through
+ * @param string $firstJoiningTable
+ * @param string $firstForeignKey
+ * @param string $firstRelatedKey
+ * @param string $secondJoiningTable
+ * @param string $secondForeignKey
+ * @param string $secondRelatedKey
+ * @param string $throughRelation
+ * @param string $relation
* @return \UserFrosting\Sprinkle\Core\Database\Relations\BelongsToManyThrough
*/
public function belongsToManyThrough(
$related,
$through,
- $firstJoiningTable = null,
- $firstForeignKey = null,
- $firstRelatedKey = null,
- $secondJoiningTable = null,
- $secondForeignKey = null,
- $secondRelatedKey = null,
- $throughRelation = null,
- $relation = null
- )
- {
+ $firstJoiningTable = NULL,
+ $firstForeignKey = NULL,
+ $firstRelatedKey = NULL,
+ $secondJoiningTable = NULL,
+ $secondForeignKey = NULL,
+ $secondRelatedKey = NULL,
+ $throughRelation = NULL,
+ $relation = NULL
+ ) {
// If no relationship name was passed, we will pull backtraces to get the
// name of the calling function. We will use that function name as the
// title of this relation since that is a great convention to apply.
@@ -153,8 +151,7 @@ trait HasRelationships
* {@inheritDoc}
* @return \UserFrosting\Sprinkle\Core\Database\Relations\BelongsToManyUnique
*/
- public function belongsToManyUnique($related, $table = null, $foreignKey = null, $relatedKey = null, $relation = null)
- {
+ public function belongsToManyUnique($related, $table = NULL, $foreignKey = NULL, $relatedKey = NULL, $relation = NULL) {
// If no relationship name was passed, we will pull backtraces to get the
// name of the calling function. We will use that function name as the
// title of this relation since that is a great convention to apply.
@@ -189,14 +186,13 @@ trait HasRelationships
* {@inheritDoc}
* @return \UserFrosting\Sprinkle\Core\Database\Relations\MorphToManyUnique
*/
- public function morphToManyUnique($related, $name, $table = null, $foreignKey = null, $otherKey = null, $inverse = false)
- {
+ public function morphToManyUnique($related, $name, $table = NULL, $foreignKey = NULL, $otherKey = NULL, $inverse = FALSE) {
$caller = $this->getBelongsToManyCaller();
// First, we will need to determine the foreign key and "other key" for the
// relationship. Once we have determined the keys we will make the query
// instances, as well as the relationship instances we need for these.
- $foreignKey = $foreignKey ?: $name.'_id';
+ $foreignKey = $foreignKey ?: $name . '_id';
$instance = new $related;
@@ -221,16 +217,15 @@ trait HasRelationships
* This has been superseded by the belongsToManyUnique relationship's `withTernary` method since 4.1.7.
*
* @deprecated since 4.1.6
- * @param string $related
- * @param string $constraintKey
- * @param string $table
- * @param string $foreignKey
- * @param string $relatedKey
- * @param string $relation
+ * @param string $related
+ * @param string $constraintKey
+ * @param string $table
+ * @param string $foreignKey
+ * @param string $relatedKey
+ * @param string $relation
* @return \UserFrosting\Sprinkle\Core\Database\Relations\BelongsToManyConstrained
*/
- public function belongsToManyConstrained($related, $constraintKey, $table = null, $foreignKey = null, $relatedKey = null, $relation = null)
- {
+ public function belongsToManyConstrained($related, $constraintKey, $table = NULL, $foreignKey = NULL, $relatedKey = NULL, $relation = NULL) {
// If no relationship name was passed, we will pull backtraces to get the
// name of the calling function. We will use that function name as the
// title of this relation since that is a great convention to apply.
@@ -264,15 +259,14 @@ trait HasRelationships
*
* @return string
*/
- protected function getBelongsToManyCaller()
- {
+ protected function getBelongsToManyCaller() {
$self = __FUNCTION__;
$caller = Arr::first(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS), function ($key, $trace) use ($self) {
$caller = $trace['function'];
- return ! in_array($caller, HasRelationships::$manyMethodsExtended) && $caller != $self;
+ return !in_array($caller, HasRelationships::$manyMethodsExtended) && $caller != $self;
});
- return ! is_null($caller) ? $caller['function'] : null;
+ return !is_null($caller) ? $caller['function'] : NULL;
}
}
diff --git a/main/app/sprinkles/core/src/Database/Models/Model.php b/main/app/sprinkles/core/src/Database/Models/Model.php
index 1c18c2c..28b6be0 100644
--- a/main/app/sprinkles/core/src/Database/Models/Model.php
+++ b/main/app/sprinkles/core/src/Database/Models/Model.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Database\Models;
use Illuminate\Database\Capsule\Manager as DB;
@@ -29,10 +30,9 @@ abstract class Model extends LaravelModel
/**
* @var bool Disable timestamps for now.
*/
- public $timestamps = false;
+ public $timestamps = FALSE;
- public function __construct(array $attributes = [])
- {
+ public function __construct(array $attributes = []) {
// Hacky way to force the DB service to load before attempting to use the model
static::$ci['db'];
@@ -42,24 +42,22 @@ abstract class Model extends LaravelModel
/**
* Determine if an attribute exists on the model - even if it is null.
*
- * @param string $key
+ * @param string $key
* @return bool
*/
- public function attributeExists($key)
- {
+ public function attributeExists($key) {
return array_key_exists($key, $this->attributes);
}
/**
* Determines whether a model exists by checking a unique column, including checking soft-deleted records
*
- * @param mixed $value
+ * @param mixed $value
* @param string $identifier
- * @param bool $checkDeleted set to true to include soft-deleted records
+ * @param bool $checkDeleted set to true to include soft-deleted records
* @return \UserFrosting\Sprinkle\Core\Database\Models\Model|null
*/
- public static function findUnique($value, $identifier, $checkDeleted = true)
- {
+ public static function findUnique($value, $identifier, $checkDeleted = TRUE) {
$query = static::where($identifier, $value);
if ($checkDeleted) {
@@ -72,11 +70,10 @@ abstract class Model extends LaravelModel
/**
* Determine if an relation exists on the model - even if it is null.
*
- * @param string $key
+ * @param string $key
* @return bool
*/
- public function relationExists($key)
- {
+ public function relationExists($key) {
return array_key_exists($key, $this->relations);
}
@@ -86,8 +83,7 @@ abstract class Model extends LaravelModel
* Calls save(), then returns the id of the new record in the database.
* @return int the id of this object.
*/
- public function store()
- {
+ public function store() {
$this->save();
// Store function should always return the id of the object
@@ -99,8 +95,7 @@ abstract class Model extends LaravelModel
*
* @return \UserFrosting\Sprinkles\Core\Database\Builder
*/
- protected function newBaseQueryBuilder()
- {
+ protected function newBaseQueryBuilder() {
/** @var UserFrosting\Sprinkle\Core\Util\ClassMapper $classMapper */
$classMapper = static::$ci->classMapper;
@@ -120,8 +115,7 @@ abstract class Model extends LaravelModel
* @deprecated since 4.1.8 There is no point in having this alias.
* @return array
*/
- public function export()
- {
+ public function export() {
return $this->toArray();
}
@@ -131,8 +125,7 @@ abstract class Model extends LaravelModel
* @deprecated since 4.1.8 setFetchMode is no longer available as of Laravel 5.4.
* @link https://github.com/laravel/framework/issues/17728
*/
- public static function queryBuilder()
- {
+ public static function queryBuilder() {
// Set query builder to fetch result sets as associative arrays (instead of creating stdClass objects)
DB::connection()->setFetchMode(\PDO::FETCH_ASSOC);
return DB::table(static::$table);
diff --git a/main/app/sprinkles/core/src/Database/Models/Throttle.php b/main/app/sprinkles/core/src/Database/Models/Throttle.php
index d13a7c1..82d2c87 100644
--- a/main/app/sprinkles/core/src/Database/Models/Throttle.php
+++ b/main/app/sprinkles/core/src/Database/Models/Throttle.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Database\Models;
/**
@@ -17,10 +18,10 @@ namespace UserFrosting\Sprinkle\Core\Database\Models;
* @property string request_data
*/
class Throttle extends Model
-{
+{
/**
* @var string The name of the table for the current model.
- */
+ */
protected $table = "throttles";
protected $fillable = [
@@ -31,6 +32,6 @@ class Throttle extends Model
/**
* @var bool Enable timestamps for Throttles.
- */
- public $timestamps = true;
+ */
+ public $timestamps = TRUE;
}
diff --git a/main/app/sprinkles/core/src/Database/Relations/BelongsToManyConstrained.php b/main/app/sprinkles/core/src/Database/Relations/BelongsToManyConstrained.php
index d652b56..cf79223 100644
--- a/main/app/sprinkles/core/src/Database/Relations/BelongsToManyConstrained.php
+++ b/main/app/sprinkles/core/src/Database/Relations/BelongsToManyConstrained.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Database\Relations;
use Illuminate\Database\Eloquent\Model;
@@ -30,17 +31,16 @@ class BelongsToManyConstrained extends BelongsToMany
/**
* Create a new belongs to many constrained relationship instance.
*
- * @param \Illuminate\Database\Eloquent\Builder $query
- * @param \Illuminate\Database\Eloquent\Model $parent
- * @param string $constraintKey
- * @param string $table
- * @param string $foreignKey
- * @param string $relatedKey
- * @param string $relationName
+ * @param \Illuminate\Database\Eloquent\Builder $query
+ * @param \Illuminate\Database\Eloquent\Model $parent
+ * @param string $constraintKey
+ * @param string $table
+ * @param string $foreignKey
+ * @param string $relatedKey
+ * @param string $relationName
* @return void
*/
- public function __construct(Builder $query, Model $parent, $constraintKey, $table, $foreignKey, $relatedKey, $relationName = null)
- {
+ public function __construct(Builder $query, Model $parent, $constraintKey, $table, $foreignKey, $relatedKey, $relationName = NULL) {
$this->constraintKey = $constraintKey;
parent::__construct($query, $parent, $table, $foreignKey, $relatedKey, $relationName);
}
@@ -48,11 +48,10 @@ class BelongsToManyConstrained extends BelongsToMany
/**
* Set the constraints for an eager load of the relation.
*
- * @param array $models
+ * @param array $models
* @return void
*/
- public function addEagerConstraints(array $models)
- {
+ public function addEagerConstraints(array $models) {
// To make the query more efficient, we only bother querying related models if their pivot key value
// matches the pivot key value of one of the parent models.
$pivotKeys = $this->getPivotKeys($models, $this->constraintKey);
@@ -63,8 +62,7 @@ class BelongsToManyConstrained extends BelongsToMany
/**
* Gets a list of unique pivot key values from an array of models.
*/
- protected function getPivotKeys(array $models, $pivotKey)
- {
+ protected function getPivotKeys(array $models, $pivotKey) {
$pivotKeys = [];
foreach ($models as $model) {
$pivotKeys[] = $model->getRelation('pivot')->{$pivotKey};
@@ -77,13 +75,12 @@ class BelongsToManyConstrained extends BelongsToMany
* in the parent object to the child objects.
*
* @link Called in https://github.com/laravel/framework/blob/2f4135d8db5ded851d1f4f611124c53b768a3c08/src/Illuminate/Database/Eloquent/Builder.php
- * @param array $models
- * @param \Illuminate\Database\Eloquent\Collection $results
- * @param string $relation
+ * @param array $models
+ * @param \Illuminate\Database\Eloquent\Collection $results
+ * @param string $relation
* @return array
*/
- public function match(array $models, Collection $results, $relation)
- {
+ public function match(array $models, Collection $results, $relation) {
$dictionary = $this->buildDictionary($results);
// Once we have an array dictionary of child objects we can easily match the
@@ -109,8 +106,7 @@ class BelongsToManyConstrained extends BelongsToMany
* @param mixed $pivotValue
* @return array
*/
- protected function findMatchingPivots($items, $pivotValue)
- {
+ protected function findMatchingPivots($items, $pivotValue) {
$result = [];
foreach ($items as $item) {
if ($item->getRelation('pivot')->{$this->constraintKey} == $pivotValue) {
diff --git a/main/app/sprinkles/core/src/Database/Relations/BelongsToManyThrough.php b/main/app/sprinkles/core/src/Database/Relations/BelongsToManyThrough.php
index 33be507..67304be 100644
--- a/main/app/sprinkles/core/src/Database/Relations/BelongsToManyThrough.php
+++ b/main/app/sprinkles/core/src/Database/Relations/BelongsToManyThrough.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Database\Relations;
use Illuminate\Database\Eloquent\Model;
@@ -34,17 +35,16 @@ class BelongsToManyThrough extends BelongsToMany
/**
* Create a new belongs to many relationship instance.
*
- * @param \Illuminate\Database\Eloquent\Builder $query
- * @param \Illuminate\Database\Eloquent\Model $parent
+ * @param \Illuminate\Database\Eloquent\Builder $query
+ * @param \Illuminate\Database\Eloquent\Model $parent
* @param \Illuminate\Database\Eloquent\Relations\Relation $intermediateRelation
- * @param string $table
- * @param string $foreignKey
- * @param string $relatedKey
- * @param string $relationName
+ * @param string $table
+ * @param string $foreignKey
+ * @param string $relatedKey
+ * @param string $relationName
* @return void
*/
- public function __construct(Builder $query, Model $parent, Relation $intermediateRelation, $table, $foreignKey, $relatedKey, $relationName = null)
- {
+ public function __construct(Builder $query, Model $parent, Relation $intermediateRelation, $table, $foreignKey, $relatedKey, $relationName = NULL) {
$this->intermediateRelation = $intermediateRelation;
parent::__construct($query, $parent, $table, $foreignKey, $relatedKey, $relationName);
@@ -57,8 +57,7 @@ class BelongsToManyThrough extends BelongsToMany
* It would be better if BelongsToMany had a simple accessor for its foreign key.
* @return string
*/
- public function getParentKeyName()
- {
+ public function getParentKeyName() {
return $this->intermediateRelation->newExistingPivot()->getForeignKey();
}
@@ -68,20 +67,18 @@ class BelongsToManyThrough extends BelongsToMany
* @see \Illuminate\Database\Eloquent\Relations\BelongsToMany
* @return string
*/
- public function getExistenceCompareKey()
- {
+ public function getExistenceCompareKey() {
return $this->intermediateRelation->getQualifiedForeignKeyName();
}
/**
* Add a "via" query to load the intermediate models through which the child models are related.
*
- * @param string $viaRelationName
+ * @param string $viaRelationName
* @param callable $viaCallback
* @return $this
*/
- public function withVia($viaRelationName = null, $viaCallback = null)
- {
+ public function withVia($viaRelationName = NULL, $viaCallback = NULL) {
$this->tertiaryRelated = $this->intermediateRelation->getRelated();
// Set tertiary key and related model
@@ -90,10 +87,10 @@ class BelongsToManyThrough extends BelongsToMany
$this->tertiaryRelationName = is_null($viaRelationName) ? $this->intermediateRelation->getRelationName() . '_via' : $viaRelationName;
$this->tertiaryCallback = is_null($viaCallback)
- ? function () {
- //
- }
- : $viaCallback;
+ ? function () {
+ //
+ }
+ : $viaCallback;
return $this;
}
@@ -101,11 +98,10 @@ class BelongsToManyThrough extends BelongsToMany
/**
* Set the constraints for an eager load of the relation.
*
- * @param array $models
+ * @param array $models
* @return void
*/
- public function addEagerConstraints(array $models)
- {
+ public function addEagerConstraints(array $models) {
// Constraint to only load models where the intermediate relation's foreign key matches the parent model
$intermediateForeignKeyName = $this->intermediateRelation->getQualifiedForeignKeyName();
@@ -117,8 +113,7 @@ class BelongsToManyThrough extends BelongsToMany
*
* @return $this
*/
- protected function addWhereConstraints()
- {
+ protected function addWhereConstraints() {
$parentKeyName = $this->getParentKeyName();
$this->query->where(
@@ -131,13 +126,12 @@ class BelongsToManyThrough extends BelongsToMany
/**
* Match the eagerly loaded results to their parents
*
- * @param array $models
- * @param \Illuminate\Database\Eloquent\Collection $results
- * @param string $relation
+ * @param array $models
+ * @param \Illuminate\Database\Eloquent\Collection $results
+ * @param string $relation
* @return array
*/
- public function match(array $models, Collection $results, $relation)
- {
+ public function match(array $models, Collection $results, $relation) {
// Build dictionary of parent (e.g. user) to related (e.g. permission) models
list($dictionary, $nestedViaDictionary) = $this->buildDictionary($results, $this->getParentKeyName());
@@ -177,8 +171,7 @@ class BelongsToManyThrough extends BelongsToMany
* @param \Illuminate\Database\Eloquent\Collection $models
* @return void
*/
- protected function unsetTertiaryPivots(Collection $models)
- {
+ protected function unsetTertiaryPivots(Collection $models) {
foreach ($models as $model) {
unset($model->pivot->{$this->foreignKey});
}
@@ -187,11 +180,10 @@ class BelongsToManyThrough extends BelongsToMany
/**
* Set the join clause for the relation query.
*
- * @param \Illuminate\Database\Eloquent\Builder|null $query
+ * @param \Illuminate\Database\Eloquent\Builder|null $query
* @return $this
*/
- protected function performJoin($query = null)
- {
+ protected function performJoin($query = NULL) {
$query = $query ?: $this->query;
parent::performJoin($query);
@@ -215,11 +207,10 @@ class BelongsToManyThrough extends BelongsToMany
*
* @return array
*/
- protected function aliasedPivotColumns()
- {
+ protected function aliasedPivotColumns() {
$defaults = [$this->foreignKey, $this->relatedKey];
$aliasedPivotColumns = collect(array_merge($defaults, $this->pivotColumns))->map(function ($column) {
- return $this->table.'.'.$column.' as pivot_'.$column;
+ return $this->table . '.' . $column . ' as pivot_' . $column;
});
$parentKeyName = $this->getParentKeyName();
diff --git a/main/app/sprinkles/core/src/Database/Relations/BelongsToManyUnique.php b/main/app/sprinkles/core/src/Database/Relations/BelongsToManyUnique.php
index f256f17..d5d473d 100644
--- a/main/app/sprinkles/core/src/Database/Relations/BelongsToManyUnique.php
+++ b/main/app/sprinkles/core/src/Database/Relations/BelongsToManyUnique.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Database\Relations;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
diff --git a/main/app/sprinkles/core/src/Database/Relations/Concerns/Syncable.php b/main/app/sprinkles/core/src/Database/Relations/Concerns/Syncable.php
index 278b762..cb32d52 100644
--- a/main/app/sprinkles/core/src/Database/Relations/Concerns/Syncable.php
+++ b/main/app/sprinkles/core/src/Database/Relations/Concerns/Syncable.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Database\Relations\Concerns;
use Illuminate\Database\Eloquent\Model;
@@ -22,12 +23,11 @@ trait Syncable
* Synchronizes an array of data for related models with a parent model.
*
* @param mixed[] $data
- * @param bool $deleting Delete models from the database that are not represented in the input data.
- * @param bool $forceCreate Ignore mass assignment restrictions on child models.
- * @param string $relatedKeyName The primary key used to determine which child models are new, updated, or deleted.
+ * @param bool $deleting Delete models from the database that are not represented in the input data.
+ * @param bool $forceCreate Ignore mass assignment restrictions on child models.
+ * @param string $relatedKeyName The primary key used to determine which child models are new, updated, or deleted.
*/
- public function sync($data, $deleting = true, $forceCreate = false, $relatedKeyName = null)
- {
+ public function sync($data, $deleting = TRUE, $forceCreate = FALSE, $relatedKeyName = NULL) {
$changes = [
'created' => [], 'deleted' => [], 'updated' => [],
];
@@ -71,9 +71,9 @@ trait Syncable
if ($deleting && count($deleteIds) > 0) {
// Remove global scopes to avoid ambiguous keys
$this->getRelated()
- ->withoutGlobalScopes()
- ->whereIn($relatedKeyName, $deleteIds)
- ->delete();
+ ->withoutGlobalScopes()
+ ->whereIn($relatedKeyName, $deleteIds)
+ ->delete();
$changes['deleted'] = $this->castKeys($deleteIds);
}
@@ -82,11 +82,11 @@ trait Syncable
foreach ($updateRows as $id => $row) {
// Remove global scopes to avoid ambiguous keys
$this->getRelated()
- ->withoutGlobalScopes()
- ->where($relatedKeyName, $id)
- ->update($row);
+ ->withoutGlobalScopes()
+ ->where($relatedKeyName, $id)
+ ->update($row);
}
-
+
$changes['updated'] = $this->castKeys($updateIds);
// Insert the new rows
@@ -109,24 +109,22 @@ trait Syncable
/**
* Cast the given keys to integers if they are numeric and string otherwise.
*
- * @param array $keys
+ * @param array $keys
* @return array
*/
- protected function castKeys(array $keys)
- {
- return (array) array_map(function ($v) {
+ protected function castKeys(array $keys) {
+ return (array)array_map(function ($v) {
return $this->castKey($v);
}, $keys);
}
-
+
/**
* Cast the given key to an integer if it is numeric.
*
- * @param mixed $key
+ * @param mixed $key
* @return mixed
*/
- protected function castKey($key)
- {
- return is_numeric($key) ? (int) $key : (string) $key;
+ protected function castKey($key) {
+ return is_numeric($key) ? (int)$key : (string)$key;
}
}
diff --git a/main/app/sprinkles/core/src/Database/Relations/Concerns/Unique.php b/main/app/sprinkles/core/src/Database/Relations/Concerns/Unique.php
index 4b529bb..71c1c4c 100644
--- a/main/app/sprinkles/core/src/Database/Relations/Concerns/Unique.php
+++ b/main/app/sprinkles/core/src/Database/Relations/Concerns/Unique.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Database\Relations\Concerns;
use Illuminate\Database\Eloquent\Builder;
@@ -23,14 +24,14 @@ trait Unique
*
* @var \Illuminate\Database\Eloquent\Model
*/
- protected $tertiaryRelated = null;
+ protected $tertiaryRelated = NULL;
/**
* The name to use for the tertiary relation (e.g. 'roles_via', etc)
*
* @var string
*/
- protected $tertiaryRelationName = null;
+ protected $tertiaryRelationName = NULL;
/**
* The foreign key to the related tertiary model instance.
@@ -44,30 +45,29 @@ trait Unique
*
* @var callable|null
*/
- protected $tertiaryCallback = null;
+ protected $tertiaryCallback = NULL;
/**
* The limit to apply on the number of related models retrieved.
*
* @var int|null
*/
- protected $limit = null;
+ protected $limit = NULL;
/**
* The offset to apply on the related models retrieved.
*
* @var int|null
*/
- protected $offset = null;
+ protected $offset = NULL;
/**
* Alias to set the "offset" value of the query.
*
- * @param int $value
+ * @param int $value
* @return $this
*/
- public function skip($value)
- {
+ public function skip($value) {
return $this->offset($value);
}
@@ -76,11 +76,10 @@ trait Unique
*
* @todo Implement for 'unionOffset' as well? (By checking the value of $this->query->getQuery()->unions)
* @see \Illuminate\Database\Query\Builder
- * @param int $value
+ * @param int $value
* @return $this
*/
- public function offset($value)
- {
+ public function offset($value) {
$this->offset = max(0, $value);
return $this;
@@ -89,11 +88,10 @@ trait Unique
/**
* Alias to set the "limit" value of the query.
*
- * @param int $value
+ * @param int $value
* @return $this
*/
- public function take($value)
- {
+ public function take($value) {
return $this->limit($value);
}
@@ -102,11 +100,10 @@ trait Unique
*
* @todo Implement for 'unionLimit' as well? (By checking the value of $this->query->getQuery()->unions)
* @see \Illuminate\Database\Query\Builder
- * @param int $value
+ * @param int $value
* @return $this
*/
- public function limit($value)
- {
+ public function limit($value) {
if ($value >= 0) {
$this->limit = $value;
}
@@ -121,8 +118,7 @@ trait Unique
* @param int $value
* @return $this
*/
- public function withLimit($value)
- {
+ public function withLimit($value) {
return $this->limit($value);
}
@@ -133,22 +129,20 @@ trait Unique
* @param int $value
* @return $this
*/
- public function withOffset($value)
- {
+ public function withOffset($value) {
return $this->offset($value);
}
/**
* Add a query to load the nested tertiary models for this relationship.
*
- * @param \Illuminate\Database\Eloquent\Model $tertiaryRelated
- * @param string $tertiaryRelationName
- * @param string $tertiaryKey
- * @param callable $tertiaryCallback
+ * @param \Illuminate\Database\Eloquent\Model $tertiaryRelated
+ * @param string $tertiaryRelationName
+ * @param string $tertiaryKey
+ * @param callable $tertiaryCallback
* @return $this
*/
- public function withTertiary($tertiaryRelated, $tertiaryRelationName = null, $tertiaryKey = null, $tertiaryCallback = null)
- {
+ public function withTertiary($tertiaryRelated, $tertiaryRelationName = NULL, $tertiaryKey = NULL, $tertiaryCallback = NULL) {
$this->tertiaryRelated = new $tertiaryRelated;
// Try to guess the tertiary related key from the tertiaryRelated model.
@@ -160,10 +154,10 @@ trait Unique
$this->tertiaryRelationName = is_null($tertiaryRelationName) ? $this->tertiaryRelated->getTable() : $tertiaryRelationName;
$this->tertiaryCallback = is_null($tertiaryCallback)
- ? function () {
- //
- }
- : $tertiaryCallback;
+ ? function () {
+ //
+ }
+ : $tertiaryCallback;
return $this;
}
@@ -174,8 +168,7 @@ trait Unique
* @see http://stackoverflow.com/a/29728129/2970321
* @return int
*/
- public function count()
- {
+ public function count() {
$constrainedBuilder = clone $this->query;
$constrainedBuilder = $constrainedBuilder->distinct();
@@ -187,12 +180,11 @@ trait Unique
* Add the constraints for a relationship count query.
*
* @see \Illuminate\Database\Eloquent\Relations\Relation
- * @param \Illuminate\Database\Eloquent\Builder $query
- * @param \Illuminate\Database\Eloquent\Builder $parentQuery
+ * @param \Illuminate\Database\Eloquent\Builder $query
+ * @param \Illuminate\Database\Eloquent\Builder $parentQuery
* @return \Illuminate\Database\Eloquent\Builder
*/
- public function getRelationExistenceCountQuery(Builder $query, Builder $parentQuery)
- {
+ public function getRelationExistenceCountQuery(Builder $query, Builder $parentQuery) {
return $this->getRelationExistenceQuery(
$query, $parentQuery, new Expression("count(distinct {$this->relatedKey})")
);
@@ -201,13 +193,12 @@ trait Unique
/**
* Match the eagerly loaded results to their parents
*
- * @param array $models
- * @param \Illuminate\Database\Eloquent\Collection $results
- * @param string $relation
+ * @param array $models
+ * @param \Illuminate\Database\Eloquent\Collection $results
+ * @param string $relation
* @return array
*/
- public function match(array $models, Collection $results, $relation)
- {
+ public function match(array $models, Collection $results, $relation) {
// Build dictionary of parent (e.g. user) to related (e.g. permission) models
list($dictionary, $nestedTertiaryDictionary) = $this->buildDictionary($results, $this->foreignKey);
@@ -240,13 +231,12 @@ trait Unique
* Execute the query as a "select" statement, getting all requested models
* and matching up any tertiary models.
*
- * @param array $columns
+ * @param array $columns
* @return \Illuminate\Database\Eloquent\Collection
*/
- public function get($columns = ['*'])
- {
+ public function get($columns = ['*']) {
// Get models and condense the result set
- $models = $this->getModels($columns, true);
+ $models = $this->getModels($columns, TRUE);
// Remove the tertiary pivot key from the condensed models
$this->unsetTertiaryPivots($models);
@@ -258,13 +248,12 @@ trait Unique
* If we are applying either a limit or offset, we'll first determine a limited/offset list of model ids
* to select from in the final query.
*
- * @param \Illuminate\Database\Eloquent\Builder $query
+ * @param \Illuminate\Database\Eloquent\Builder $query
* @param int $limit
* @param int $offset
* @return \Illuminate\Database\Eloquent\Builder
*/
- public function getPaginatedQuery(Builder $query, $limit = null, $offset = null)
- {
+ public function getPaginatedQuery(Builder $query, $limit = NULL, $offset = NULL) {
$constrainedBuilder = clone $query;
// Since some unique models will be represented by more than one row in the database,
@@ -278,7 +267,7 @@ trait Unique
// Apply an additional scope to override any selected columns in other global scopes
$uniqueIdScope = function ($subQuery) use ($relatedKeyName) {
$subQuery->select($relatedKeyName)
- ->groupBy($relatedKeyName);
+ ->groupBy($relatedKeyName);
};
$identifier = spl_object_hash($uniqueIdScope);
@@ -308,21 +297,19 @@ trait Unique
*
* @return \Illuminate\Database\Eloquent\Collection
*/
- public function getEager()
- {
- return $this->getModels(['*'], false);
+ public function getEager() {
+ return $this->getModels(['*'], FALSE);
}
/**
* Get the hydrated models and eager load their relations, optionally
* condensing the set of models before performing the eager loads.
*
- * @param array $columns
- * @param bool $condenseModels
+ * @param array $columns
+ * @param bool $condenseModels
* @return \Illuminate\Database\Eloquent\Collection
*/
- public function getModels($columns = ['*'], $condenseModels = true)
- {
+ public function getModels($columns = ['*'], $condenseModels = TRUE) {
// First we'll add the proper select columns onto the query so it is run with
// the proper columns. Then, we will get the results and hydrate out pivot
// models with the result of those columns as a separate model relation.
@@ -367,10 +354,9 @@ trait Unique
* @param array $models
* @return array
*/
- protected function condenseModels(array $models)
- {
+ protected function condenseModels(array $models) {
// Build dictionary of tertiary models, if `withTertiary` was called
- $dictionary = null;
+ $dictionary = NULL;
if ($this->tertiaryRelated) {
$dictionary = $this->buildTertiaryDictionary($models);
}
@@ -392,12 +378,11 @@ trait Unique
* that maps parent ids to arrays of related ids, which in turn map to arrays
* of tertiary models corresponding to each relationship.
*
- * @param \Illuminate\Database\Eloquent\Collection $results
+ * @param \Illuminate\Database\Eloquent\Collection $results
* @param string $parentKey
* @return array
*/
- protected function buildDictionary(Collection $results, $parentKey = null)
- {
+ protected function buildDictionary(Collection $results, $parentKey = NULL) {
// First we will build a dictionary of child models keyed by the "parent key" (foreign key
// of the intermediate relation) so that we will easily and quickly match them to their
// parents without having a possibly slow inner loops for every models.
@@ -416,8 +401,8 @@ trait Unique
// ],
// ...
//]
- $nestedTertiaryDictionary = null;
- $tertiaryModels = null;
+ $nestedTertiaryDictionary = NULL;
+ $tertiaryModels = NULL;
if ($this->tertiaryRelationName) {
// Get all tertiary models from the result set matching any of the parent models.
@@ -439,11 +424,11 @@ trait Unique
if (!is_null($tertiaryKeyValue)) {
$tertiaryModel = clone $tertiaryModels[$tertiaryKeyValue];
-
+
// We also transfer the pivot relation at this point, since we have already coalesced
// any tertiary models into the nested dictionary.
$this->transferPivotsToTertiary($result, $tertiaryModel);
-
+
$nestedTertiaryDictionary[$parentKeyValue][$result->getKey()][] = $tertiaryModel;
}
}
@@ -455,11 +440,10 @@ trait Unique
/**
* Build dictionary of tertiary models keyed by the corresponding related model keys.
*
- * @param array $models
+ * @param array $models
* @return array
*/
- protected function buildTertiaryDictionary(array $models)
- {
+ protected function buildTertiaryDictionary(array $models) {
$dictionary = [];
// Find the related tertiary entities (e.g. tasks) for all related models (e.g. locations)
@@ -479,8 +463,7 @@ trait Unique
return $dictionary;
}
- protected function transferPivotsToTertiary($model, $tertiaryModel)
- {
+ protected function transferPivotsToTertiary($model, $tertiaryModel) {
$pivotAttributes = [];
foreach ($this->pivotColumns as $column) {
$pivotAttributes[$column] = $model->pivot->$column;
@@ -499,11 +482,10 @@ trait Unique
/**
* Get the tertiary models for the relationship.
*
- * @param array $models
+ * @param array $models
* @return \Illuminate\Database\Eloquent\Collection
*/
- protected function getTertiaryModels(array $models)
- {
+ protected function getTertiaryModels(array $models) {
$tertiaryClass = $this->tertiaryRelated;
$keys = [];
@@ -529,11 +511,10 @@ trait Unique
* Match a collection of child models into a collection of parent models using a dictionary.
*
* @param array $dictionary
- * @param \Illuminate\Database\Eloquent\Collection $results
+ * @param \Illuminate\Database\Eloquent\Collection $results
* @return void
*/
- protected function matchTertiaryModels(array $dictionary, Collection $results)
- {
+ protected function matchTertiaryModels(array $dictionary, Collection $results) {
// Now go through and set the tertiary relation on each child model
foreach ($results as $model) {
if (isset($dictionary[$key = $model->getKey()])) {
@@ -552,8 +533,7 @@ trait Unique
* @param \Illuminate\Database\Eloquent\Collection $models
* @return void
*/
- protected function unsetTertiaryPivots(Collection $models)
- {
+ protected function unsetTertiaryPivots(Collection $models) {
foreach ($models as $model) {
foreach ($this->pivotColumns as $column) {
unset($model->pivot->$column);
diff --git a/main/app/sprinkles/core/src/Database/Relations/HasManySyncable.php b/main/app/sprinkles/core/src/Database/Relations/HasManySyncable.php
index bcf2a9d..9d85b1f 100644
--- a/main/app/sprinkles/core/src/Database/Relations/HasManySyncable.php
+++ b/main/app/sprinkles/core/src/Database/Relations/HasManySyncable.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Database\Relations;
use Illuminate\Database\Eloquent\Relations\HasMany;
diff --git a/main/app/sprinkles/core/src/Database/Relations/MorphManySyncable.php b/main/app/sprinkles/core/src/Database/Relations/MorphManySyncable.php
index 2786193..bb90257 100644
--- a/main/app/sprinkles/core/src/Database/Relations/MorphManySyncable.php
+++ b/main/app/sprinkles/core/src/Database/Relations/MorphManySyncable.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Database\Relations;
use Illuminate\Database\Eloquent\Relations\MorphMany;
diff --git a/main/app/sprinkles/core/src/Database/Relations/MorphToManyUnique.php b/main/app/sprinkles/core/src/Database/Relations/MorphToManyUnique.php
index cc9a03f..0920d1c 100644
--- a/main/app/sprinkles/core/src/Database/Relations/MorphToManyUnique.php
+++ b/main/app/sprinkles/core/src/Database/Relations/MorphToManyUnique.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Database\Relations;
use Illuminate\Database\Eloquent\Relations\MorphToMany;
diff --git a/main/app/sprinkles/core/src/Error/ExceptionHandlerManager.php b/main/app/sprinkles/core/src/Error/ExceptionHandlerManager.php
index 4680da5..716ccdd 100644
--- a/main/app/sprinkles/core/src/Error/ExceptionHandlerManager.php
+++ b/main/app/sprinkles/core/src/Error/ExceptionHandlerManager.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Error;
use Interop\Container\ContainerInterface;
@@ -41,8 +42,7 @@ class ExceptionHandlerManager
* @param ContainerInterface $ci The global container object, which holds all your services.
* @param boolean $displayErrorDetails Set to true to display full details
*/
- public function __construct(ContainerInterface $ci, $displayErrorDetails = false)
- {
+ public function __construct(ContainerInterface $ci, $displayErrorDetails = FALSE) {
$this->ci = $ci;
$this->displayErrorDetails = (bool)$displayErrorDetails;
}
@@ -50,14 +50,13 @@ class ExceptionHandlerManager
/**
* Invoke error handler
*
- * @param ServerRequestInterface $request The most recent Request object
- * @param ResponseInterface $response The most recent Response object
- * @param Throwable $exception The caught Exception object
+ * @param ServerRequestInterface $request The most recent Request object
+ * @param ResponseInterface $response The most recent Response object
+ * @param Throwable $exception The caught Exception object
*
* @return ResponseInterface
*/
- public function __invoke(ServerRequestInterface $request, ResponseInterface $response, $exception)
- {
+ public function __invoke(ServerRequestInterface $request, ResponseInterface $response, $exception) {
// Default exception handler class
$handlerClass = '\UserFrosting\Sprinkle\Core\Error\Handler\ExceptionHandler';
@@ -82,9 +81,8 @@ class ExceptionHandlerManager
* @param string $handlerClass The fully qualified class name of the assigned handler.
* @throws InvalidArgumentException If the registered handler fails to implement ExceptionHandlerInterface
*/
- public function registerHandler($exceptionClass, $handlerClass)
- {
- if (!is_a($handlerClass, '\UserFrosting\Sprinkle\Core\Error\Handler\ExceptionHandlerInterface', true)) {
+ public function registerHandler($exceptionClass, $handlerClass) {
+ if (!is_a($handlerClass, '\UserFrosting\Sprinkle\Core\Error\Handler\ExceptionHandlerInterface', TRUE)) {
throw new \InvalidArgumentException("Registered exception handler must implement ExceptionHandlerInterface!");
}
diff --git a/main/app/sprinkles/core/src/Error/Handler/ExceptionHandler.php b/main/app/sprinkles/core/src/Error/Handler/ExceptionHandler.php
index 4fdc51d..89e890e 100644
--- a/main/app/sprinkles/core/src/Error/Handler/ExceptionHandler.php
+++ b/main/app/sprinkles/core/src/Error/Handler/ExceptionHandler.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Error\Handler;
use Interop\Container\ContainerInterface;
@@ -50,7 +51,7 @@ class ExceptionHandler implements ExceptionHandlerInterface
/**
* @var ErrorRendererInterface
*/
- protected $renderer = null;
+ protected $renderer = NULL;
/**
* @var string
@@ -73,18 +74,18 @@ class ExceptionHandler implements ExceptionHandlerInterface
/**
* Create a new ExceptionHandler object.
*
- * @param ContainerInterface $ci
- * @param ServerRequestInterface $request The most recent Request object
- * @param ResponseInterface $response The most recent Response object
- * @param Throwable $exception The caught Exception object
- * @param bool $displayErrorDetails
+ * @param ContainerInterface $ci
+ * @param ServerRequestInterface $request The most recent Request object
+ * @param ResponseInterface $response The most recent Response object
+ * @param Throwable $exception The caught Exception object
+ * @param bool $displayErrorDetails
*/
public function __construct(
ContainerInterface $ci,
ServerRequestInterface $request,
ResponseInterface $response,
$exception,
- $displayErrorDetails = false
+ $displayErrorDetails = FALSE
) {
$this->ci = $ci;
$this->request = $request;
@@ -102,8 +103,7 @@ class ExceptionHandler implements ExceptionHandlerInterface
*
* @return ResponseInterface
*/
- public function handle()
- {
+ public function handle() {
// If displayErrorDetails is set to true, we'll halt and immediately respond with a detailed debugging page.
// We do not log errors in this case.
if ($this->displayErrorDetails) {
@@ -129,8 +129,7 @@ class ExceptionHandler implements ExceptionHandlerInterface
*
* @return ResponseInterface
*/
- public function renderDebugResponse()
- {
+ public function renderDebugResponse() {
$body = $this->renderer->renderWithBody();
return $this->response
@@ -144,8 +143,7 @@ class ExceptionHandler implements ExceptionHandlerInterface
*
* @return ResponseInterface
*/
- public function renderGenericResponse()
- {
+ public function renderGenericResponse() {
$messages = $this->determineUserMessages();
$httpCode = $this->statusCode;
@@ -168,9 +166,8 @@ class ExceptionHandler implements ExceptionHandlerInterface
*
* @return void
*/
- public function writeToErrorLog()
- {
- $renderer = new PlainTextRenderer($this->request, $this->response, $this->exception, true);
+ public function writeToErrorLog() {
+ $renderer = new PlainTextRenderer($this->request, $this->response, $this->exception, TRUE);
$error = $renderer->render();
$error .= PHP_EOL . 'View in rendered output by enabling the "displayErrorDetails" setting.' . PHP_EOL;
$this->logError($error);
@@ -181,8 +178,7 @@ class ExceptionHandler implements ExceptionHandlerInterface
*
* @return void
*/
- public function writeAlerts()
- {
+ public function writeAlerts() {
$messages = $this->determineUserMessages();
foreach ($messages as $message) {
@@ -198,8 +194,7 @@ class ExceptionHandler implements ExceptionHandlerInterface
*
* @throws \RuntimeException
*/
- protected function determineRenderer()
- {
+ protected function determineRenderer() {
$renderer = $this->renderer;
if ((!is_null($renderer) && !class_exists($renderer))
@@ -242,8 +237,7 @@ class ExceptionHandler implements ExceptionHandlerInterface
*
* @return int
*/
- protected function determineStatusCode()
- {
+ protected function determineStatusCode() {
if ($this->request->getMethod() === 'OPTIONS') {
return 200;
}
@@ -255,8 +249,7 @@ class ExceptionHandler implements ExceptionHandlerInterface
*
* @return array
*/
- protected function determineUserMessages()
- {
+ protected function determineUserMessages() {
return [
new UserMessage("ERROR.SERVER")
];
@@ -268,8 +261,7 @@ class ExceptionHandler implements ExceptionHandlerInterface
* @param $message
* @return void
*/
- protected function logError($message)
- {
+ protected function logError($message) {
$this->ci->errorLogger->error($message);
}
}
diff --git a/main/app/sprinkles/core/src/Error/Handler/ExceptionHandlerInterface.php b/main/app/sprinkles/core/src/Error/Handler/ExceptionHandlerInterface.php
index a928b69..2ac9ada 100644
--- a/main/app/sprinkles/core/src/Error/Handler/ExceptionHandlerInterface.php
+++ b/main/app/sprinkles/core/src/Error/Handler/ExceptionHandlerInterface.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Error\Handler;
use Interop\Container\ContainerInterface;
@@ -18,7 +19,7 @@ use Psr\Http\Message\ServerRequestInterface;
*/
interface ExceptionHandlerInterface
{
- public function __construct(ContainerInterface $ci, ServerRequestInterface $request, ResponseInterface $response, $exception, $displayErrorDetails = false);
+ public function __construct(ContainerInterface $ci, ServerRequestInterface $request, ResponseInterface $response, $exception, $displayErrorDetails = FALSE);
public function handle();
diff --git a/main/app/sprinkles/core/src/Error/Handler/HttpExceptionHandler.php b/main/app/sprinkles/core/src/Error/Handler/HttpExceptionHandler.php
index 946bda7..cb66919 100644
--- a/main/app/sprinkles/core/src/Error/Handler/HttpExceptionHandler.php
+++ b/main/app/sprinkles/core/src/Error/Handler/HttpExceptionHandler.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Error\Handler;
use UserFrosting\Support\Exception\HttpException;
@@ -21,8 +22,7 @@ class HttpExceptionHandler extends ExceptionHandler
*
* @return void
*/
- public function writeToErrorLog()
- {
+ public function writeToErrorLog() {
if ($this->statusCode != 500) {
return;
}
@@ -35,11 +35,10 @@ class HttpExceptionHandler extends ExceptionHandler
*
* @return int
*/
- protected function determineStatusCode()
- {
+ protected function determineStatusCode() {
if ($this->request->getMethod() === 'OPTIONS') {
return 200;
- } elseif ($this->exception instanceof HttpException) {
+ } else if ($this->exception instanceof HttpException) {
return $this->exception->getHttpErrorCode();
}
return 500;
@@ -50,8 +49,7 @@ class HttpExceptionHandler extends ExceptionHandler
*
* @return array
*/
- protected function determineUserMessages()
- {
+ protected function determineUserMessages() {
if ($this->exception instanceof HttpException) {
return $this->exception->getUserMessages();
}
diff --git a/main/app/sprinkles/core/src/Error/Handler/NotFoundExceptionHandler.php b/main/app/sprinkles/core/src/Error/Handler/NotFoundExceptionHandler.php
index 306feed..a866cc3 100644
--- a/main/app/sprinkles/core/src/Error/Handler/NotFoundExceptionHandler.php
+++ b/main/app/sprinkles/core/src/Error/Handler/NotFoundExceptionHandler.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Error\Handler;
use UserFrosting\Sprinkle\Core\Error\Handler\HttpExceptionHandler;
@@ -23,8 +24,7 @@ class NotFoundExceptionHandler extends HttpExceptionHandler
*
* @return Response
*/
- public function handle()
- {
+ public function handle() {
// Render generic error page
$response = $this->renderGenericResponse();
diff --git a/main/app/sprinkles/core/src/Error/Handler/PhpMailerExceptionHandler.php b/main/app/sprinkles/core/src/Error/Handler/PhpMailerExceptionHandler.php
index 45f0e8d..e7117e9 100644
--- a/main/app/sprinkles/core/src/Error/Handler/PhpMailerExceptionHandler.php
+++ b/main/app/sprinkles/core/src/Error/Handler/PhpMailerExceptionHandler.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Error\Handler;
use UserFrosting\Support\Message\UserMessage;
@@ -21,8 +22,7 @@ class PhpMailerExceptionHandler extends ExceptionHandler
*
* @return array
*/
- protected function determineUserMessages()
- {
+ protected function determineUserMessages() {
return [
new UserMessage("ERROR.MAIL")
];
diff --git a/main/app/sprinkles/core/src/Error/Renderer/ErrorRenderer.php b/main/app/sprinkles/core/src/Error/Renderer/ErrorRenderer.php
index f065af0..0cf12f3 100644
--- a/main/app/sprinkles/core/src/Error/Renderer/ErrorRenderer.php
+++ b/main/app/sprinkles/core/src/Error/Renderer/ErrorRenderer.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Error\Renderer;
use Slim\Http\Body;
@@ -37,13 +38,12 @@ abstract class ErrorRenderer implements ErrorRendererInterface
/**
* Create a new ErrorRenderer object.
*
- * @param ServerRequestInterface $request The most recent Request object
- * @param ResponseInterface $response The most recent Response object
- * @param Exception $exception The caught Exception object
- * @param bool $displayErrorDetails
+ * @param ServerRequestInterface $request The most recent Request object
+ * @param ResponseInterface $response The most recent Response object
+ * @param Exception $exception The caught Exception object
+ * @param bool $displayErrorDetails
*/
- public function __construct($request, $response, $exception, $displayErrorDetails = false)
- {
+ public function __construct($request, $response, $exception, $displayErrorDetails = FALSE) {
$this->request = $request;
$this->response = $response;
$this->exception = $exception;
@@ -55,8 +55,7 @@ abstract class ErrorRenderer implements ErrorRendererInterface
/**
* @return Body
*/
- public function renderWithBody()
- {
+ public function renderWithBody() {
$body = new Body(fopen('php://temp', 'r+'));
$body->write($this->render());
return $body;
diff --git a/main/app/sprinkles/core/src/Error/Renderer/ErrorRendererInterface.php b/main/app/sprinkles/core/src/Error/Renderer/ErrorRendererInterface.php
index 7af269a..efb0bd6 100644
--- a/main/app/sprinkles/core/src/Error/Renderer/ErrorRendererInterface.php
+++ b/main/app/sprinkles/core/src/Error/Renderer/ErrorRendererInterface.php
@@ -5,18 +5,19 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Error\Renderer;
interface ErrorRendererInterface
{
/**
- * @param ServerRequestInterface $request The most recent Request object
- * @param ResponseInterface $response The most recent Response object
- * @param Exception $exception The caught Exception object
+ * @param ServerRequestInterface $request The most recent Request object
+ * @param ResponseInterface $response The most recent Response object
+ * @param Exception $exception The caught Exception object
* @param bool $displayErrorDetails
*/
- public function __construct($request, $response, $exception, $displayErrorDetails = false);
-
+ public function __construct($request, $response, $exception, $displayErrorDetails = FALSE);
+
/**
* @return string
*/
diff --git a/main/app/sprinkles/core/src/Error/Renderer/HtmlRenderer.php b/main/app/sprinkles/core/src/Error/Renderer/HtmlRenderer.php
index 1f32675..e97a5de 100644
--- a/main/app/sprinkles/core/src/Error/Renderer/HtmlRenderer.php
+++ b/main/app/sprinkles/core/src/Error/Renderer/HtmlRenderer.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Error\Renderer;
class HtmlRenderer extends ErrorRenderer
@@ -14,8 +15,7 @@ class HtmlRenderer extends ErrorRenderer
*
* @return string
*/
- public function render()
- {
+ public function render() {
$title = 'UserFrosting Application Error';
if ($this->displayErrorDetails) {
@@ -60,8 +60,7 @@ class HtmlRenderer extends ErrorRenderer
* @param Exception $exception
* @return string
*/
- public function renderException($exception)
- {
+ public function renderException($exception) {
$html = sprintf('<div><strong>Type:</strong> %s</div>', get_class($exception));
if (($code = $exception->getCode())) {
@@ -93,8 +92,7 @@ class HtmlRenderer extends ErrorRenderer
*
* @return string
*/
- public function renderRequest()
- {
+ public function renderRequest() {
$method = $this->request->getMethod();
$uri = $this->request->getUri();
$params = $this->request->getParams();
@@ -120,8 +118,7 @@ class HtmlRenderer extends ErrorRenderer
*
* @return string
*/
- public function renderResponseHeaders()
- {
+ public function renderResponseHeaders() {
$html = '<h3>Response headers:</h3>';
$html .= '<em>Additional response headers may have been set by Slim after the error handling routine. Please check your browser console for a complete list.</em><br>';
@@ -137,11 +134,10 @@ class HtmlRenderer extends ErrorRenderer
*
* @return string
*/
- protected function renderTable($data)
- {
+ protected function renderTable($data) {
$html = '<table><tr><th>Name</th><th>Value</th></tr>';
foreach ($data as $name => $value) {
- $value = print_r($value, true);
+ $value = print_r($value, TRUE);
$html .= "<tr><td>$name</td><td>$value</td></tr>";
}
$html .= '</table>';
diff --git a/main/app/sprinkles/core/src/Error/Renderer/JsonRenderer.php b/main/app/sprinkles/core/src/Error/Renderer/JsonRenderer.php
index 3adfd45..6a96780 100644
--- a/main/app/sprinkles/core/src/Error/Renderer/JsonRenderer.php
+++ b/main/app/sprinkles/core/src/Error/Renderer/JsonRenderer.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Error\Renderer;
/**
@@ -15,8 +16,7 @@ class JsonRenderer extends ErrorRenderer
/**
* @return string
*/
- public function render()
- {
+ public function render() {
$message = $this->exception->getMessage();
return $this->formatExceptionPayload($message);
}
@@ -25,8 +25,7 @@ class JsonRenderer extends ErrorRenderer
* @param $message
* @return string
*/
- public function formatExceptionPayload($message)
- {
+ public function formatExceptionPayload($message) {
$e = $this->exception;
$error = ['message' => $message];
@@ -44,8 +43,7 @@ class JsonRenderer extends ErrorRenderer
* @param \Exception|\Throwable $e
* @return array
*/
- public function formatExceptionFragment($e)
- {
+ public function formatExceptionFragment($e) {
return [
'type' => get_class($e),
'code' => $e->getCode(),
diff --git a/main/app/sprinkles/core/src/Error/Renderer/PlainTextRenderer.php b/main/app/sprinkles/core/src/Error/Renderer/PlainTextRenderer.php
index a4984fc..9922f22 100644
--- a/main/app/sprinkles/core/src/Error/Renderer/PlainTextRenderer.php
+++ b/main/app/sprinkles/core/src/Error/Renderer/PlainTextRenderer.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Error\Renderer;
/**
@@ -12,8 +13,7 @@ namespace UserFrosting\Sprinkle\Core\Error\Renderer;
*/
class PlainTextRenderer extends ErrorRenderer
{
- public function render()
- {
+ public function render() {
if ($this->displayErrorDetails) {
return $this->formatExceptionBody();
}
@@ -21,8 +21,7 @@ class PlainTextRenderer extends ErrorRenderer
return $this->exception->getMessage();
}
- public function formatExceptionBody()
- {
+ public function formatExceptionBody() {
$e = $this->exception;
$text = 'UserFrosting Application Error:' . PHP_EOL;
@@ -40,8 +39,7 @@ class PlainTextRenderer extends ErrorRenderer
* @param \Exception|\Throwable $e
* @return string
*/
- public function formatExceptionFragment($e)
- {
+ public function formatExceptionFragment($e) {
$text = sprintf('Type: %s' . PHP_EOL, get_class($e));
if ($code = $e->getCode()) {
diff --git a/main/app/sprinkles/core/src/Error/Renderer/WhoopsRenderer.php b/main/app/sprinkles/core/src/Error/Renderer/WhoopsRenderer.php
index 767ce1b..2ef6588 100644
--- a/main/app/sprinkles/core/src/Error/Renderer/WhoopsRenderer.php
+++ b/main/app/sprinkles/core/src/Error/Renderer/WhoopsRenderer.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Error\Renderer;
use InvalidArgumentException;
@@ -41,7 +42,7 @@ class WhoopsRenderer extends ErrorRenderer
*
* @var string
*/
- private $customCss = null;
+ private $customCss = NULL;
/**
* @var array[]
@@ -51,7 +52,7 @@ class WhoopsRenderer extends ErrorRenderer
/**
* @var bool
*/
- private $handleUnconditionally = false;
+ private $handleUnconditionally = FALSE;
/**
* @var string
@@ -93,12 +94,12 @@ class WhoopsRenderer extends ErrorRenderer
* @var array
*/
protected $editors = [
- "sublime" => "subl://open?url=file://%file&line=%line",
+ "sublime" => "subl://open?url=file://%file&line=%line",
"textmate" => "txmt://open?url=file://%file&line=%line",
- "emacs" => "emacs://open?url=file://%file&line=%line",
- "macvim" => "mvim://open/?url=file://%file&line=%line",
+ "emacs" => "emacs://open?url=file://%file&line=%line",
+ "macvim" => "mvim://open/?url=file://%file&line=%line",
"phpstorm" => "phpstorm://open?file=%file&line=%line",
- "idea" => "idea://open?file=%file&line=%line",
+ "idea" => "idea://open?file=%file&line=%line",
];
/**
@@ -114,8 +115,7 @@ class WhoopsRenderer extends ErrorRenderer
/**
* {@inheritDoc}
*/
- public function __construct($request, $response, $exception, $displayErrorDetails = false)
- {
+ public function __construct($request, $response, $exception, $displayErrorDetails = FALSE) {
$this->request = $request;
$this->response = $response;
$this->exception = $exception;
@@ -162,8 +162,7 @@ class WhoopsRenderer extends ErrorRenderer
/**
* {@inheritDoc}
*/
- public function render()
- {
+ public function render() {
if (!$this->handleUnconditionally()) {
// Check conditions for outputting HTML:
// @todo: Make this more robust
@@ -173,7 +172,7 @@ class WhoopsRenderer extends ErrorRenderer
if (isset($_ENV['whoops-test'])) {
throw new \Exception(
'Use handleUnconditionally instead of whoops-test'
- .' environment variable'
+ . ' environment variable'
);
}
@@ -182,17 +181,17 @@ class WhoopsRenderer extends ErrorRenderer
}
$templateFile = $this->getResource("views/layout.html.php");
- $cssFile = $this->getResource("css/whoops.base.css");
- $zeptoFile = $this->getResource("js/zepto.min.js");
- $clipboard = $this->getResource("js/clipboard.min.js");
- $jsFile = $this->getResource("js/whoops.base.js");
+ $cssFile = $this->getResource("css/whoops.base.css");
+ $zeptoFile = $this->getResource("js/zepto.min.js");
+ $clipboard = $this->getResource("js/clipboard.min.js");
+ $jsFile = $this->getResource("js/whoops.base.js");
if ($this->customCss) {
$customCssFile = $this->getResource($this->customCss);
}
$inspector = $this->getInspector();
- $frames = $inspector->getFrames();
+ $frames = $inspector->getFrames();
$code = $inspector->getException()->getCode();
@@ -207,7 +206,7 @@ class WhoopsRenderer extends ErrorRenderer
foreach ($frames as $frame) {
foreach ($this->applicationPaths as $path) {
if (substr($frame->getFile(), 0, strlen($path)) === $path) {
- $frame->setApplication(true);
+ $frame->setApplication(TRUE);
break;
}
}
@@ -215,7 +214,7 @@ class WhoopsRenderer extends ErrorRenderer
}
// Nicely format the session object
- $session = isset($_SESSION) ? $this->masked($_SESSION, '_SESSION') : [];
+ $session = isset($_SESSION) ? $this->masked($_SESSION, '_SESSION') : [];
$session = ['session' => Util::prettyPrintArray($session)];
// List of variables that will be passed to the layout template.
@@ -224,43 +223,43 @@ class WhoopsRenderer extends ErrorRenderer
// @todo: Asset compiler
"stylesheet" => file_get_contents($cssFile),
- "zepto" => file_get_contents($zeptoFile),
- "clipboard" => file_get_contents($clipboard),
+ "zepto" => file_get_contents($zeptoFile),
+ "clipboard" => file_get_contents($clipboard),
"javascript" => file_get_contents($jsFile),
// Template paths:
- "header" => $this->getResource("views/header.html.php"),
- "header_outer" => $this->getResource("views/header_outer.html.php"),
- "frame_list" => $this->getResource("views/frame_list.html.php"),
- "frames_description" => $this->getResource("views/frames_description.html.php"),
- "frames_container" => $this->getResource("views/frames_container.html.php"),
- "panel_details" => $this->getResource("views/panel_details.html.php"),
- "panel_details_outer" => $this->getResource("views/panel_details_outer.html.php"),
- "panel_left" => $this->getResource("views/panel_left.html.php"),
- "panel_left_outer" => $this->getResource("views/panel_left_outer.html.php"),
- "frame_code" => $this->getResource("views/frame_code.html.php"),
- "env_details" => $this->getResource("views/env_details.html.php"),
-
- "title" => $this->getPageTitle(),
- "name" => explode("\\", $inspector->getExceptionName()),
- "message" => $inspector->getException()->getMessage(),
- "code" => $code,
+ "header" => $this->getResource("views/header.html.php"),
+ "header_outer" => $this->getResource("views/header_outer.html.php"),
+ "frame_list" => $this->getResource("views/frame_list.html.php"),
+ "frames_description" => $this->getResource("views/frames_description.html.php"),
+ "frames_container" => $this->getResource("views/frames_container.html.php"),
+ "panel_details" => $this->getResource("views/panel_details.html.php"),
+ "panel_details_outer" => $this->getResource("views/panel_details_outer.html.php"),
+ "panel_left" => $this->getResource("views/panel_left.html.php"),
+ "panel_left_outer" => $this->getResource("views/panel_left_outer.html.php"),
+ "frame_code" => $this->getResource("views/frame_code.html.php"),
+ "env_details" => $this->getResource("views/env_details.html.php"),
+
+ "title" => $this->getPageTitle(),
+ "name" => explode("\\", $inspector->getExceptionName()),
+ "message" => $inspector->getException()->getMessage(),
+ "code" => $code,
"plain_exception" => Formatter::formatExceptionPlain($inspector),
- "frames" => $frames,
- "has_frames" => !!count($frames),
- "handler" => $this,
- "handlers" => [$this],
-
- "active_frames_tab" => count($frames) && $frames->offsetGet(0)->isApplication() ? 'application' : 'all',
- "has_frames_tabs" => $this->getApplicationPaths(),
-
- "tables" => [
- "GET Data" => $this->masked($_GET, '_GET'),
- "POST Data" => $this->masked($_POST, '_POST'),
- "Files" => isset($_FILES) ? $this->masked($_FILES, '_FILES') : [],
- "Cookies" => $this->masked($_COOKIE, '_COOKIE'),
- "Session" => $session,
- "Server/Request Data" => $this->masked($_SERVER, '_SERVER'),
+ "frames" => $frames,
+ "has_frames" => !!count($frames),
+ "handler" => $this,
+ "handlers" => [$this],
+
+ "active_frames_tab" => count($frames) && $frames->offsetGet(0)->isApplication() ? 'application' : 'all',
+ "has_frames_tabs" => $this->getApplicationPaths(),
+
+ "tables" => [
+ "GET Data" => $this->masked($_GET, '_GET'),
+ "POST Data" => $this->masked($_POST, '_POST'),
+ "Files" => isset($_FILES) ? $this->masked($_FILES, '_FILES') : [],
+ "Cookies" => $this->masked($_COOKIE, '_COOKIE'),
+ "Session" => $session,
+ "Server/Request Data" => $this->masked($_SERVER, '_SERVER'),
"Environment Variables" => $this->masked($_ENV, '_ENV'),
],
];
@@ -295,10 +294,9 @@ class WhoopsRenderer extends ErrorRenderer
* The expected data is a simple associative array. Any nested arrays
* will be flattened with print_r
* @param string $label
- * @param array $data
+ * @param array $data
*/
- public function addDataTable($label, array $data)
- {
+ public function addDataTable($label, array $data) {
$this->extraTables[$label] = $data;
}
@@ -309,16 +307,16 @@ class WhoopsRenderer extends ErrorRenderer
* be flattened with print_r.
*
* @throws InvalidArgumentException If $callback is not callable
- * @param string $label
- * @param callable $callback Callable returning an associative array
+ * @param string $label
+ * @param callable $callback Callable returning an associative array
*/
- public function addDataTableCallback($label, /* callable */ $callback)
- {
+ public function addDataTableCallback($label, /* callable */
+ $callback) {
if (!is_callable($callback)) {
throw new InvalidArgumentException('Expecting callback argument to be callable');
}
- $this->extraTables[$label] = function (\Whoops\Exception\Inspector $inspector = null) use ($callback) {
+ $this->extraTables[$label] = function (\Whoops\Exception\Inspector $inspector = NULL) use ($callback) {
try {
$result = call_user_func($callback, $inspector);
@@ -337,8 +335,7 @@ class WhoopsRenderer extends ErrorRenderer
* @param $superGlobalName string the name of the superglobal array, e.g. '_GET'
* @param $key string the key within the superglobal
*/
- public function blacklist($superGlobalName, $key)
- {
+ public function blacklist($superGlobalName, $key) {
$this->blacklist[$superGlobalName][] = $key;
}
@@ -346,14 +343,13 @@ class WhoopsRenderer extends ErrorRenderer
* Returns all the extra data tables registered with this handler.
* Optionally accepts a 'label' parameter, to only return the data
* table under that label.
- * @param string|null $label
+ * @param string|null $label
* @return array[]|callable
*/
- public function getDataTables($label = null)
- {
- if ($label !== null) {
+ public function getDataTables($label = NULL) {
+ if ($label !== NULL) {
return isset($this->extraTables[$label]) ?
- $this->extraTables[$label] : [];
+ $this->extraTables[$label] : [];
}
return $this->extraTables;
@@ -366,13 +362,12 @@ class WhoopsRenderer extends ErrorRenderer
* @param bool|null $value
* @return bool|null
*/
- public function handleUnconditionally($value = null)
- {
+ public function handleUnconditionally($value = NULL) {
if (func_num_args() == 0) {
return $this->handleUnconditionally;
}
- $this->handleUnconditionally = (bool) $value;
+ $this->handleUnconditionally = (bool)$value;
}
/**
@@ -391,8 +386,7 @@ class WhoopsRenderer extends ErrorRenderer
* @param string $identifier
* @param string $resolver
*/
- public function addEditor($identifier, $resolver)
- {
+ public function addEditor($identifier, $resolver) {
$this->editors[$identifier] = $resolver;
}
@@ -408,10 +402,9 @@ class WhoopsRenderer extends ErrorRenderer
* $run->setEditor('sublime');
*
* @throws InvalidArgumentException If invalid argument identifier provided
- * @param string|callable $editor
+ * @param string|callable $editor
*/
- public function setEditor($editor)
- {
+ public function setEditor($editor) {
if (!is_callable($editor) && !isset($this->editors[$editor])) {
throw new InvalidArgumentException(
"Unknown editor identifier: $editor. Known editors:" .
@@ -429,16 +422,15 @@ class WhoopsRenderer extends ErrorRenderer
* file reference.
*
* @throws InvalidArgumentException If editor resolver does not return a string
- * @param string $filePath
- * @param int $line
+ * @param string $filePath
+ * @param int $line
* @return string|bool
*/
- public function getEditorHref($filePath, $line)
- {
+ public function getEditorHref($filePath, $line) {
$editor = $this->getEditor($filePath, $line);
if (empty($editor)) {
- return false;
+ return FALSE;
}
// Check that the editor is a string, and replace the
@@ -461,12 +453,11 @@ class WhoopsRenderer extends ErrorRenderer
* valid callable function/closure
*
* @throws UnexpectedValueException If editor resolver does not return a boolean
- * @param string $filePath
- * @param int $line
+ * @param string $filePath
+ * @param int $line
* @return bool
*/
- public function getEditorAjax($filePath, $line)
- {
+ public function getEditorAjax($filePath, $line) {
$editor = $this->getEditor($filePath, $line);
// Check that the ajax is a bool
@@ -482,16 +473,14 @@ class WhoopsRenderer extends ErrorRenderer
* @param string $title
* @return void
*/
- public function setPageTitle($title)
- {
- $this->pageTitle = (string) $title;
+ public function setPageTitle($title) {
+ $this->pageTitle = (string)$title;
}
/**
* @return string
*/
- public function getPageTitle()
- {
+ public function getPageTitle() {
return $this->pageTitle;
}
@@ -504,8 +493,7 @@ class WhoopsRenderer extends ErrorRenderer
* @param string $path
* @return void
*/
- public function addResourcePath($path)
- {
+ public function addResourcePath($path) {
if (!is_dir($path)) {
throw new InvalidArgumentException(
"'$path' is not a valid directory"
@@ -521,16 +509,14 @@ class WhoopsRenderer extends ErrorRenderer
* @param string $name
* @return void
*/
- public function addCustomCss($name)
- {
+ public function addCustomCss($name) {
$this->customCss = $name;
}
/**
* @return array
*/
- public function getResourcePaths()
- {
+ public function getResourcePaths() {
return $this->searchPaths;
}
@@ -539,12 +525,11 @@ class WhoopsRenderer extends ErrorRenderer
*
* @return string
*/
- public function getResourcesPath()
- {
+ public function getResourcesPath() {
$allPaths = $this->getResourcePaths();
// Compat: return only the first path added
- return end($allPaths) ?: null;
+ return end($allPaths) ?: NULL;
}
/**
@@ -553,8 +538,7 @@ class WhoopsRenderer extends ErrorRenderer
* @param string $resourcesPath
* @return void
*/
- public function setResourcesPath($resourcesPath)
- {
+ public function setResourcesPath($resourcesPath) {
$this->addResourcePath($resourcesPath);
}
@@ -563,8 +547,7 @@ class WhoopsRenderer extends ErrorRenderer
*
* @return array
*/
- public function getApplicationPaths()
- {
+ public function getApplicationPaths() {
return $this->applicationPaths;
}
@@ -573,8 +556,7 @@ class WhoopsRenderer extends ErrorRenderer
*
* @param array $applicationPaths
*/
- public function setApplicationPaths($applicationPaths)
- {
+ public function setApplicationPaths($applicationPaths) {
$this->applicationPaths = $applicationPaths;
}
@@ -583,8 +565,7 @@ class WhoopsRenderer extends ErrorRenderer
*
* @param string $applicationRootPath
*/
- public function setApplicationRootPath($applicationRootPath)
- {
+ public function setApplicationRootPath($applicationRootPath) {
$this->templateHelper->setApplicationRootPath($applicationRootPath);
}
@@ -594,18 +575,17 @@ class WhoopsRenderer extends ErrorRenderer
* valid callable function/closure
*
* @param string $filePath
- * @param int $line
+ * @param int $line
* @return array
*/
- protected function getEditor($filePath, $line)
- {
+ protected function getEditor($filePath, $line) {
if (!$this->editor || (!is_string($this->editor) && !is_callable($this->editor))) {
return [];
}
if (is_string($this->editor) && isset($this->editors[$this->editor]) && !is_callable($this->editors[$this->editor])) {
- return [
- 'ajax' => false,
+ return [
+ 'ajax' => FALSE,
'url' => $this->editors[$this->editor],
];
}
@@ -619,13 +599,13 @@ class WhoopsRenderer extends ErrorRenderer
if (is_string($callback)) {
return [
- 'ajax' => false,
+ 'ajax' => FALSE,
'url' => $callback,
];
}
return [
- 'ajax' => isset($callback['ajax']) ? $callback['ajax'] : false,
+ 'ajax' => isset($callback['ajax']) ? $callback['ajax'] : FALSE,
'url' => isset($callback['url']) ? $callback['url'] : $callback,
];
}
@@ -636,16 +616,14 @@ class WhoopsRenderer extends ErrorRenderer
/**
* @return \Throwable
*/
- protected function getException()
- {
+ protected function getException() {
return $this->exception;
}
/**
* @return Inspector
*/
- protected function getInspector()
- {
+ protected function getInspector() {
return $this->inspector;
}
@@ -660,8 +638,7 @@ class WhoopsRenderer extends ErrorRenderer
* @param string $resource
* @return string
*/
- protected function getResource($resource)
- {
+ protected function getResource($resource) {
// If the resource was found before, we can speed things up
// by caching its absolute, resolved path:
if (isset($this->resourceCache[$resource])) {
@@ -683,7 +660,7 @@ class WhoopsRenderer extends ErrorRenderer
// If we got this far, nothing was found.
throw new RuntimeException(
"Could not find resource '$resource' in any resource paths."
- . "(searched: " . join(", ", $this->searchPaths). ")"
+ . "(searched: " . join(", ", $this->searchPaths) . ")"
);
}
@@ -697,12 +674,11 @@ class WhoopsRenderer extends ErrorRenderer
* @param string $superGlobalName the name of the superglobal array, e.g. '_GET'
* @return array $values without sensitive data
*/
- private function masked(array $superGlobal, $superGlobalName)
- {
+ private function masked(array $superGlobal, $superGlobalName) {
$blacklisted = $this->blacklist[$superGlobalName];
$values = $superGlobal;
- foreach($blacklisted as $key) {
+ foreach ($blacklisted as $key) {
if (isset($superGlobal[$key])) {
$values[$key] = str_repeat('*', strlen($superGlobal[$key]));
}
diff --git a/main/app/sprinkles/core/src/Error/Renderer/XmlRenderer.php b/main/app/sprinkles/core/src/Error/Renderer/XmlRenderer.php
index 52e71cf..5c51d8d 100644
--- a/main/app/sprinkles/core/src/Error/Renderer/XmlRenderer.php
+++ b/main/app/sprinkles/core/src/Error/Renderer/XmlRenderer.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Error\Renderer;
/**
@@ -15,8 +16,7 @@ class XmlRenderer extends ErrorRenderer
/**
* @return string
*/
- public function render()
- {
+ public function render() {
$e = $this->exception;
$xml = "<error>\n <message>UserFrosting Application Error</message>\n";
if ($this->displayErrorDetails) {
@@ -41,8 +41,7 @@ class XmlRenderer extends ErrorRenderer
* @param string $content
* @return string
*/
- private function createCdataSection($content)
- {
+ private function createCdataSection($content) {
return sprintf('<![CDATA[%s]]>', str_replace(']]>', ']]]]><![CDATA[>', $content));
}
}
diff --git a/main/app/sprinkles/core/src/Facades/Debug.php b/main/app/sprinkles/core/src/Facades/Debug.php
index 86ef450..40cc263 100644
--- a/main/app/sprinkles/core/src/Facades/Debug.php
+++ b/main/app/sprinkles/core/src/Facades/Debug.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Facades;
use UserFrosting\System\Facade;
@@ -21,8 +22,7 @@ class Debug extends Facade
*
* @return string
*/
- protected static function getFacadeAccessor()
- {
+ protected static function getFacadeAccessor() {
return 'debugLogger';
}
}
diff --git a/main/app/sprinkles/core/src/Facades/Translator.php b/main/app/sprinkles/core/src/Facades/Translator.php
index e6fcccc..d1d365b 100644
--- a/main/app/sprinkles/core/src/Facades/Translator.php
+++ b/main/app/sprinkles/core/src/Facades/Translator.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Facades;
use UserFrosting\System\Facade;
@@ -21,8 +22,7 @@ class Translator extends Facade
*
* @return string
*/
- protected static function getFacadeAccessor()
- {
+ protected static function getFacadeAccessor() {
return 'translator';
}
}
diff --git a/main/app/sprinkles/core/src/Http/Concerns/DeterminesContentType.php b/main/app/sprinkles/core/src/Http/Concerns/DeterminesContentType.php
index e963afa..06cf0b3 100644
--- a/main/app/sprinkles/core/src/Http/Concerns/DeterminesContentType.php
+++ b/main/app/sprinkles/core/src/Http/Concerns/DeterminesContentType.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Http\Concerns;
use Psr\Http\Message\ServerRequestInterface;
@@ -39,8 +40,7 @@ trait DeterminesContentType
* @param ServerRequestInterface $request
* @return string
*/
- protected function determineContentType(ServerRequestInterface $request, $ajaxDebug = false)
- {
+ protected function determineContentType(ServerRequestInterface $request, $ajaxDebug = FALSE) {
// For AJAX requests, if AJAX debugging is turned on, always return html
if ($ajaxDebug && $request->isXhr()) {
return 'text/html';
diff --git a/main/app/sprinkles/core/src/Log/DatabaseHandler.php b/main/app/sprinkles/core/src/Log/DatabaseHandler.php
index c78308c..d4c9fce 100644
--- a/main/app/sprinkles/core/src/Log/DatabaseHandler.php
+++ b/main/app/sprinkles/core/src/Log/DatabaseHandler.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Log;
use Monolog\Logger;
@@ -32,11 +33,10 @@ class DatabaseHandler extends AbstractProcessingHandler
*
* @param ClassMapper $classMapper Maps the modelIdentifier to the specific Eloquent model.
* @param string $modelIdentifier
- * @param int $level The minimum logging level at which this handler will be triggered
+ * @param int $level The minimum logging level at which this handler will be triggered
* @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
*/
- public function __construct($classMapper, $modelIdentifier, $level = Logger::DEBUG, $bubble = true)
- {
+ public function __construct($classMapper, $modelIdentifier, $level = Logger::DEBUG, $bubble = TRUE) {
$this->classMapper = $classMapper;
$this->modelName = $modelIdentifier;
parent::__construct($level, $bubble);
@@ -45,8 +45,7 @@ class DatabaseHandler extends AbstractProcessingHandler
/**
* {@inheritDoc}
*/
- protected function write(array $record)
- {
+ protected function write(array $record) {
$log = $this->classMapper->createInstance($this->modelName, $record['extra']);
$log->save();
}
diff --git a/main/app/sprinkles/core/src/Log/MixedFormatter.php b/main/app/sprinkles/core/src/Log/MixedFormatter.php
index beae788..ce21879 100644
--- a/main/app/sprinkles/core/src/Log/MixedFormatter.php
+++ b/main/app/sprinkles/core/src/Log/MixedFormatter.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Log;
use Monolog\Formatter\LineFormatter;
@@ -23,13 +24,12 @@ class MixedFormatter extends LineFormatter
/**
* Return the JSON representation of a value
*
- * @param mixed $data
- * @param bool $ignoreErrors
+ * @param mixed $data
+ * @param bool $ignoreErrors
* @throws \RuntimeException if encoding fails and errors are not ignored
* @return string
*/
- protected function toJson($data, $ignoreErrors = false)
- {
+ protected function toJson($data, $ignoreErrors = FALSE) {
// suppress json_encode errors since it's twitchy with some inputs
if ($ignoreErrors) {
return @$this->jsonEncodePretty($data);
@@ -37,7 +37,7 @@ class MixedFormatter extends LineFormatter
$json = $this->jsonEncodePretty($data);
- if ($json === false) {
+ if ($json === FALSE) {
$json = $this->handleJsonError(json_last_error(), $data);
}
@@ -45,11 +45,10 @@ class MixedFormatter extends LineFormatter
}
/**
- * @param mixed $data
+ * @param mixed $data
* @return string JSON encoded data or null on failure
*/
- private function jsonEncodePretty($data)
- {
+ private function jsonEncodePretty($data) {
if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
return json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
}
diff --git a/main/app/sprinkles/core/src/Mail/EmailRecipient.php b/main/app/sprinkles/core/src/Mail/EmailRecipient.php
index 0b9381a..33b7db7 100644
--- a/main/app/sprinkles/core/src/Mail/EmailRecipient.php
+++ b/main/app/sprinkles/core/src/Mail/EmailRecipient.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Mail;
/**
@@ -49,8 +50,7 @@ class EmailRecipient
* @param string $name The primary recipient name.
* @param array $params An array of template parameters to render the email message with for this particular recipient.
*/
- public function __construct($email, $name = "", $params = [])
- {
+ public function __construct($email, $name = "", $params = []) {
$this->email = $email;
$this->name = $name;
$this->params = $params;
@@ -62,8 +62,7 @@ class EmailRecipient
* @param string $email The CC recipient email address.
* @param string $name The CC recipient name.
*/
- public function cc($email, $name = "")
- {
+ public function cc($email, $name = "") {
$this->cc[] = [
"email" => $email,
"name" => $name
@@ -76,8 +75,7 @@ class EmailRecipient
* @param string $email The BCC recipient email address.
* @param string $name The BCC recipient name.
*/
- public function bcc($email, $name = "")
- {
+ public function bcc($email, $name = "") {
$this->bcc[] = [
"email" => $email,
"name" => $name
@@ -89,8 +87,7 @@ class EmailRecipient
*
* @return string the primary recipient email address.
*/
- public function getEmail()
- {
+ public function getEmail() {
return $this->email;
}
@@ -99,8 +96,7 @@ class EmailRecipient
*
* @return string the primary recipient name.
*/
- public function getName()
- {
+ public function getName() {
return $this->name;
}
@@ -109,8 +105,7 @@ class EmailRecipient
*
* @return array The parameters (name => value) to use when rendering an email template for this recipient.
*/
- public function getParams()
- {
+ public function getParams() {
return $this->params;
}
@@ -119,8 +114,7 @@ class EmailRecipient
*
* @return array A list of CCs for this recipient. Each CC is an associative array with `email` and `name` properties.
*/
- public function getCCs()
- {
+ public function getCCs() {
return $this->cc;
}
@@ -129,8 +123,7 @@ class EmailRecipient
*
* @return array A list of BCCs for this recipient. Each BCC is an associative array with `email` and `name` properties.
*/
- public function getBCCs()
- {
+ public function getBCCs() {
return $this->bcc;
}
}
diff --git a/main/app/sprinkles/core/src/Mail/MailMessage.php b/main/app/sprinkles/core/src/Mail/MailMessage.php
index 29bcf15..6aea56d 100644
--- a/main/app/sprinkles/core/src/Mail/MailMessage.php
+++ b/main/app/sprinkles/core/src/Mail/MailMessage.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Mail;
/**
@@ -24,7 +25,7 @@ abstract class MailMessage
/**
* @var string The current sender name.
*/
- protected $fromName = null;
+ protected $fromName = NULL;
/**
* @var EmailRecipient[] A list of recipients for this message.
@@ -34,12 +35,12 @@ abstract class MailMessage
/**
* @var string The current reply-to email.
*/
- protected $replyEmail = null;
+ protected $replyEmail = NULL;
/**
* @var string The current reply-to name.
*/
- protected $replyName = null;
+ protected $replyName = NULL;
/**
* Gets the fully rendered text of the message body.
@@ -60,8 +61,7 @@ abstract class MailMessage
*
* @param EmailRecipient $recipient
*/
- public function addEmailRecipient(EmailRecipient $recipient)
- {
+ public function addEmailRecipient(EmailRecipient $recipient) {
$this->recipients[] = $recipient;
return $this;
}
@@ -69,8 +69,7 @@ abstract class MailMessage
/**
* Clears out all recipients for this message.
*/
- public function clearRecipients()
- {
+ public function clearRecipients() {
$this->recipients = array();
}
@@ -80,12 +79,11 @@ abstract class MailMessage
* This is a shortcut for calling setFromEmail, setFromName, setReplyEmail, and setReplyName.
* @param string $fromInfo An array containing 'email', 'name', 'reply_email', and 'reply_name'.
*/
- public function from($fromInfo = [])
- {
+ public function from($fromInfo = []) {
$this->setFromEmail(isset($fromInfo['email']) ? $fromInfo['email'] : "");
- $this->setFromName(isset($fromInfo['name']) ? $fromInfo['name'] : null);
- $this->setReplyEmail(isset($fromInfo['reply_email']) ? $fromInfo['reply_email'] : null);
- $this->setReplyName(isset($fromInfo['reply_name']) ? $fromInfo['reply_name'] : null);
+ $this->setFromName(isset($fromInfo['name']) ? $fromInfo['name'] : NULL);
+ $this->setReplyEmail(isset($fromInfo['reply_email']) ? $fromInfo['reply_email'] : NULL);
+ $this->setReplyName(isset($fromInfo['reply_name']) ? $fromInfo['reply_name'] : NULL);
return $this;
}
@@ -95,8 +93,7 @@ abstract class MailMessage
*
* @return string
*/
- public function getFromEmail()
- {
+ public function getFromEmail() {
return $this->fromEmail;
}
@@ -105,8 +102,7 @@ abstract class MailMessage
*
* @return string
*/
- public function getFromName()
- {
+ public function getFromName() {
return isset($this->fromName) ? $this->fromName : $this->getFromEmail();
}
@@ -115,8 +111,7 @@ abstract class MailMessage
*
* @return EmailRecipient[]
*/
- public function getRecipients()
- {
+ public function getRecipients() {
return $this->recipients;
}
@@ -125,8 +120,7 @@ abstract class MailMessage
*
* @return string
*/
- public function getReplyEmail()
- {
+ public function getReplyEmail() {
return isset($this->replyEmail) ? $this->replyEmail : $this->getFromEmail();
}
@@ -135,8 +129,7 @@ abstract class MailMessage
*
* @return string
*/
- public function getReplyName()
- {
+ public function getReplyName() {
return isset($this->replyName) ? $this->replyName : $this->getFromName();
}
@@ -145,8 +138,7 @@ abstract class MailMessage
*
* @param string $fromEmail
*/
- public function setFromEmail($fromEmail)
- {
+ public function setFromEmail($fromEmail) {
$this->fromEmail = $fromEmail;
return $this;
}
@@ -156,8 +148,7 @@ abstract class MailMessage
*
* @param string $fromName
*/
- public function setFromName($fromName)
- {
+ public function setFromName($fromName) {
$this->fromName = $fromName;
return $this;
}
@@ -167,8 +158,7 @@ abstract class MailMessage
*
* @param string $replyEmail
*/
- public function setReplyEmail($replyEmail)
- {
+ public function setReplyEmail($replyEmail) {
$this->replyEmail = $replyEmail;
return $this;
}
@@ -178,8 +168,7 @@ abstract class MailMessage
*
* @param string $replyName
*/
- public function setReplyName($replyName)
- {
+ public function setReplyName($replyName) {
$this->replyName = $replyName;
return $this;
}
diff --git a/main/app/sprinkles/core/src/Mail/Mailer.php b/main/app/sprinkles/core/src/Mail/Mailer.php
index 5b346b4..82302b8 100644
--- a/main/app/sprinkles/core/src/Mail/Mailer.php
+++ b/main/app/sprinkles/core/src/Mail/Mailer.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Mail;
use Monolog\Logger;
@@ -35,12 +36,11 @@ class Mailer
* @param mixed[] $config An array of configuration parameters for phpMailer.
* @throws \phpmailerException Wrong mailer config value given.
*/
- public function __construct($logger, $config = [])
- {
+ public function __construct($logger, $config = []) {
$this->logger = $logger;
// 'true' tells PHPMailer to use exceptions instead of error codes
- $this->phpMailer = new \PHPMailer(true);
+ $this->phpMailer = new \PHPMailer(TRUE);
// Configuration options
if (isset($config['mailer'])) {
@@ -49,14 +49,14 @@ class Mailer
}
if ($config['mailer'] == 'smtp') {
- $this->phpMailer->isSMTP(true);
- $this->phpMailer->Host = $config['host'];
- $this->phpMailer->Port = $config['port'];
- $this->phpMailer->SMTPAuth = $config['auth'];
+ $this->phpMailer->isSMTP(TRUE);
+ $this->phpMailer->Host = $config['host'];
+ $this->phpMailer->Port = $config['port'];
+ $this->phpMailer->SMTPAuth = $config['auth'];
$this->phpMailer->SMTPSecure = $config['secure'];
- $this->phpMailer->Username = $config['username'];
- $this->phpMailer->Password = $config['password'];
- $this->phpMailer->SMTPDebug = $config['smtp_debug'];
+ $this->phpMailer->Username = $config['username'];
+ $this->phpMailer->Password = $config['password'];
+ $this->phpMailer->SMTPDebug = $config['smtp_debug'];
if (isset($config['smtp_options'])) {
$this->phpMailer->SMTPOptions = $config['smtp_options'];
@@ -71,7 +71,7 @@ class Mailer
}
// Pass logger into phpMailer object
- $this->phpMailer->Debugoutput = function($message, $level) {
+ $this->phpMailer->Debugoutput = function ($message, $level) {
$this->logger->debug($message);
};
}
@@ -81,8 +81,7 @@ class Mailer
*
* @return \PHPMailer
*/
- public function getPhpMailer()
- {
+ public function getPhpMailer() {
return $this->phpMailer;
}
@@ -95,8 +94,7 @@ class Mailer
* @param bool $clearRecipients Set to true to clear the list of recipients in the message after calling send(). This helps avoid accidentally sending a message multiple times.
* @throws \phpmailerException The message could not be sent.
*/
- public function send(MailMessage $message, $clearRecipients = true)
- {
+ public function send(MailMessage $message, $clearRecipients = TRUE) {
$this->phpMailer->From = $message->getFromEmail();
$this->phpMailer->FromName = $message->getFromName();
$this->phpMailer->addReplyTo($message->getReplyEmail(), $message->getReplyName());
@@ -107,20 +105,20 @@ class Mailer
// Add any CCs and BCCs
if ($recipient->getCCs()) {
- foreach($recipient->getCCs() as $cc) {
+ foreach ($recipient->getCCs() as $cc) {
$this->phpMailer->addCC($cc['email'], $cc['name']);
}
}
-
+
if ($recipient->getBCCs()) {
- foreach($recipient->getBCCs() as $bcc) {
+ foreach ($recipient->getBCCs() as $bcc) {
$this->phpMailer->addBCC($bcc['email'], $bcc['name']);
}
}
}
$this->phpMailer->Subject = $message->renderSubject();
- $this->phpMailer->Body = $message->renderBody();
+ $this->phpMailer->Body = $message->renderBody();
// Try to send the mail. Will throw an exception on failure.
$this->phpMailer->send();
@@ -136,15 +134,14 @@ class Mailer
}
/**
- * Send a MailMessage message, sending a separate email to each recipient.
+ * Send a MailMessage message, sending a separate email to each recipient.
*
* If the message object supports message templates, this will render the template with the corresponding placeholder values for each recipient.
* @param MailMessage $message
* @param bool $clearRecipients Set to true to clear the list of recipients in the message after calling send(). This helps avoid accidentally sending a message multiple times.
* @throws \phpmailerException The message could not be sent.
*/
- public function sendDistinct(MailMessage $message, $clearRecipients = true)
- {
+ public function sendDistinct(MailMessage $message, $clearRecipients = TRUE) {
$this->phpMailer->From = $message->getFromEmail();
$this->phpMailer->FromName = $message->getFromName();
$this->phpMailer->addReplyTo($message->getReplyEmail(), $message->getReplyName());
@@ -155,23 +152,23 @@ class Mailer
// Add any CCs and BCCs
if ($recipient->getCCs()) {
- foreach($recipient->getCCs() as $cc) {
+ foreach ($recipient->getCCs() as $cc) {
$this->phpMailer->addCC($cc['email'], $cc['name']);
}
}
-
+
if ($recipient->getBCCs()) {
- foreach($recipient->getBCCs() as $bcc) {
+ foreach ($recipient->getBCCs() as $bcc) {
$this->phpMailer->addBCC($bcc['email'], $bcc['name']);
}
}
-
+
$this->phpMailer->Subject = $message->renderSubject($recipient->getParams());
- $this->phpMailer->Body = $message->renderBody($recipient->getParams());
-
+ $this->phpMailer->Body = $message->renderBody($recipient->getParams());
+
// Try to send the mail. Will throw an exception on failure.
$this->phpMailer->send();
-
+
// Clear recipients from the PHPMailer object for this iteration,
// so that we can send a separate email to the next recipient.
$this->phpMailer->clearAllRecipients();
@@ -189,8 +186,7 @@ class Mailer
* @param mixed[] $options
* @return Mailer
*/
- public function setOptions($options)
- {
+ public function setOptions($options) {
if (isset($options['isHtml'])) {
$this->phpMailer->isHTML($options['isHtml']);
}
diff --git a/main/app/sprinkles/core/src/Mail/StaticMailMessage.php b/main/app/sprinkles/core/src/Mail/StaticMailMessage.php
index 098bbfc..482226c 100644
--- a/main/app/sprinkles/core/src/Mail/StaticMailMessage.php
+++ b/main/app/sprinkles/core/src/Mail/StaticMailMessage.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Mail;
/**
@@ -32,8 +33,7 @@ class StaticMailMessage extends MailMessage
* @param string $subject
* @param string $body
*/
- public function __construct($subject = "", $body = "")
- {
+ public function __construct($subject = "", $body = "") {
$this->subject = $subject;
$this->body = $body;
}
@@ -41,16 +41,14 @@ class StaticMailMessage extends MailMessage
/**
* {@inheritDoc}
*/
- public function renderBody($params = [])
- {
+ public function renderBody($params = []) {
return $this->body;
}
/**
* {@inheritDoc}
*/
- public function renderSubject($params = [])
- {
+ public function renderSubject($params = []) {
return $this->subject;
}
@@ -59,8 +57,7 @@ class StaticMailMessage extends MailMessage
*
* @param string $subject
*/
- public function setSubject($subject)
- {
+ public function setSubject($subject) {
$this->subject = $subject;
return $this;
}
@@ -70,8 +67,7 @@ class StaticMailMessage extends MailMessage
*
* @param string $body
*/
- public function setBody($body)
- {
+ public function setBody($body) {
$this->body = $body;
return $this;
}
diff --git a/main/app/sprinkles/core/src/Mail/TwigMailMessage.php b/main/app/sprinkles/core/src/Mail/TwigMailMessage.php
index aa65240..e20b906 100644
--- a/main/app/sprinkles/core/src/Mail/TwigMailMessage.php
+++ b/main/app/sprinkles/core/src/Mail/TwigMailMessage.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Mail;
/**
@@ -37,8 +38,7 @@ class TwigMailMessage extends MailMessage
* @param Slim\Views\Twig $view The Twig view object used to render mail templates.
* @param string $filename optional Set the Twig template to use for this message.
*/
- public function __construct($view, $filename = null)
- {
+ public function __construct($view, $filename = NULL) {
$this->view = $view;
$twig = $this->view->getEnvironment();
@@ -46,7 +46,7 @@ class TwigMailMessage extends MailMessage
// TODO: should we keep this separate from the local parameters?
$this->params = $twig->getGlobals();
- if ($filename !== null) {
+ if ($filename !== NULL) {
$this->template = $twig->loadTemplate($filename);
}
}
@@ -56,8 +56,7 @@ class TwigMailMessage extends MailMessage
*
* @param mixed[] $params
*/
- public function addParams($params = [])
- {
+ public function addParams($params = []) {
$this->params = array_replace_recursive($this->params, $params);
return $this;
}
@@ -65,8 +64,7 @@ class TwigMailMessage extends MailMessage
/**
* {@inheritDoc}
*/
- public function renderSubject($params = [])
- {
+ public function renderSubject($params = []) {
$params = array_replace_recursive($this->params, $params);
return $this->template->renderBlock('subject', $params);
}
@@ -74,8 +72,7 @@ class TwigMailMessage extends MailMessage
/**
* {@inheritDoc}
*/
- public function renderBody($params = [])
- {
+ public function renderBody($params = []) {
$params = array_replace_recursive($this->params, $params);
return $this->template->renderBlock('body', $params);
}
@@ -85,8 +82,7 @@ class TwigMailMessage extends MailMessage
*
* @param Twig_Template $template The Twig template object, to source the content for this message.
*/
- public function setTemplate($template)
- {
+ public function setTemplate($template) {
$this->template = $template;
return $this;
}
diff --git a/main/app/sprinkles/core/src/Model/UFModel.php b/main/app/sprinkles/core/src/Model/UFModel.php
index 0d9feff..d852606 100644
--- a/main/app/sprinkles/core/src/Model/UFModel.php
+++ b/main/app/sprinkles/core/src/Model/UFModel.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Model;
use UserFrosting\Sprinkle\Core\Database\Models\Model;
@@ -18,8 +19,7 @@ use UserFrosting\Sprinkle\Core\Facades\Debug;
*/
abstract class UFModel extends Model
{
- public function __construct(array $attributes = [])
- {
+ public function __construct(array $attributes = []) {
Debug::debug("UFModel has been deprecated and will be removed in future versions. Please move your model " . static::class . " to Database/Models/ and have it extend the base Database/Models/Model class.");
parent::__construct($attributes);
diff --git a/main/app/sprinkles/core/src/Router.php b/main/app/sprinkles/core/src/Router.php
index 8a10c85..09a358a 100644
--- a/main/app/sprinkles/core/src/Router.php
+++ b/main/app/sprinkles/core/src/Router.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core;
use FastRoute\Dispatcher;
@@ -38,15 +39,14 @@ class Router extends \Slim\Router implements RouterInterface
* Add route
*
* @param string[] $methods Array of HTTP methods
- * @param string $pattern The route pattern
+ * @param string $pattern The route pattern
* @param callable $handler The route callable
*
* @return RouteInterface
*
* @throws InvalidArgumentException if the route pattern isn't a string
*/
- public function map($methods, $pattern, $handler)
- {
+ public function map($methods, $pattern, $handler) {
if (!is_string($pattern)) {
throw new InvalidArgumentException('Route pattern must be a string');
}
@@ -85,8 +85,7 @@ class Router extends \Slim\Router implements RouterInterface
* @access public
* @return bool true/false if operation is successfull
*/
- public function clearCache()
- {
+ public function clearCache() {
// Get Filesystem instance
$fs = new FileSystem;
@@ -96,6 +95,6 @@ class Router extends \Slim\Router implements RouterInterface
}
// It's still considered a success if file doesn't exist
- return true;
+ return TRUE;
}
}
diff --git a/main/app/sprinkles/core/src/Sprunje/Sprunje.php b/main/app/sprinkles/core/src/Sprunje/Sprunje.php
index 5525dc4..840eff0 100644
--- a/main/app/sprinkles/core/src/Sprunje/Sprunje.php
+++ b/main/app/sprinkles/core/src/Sprunje/Sprunje.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Sprunje;
use Carbon\Carbon;
@@ -54,7 +55,7 @@ abstract class Sprunje
'filters' => [],
'lists' => [],
'size' => 'all',
- 'page' => null,
+ 'page' => NULL,
'format' => 'json'
];
@@ -127,8 +128,7 @@ abstract class Sprunje
* @param ClassMapper $classMapper
* @param mixed[] $options
*/
- public function __construct(ClassMapper $classMapper, array $options)
- {
+ public function __construct(ClassMapper $classMapper, array $options) {
$this->classMapper = $classMapper;
// Validation on input data
@@ -140,10 +140,10 @@ abstract class Sprunje
$v->rule('regex', 'format', '/json|csv/i');
// TODO: translated rules
- if(!$v->validate()) {
+ if (!$v->validate()) {
$e = new BadRequestException();
foreach ($v->errors() as $idx => $field) {
- foreach($field as $eidx => $error) {
+ foreach ($field as $eidx => $error) {
$e->addUserMessage($error);
}
}
@@ -166,8 +166,7 @@ abstract class Sprunje
* @param callable $callback A callback which accepts and returns a Builder instance.
* @return $this
*/
- public function extendQuery(callable $callback)
- {
+ public function extendQuery(callable $callback) {
$this->query = $callback($this->query);
return $this;
}
@@ -178,8 +177,7 @@ abstract class Sprunje
* @param ResponseInterface $response
* @return ResponseInterface
*/
- public function toResponse(Response $response)
- {
+ public function toResponse(Response $response) {
$format = $this->options['format'];
if ($format == 'csv') {
@@ -191,7 +189,7 @@ abstract class Sprunje
$response = $response->withAddedHeader('Content-Disposition', "attachment;filename=$date-{$this->name}-$settings.csv");
$response = $response->withAddedHeader('Content-Type', 'text/csv; charset=utf-8');
return $response->write($result);
- // Default to JSON
+ // Default to JSON
} else {
$result = $this->getArray();
return $response->withJson($result, 200, JSON_PRETTY_PRINT);
@@ -205,16 +203,15 @@ abstract class Sprunje
* and `rows` (the filtered result set).
* @return mixed[]
*/
- public function getArray()
- {
+ public function getArray() {
list($count, $countFiltered, $rows) = $this->getModels();
// Return sprunjed results
return [
- $this->countKey => $count,
- $this->countFilteredKey => $countFiltered,
- $this->rowsKey => $rows->values()->toArray(),
- $this->listableKey => $this->getListable()
+ $this->countKey => $count,
+ $this->countFilteredKey => $countFiltered,
+ $this->rowsKey => $rows->values()->toArray(),
+ $this->listableKey => $this->getListable()
];
}
@@ -223,8 +220,7 @@ abstract class Sprunje
*
* @return SplTempFileObject
*/
- public function getCsv()
- {
+ public function getCsv() {
$filteredQuery = clone $this->query;
// Apply filters
@@ -280,8 +276,7 @@ abstract class Sprunje
* Returns the filtered, paginated result set and the counts.
* @return mixed[]
*/
- public function getModels()
- {
+ public function getModels() {
// Count unfiltered total
$count = $this->count($this->query);
@@ -313,13 +308,12 @@ abstract class Sprunje
*
* @return array
*/
- public function getListable()
- {
+ public function getListable() {
$result = [];
foreach ($this->listable as $name) {
// Determine if a custom filter method has been defined
- $methodName = 'list'.studly_case($name);
+ $methodName = 'list' . studly_case($name);
if (method_exists($this, $methodName)) {
$result[$name] = $this->$methodName();
@@ -336,8 +330,7 @@ abstract class Sprunje
*
* @return Builder
*/
- public function getQuery()
- {
+ public function getQuery() {
return $this->query;
}
@@ -347,8 +340,7 @@ abstract class Sprunje
* @param Builder $query
* @return $this
*/
- public function setQuery($query)
- {
+ public function setQuery($query) {
$this->query = $query;
return $this;
}
@@ -359,8 +351,7 @@ abstract class Sprunje
* @param Builder $query
* @return $this
*/
- public function applyFilters($query)
- {
+ public function applyFilters($query) {
foreach ($this->options['filters'] as $name => $value) {
// Check that this filter is allowed
if (($name != '_all') && !in_array($name, $this->filterable)) {
@@ -383,8 +374,7 @@ abstract class Sprunje
* @param Builder $query
* @return $this
*/
- public function applySorts($query)
- {
+ public function applySorts($query) {
foreach ($this->options['sorts'] as $name => $direction) {
// Check that this sort is allowed
if (!in_array($name, $this->sortable)) {
@@ -394,7 +384,7 @@ abstract class Sprunje
}
// Determine if a custom sort method has been defined
- $methodName = 'sort'.studly_case($name);
+ $methodName = 'sort' . studly_case($name);
if (method_exists($this, $methodName)) {
$this->$methodName($query, $direction);
@@ -412,16 +402,15 @@ abstract class Sprunje
* @param Builder $query
* @return $this
*/
- public function applyPagination($query)
- {
+ public function applyPagination($query) {
if (
- ($this->options['page'] !== null) &&
- ($this->options['size'] !== null) &&
+ ($this->options['page'] !== NULL) &&
+ ($this->options['size'] !== NULL) &&
($this->options['size'] != 'all')
) {
- $offset = $this->options['size']*$this->options['page'];
+ $offset = $this->options['size'] * $this->options['page'];
$query->skip($offset)
- ->take($this->options['size']);
+ ->take($this->options['size']);
}
return $this;
@@ -434,8 +423,7 @@ abstract class Sprunje
* @param mixed $value
* @return $this
*/
- protected function filterAll($query, $value)
- {
+ protected function filterAll($query, $value) {
foreach ($this->filterable as $name) {
if (studly_case($name) != 'all' && !in_array($name, $this->excludeForAll)) {
// Since we want to match _any_ of the fields, we wrap the field callback in a 'orWhere' callback
@@ -456,9 +444,8 @@ abstract class Sprunje
* @param mixed $value
* @return $this
*/
- protected function buildFilterQuery($query, $name, $value)
- {
- $methodName = 'filter'.studly_case($name);
+ protected function buildFilterQuery($query, $name, $value) {
+ $methodName = 'filter' . studly_case($name);
// Determine if a custom filter method has been defined
if (method_exists($this, $methodName)) {
@@ -479,8 +466,7 @@ abstract class Sprunje
* @param mixed $value
* @return $this
*/
- protected function buildFilterDefaultFieldQuery($query, $name, $value)
- {
+ protected function buildFilterDefaultFieldQuery($query, $name, $value) {
// Default filter - split value on separator for OR queries
// and search by column name
$values = explode($this->orSeparator, $value);
@@ -497,8 +483,7 @@ abstract class Sprunje
* @param \Illuminate\Database\Eloquent\Collection $collection
* @return \Illuminate\Database\Eloquent\Collection
*/
- protected function applyTransformations($collection)
- {
+ protected function applyTransformations($collection) {
return $collection;
}
@@ -516,8 +501,7 @@ abstract class Sprunje
* @param string $column
* @return array
*/
- protected function getColumnValues($column)
- {
+ protected function getColumnValues($column) {
$rawValues = $this->query->select($column)->distinct()->orderBy($column, 'asc')->get();
$values = [];
foreach ($rawValues as $raw) {
@@ -535,8 +519,7 @@ abstract class Sprunje
* @param Builder $query
* @return int
*/
- protected function count($query)
- {
+ protected function count($query) {
return $query->count();
}
@@ -546,8 +529,7 @@ abstract class Sprunje
* @param Builder $query
* @return int
*/
- protected function countFiltered($query)
- {
+ protected function countFiltered($query) {
return $query->count();
}
@@ -559,8 +541,7 @@ abstract class Sprunje
* @deprecated since 4.1.7 Use getArray() instead.
* @return mixed[]
*/
- public function getResults()
- {
+ public function getResults() {
return $this->getArray();
}
}
diff --git a/main/app/sprinkles/core/src/Throttle/ThrottleRule.php b/main/app/sprinkles/core/src/Throttle/ThrottleRule.php
index b71f296..c5e0c82 100644
--- a/main/app/sprinkles/core/src/Throttle/ThrottleRule.php
+++ b/main/app/sprinkles/core/src/Throttle/ThrottleRule.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Throttle;
/**
@@ -35,8 +36,7 @@ class ThrottleRule
* @param int $interval The amount of time, in seconds, to look back in determining attempts to consider.
* @param int[] $delays A mapping of minimum observation counts (x) to delays (y), in seconds.
*/
- public function __construct($method, $interval, $delays)
- {
+ public function __construct($method, $interval, $delays) {
$this->setMethod($method);
$this->setInterval($interval);
$this->setDelays($delays);
@@ -48,8 +48,7 @@ class ThrottleRule
* @param Carbon\Carbon $lastEventTime The timestamp for the last countable event.
* @param int $count The total number of events which have occurred in an interval.
*/
- public function getDelay($lastEventTime, $count)
- {
+ public function getDelay($lastEventTime, $count) {
// Zero occurrences always maps to a delay of 0 seconds.
if ($count == 0) {
return 0;
@@ -75,8 +74,7 @@ class ThrottleRule
*
* @return int[]
*/
- public function getDelays()
- {
+ public function getDelays() {
return $this->delays;
}
@@ -85,8 +83,7 @@ class ThrottleRule
*
* @return int
*/
- public function getInterval()
- {
+ public function getInterval() {
return $this->interval;
}
@@ -95,8 +92,7 @@ class ThrottleRule
*
* @return string
*/
- public function getMethod()
- {
+ public function getMethod() {
return $this->method;
}
@@ -105,8 +101,7 @@ class ThrottleRule
*
* @param int[] A mapping of minimum observation counts (x) to delays (y), in seconds.
*/
- public function setDelays($delays)
- {
+ public function setDelays($delays) {
// Sort the array by key, from highest to lowest value
$this->delays = $delays;
krsort($this->delays);
@@ -119,8 +114,7 @@ class ThrottleRule
*
* @param int The amount of time, in seconds, to look back in determining attempts to consider.
*/
- public function setInterval($interval)
- {
+ public function setInterval($interval) {
$this->interval = $interval;
return $this;
@@ -131,8 +125,7 @@ class ThrottleRule
*
* @param string Set to 'ip' for ip-based throttling, 'data' for request-data-based throttling.
*/
- public function setMethod($method)
- {
+ public function setMethod($method) {
$this->method = $method;
return $this;
diff --git a/main/app/sprinkles/core/src/Throttle/Throttler.php b/main/app/sprinkles/core/src/Throttle/Throttler.php
index 0d42442..4ab9dd6 100644
--- a/main/app/sprinkles/core/src/Throttle/Throttler.php
+++ b/main/app/sprinkles/core/src/Throttle/Throttler.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Throttle;
use Carbon\Carbon;
@@ -32,8 +33,7 @@ class Throttler
*
* @param ClassMapper $classMapper Maps generic class identifiers to specific class names.
*/
- public function __construct(ClassMapper $classMapper)
- {
+ public function __construct(ClassMapper $classMapper) {
$this->classMapper = $classMapper;
$this->throttleRules = [];
}
@@ -44,9 +44,8 @@ class Throttler
* @param string $type The type of throttle event to check against.
* @param ThrottleRule $rule The rule to use when throttling this type of event.
*/
- public function addThrottleRule($type, $rule)
- {
- if (!($rule instanceof ThrottleRule || ($rule === null))) {
+ public function addThrottleRule($type, $rule) {
+ if (!($rule instanceof ThrottleRule || ($rule === NULL))) {
throw new ThrottlerException('$rule must be of type ThrottleRule (or null).');
}
@@ -62,8 +61,7 @@ class Throttler
* @param mixed[] $requestData Any additional request parameters to use in checking the throttle.
* @return bool
*/
- public function getDelay($type, $requestData = [])
- {
+ public function getDelay($type, $requestData = []) {
$throttleRule = $this->getRule($type);
if (is_null($throttleRule)) {
@@ -93,11 +91,11 @@ class Throttler
// then filter out this event from the collection.
foreach ($requestData as $name => $value) {
if (!isset($data->$name) || ($data->$name != $value)) {
- return false;
+ return FALSE;
}
}
- return true;
+ return TRUE;
});
}
@@ -112,8 +110,7 @@ class Throttler
* @throws ThrottlerException
* @return ThrottleRule[]
*/
- public function getRule($type)
- {
+ public function getRule($type) {
if (!array_key_exists($type, $this->throttleRules)) {
throw new ThrottlerException("The throttling rule for '$type' could not be found.");
}
@@ -126,8 +123,7 @@ class Throttler
*
* @return ThrottleRule[]
*/
- public function getThrottleRules()
- {
+ public function getThrottleRules() {
return $this->throttleRules;
}
@@ -137,8 +133,7 @@ class Throttler
* @param string $type the type of event
* @param string[] $requestData an array of field names => values that are relevant to throttling for this event (e.g. username, email, etc).
*/
- public function logEvent($type, $requestData = [])
- {
+ public function logEvent($type, $requestData = []) {
// Just a check to make sure the rule exists
$throttleRule = $this->getRule($type);
@@ -164,8 +159,7 @@ class Throttler
* @param ThrottleRule $throttleRule a rule representing the strategy to use for throttling a particular type of event.
* @return int seconds remaining until a particular event is permitted to be attempted again.
*/
- protected function computeDelay($events, $throttleRule)
- {
+ protected function computeDelay($events, $throttleRule) {
// If no matching events found, then there is no delay
if (!$events->count()) {
return 0;
diff --git a/main/app/sprinkles/core/src/Throttle/ThrottlerException.php b/main/app/sprinkles/core/src/Throttle/ThrottlerException.php
index 2fd9035..08f2919 100644
--- a/main/app/sprinkles/core/src/Throttle/ThrottlerException.php
+++ b/main/app/sprinkles/core/src/Throttle/ThrottlerException.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Throttle;
/**
diff --git a/main/app/sprinkles/core/src/Twig/CacheHelper.php b/main/app/sprinkles/core/src/Twig/CacheHelper.php
index 14aea49..a3c11c6 100644
--- a/main/app/sprinkles/core/src/Twig/CacheHelper.php
+++ b/main/app/sprinkles/core/src/Twig/CacheHelper.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Twig;
use Interop\Container\ContainerInterface;
@@ -28,8 +29,7 @@ class CacheHelper
*
* @param ContainerInterface $ci The global container object, which holds all your services.
*/
- public function __construct(ContainerInterface $ci)
- {
+ public function __construct(ContainerInterface $ci) {
$this->ci = $ci;
}
@@ -39,20 +39,19 @@ class CacheHelper
* @access public
* @return bool true/false if operation is successfull
*/
- public function clearCache()
- {
+ public function clearCache() {
// Get location
- $path = $this->ci->locator->findResource('cache://twig', true, true);
+ $path = $this->ci->locator->findResource('cache://twig', TRUE, TRUE);
// Get Filesystem instance
$fs = new FileSystem;
// Make sure directory exist and delete it
if ($fs->exists($path)) {
- return $fs->deleteDirectory($path, true);
+ return $fs->deleteDirectory($path, TRUE);
}
// It's still considered a success if directory doesn't exist yet
- return true;
+ return TRUE;
}
}
diff --git a/main/app/sprinkles/core/src/Twig/CoreExtension.php b/main/app/sprinkles/core/src/Twig/CoreExtension.php
index 6a89d12..2837e84 100644
--- a/main/app/sprinkles/core/src/Twig/CoreExtension.php
+++ b/main/app/sprinkles/core/src/Twig/CoreExtension.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Twig;
use Interop\Container\ContainerInterface;
@@ -28,8 +29,7 @@ class CoreExtension extends \Twig_Extension implements \Twig_Extension_GlobalsIn
*
* @param ContainerInterface $services The global container object, which holds all your services.
*/
- public function __construct(ContainerInterface $services)
- {
+ public function __construct(ContainerInterface $services) {
$this->services = $services;
}
@@ -38,8 +38,7 @@ class CoreExtension extends \Twig_Extension implements \Twig_Extension_GlobalsIn
*
* @return string
*/
- public function getName()
- {
+ public function getName() {
return 'userfrosting/core';
}
@@ -48,11 +47,10 @@ class CoreExtension extends \Twig_Extension implements \Twig_Extension_GlobalsIn
*
* @return array[\Twig_SimpleFunction]
*/
- public function getFunctions()
- {
+ public function getFunctions() {
return array(
// Add Twig function for fetching alerts
- new \Twig_SimpleFunction('getAlerts', function ($clear = true) {
+ new \Twig_SimpleFunction('getAlerts', function ($clear = TRUE) {
if ($clear) {
return $this->services['alerts']->getAndClearMessages();
} else {
@@ -72,13 +70,12 @@ class CoreExtension extends \Twig_Extension implements \Twig_Extension_GlobalsIn
*
* @return array[\Twig_SimpleFilter]
*/
- public function getFilters()
- {
+ public function getFilters() {
return array(
/**
* Converts phone numbers to a standard format.
*
- * @param String $num A unformatted phone number
+ * @param String $num A unformatted phone number
* @return String Returns the formatted phone number
*/
new \Twig_SimpleFilter('phone', function ($num) {
@@ -95,8 +92,7 @@ class CoreExtension extends \Twig_Extension implements \Twig_Extension_GlobalsIn
*
* @return array[mixed]
*/
- public function getGlobals()
- {
+ public function getGlobals() {
// CSRF token name and value
$csrfNameKey = $this->services->csrf->getTokenNameKey();
$csrfValueKey = $this->services->csrf->getTokenValueKey();
@@ -104,12 +100,12 @@ class CoreExtension extends \Twig_Extension implements \Twig_Extension_GlobalsIn
$csrfValue = $this->services->csrf->getTokenValue();
$csrf = [
- 'csrf' => [
+ 'csrf' => [
'keys' => [
- 'name' => $csrfNameKey,
+ 'name' => $csrfNameKey,
'value' => $csrfValueKey
],
- 'name' => $csrfName,
+ 'name' => $csrfName,
'value' => $csrfValue
]
];
@@ -117,7 +113,7 @@ class CoreExtension extends \Twig_Extension implements \Twig_Extension_GlobalsIn
$site = array_replace_recursive($this->services->config['site'], $csrf);
return [
- 'site' => $site,
+ 'site' => $site,
'assets' => $this->services->assets
];
}
diff --git a/main/app/sprinkles/core/src/Util/BadClassNameException.php b/main/app/sprinkles/core/src/Util/BadClassNameException.php
index 09c4ea5..1cd6f4e 100644
--- a/main/app/sprinkles/core/src/Util/BadClassNameException.php
+++ b/main/app/sprinkles/core/src/Util/BadClassNameException.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Util;
/**
diff --git a/main/app/sprinkles/core/src/Util/Captcha.php b/main/app/sprinkles/core/src/Util/Captcha.php
index c788b77..4c221cb 100644
--- a/main/app/sprinkles/core/src/Util/Captcha.php
+++ b/main/app/sprinkles/core/src/Util/Captcha.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Util;
use UserFrosting\Session\Session;
@@ -43,8 +44,7 @@ class Captcha
/**
* Create a new captcha.
*/
- public function __construct($session, $key)
- {
+ public function __construct($session, $key) {
$this->session = $session;
$this->key = $key;
@@ -59,9 +59,8 @@ class Captcha
* This generates a random 5-character captcha and stores it in the session with an md5 hash.
* Also, generates the corresponding captcha image.
*/
- public function generateRandomCode()
- {
- $md5_hash = md5(rand(0,99999));
+ public function generateRandomCode() {
+ $md5_hash = md5(rand(0, 99999));
$this->code = substr($md5_hash, 25, 5);
$enc = md5($this->code);
@@ -74,16 +73,14 @@ class Captcha
/**
* Returns the captcha code.
*/
- public function getCaptcha()
- {
+ public function getCaptcha() {
return $this->code;
}
/**
* Returns the captcha image.
*/
- public function getImage()
- {
+ public function getImage() {
return $this->image;
}
@@ -94,8 +91,7 @@ class Captcha
* @param string
* @return bool
*/
- public function verifyCode($code)
- {
+ public function verifyCode($code) {
return (md5($code) == $this->session[$this->key]);
}
@@ -104,8 +100,7 @@ class Captcha
*
* This generates an image as a binary string.
*/
- protected function generateImage()
- {
+ protected function generateImage() {
$width = 150;
$height = 30;
@@ -114,39 +109,39 @@ class Captcha
//color pallette
$white = imagecolorallocate($image, 255, 255, 255);
$black = imagecolorallocate($image, 0, 0, 0);
- $red = imagecolorallocate($image,255,0,0);
+ $red = imagecolorallocate($image, 255, 0, 0);
$yellow = imagecolorallocate($image, 255, 255, 0);
- $dark_grey = imagecolorallocate($image, 64,64,64);
- $blue = imagecolorallocate($image, 0,0,255);
+ $dark_grey = imagecolorallocate($image, 64, 64, 64);
+ $blue = imagecolorallocate($image, 0, 0, 255);
//create white rectangle
- imagefilledrectangle($image,0,0,150,30,$white);
+ imagefilledrectangle($image, 0, 0, 150, 30, $white);
//add some lines
- for($i=0;$i<2;$i++) {
- imageline($image,0,rand()%10,10,rand()%30,$dark_grey);
- imageline($image,0,rand()%30,150,rand()%30,$red);
- imageline($image,0,rand()%30,150,rand()%30,$yellow);
+ for ($i = 0; $i < 2; $i++) {
+ imageline($image, 0, rand() % 10, 10, rand() % 30, $dark_grey);
+ imageline($image, 0, rand() % 30, 150, rand() % 30, $red);
+ imageline($image, 0, rand() % 30, 150, rand() % 30, $yellow);
}
// RandTab color pallette
$randc[0] = imagecolorallocate($image, 0, 0, 0);
- $randc[1] = imagecolorallocate($image,255,0,0);
+ $randc[1] = imagecolorallocate($image, 255, 0, 0);
$randc[2] = imagecolorallocate($image, 255, 255, 0);
- $randc[3] = imagecolorallocate($image, 64,64,64);
- $randc[4] = imagecolorallocate($image, 0,0,255);
+ $randc[3] = imagecolorallocate($image, 64, 64, 64);
+ $randc[4] = imagecolorallocate($image, 0, 0, 255);
//add some dots
- for($i=0;$i<1000;$i++) {
- imagesetpixel($image,rand()%200,rand()%50,$randc[rand()%5]);
+ for ($i = 0; $i < 1000; $i++) {
+ imagesetpixel($image, rand() % 200, rand() % 50, $randc[rand() % 5]);
}
//calculate center of text
- $x = ( 150 - 0 - imagefontwidth( 5 ) * strlen( $this->code ) ) / 2 + 0 + 5;
+ $x = (150 - 0 - imagefontwidth(5) * strlen($this->code)) / 2 + 0 + 5;
//write string twice
- imagestring($image,5, $x, 7, $this->code, $black);
- imagestring($image,5, $x, 7, $this->code, $black);
+ imagestring($image, 5, $x, 7, $this->code, $black);
+ imagestring($image, 5, $x, 7, $this->code, $black);
//start ob
ob_start();
imagepng($image);
diff --git a/main/app/sprinkles/core/src/Util/CheckEnvironment.php b/main/app/sprinkles/core/src/Util/CheckEnvironment.php
index 26925d9..05b555f 100644
--- a/main/app/sprinkles/core/src/Util/CheckEnvironment.php
+++ b/main/app/sprinkles/core/src/Util/CheckEnvironment.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Util;
use Psr\Http\Message\ResponseInterface;
@@ -49,8 +50,7 @@ class CheckEnvironment
* @param $view \Slim\Views\Twig The view object, needed for rendering error page.
* @param $locator \RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator Locator service for stream resources.
*/
- public function __construct($view, $locator, $cache)
- {
+ public function __construct($view, $locator, $cache) {
$this->view = $view;
$this->locator = $locator;
$this->cache = $cache;
@@ -59,15 +59,14 @@ class CheckEnvironment
/**
* Invoke the CheckEnvironment middleware, performing all pre-flight checks and returning an error page if problems were found.
*
- * @param \Psr\Http\Message\ServerRequestInterface $request PSR7 request
- * @param \Psr\Http\Message\ResponseInterface $response PSR7 response
- * @param callable $next Next middleware
+ * @param \Psr\Http\Message\ServerRequestInterface $request PSR7 request
+ * @param \Psr\Http\Message\ResponseInterface $response PSR7 response
+ * @param callable $next Next middleware
*
* @return \Psr\Http\Message\ResponseInterface
*/
- public function __invoke($request, $response, $next)
- {
- $problemsFound = false;
+ public function __invoke($request, $response, $next) {
+ $problemsFound = FALSE;
// If production environment and no cached checks, perform environment checks
if ($this->isProduction() && $this->cache->get('checkEnvironment') != 'pass') {
@@ -77,7 +76,7 @@ class CheckEnvironment
if (!$problemsFound) {
$this->cache->forever('checkEnvironment', 'pass');
}
- } elseif (!$this->isProduction()) {
+ } else if (!$this->isProduction()) {
$problemsFound = $this->checkAll();
}
@@ -97,21 +96,20 @@ class CheckEnvironment
/**
* Run through all pre-flight checks.
*/
- public function checkAll()
- {
- $problemsFound = false;
+ public function checkAll() {
+ $problemsFound = FALSE;
- if ($this->checkApache()) $problemsFound = true;
+ if ($this->checkApache()) $problemsFound = TRUE;
- if ($this->checkPhp()) $problemsFound = true;
+ if ($this->checkPhp()) $problemsFound = TRUE;
- if ($this->checkPdo()) $problemsFound = true;
+ if ($this->checkPdo()) $problemsFound = TRUE;
- if ($this->checkGd()) $problemsFound = true;
+ if ($this->checkGd()) $problemsFound = TRUE;
- if ($this->checkImageFunctions()) $problemsFound = true;
+ if ($this->checkImageFunctions()) $problemsFound = TRUE;
- if ($this->checkPermissions()) $problemsFound = true;
+ if ($this->checkPermissions()) $problemsFound = TRUE;
return $problemsFound;
}
@@ -119,12 +117,11 @@ class CheckEnvironment
/**
* For Apache environments, check that required Apache modules are installed.
*/
- public function checkApache()
- {
- $problemsFound = false;
+ public function checkApache() {
+ $problemsFound = FALSE;
// Perform some Apache checks. We may also need to do this before any routing takes place.
- if (strpos(php_sapi_name(), 'apache') !== false) {
+ if (strpos(php_sapi_name(), 'apache') !== FALSE) {
$require_apache_modules = ['mod_rewrite'];
$apache_modules = apache_get_modules();
@@ -133,17 +130,17 @@ class CheckEnvironment
foreach ($require_apache_modules as $module) {
if (!in_array($module, $apache_modules)) {
- $problemsFound = true;
+ $problemsFound = TRUE;
$this->resultsFailed['apache-' . $module] = [
"title" => "<i class='fa fa-server fa-fw'></i> Missing Apache module <b>$module</b>.",
"message" => "Please make sure that the <code>$module</code> Apache module is installed and enabled. If you use shared hosting, you will need to ask your web host to do this for you.",
- "success" => false
+ "success" => FALSE
];
} else {
$this->resultsSuccess['apache-' . $module] = [
"title" => "<i class='fa fa-server fa-fw'></i> Apache module <b>$module</b> is installed and enabled.",
"message" => "Great, we found the <code>$module</code> Apache module!",
- "success" => true
+ "success" => TRUE
];
}
}
@@ -155,22 +152,21 @@ class CheckEnvironment
/**
* Check for GD library (required for Captcha).
*/
- public function checkGd()
- {
- $problemsFound = false;
+ public function checkGd() {
+ $problemsFound = FALSE;
if (!(extension_loaded('gd') && function_exists('gd_info'))) {
- $problemsFound = true;
+ $problemsFound = TRUE;
$this->resultsFailed['gd'] = [
"title" => "<i class='fa fa-image fa-fw'></i> GD library not installed",
"message" => "We could not confirm that the <code>GD</code> library is installed and enabled. GD is an image processing library that UserFrosting uses to generate captcha codes for user account registration.",
- "success" => false
+ "success" => FALSE
];
} else {
$this->resultsSuccess['gd'] = [
"title" => "<i class='fa fa-image fa-fw'></i> GD library installed!",
"message" => "Great, you have <code>GD</code> installed and enabled.",
- "success" => true
+ "success" => TRUE
];
}
@@ -182,9 +178,8 @@ class CheckEnvironment
*
* Some versions of GD are missing one or more of these functions, thus why we check for them explicitly.
*/
- public function checkImageFunctions()
- {
- $problemsFound = false;
+ public function checkImageFunctions() {
+ $problemsFound = FALSE;
$funcs = [
'imagepng',
@@ -199,17 +194,17 @@ class CheckEnvironment
foreach ($funcs as $func) {
if (!function_exists($func)) {
- $problemsFound = true;
+ $problemsFound = TRUE;
$this->resultsFailed['function-' . $func] = [
"title" => "<i class='fa fa-code fa-fw'></i> Missing image manipulation function.",
"message" => "It appears that function <code>$func</code> is not available. UserFrosting needs this to render captchas.",
- "success" => false
+ "success" => FALSE
];
} else {
$this->resultsSuccess['function-' . $func] = [
"title" => "<i class='fa fa-code fa-fw'></i> Function <b>$func</b> is available!",
"message" => "Sweet!",
- "success" => true
+ "success" => TRUE
];
}
}
@@ -220,22 +215,21 @@ class CheckEnvironment
/**
* Check that PDO is installed and enabled.
*/
- public function checkPdo()
- {
- $problemsFound = false;
+ public function checkPdo() {
+ $problemsFound = FALSE;
if (!class_exists('PDO')) {
- $problemsFound = true;
+ $problemsFound = TRUE;
$this->resultsFailed['pdo'] = [
"title" => "<i class='fa fa-database fa-fw'></i> PDO is not installed.",
"message" => "I'm sorry, you must have PDO installed and enabled in order for UserFrosting to access the database. If you don't know what PDO is, please see <a href='http://php.net/manual/en/book.pdo.php'>http://php.net/manual/en/book.pdo.php</a>.",
- "success" => false
+ "success" => FALSE
];
} else {
$this->resultsSuccess['pdo'] = [
"title" => "<i class='fa fa-database fa-fw'></i> PDO is installed!",
"message" => "You've got PDO installed. Good job!",
- "success" => true
+ "success" => TRUE
];
}
@@ -245,38 +239,37 @@ class CheckEnvironment
/**
* Check that log, cache, and session directories are writable, and that other directories are set appropriately for the environment.
*/
- function checkPermissions()
- {
- $problemsFound = false;
+ function checkPermissions() {
+ $problemsFound = FALSE;
$shouldBeWriteable = [
- $this->locator->findResource('log://') => true,
- $this->locator->findResource('cache://') => true,
- $this->locator->findResource('session://') => true
+ $this->locator->findResource('log://') => TRUE,
+ $this->locator->findResource('cache://') => TRUE,
+ $this->locator->findResource('session://') => TRUE
];
if ($this->isProduction()) {
// Should be write-protected in production!
$shouldBeWriteable = array_merge($shouldBeWriteable, [
- \UserFrosting\SPRINKLES_DIR => false,
- \UserFrosting\VENDOR_DIR => false
+ \UserFrosting\SPRINKLES_DIR => FALSE,
+ \UserFrosting\VENDOR_DIR => FALSE
]);
}
// Check for essential files & perms
foreach ($shouldBeWriteable as $file => $assertWriteable) {
- $is_dir = false;
+ $is_dir = FALSE;
if (!file_exists($file)) {
- $problemsFound = true;
+ $problemsFound = TRUE;
$this->resultsFailed['file-' . $file] = [
"title" => "<i class='fa fa-file-o fa-fw'></i> File or directory does not exist.",
"message" => "We could not find the file or directory <code>$file</code>.",
- "success" => false
+ "success" => FALSE
];
} else {
$writeable = is_writable($file);
if ($assertWriteable !== $writeable) {
- $problemsFound = true;
+ $problemsFound = TRUE;
$this->resultsFailed['file-' . $file] = [
"title" => "<i class='fa fa-file-o fa-fw'></i> Incorrect permissions for file or directory.",
"message" => "<code>$file</code> is "
@@ -286,7 +279,7 @@ class CheckEnvironment
. ". Please modify the OS user or group permissions so that user <b>"
. exec('whoami') . "</b> "
. ($assertWriteable ? "has" : "does not have") . " write permissions for this directory.",
- "success" => false
+ "success" => FALSE
];
} else {
$this->resultsSuccess['file-' . $file] = [
@@ -294,7 +287,7 @@ class CheckEnvironment
"message" => "<code>$file</code> exists and is correctly set as <b>"
. ($writeable ? "writeable" : "not writeable")
. "</b>.",
- "success" => true
+ "success" => TRUE
];
}
}
@@ -305,23 +298,22 @@ class CheckEnvironment
/**
* Check that PHP meets the minimum required version.
*/
- public function checkPhp()
- {
- $problemsFound = false;
+ public function checkPhp() {
+ $problemsFound = FALSE;
// Check PHP version
if (version_compare(phpversion(), \UserFrosting\PHP_MIN_VERSION, '<')) {
- $problemsFound = true;
+ $problemsFound = TRUE;
$this->resultsFailed['phpVersion'] = [
"title" => "<i class='fa fa-code fa-fw'></i> You need to upgrade your PHP installation.",
"message" => "I'm sorry, UserFrosting requires version " . \UserFrosting\PHP_MIN_VERSION . " or greater. Please upgrade your version of PHP, or contact your web hosting service and ask them to upgrade it for you.",
- "success" => false
+ "success" => FALSE
];
} else {
$this->resultsSuccess['phpVersion'] = [
"title" => "<i class='fa fa-code fa-fw'></i> PHP version checks out!",
- "message" => "You're using PHP " . \UserFrosting\PHP_MIN_VERSION . "or higher. Great!",
- "success" => true
+ "message" => "You're using PHP " . \UserFrosting\PHP_MIN_VERSION . "or higher. Great!",
+ "success" => TRUE
];
}
@@ -333,8 +325,7 @@ class CheckEnvironment
*
* @return bool
*/
- public function isProduction()
- {
+ public function isProduction() {
return (getenv('UF_MODE') == 'production');
}
}
diff --git a/main/app/sprinkles/core/src/Util/ClassMapper.php b/main/app/sprinkles/core/src/Util/ClassMapper.php
index 5fa0881..11720f6 100644
--- a/main/app/sprinkles/core/src/Util/ClassMapper.php
+++ b/main/app/sprinkles/core/src/Util/ClassMapper.php
@@ -30,8 +30,7 @@ class ClassMapper
* @param string $identifier The identifier for the class, e.g. 'user'
* @param mixed ...$arg Whatever needs to be passed to the constructor.
*/
- public function createInstance($identifier)
- {
+ public function createInstance($identifier) {
$className = $this->getClassMapping($identifier);
$params = array_slice(func_get_args(), 1);
@@ -48,8 +47,7 @@ class ClassMapper
* @param string $identifier
* @return string
*/
- public function getClassMapping($identifier)
- {
+ public function getClassMapping($identifier) {
if (isset($this->classMappings[$identifier])) {
return $this->classMappings[$identifier];
} else {
@@ -64,11 +62,10 @@ class ClassMapper
* @param string $className
* @return ClassMapper
*/
- public function setClassMapping($identifier, $className)
- {
+ public function setClassMapping($identifier, $className) {
// Check that class exists
if (!class_exists($className)) {
- throw new BadClassNameException("Unable to find the class '$className'." );
+ throw new BadClassNameException("Unable to find the class '$className'.");
}
$this->classMappings[$identifier] = $className;
@@ -83,8 +80,7 @@ class ClassMapper
* @param string $methodName The method to be invoked.
* @param mixed ...$arg Whatever needs to be passed to the method.
*/
- public function staticMethod($identifier, $methodName)
- {
+ public function staticMethod($identifier, $methodName) {
$className = $this->getClassMapping($identifier);
$params = array_slice(func_get_args(), 2);
diff --git a/main/app/sprinkles/core/src/Util/EnvironmentInfo.php b/main/app/sprinkles/core/src/Util/EnvironmentInfo.php
index aba9837..116a59e 100644
--- a/main/app/sprinkles/core/src/Util/EnvironmentInfo.php
+++ b/main/app/sprinkles/core/src/Util/EnvironmentInfo.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Util;
use Illuminate\Database\Capsule\Manager as Capsule;
@@ -28,8 +29,7 @@ class EnvironmentInfo
*
* @return string[] the properties of this database.
*/
- public static function database()
- {
+ public static function database() {
static::$ci['db'];
$pdo = Capsule::connection()->getPdo();
@@ -55,14 +55,13 @@ class EnvironmentInfo
*
* @return bool true if the connection can be established, false otherwise.
*/
- public static function canConnectToDatabase()
- {
+ public static function canConnectToDatabase() {
try {
Capsule::connection()->getPdo();
} catch (\PDOException $e) {
- return false;
+ return FALSE;
}
- return true;
+ return TRUE;
}
}
diff --git a/main/app/sprinkles/core/src/Util/ShutdownHandler.php b/main/app/sprinkles/core/src/Util/ShutdownHandler.php
index e7a6903..5447c8f 100644
--- a/main/app/sprinkles/core/src/Util/ShutdownHandler.php
+++ b/main/app/sprinkles/core/src/Util/ShutdownHandler.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Util;
use Interop\Container\ContainerInterface;
@@ -36,8 +37,7 @@ class ShutdownHandler
* @param ContainerInterface $ci The global container object, which holds all your services.
* @param bool $displayErrorInfo
*/
- public function __construct(ContainerInterface $ci, $displayErrorInfo)
- {
+ public function __construct(ContainerInterface $ci, $displayErrorInfo) {
$this->ci = $ci;
$this->displayErrorInfo = $displayErrorInfo;
}
@@ -47,16 +47,14 @@ class ShutdownHandler
*
* @return void
*/
- public function register()
- {
+ public function register() {
register_shutdown_function([$this, 'fatalHandler']);
}
/**
* Set up the fatal error handler, so that we get a clean error message and alert instead of a WSOD.
*/
- public function fatalHandler()
- {
+ public function fatalHandler() {
$error = error_get_last();
$fatalErrorTypes = [
E_ERROR,
@@ -78,7 +76,7 @@ class ShutdownHandler
// For CLI, just print the message and exit.
if (php_sapi_name() === 'cli') {
- exit($errorMessage . PHP_EOL);
+ exit($errorMessage . PHP_EOL);
}
// For all other environments, print a debug response for the requested data type
@@ -102,11 +100,10 @@ class ShutdownHandler
* @param array $error
* @return string
*/
- protected function buildErrorInfoMessage(array $error)
- {
+ protected function buildErrorInfoMessage(array $error) {
$errfile = $error['file'];
- $errline = (string) $error['line'];
- $errstr = $error['message'];
+ $errline = (string)$error['line'];
+ $errstr = $error['message'];
$errorTypes = [
E_ERROR => 'Fatal error',
@@ -125,8 +122,7 @@ class ShutdownHandler
* @param string $message
* @return string
*/
- protected function buildErrorPage($message)
- {
+ protected function buildErrorPage($message) {
$contentType = $this->determineContentType($this->ci->request, $this->ci->config['site.debug.ajax']);
switch ($contentType) {
@@ -149,8 +145,7 @@ class ShutdownHandler
* @param string $errorMessage
* @return string
*/
- protected function buildHtmlErrorPage($message)
- {
+ protected function buildHtmlErrorPage($message) {
$title = 'UserFrosting Application Error';
$html = "<p>$message</p>";
diff --git a/main/app/sprinkles/core/src/Util/Util.php b/main/app/sprinkles/core/src/Util/Util.php
index ae551cf..0db3b72 100644
--- a/main/app/sprinkles/core/src/Util/Util.php
+++ b/main/app/sprinkles/core/src/Util/Util.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Util;
/**
@@ -24,8 +25,7 @@ class Util
* @param bool $remove
* @return mixed[]
*/
- static public function extractFields(&$inputArray, $fieldArray, $remove = true)
- {
+ static public function extractFields(&$inputArray, $fieldArray, $remove = TRUE) {
$result = [];
foreach ($fieldArray as $name) {
@@ -48,8 +48,7 @@ class Util
* @param string $str
* @return string
*/
- static public function extractDigits($str)
- {
+ static public function extractDigits($str) {
return preg_replace('/[^0-9]/', '', $str);
}
@@ -59,15 +58,14 @@ class Util
* @param string $phone
* @return string
*/
- static public function formatPhoneNumber($phone)
- {
+ static public function formatPhoneNumber($phone) {
$num = static::extractDigits($phone);
$len = strlen($num);
if ($len == 7) {
$num = preg_replace('/([0-9]{3})([0-9]{4})/', '$1-$2', $num);
- } elseif ($len == 10) {
+ } else if ($len == 10) {
$num = preg_replace('/([0-9]{3})([0-9]{3})([0-9]{4})/', '($1) $2-$3', $num);
}
@@ -81,13 +79,12 @@ class Util
* @param array $arr
* @return string
*/
- static public function prettyPrintArray(array $arr)
- {
+ static public function prettyPrintArray(array $arr) {
$json = json_encode($arr);
$result = '';
$level = 0;
- $inQuotes = false;
- $inEscape = false;
+ $inQuotes = FALSE;
+ $inEscape = FALSE;
$endsLineLevel = NULL;
$jsonLength = strlen($json);
@@ -100,18 +97,20 @@ class Util
$endsLineLevel = NULL;
}
if ($inEscape) {
- $inEscape = false;
- } elseif ($char === '"') {
+ $inEscape = FALSE;
+ } else if ($char === '"') {
$inQuotes = !$inQuotes;
- } elseif (!$inQuotes) {
+ } else if (!$inQuotes) {
switch ($char) {
- case '}': case ']':
+ case '}':
+ case ']':
$level--;
$endsLineLevel = NULL;
$newLineLevel = $level;
break;
- case '{': case '[':
+ case '{':
+ case '[':
$level++;
case ',':
@@ -122,21 +121,24 @@ class Util
$post = ' ';
break;
- case ' ': case '\t': case '\n': case '\r':
+ case ' ':
+ case '\t':
+ case '\n':
+ case '\r':
$char = '';
$endsLineLevel = $newLineLevel;
$newLineLevel = NULL;
break;
}
- } elseif ($char === '\\') {
- $inEscape = true;
+ } else if ($char === '\\') {
+ $inEscape = TRUE;
}
if ($newLineLevel !== NULL) {
- $result .= '<br>'.str_repeat( '&nbsp;&nbsp;', $newLineLevel);
+ $result .= '<br>' . str_repeat('&nbsp;&nbsp;', $newLineLevel);
}
- $result .= $char.$post;
+ $result .= $char . $post;
}
return $result;
@@ -151,8 +153,7 @@ class Util
* @param string $separator
* @return string
*/
- static public function randomPhrase($numAdjectives, $maxLength = 9999999, $maxTries = 10, $separator = '-')
- {
+ static public function randomPhrase($numAdjectives, $maxLength = 9999999, $maxTries = 10, $separator = '-') {
$adjectives = include('extra://adjectives.php');
$nouns = include('extra://nouns.php');