Skip to content

Commit

Permalink
chore: ECS code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Jan 31, 2024
1 parent 0d9b57f commit 61babd9
Show file tree
Hide file tree
Showing 1,503 changed files with 255,280 additions and 255,364 deletions.
4 changes: 2 additions & 2 deletions src/Node/Expression/EmptyCoalesceExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ public function compile(Compiler $compiler)
{
//$this->getNode('expr1')->setAttribute('always_defined', true);
$compiler
->raw('(('.self::class.'::empty(')
->raw('((' . self::class . '::empty(')
->subcompile($this->getNode('left'))
->raw(') ? null : ')
->subcompile($this->getNode('left'))
->raw(') ?? ('.self::class.'::empty(')
->raw(') ?? (' . self::class . '::empty(')
->subcompile($this->getNode('right'))
->raw(') ? null : ')
->subcompile($this->getNode('right'))
Expand Down
52 changes: 26 additions & 26 deletions src/Seomatic.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ protected function installEventListeners()
// Install our event listeners only if our table schema exists
if ($this->migrationsAndSchemaReady()) {
// Add in our Twig extensions
self::$view->registerTwigExtension(new SeomaticTwigExtension);
self::$view->registerTwigExtension(new SeomaticTwigExtension());
$request = Craft::$app->getRequest();
// Add in our event listeners that are needed for every request
$this->installGlobalEventListeners();
Expand All @@ -349,7 +349,7 @@ protected function installEventListeners()
Event::on(
Plugins::class,
Plugins::EVENT_AFTER_INSTALL_PLUGIN,
function (PluginEvent $event) {
function(PluginEvent $event) {
if ($event->plugin === $this) {
// Invalidate our caches after we've been installed
$this->clearAllCaches();
Expand All @@ -370,7 +370,7 @@ function (PluginEvent $event) {
Event::on(
ClearCaches::class,
ClearCaches::EVENT_REGISTER_CACHE_OPTIONS,
function (RegisterCacheOptionsEvent $event) {
function(RegisterCacheOptionsEvent $event) {
Craft::debug(
'ClearCaches::EVENT_REGISTER_CACHE_OPTIONS',
__METHOD__
Expand All @@ -386,7 +386,7 @@ function (RegisterCacheOptionsEvent $event) {
Event::on(
Plugins::class,
Plugins::EVENT_BEFORE_SAVE_PLUGIN_SETTINGS,
function (PluginEvent $event) {
function(PluginEvent $event) {
if ($event->plugin === $this && !Craft::$app->getDb()->getSupportsMb4()) {
// For all the emojis
$settingsModel = $this->getSettings();
Expand Down Expand Up @@ -439,7 +439,7 @@ protected function installGlobalEventListeners()
Event::on(
Plugins::class,
Plugins::EVENT_AFTER_LOAD_PLUGINS,
function () {
function() {
// Delay registering SEO Elements to give other plugins a chance to load first
$this->seoElements->getAllSeoElementTypes(false);
// Delay installing GQL handlers to give other plugins a chance to register their own first
Expand All @@ -460,7 +460,7 @@ function () {
Event::on(
Fields::class,
Fields::EVENT_REGISTER_FIELD_TYPES,
function (RegisterComponentTypesEvent $event) {
function(RegisterComponentTypesEvent $event) {
$event->types[] = SeoSettingsField::class;
$event->types[] = Seomatic_MetaField::class;
}
Expand All @@ -469,7 +469,7 @@ function (RegisterComponentTypesEvent $event) {
Event::on(
Element::class,
Element::EVENT_AFTER_PROPAGATE,
static function (ModelEvent $event) {
static function(ModelEvent $event) {
Craft::debug(
'Element::EVENT_AFTER_PROPAGATE',
__METHOD__
Expand All @@ -489,7 +489,7 @@ static function (ModelEvent $event) {
Event::on(
Elements::class,
Elements::EVENT_AFTER_DELETE_ELEMENT,
function (ElementEvent $event) {
function(ElementEvent $event) {
Craft::debug(
'Elements::EVENT_AFTER_DELETE_ELEMENT',
__METHOD__
Expand All @@ -508,7 +508,7 @@ function (ElementEvent $event) {
Event::on(
Entry::class,
Entry::EVENT_REGISTER_PREVIEW_TARGETS,
function (RegisterPreviewTargetsEvent $e) {
function(RegisterPreviewTargetsEvent $e) {
/** @var Element $element */
$element = $e->sender;
if ($element->uri !== null) {
Expand All @@ -529,7 +529,7 @@ function (RegisterPreviewTargetsEvent $e) {
Event::on(
Application::class,
BaseApplication::EVENT_BEFORE_REQUEST,
static function () {
static function() {
/** @var Module|null $debugModule */
$debugModule = Craft::$app->getModule('debug');

Expand All @@ -546,7 +546,7 @@ static function () {
Event::on(
FeedMeFields::class,
FeedMeFields::EVENT_REGISTER_FEED_ME_FIELDS,
function (RegisterFeedMeFieldsEvent $e) {
function(RegisterFeedMeFieldsEvent $e) {
Craft::debug(
'FeedMeFields::EVENT_REGISTER_FEED_ME_FIELDS',
__METHOD__
Expand All @@ -555,7 +555,7 @@ function (RegisterFeedMeFieldsEvent $e) {
}
);
}
$updateMetaBundles = function ($message) {
$updateMetaBundles = function($message) {
Craft::debug(
$message,
__METHOD__
Expand All @@ -574,7 +574,7 @@ function (RegisterFeedMeFieldsEvent $e) {
Event::on(
SitesService::class,
SitesService::EVENT_AFTER_SAVE_SITE,
function () use ($updateMetaBundles) {
function() use ($updateMetaBundles) {
$updateMetaBundles('SitesService::EVENT_AFTER_SAVE_SITE');
}
);
Expand All @@ -583,7 +583,7 @@ function () use ($updateMetaBundles) {
Event::on(
SitesService::class,
SitesService::EVENT_AFTER_DELETE_SITE,
function () use ($updateMetaBundles) {
function() use ($updateMetaBundles) {
$updateMetaBundles('SitesService::EVENT_AFTER_DELETE_SITE');
}
);
Expand All @@ -602,7 +602,7 @@ protected function installGqlHandlers()
Event::on(
Gql::class,
Gql::EVENT_REGISTER_GQL_TYPES,
function (RegisterGqlTypesEvent $event) {
function(RegisterGqlTypesEvent $event) {
Craft::debug(
'Gql::EVENT_REGISTER_GQL_TYPES',
__METHOD__
Expand All @@ -615,7 +615,7 @@ function (RegisterGqlTypesEvent $event) {
Event::on(
Gql::class,
Gql::EVENT_REGISTER_GQL_QUERIES,
function (RegisterGqlQueriesEvent $event) {
function(RegisterGqlQueriesEvent $event) {
Craft::debug(
'Gql::EVENT_REGISTER_GQL_QUERIES',
__METHOD__
Expand All @@ -631,7 +631,7 @@ function (RegisterGqlQueriesEvent $event) {
Event::on(
Gql::class,
Gql::EVENT_REGISTER_GQL_SCHEMA_COMPONENTS,
function (RegisterGqlSchemaComponentsEvent $event) {
function(RegisterGqlSchemaComponentsEvent $event) {
Craft::debug(
'Gql::EVENT_REGISTER_GQL_SCHEMA_COMPONENTS',
__METHOD__
Expand All @@ -649,7 +649,7 @@ function (RegisterGqlSchemaComponentsEvent $event) {
Event::on(
TypeManager::class,
TypeManager::EVENT_DEFINE_GQL_TYPE_FIELDS,
function (DefineGqlTypeFieldsEvent $event) use ($knownInterfaceNames) {
function(DefineGqlTypeFieldsEvent $event) use ($knownInterfaceNames) {
if (in_array($event->typeName, $knownInterfaceNames, true)) {
Craft::debug(
'TypeManager::EVENT_DEFINE_GQL_TYPE_FIELDS',
Expand All @@ -663,7 +663,7 @@ function (DefineGqlTypeFieldsEvent $event) use ($knownInterfaceNames) {
'type' => SeomaticInterface::getType(),
'args' => SeomaticArguments::getArguments(),
'resolve' => SeomaticResolver::class . '::resolve',
'description' => Craft::t('seomatic', 'This query is used to query for SEOmatic meta data.')
'description' => Craft::t('seomatic', 'This query is used to query for SEOmatic meta data.'),
];
}
}
Expand All @@ -690,7 +690,7 @@ protected function handleSiteRequest()
Event::on(
View::class,
View::EVENT_END_PAGE,
function () {
function() {
Craft::debug(
'View::EVENT_END_PAGE',
__METHOD__
Expand All @@ -713,7 +713,7 @@ protected function handleAdminCpRequest()
// Don't cache Control Panel requests
self::$cacheDuration = 1;
// Prefix the Control Panel title
self::$view->hook('cp.layouts.base', function (&$context) {
self::$view->hook('cp.layouts.base', function(&$context) {
if (self::$devMode) {
$context['docTitle'] = self::$settings->devModeCpTitlePrefix . $context['docTitle'];
} else {
Expand All @@ -735,7 +735,7 @@ protected function installSiteEventListeners()
Event::on(
UrlManager::class,
UrlManager::EVENT_REGISTER_SITE_URL_RULES,
function (RegisterUrlRulesEvent $event) {
function(RegisterUrlRulesEvent $event) {
Craft::debug(
'UrlManager::EVENT_REGISTER_SITE_URL_RULES',
__METHOD__
Expand Down Expand Up @@ -777,7 +777,7 @@ protected function installCpEventListeners()
Event::on(
UrlManager::class,
UrlManager::EVENT_REGISTER_CP_URL_RULES,
function (RegisterUrlRulesEvent $event) {
function(RegisterUrlRulesEvent $event) {
Craft::debug(
'UrlManager::EVENT_REGISTER_CP_URL_RULES',
__METHOD__
Expand All @@ -793,7 +793,7 @@ function (RegisterUrlRulesEvent $event) {
Event::on(
UserPermissions::class,
UserPermissions::EVENT_REGISTER_PERMISSIONS,
function (RegisterUserPermissionsEvent $event) {
function(RegisterUserPermissionsEvent $event) {
Craft::debug(
'UserPermissions::EVENT_REGISTER_PERMISSIONS',
__METHOD__
Expand All @@ -804,7 +804,7 @@ function (RegisterUserPermissionsEvent $event) {
);
// Handler: AutocompleteService::EVENT_REGISTER_CODEEDITOR_AUTOCOMPLETES
Event::on(AutocompleteService::class, AutocompleteService::EVENT_REGISTER_CODEEDITOR_AUTOCOMPLETES,
function (RegisterCodeEditorAutocompletesEvent $event) {
function(RegisterCodeEditorAutocompletesEvent $event) {
if ($event->fieldType === self::SEOMATIC_EXPRESSION_FIELD_TYPE) {
$event->types[] = EnvironmentVariableAutocomplete::class;
}
Expand All @@ -816,7 +816,7 @@ function (RegisterCodeEditorAutocompletesEvent $event) {
// Handler: TwigTemplateValidator::EVENT_REGISTER_TWIG_VALIDATOR_VARIABLES
Event::on(TwigTemplateValidator::class,
TwigTemplateValidator::EVENT_REGISTER_TWIG_VALIDATOR_VARIABLES,
function (RegisterTwigValidatorVariablesEvent $event) {
function(RegisterTwigValidatorVariablesEvent $event) {
if (Seomatic::$seomaticVariable === null) {
Seomatic::$seomaticVariable = new SeomaticVariable();
Seomatic::$plugin->metaContainers->loadGlobalMetaContainers();
Expand Down
4 changes: 2 additions & 2 deletions src/base/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

namespace nystudio107\seomatic\base;

use nystudio107\seomatic\helpers\Dependency;
use craft\validators\ArrayValidator;
use nystudio107\seomatic\events\IncludeContainerEvent;

use craft\validators\ArrayValidator;
use nystudio107\seomatic\helpers\Dependency;

/**
* @author nystudio107
Expand Down
1 change: 0 additions & 1 deletion src/base/ContainerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
interface ContainerInterface
{

// Constants
// =========================================================================

Expand Down
3 changes: 1 addition & 2 deletions src/base/FluentModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
*/
abstract class FluentModel extends Model
{

// Static Protected Methods
// =========================================================================

Expand Down Expand Up @@ -78,7 +77,7 @@ public function __call($method, $args)
// Set the property
$value = $args[0];
if (\is_object($value) && $value instanceof Markup) {
$value = (string)$value;
$value = (string)$value;
}
$property->setValue($this, $value);

Expand Down
2 changes: 1 addition & 1 deletion src/base/FrontendTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

namespace nystudio107\seomatic\base;

use nystudio107\seomatic\Seomatic;
use nystudio107\seomatic\helpers\PluginTemplate;
use nystudio107\seomatic\Seomatic;

/**
* @author nystudio107
Expand Down
1 change: 0 additions & 1 deletion src/base/FrontendTemplateInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
interface FrontendTemplateInterface
{

// Constants
// =========================================================================

Expand Down
6 changes: 0 additions & 6 deletions src/base/GqlSeoElementInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@

namespace nystudio107\seomatic\base;

use nystudio107\seomatic\models\MetaBundle;

use craft\base\ElementInterface;
use craft\base\Model;
use craft\elements\db\ElementQueryInterface;

/**
* @author nystudio107
* @package Seomatic
Expand Down
1 change: 0 additions & 1 deletion src/base/InheritableSettingsModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
*/
abstract class InheritableSettingsModel extends VarsModel
{

/**
* @var array A list of all the settings for which the inherited values should be used.
*/
Expand Down
6 changes: 2 additions & 4 deletions src/base/MetaItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ public function renderAttributes(array $params = []): array
public function debugMetaItem(
$errorLabel = 'Error: ',
array $scenarios = ['default' => 'error']
)
{
) {
$isMetaJsonLdModel = false;
if (is_subclass_of($this, MetaJsonLd::class)) {
$isMetaJsonLdModel = true;
Expand Down Expand Up @@ -271,8 +270,7 @@ public function tagAttributesArray(): array
public function validateStringOrArray(
$attribute,
$params
)
{
) {
$validated = false;
if (\is_string($attribute)) {
$validated = true;
Expand Down
1 change: 0 additions & 1 deletion src/base/MetaItemInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
interface MetaItemInterface
{

// Constants
// =========================================================================

Expand Down
5 changes: 2 additions & 3 deletions src/base/MetaService.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@

namespace nystudio107\seomatic\base;

use nystudio107\seomatic\Seomatic;

use Craft;
use craft\base\Component;

use nystudio107\seomatic\Seomatic;

/**
* @author nystudio107
* @package Seomatic
Expand Down
8 changes: 4 additions & 4 deletions src/base/NonceContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

namespace nystudio107\seomatic\base;

use Craft;
use nystudio107\seomatic\helpers\Dependency;
use nystudio107\seomatic\models\MetaJsonLdContainer;
use nystudio107\seomatic\models\MetaScriptContainer;
use nystudio107\seomatic\Seomatic;
use nystudio107\seomatic\helpers\Dependency;

use Craft;
use nystudio107\seomatic\Seomatic;

/**
* @author nystudio107
Expand Down Expand Up @@ -71,7 +71,7 @@ public function addNonceHeaders(array $cspNonces)
$serializedNonces = implode(" ", $cspNonces);
$cspDirective = self::CSP_DIRECTIVE;
$cspValue = "{$cspDirective} {$serializedNonces};";
foreach(self::CSP_HEADERS as $cspHeader) {
foreach (self::CSP_HEADERS as $cspHeader) {
Craft::$app->getResponse()->getHeaders()->add($cspHeader, $cspValue);
}
}
Expand Down
Loading

0 comments on commit 61babd9

Please sign in to comment.