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 e06edce commit c789211
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
11 changes: 4 additions & 7 deletions src/base/MetaItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,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 @@ -194,10 +193,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 @@ -276,8 +274,7 @@ public function tagAttributesArray(): array
public function validateStringOrArray(
$attribute,
$params,
)
{
) {
$validated = false;
if (is_string($attribute)) {
$validated = true;
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/DynamicMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ public static function addSameAsMeta()
}
// Site Identity JSON-LD
$identity = Seomatic::$plugin->jsonLd->get('identity');
/** @var Thing $identity */
/** @var Thing|null $identity */
if ($identity !== null && property_exists($identity, 'sameAs')) {
$identity->sameAs = $sameAsUrls;
}
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 @@ -248,8 +254,7 @@ public function render(
'renderScriptTags' => true,
'array' => false,
],
): string
{
): string {
$html = '';
$options = $this->tagAttributes();
if ($this->prepForRender($options)) {
Expand Down Expand Up @@ -371,8 +376,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 c789211

Please sign in to comment.