studioespresso/craft-seo-fields

View on GitHub
src/fields/SeoField.php

Summary

Maintainability
A
0 mins
Test Coverage

Avoid using static access to class '\craft\helpers\Json' in method 'getInputHtml'.
Open

        $jsonVars = Json::encode($jsonVars);
Severity: Minor
Found in src/fields/SeoField.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\Craft' in method 'displayName'.
Open

        return Craft::t('seo-fields', 'SEO Fields');
Severity: Minor
Found in src/fields/SeoField.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\craft\helpers\Json' in method 'normalizeValue'.
Open

            $model->setAttributes(Json::decodeIfJson($value));
Severity: Minor
Found in src/fields/SeoField.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid unused parameters such as '$element'.
Open

    public function normalizeValue($value, ElementInterface $element = null): mixed
Severity: Minor
Found in src/fields/SeoField.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Class extends undeclared class \craft\base\Field
Open

class SeoField extends Field
Severity: Critical
Found in src/fields/SeoField.php by phan

Call to method decodeIfJson from undeclared class \craft\helpers\Json
Open

            $model->setAttributes(Json::decodeIfJson($value));
Severity: Critical
Found in src/fields/SeoField.php by phan

Reference to undeclared class \craft\base\Field
Open

        return parent::serializeValue($value, $element);
Severity: Critical
Found in src/fields/SeoField.php by phan

Reference to static property app from undeclared class \Craft
Invalid

        $id = Craft::$app->getView()->formatInputId($this->handle);
Severity: Critical
Found in src/fields/SeoField.php by phan

Reference to static property app from undeclared class \Craft
Open

        Craft::$app->getView()->registerJs("$('#{$namespacedId}-field').SeoField(" . $jsonVars . ");");
Severity: Critical
Found in src/fields/SeoField.php by phan

Doc-block of serializeValue contains declared return type null which is incompatible with the return type \studioespresso\seofields\fields\mixed declared in the signature
Open

     * @return null|false `false` in the event that the method is sure that no elements are going to be found.
Severity: Minor
Found in src/fields/SeoField.php by phan

Reference to undeclared property \studioespresso\seofields\fields\SeoField->handle
Open

        $id = Craft::$app->getView()->formatInputId($this->handle);
Severity: Minor
Found in src/fields/SeoField.php by phan

Call to method encode from undeclared class \craft\helpers\Json
Open

        $jsonVars = Json::encode($jsonVars);
Severity: Critical
Found in src/fields/SeoField.php by phan

Return type of serializeValue() is undeclared type \studioespresso\seofields\fields\mixed
Open

    public function serializeValue($value, ElementInterface $element = null): mixed
Severity: Minor
Found in src/fields/SeoField.php by phan

Reference to undeclared property \studioespresso\seofields\fields\SeoField->handle
Open

                'name' => $this->handle,
Severity: Minor
Found in src/fields/SeoField.php by phan

Possibly zero references to use statement for classlike/namespace SeoFields (\studioespresso\seofields\SeoFields)
Open

use studioespresso\seofields\SeoFields;
Severity: Minor
Found in src/fields/SeoField.php by phan

Reference to constant TYPE_TEXT from undeclared class \yii\db\Schema
Open

        return Schema::TYPE_TEXT;
Severity: Critical
Found in src/fields/SeoField.php by phan

Reference to undeclared property \studioespresso\seofields\fields\SeoField->handle
Open

            'name' => $this->handle,
Severity: Minor
Found in src/fields/SeoField.php by phan

Reference to static property app from undeclared class \Craft
Open

            'prefix' => Craft::$app->getView()->namespaceInputId(''),
Severity: Critical
Found in src/fields/SeoField.php by phan

Doc-block of normalizeValue contains declared return type mixed which is incompatible with the return type \studioespresso\seofields\fields\mixed declared in the signature
Open

     * @return mixed The prepared field value
Severity: Minor
Found in src/fields/SeoField.php by phan

Parameter $element has undeclared type \craft\base\ElementInterface
Open

    public function normalizeValue($value, ElementInterface $element = null): mixed
Severity: Minor
Found in src/fields/SeoField.php by phan

Reference to static property app from undeclared class \Craft
Open

        return Craft::$app->getView()->renderTemplate(
Severity: Critical
Found in src/fields/SeoField.php by phan

Call to undeclared method \studioespresso\seofields\models\SeoFieldModel::setAttributes
Open

            $model->setAttributes($value);
Severity: Critical
Found in src/fields/SeoField.php by phan

Doc-block of serializeValue contains declared return type false which is incompatible with the return type \studioespresso\seofields\fields\mixed declared in the signature
Open

     * @return null|false `false` in the event that the method is sure that no elements are going to be found.
Severity: Minor
Found in src/fields/SeoField.php by phan

Reference to undeclared class \craft\base\Field
Open

        $rules = parent::rules();
Severity: Critical
Found in src/fields/SeoField.php by phan

Parameter $element has undeclared type ?\craft\base\ElementInterface
Open

    public function serializeValue($value, ElementInterface $element = null): mixed
Severity: Minor
Found in src/fields/SeoField.php by phan

Assigning array{} to property but \studioespresso\seofields\fields\SeoField->tabs is string
Open

    public $tabs = [];
Severity: Minor
Found in src/fields/SeoField.php by phan

Reference to static property app from undeclared class \Craft
Open

        $namespacedId = Craft::$app->getView()->namespaceInputId($id);
Severity: Critical
Found in src/fields/SeoField.php by phan

Call to method t from undeclared class \Craft
Open

        return Craft::t('seo-fields', 'SEO Fields');
Severity: Critical
Found in src/fields/SeoField.php by phan

Return type of normalizeValue() is undeclared type \studioespresso\seofields\fields\mixed
Open

    public function normalizeValue($value, ElementInterface $element = null): mixed
Severity: Minor
Found in src/fields/SeoField.php by phan

Call to undeclared method \studioespresso\seofields\models\SeoFieldModel::setAttributes
Open

            $model->setAttributes(Json::decodeIfJson($value));
Severity: Critical
Found in src/fields/SeoField.php by phan

Reference to static property app from undeclared class \Craft
Open

        return Craft::$app->getView()->renderTemplate(
Severity: Critical
Found in src/fields/SeoField.php by phan

Parameter $element has undeclared type \craft\base\ElementInterface
Open

    public function getInputHtml($value, ElementInterface $element = null): string
Severity: Minor
Found in src/fields/SeoField.php by phan

Reference to instance property siteId from undeclared class \craft\base\ElementInterface
Open

        $value->siteId = $element->siteId;
Severity: Minor
Found in src/fields/SeoField.php by phan

Avoid excessively long variable names like $allowSitenameOverwrite. Keep variable name length under 20.
Open

    public $allowSitenameOverwrite = false;
Severity: Minor
Found in src/fields/SeoField.php by phpmd

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

Source https://phpmd.org/rules/naming.html#longvariable

Avoid variables with short names like $id. Configured minimum length is 3.
Open

        $id = Craft::$app->getView()->formatInputId($this->handle);
Severity: Minor
Found in src/fields/SeoField.php by phpmd

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

Source https://phpmd.org/rules/naming.html#shortvariable

There are no issues that match your filters.

Category
Status