Skip to content

Commit

Permalink
refactor: PHPStan code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Feb 18, 2024
1 parent a7bbbf3 commit 6b85dae
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
11 changes: 4 additions & 7 deletions src/base/MetaItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,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 @@ -195,10 +194,9 @@ public function debugMetaItem(
if ($isMetaJsonLdModel) {
/** @var MetaJsonLd $className */
$className = get_class($this);
if (!empty($className::$schemaPropertyDescriptions[$param])) {
if (!empty($className->schemaPropertyDescriptions[$param])) {
$errorMsg = Craft::t('seomatic', $errorLabel) . $param;
/** @var $className MetaJsonLd */
$errorMsg .= ' -> ' . $className::$schemaPropertyDescriptions[$param];
$errorMsg .= ' -> ' . $className->schemaPropertyDescriptions[$param];
Craft::info($errorMsg, __METHOD__);
}
}
Expand Down Expand Up @@ -277,8 +275,7 @@ public function tagAttributesArray(): array
public function validateStringOrArray(
$attribute,
$params
)
{
) {
$validated = false;
if (is_string($attribute)) {
$validated = true;
Expand Down
12 changes: 8 additions & 4 deletions src/models/MetaJsonLd.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
* @author nystudio107
* @package Seomatic
* @since 3.0.0
*
* @property-read array $googleRecommendedSchema
* @property-read array $googleRequiredSchema
* @property-read array $schemaPropertyDescriptions
* @property-read array $schemaPropertyExpectedTypes
* @property-read array $schemaPropertyNames
*/
class MetaJsonLd extends NonceItem
{
Expand Down Expand Up @@ -239,8 +245,7 @@ public function render(
'renderScriptTags' => true,
'array' => false,
]
): string
{
): string {
$html = '';
$options = $this->tagAttributes();
if ($this->prepForRender($options)) {
Expand Down Expand Up @@ -362,8 +367,7 @@ public function datetimeAttributes(): array
public function validateJsonSchema(
$attribute,
$params
)
{
) {
if (!in_array($attribute, $this->getSchemaPropertyNames(), true)) {
$this->addError($attribute, 'The attribute does not exist.');
} else {
Expand Down

0 comments on commit 6b85dae

Please sign in to comment.