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 7f01abd commit 8b314a2
Show file tree
Hide file tree
Showing 1,518 changed files with 255,401 additions and 255,496 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
56 changes: 28 additions & 28 deletions src/Seomatic.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ class Seomatic extends Plugin

protected const FRONTEND_PREVIEW_PATH = 'seomatic/preview-social-media';

const SEOMATIC_EXPRESSION_FIELD_TYPE = 'SeomaticExpressionField';
const SEOMATIC_TRACKING_FIELD_TYPE = 'SeomaticTrackingField';
public const SEOMATIC_EXPRESSION_FIELD_TYPE = 'SeomaticExpressionField';
public const SEOMATIC_TRACKING_FIELD_TYPE = 'SeomaticTrackingField';

// Static Properties
// =========================================================================
Expand Down Expand Up @@ -406,7 +406,7 @@ protected function installEventListeners(): void
// 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 @@ -423,7 +423,7 @@ protected function installEventListeners(): void
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 @@ -444,7 +444,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 @@ -460,7 +460,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 @@ -490,7 +490,7 @@ protected function installGlobalEventListeners(): void
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 @@ -511,7 +511,7 @@ function () {
Event::on(
Fields::class,
Fields::EVENT_REGISTER_FIELD_TYPES,
static function (RegisterComponentTypesEvent $event) {
static function(RegisterComponentTypesEvent $event) {
$event->types[] = SeoSettingsField::class;
$event->types[] = Seomatic_MetaField::class;
}
Expand All @@ -520,7 +520,7 @@ static 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 @@ -540,7 +540,7 @@ static function (ModelEvent $event) {
Event::on(
Elements::class,
Elements::EVENT_AFTER_DELETE_ELEMENT,
static function (ElementEvent $event) {
static function(ElementEvent $event) {
Craft::debug(
'Elements::EVENT_AFTER_DELETE_ELEMENT',
__METHOD__
Expand All @@ -559,7 +559,7 @@ static function (ElementEvent $event) {
Event::on(
Entry::class,
Element::EVENT_REGISTER_PREVIEW_TARGETS,
static function (RegisterPreviewTargetsEvent $e) {
static function(RegisterPreviewTargetsEvent $e) {
/** @var Element $element */
$element = $e->sender;
if ($element->uri !== null) {
Expand All @@ -580,7 +580,7 @@ static 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 @@ -597,7 +597,7 @@ static function () {
Event::on(
FeedMeFields::class,

Check failure on line 598 in src/Seomatic.php

View workflow job for this annotation

GitHub Actions / PHPStan

Class craft\feedme\services\Fields not found.
FeedMeFields::EVENT_REGISTER_FEED_ME_FIELDS,

Check failure on line 599 in src/Seomatic.php

View workflow job for this annotation

GitHub Actions / PHPStan

Access to constant EVENT_REGISTER_FEED_ME_FIELDS on an unknown class craft\feedme\services\Fields.
static function (RegisterFeedMeFieldsEvent $e) {
static function(RegisterFeedMeFieldsEvent $e) {

Check failure on line 600 in src/Seomatic.php

View workflow job for this annotation

GitHub Actions / PHPStan

Parameter $e of anonymous function has invalid type craft\feedme\events\RegisterFeedMeFieldsEvent.
Craft::debug(
'FeedMeFields::EVENT_REGISTER_FEED_ME_FIELDS',
__METHOD__
Expand All @@ -606,7 +606,7 @@ static function (RegisterFeedMeFieldsEvent $e) {
}
);
}
$updateMetaBundles = static function ($message) {
$updateMetaBundles = static function($message) {
Craft::debug(
$message,
__METHOD__
Expand All @@ -625,7 +625,7 @@ static function (RegisterFeedMeFieldsEvent $e) {
Event::on(
SitesService::class,
SitesService::EVENT_AFTER_SAVE_SITE,
static function () use ($updateMetaBundles) {
static function() use ($updateMetaBundles) {
$updateMetaBundles('SitesService::EVENT_AFTER_SAVE_SITE');
}
);
Expand All @@ -634,7 +634,7 @@ static function () use ($updateMetaBundles) {
Event::on(
SitesService::class,
SitesService::EVENT_AFTER_DELETE_SITE,
static function () use ($updateMetaBundles) {
static function() use ($updateMetaBundles) {
$updateMetaBundles('SitesService::EVENT_AFTER_DELETE_SITE');
}
);
Expand All @@ -651,7 +651,7 @@ protected function installGqlHandlers(): void
Event::on(
Gql::class,
Gql::EVENT_REGISTER_GQL_TYPES,
static function (RegisterGqlTypesEvent $event) {
static function(RegisterGqlTypesEvent $event) {
Craft::debug(
'Gql::EVENT_REGISTER_GQL_TYPES',
__METHOD__
Expand All @@ -664,7 +664,7 @@ static function (RegisterGqlTypesEvent $event) {
Event::on(
Gql::class,
Gql::EVENT_REGISTER_GQL_QUERIES,
static function (RegisterGqlQueriesEvent $event) {
static function(RegisterGqlQueriesEvent $event) {
Craft::debug(
'Gql::EVENT_REGISTER_GQL_QUERIES',
__METHOD__
Expand All @@ -679,7 +679,7 @@ static function (RegisterGqlQueriesEvent $event) {
Event::on(
Gql::class,
Gql::EVENT_REGISTER_GQL_SCHEMA_COMPONENTS,
static function (RegisterGqlSchemaComponentsEvent $event) {
static function(RegisterGqlSchemaComponentsEvent $event) {
Craft::debug(
'Gql::EVENT_REGISTER_GQL_SCHEMA_COMPONENTS',
__METHOD__
Expand All @@ -694,7 +694,7 @@ static function (RegisterGqlSchemaComponentsEvent $event) {
Event::on(
TypeManager::class,
TypeManager::EVENT_DEFINE_GQL_TYPE_FIELDS,
static function (DefineGqlTypeFieldsEvent $event) use ($knownInterfaceNames) {
static function(DefineGqlTypeFieldsEvent $event) use ($knownInterfaceNames) {
if (in_array($event->typeName, $knownInterfaceNames, true)) {
Craft::debug(
'TypeManager::EVENT_DEFINE_GQL_TYPE_FIELDS',
Expand All @@ -708,7 +708,7 @@ static 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 @@ -726,7 +726,7 @@ protected function handleSiteRequest(): void
Event::on(
View::class,
BaseView::EVENT_END_PAGE,
static function () {
static function() {
Craft::debug(
'View::EVENT_END_PAGE',
__METHOD__
Expand All @@ -749,7 +749,7 @@ protected function handleAdminCpRequest(): void
// 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 @@ -771,7 +771,7 @@ protected function installSiteEventListeners(): void
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 @@ -813,7 +813,7 @@ protected function installCpEventListeners(): void
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 @@ -829,7 +829,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 @@ -843,7 +843,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 @@ -855,7 +855,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
5 changes: 2 additions & 3 deletions src/base/ContainerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@
*/
interface ContainerInterface
{

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

const CONTAINER_TYPE = 'GenericContainer';
public const CONTAINER_TYPE = 'GenericContainer';

/**
* @event IncludeContainerEvent The event that is triggered when a container is
Expand All @@ -38,7 +37,7 @@ interface ContainerInterface
* });
* ```
*/
const EVENT_INCLUDE_CONTAINER = 'includeContainer';
public const EVENT_INCLUDE_CONTAINER = 'includeContainer';

// Static Methods
// =========================================================================
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
3 changes: 1 addition & 2 deletions src/base/FrontendTemplateInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@
*/
interface FrontendTemplateInterface
{

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

const TEMPLATE_TYPE = 'GenericTemplate';
public const TEMPLATE_TYPE = 'GenericTemplate';

// Public Methods
// =========================================================================
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
12 changes: 5 additions & 7 deletions src/base/MetaItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ abstract class MetaItem extends FluentModel implements MetaItemInterface
// Constants
// =========================================================================

const ARRAY_PROPERTIES = [
public const ARRAY_PROPERTIES = [
];

// Public Methods
Expand Down Expand Up @@ -141,9 +141,8 @@ public function renderAttributes(array $params = []): array
*/
public function debugMetaItem(
$errorLabel = 'Error: ',
array $scenarios = ['default' => 'error']
)
{
array $scenarios = ['default' => 'error'],
) {
$isMetaJsonLdModel = false;
if (is_subclass_of($this, MetaJsonLd::class)) {
$isMetaJsonLdModel = true;
Expand Down Expand Up @@ -270,9 +269,8 @@ public function tagAttributesArray(): array
*/
public function validateStringOrArray(
$attribute,
$params
)
{
$params,
) {
$validated = false;
if (\is_string($attribute)) {
$validated = true;
Expand Down
3 changes: 1 addition & 2 deletions src/base/MetaItemInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@
*/
interface MetaItemInterface
{

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

const ITEM_TYPE = 'Generic';
public const ITEM_TYPE = 'Generic';

// Public Methods
// =========================================================================
Expand Down
Loading

0 comments on commit 8b314a2

Please sign in to comment.