mirror of
https://github.com/archtechx/laravel-seo.git
synced 2025-12-12 01:44:03 +00:00
Fix some PHPStan errors (#12)
* Fix some PHPStan errors * Fix return type of SEOManager::meta * Fix CS * Update SEOManager.php * Update helpers.php * Update SEOManager.php
This commit is contained in:
parent
7b24a50bd6
commit
20f55c3342
3 changed files with 18 additions and 13 deletions
|
|
@ -28,8 +28,8 @@
|
|||
"imliam/laravel-blade-helper": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"orchestra/testbench": "^6.9",
|
||||
"nunomaduro/larastan": "^0.6.10",
|
||||
"orchestra/testbench": "^6.23",
|
||||
"nunomaduro/larastan": "^1.0",
|
||||
"pestphp/pest": "^1.2",
|
||||
"pestphp/pest-plugin-laravel": "^1.0",
|
||||
"intervention/image": "^2.7"
|
||||
|
|
|
|||
10
phpstan.neon
10
phpstan.neon
|
|
@ -10,11 +10,9 @@ parameters:
|
|||
universalObjectCratesClasses:
|
||||
- Illuminate\Routing\Route
|
||||
- ArchTech\SEO\SEOManager
|
||||
checkMissingIterableValueType: false
|
||||
|
||||
ignoreErrors:
|
||||
- '#SEOManager\|array\|string\|null#'
|
||||
- '#string\|false given#'
|
||||
- '#flipp\(\) should return#'
|
||||
- '#\_\_set\(\) has no return typehint specified#'
|
||||
|
||||
checkMissingIterableValueType: false
|
||||
# Waiting for https://github.com/phpstan/phpstan/issues/5706
|
||||
- '#^Cannot call method (flipp|get|set)\(\) on ArchTech\\SEO\\SEOManager\|array\|string\|null\.$#'
|
||||
- '#^Method ArchTech\\SEO\\SEOManager::flipp\(\) should return static\(ArchTech\\SEO\\SEOManager\)\|string but returns array\|string\|null\.$#'
|
||||
|
|
|
|||
|
|
@ -82,11 +82,14 @@ class SEOManager
|
|||
: value($this->values[$key]);
|
||||
}
|
||||
|
||||
/** Set one or more values. */
|
||||
/**
|
||||
* Set one or more values.
|
||||
*
|
||||
* @param string|array<string, string> $key
|
||||
*/
|
||||
public function set(string|array $key, string|Closure|null $value = null): string|array|null
|
||||
{
|
||||
if (is_array($key)) {
|
||||
/** @var array<string, string> $key */
|
||||
foreach ($key as $k => $v) {
|
||||
$this->set($k, $v);
|
||||
}
|
||||
|
|
@ -166,7 +169,7 @@ class SEOManager
|
|||
];
|
||||
}
|
||||
|
||||
$query = base64_encode(json_encode($data));
|
||||
$query = base64_encode(json_encode($data, JSON_THROW_ON_ERROR));
|
||||
|
||||
/** @var string $template */
|
||||
$template = $this->meta("flipp.templates.$alias");
|
||||
|
|
@ -220,7 +223,7 @@ class SEOManager
|
|||
* Get or set metadata.
|
||||
* @param string|array $key The key or key-value pair being set.
|
||||
* @param string|array|null $value The value (if a single key is provided).
|
||||
* @return $this|string
|
||||
* @return $this|string|null
|
||||
*/
|
||||
public function meta(string|array $key, string|array $value = null): mixed
|
||||
{
|
||||
|
|
@ -281,7 +284,11 @@ class SEOManager
|
|||
return $this->get(Str::snake($key, '.'));
|
||||
}
|
||||
|
||||
/** Handle magic set. */
|
||||
/**
|
||||
* Handle magic set.
|
||||
*
|
||||
* @return string|array|null
|
||||
*/
|
||||
public function __set(string $key, string $value)
|
||||
{
|
||||
return $this->set(Str::snake($key, '.'), $value);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue