These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace MadWeb\Seoable\Protocols; |
||
4 | |||
5 | use MadWeb\Seoable\Fields\Meta\Next; |
||
6 | use MadWeb\Seoable\Fields\Meta\Prev; |
||
7 | use MadWeb\Seoable\Fields\Meta\Title; |
||
8 | use MadWeb\Seoable\Fields\Meta\MetaTag; |
||
9 | use MadWeb\Seoable\Fields\Meta\Keywords; |
||
10 | use MadWeb\Seoable\Fields\Meta\Canonical; |
||
11 | use MadWeb\Seoable\Fields\Meta\Languages; |
||
12 | use MadWeb\Seoable\Fields\Meta\Description; |
||
13 | use MadWeb\Seoable\Fields\Meta\TitleSeparator; |
||
14 | |||
15 | /** |
||
16 | * @method Meta setMetaRaw(array $value) |
||
17 | * @method Meta addMetaRaw(string $meta, string $value, string $name = 'name') |
||
18 | * @method Meta setTitleRaw(string $value) |
||
19 | * @method Meta setTitleSeparatorRaw(string $value) |
||
20 | * @method Meta setDescriptionRaw(string $value) |
||
21 | * @method Meta setCanonicalRaw(string $value) |
||
22 | * @method Meta setPrevRaw(string $value) |
||
23 | * @method Meta setNextRaw(string $value) |
||
24 | * @method Meta setKeywordsRaw(array|string $value) |
||
25 | * @method Meta setLanguagesRaw(array $value) |
||
26 | * @method Meta addLanguageRaw(string $lang, string $url) |
||
27 | */ |
||
28 | class Meta extends Protocol |
||
29 | { |
||
30 | public function setMeta(array $tags): self |
||
31 | { |
||
32 | foreach ($this->parseValue($tags, MetaTag::class) as $item) { |
||
33 | $this->metaService->addMeta(...array_values($item)); |
||
34 | } |
||
35 | |||
36 | return $this; |
||
37 | } |
||
38 | |||
39 | public function addMeta(string $meta, string $value, string $name = 'name'): self |
||
40 | { |
||
41 | $this->metaService->addMeta(...array_values( |
||
42 | $this->parseValue( |
||
43 | [compact('meta', 'value', 'name')], |
||
44 | MetaTag::class |
||
45 | )[0] |
||
46 | )); |
||
47 | |||
48 | return $this; |
||
49 | } |
||
50 | |||
51 | /** @param array|string $value */ |
||
52 | public function setTitle($value, string $templateKey = ''): self |
||
53 | { |
||
54 | $this->seoTools->setTitle($this->parseValue( |
||
55 | $value, |
||
56 | $templateKey ? new Title($value, $this->model, $templateKey) : Title::class |
||
57 | )); |
||
58 | |||
59 | return $this; |
||
60 | } |
||
61 | |||
62 | /** @param string $value */ |
||
63 | public function setTitleSeparator(string $value): self |
||
64 | { |
||
65 | $this->metaService->setTitleSeparator($this->parseValue($value, TitleSeparator::class)); |
||
66 | |||
67 | return $this; |
||
68 | } |
||
69 | |||
70 | /** @param array|string $value */ |
||
71 | public function setDescription($value, string $templateKey = ''): self |
||
72 | { |
||
73 | $this->seoTools->setDescription($this->parseValue( |
||
74 | $value, |
||
75 | $templateKey ? new Description($value, $this->model, $templateKey) : Description::class |
||
76 | )); |
||
77 | |||
78 | return $this; |
||
79 | } |
||
80 | |||
81 | public function setCanonical(string $value): self |
||
82 | { |
||
83 | $this->seoTools->setCanonical($this->parseValue($value, Canonical::class)); |
||
84 | |||
85 | return $this; |
||
86 | } |
||
87 | |||
88 | public function setPrev(string $value): self |
||
89 | { |
||
90 | $this->metaService->setPrev($this->parseValue($value, Prev::class)); |
||
91 | |||
92 | return $this; |
||
93 | } |
||
94 | |||
95 | public function setNext(string $value): self |
||
96 | { |
||
97 | $this->metaService->setNext($this->parseValue($value, Next::class)); |
||
98 | |||
99 | return $this; |
||
100 | } |
||
101 | |||
102 | /** @param array|string $value */ |
||
103 | public function setKeywords($value): self |
||
104 | { |
||
105 | $this->metaService->setKeywords($this->parseValue($value, Keywords::class)); |
||
106 | |||
107 | return $this; |
||
108 | } |
||
109 | |||
110 | public function setLanguages(array $value): self |
||
111 | { |
||
112 | $this->metaService->addAlternateLanguages($this->parseValue($value, Languages::class)); |
||
113 | |||
114 | return $this; |
||
115 | } |
||
116 | |||
117 | public function addLanguage(string $lang, string $url): self |
||
118 | { |
||
119 | $this->metaService->addAlternateLanguage(...array_values( |
||
0 ignored issues
–
show
|
|||
120 | $this->parseValue( |
||
121 | [compact('lang', 'url')], |
||
122 | Languages::class |
||
123 | )[0] |
||
124 | )); |
||
125 | |||
126 | return $this; |
||
127 | } |
||
128 | |||
129 | protected function getRawFields(): array |
||
130 | { |
||
131 | return $this->modelSeoData; |
||
132 | } |
||
133 | } |
||
134 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: