Skip to content

Commit 5234ae3

Browse files
Fix working for 7.4 (#261)
1 parent c23c190 commit 5234ae3

11 files changed

+33
-32
lines changed

src/Main/Markup/OGP/OpenGraph.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class OpenGraph
112112
/**
113113
* @return static
114114
*/
115-
public static function create(): static
115+
public static function create(): OpenGraph
116116
{
117117
return new static;
118118
}
@@ -121,7 +121,7 @@ public static function create(): static
121121
* @param string $title
122122
* @return static
123123
*/
124-
public function setTitle(string $title): static
124+
public function setTitle(string $title): OpenGraph
125125
{
126126
$this->title = $title;
127127

@@ -132,7 +132,7 @@ public function setTitle(string $title): static
132132
* @param string $description
133133
* @return static
134134
*/
135-
public function setDescription(string $description): static
135+
public function setDescription(string $description): OpenGraph
136136
{
137137
$this->description = $description;
138138

@@ -144,7 +144,7 @@ public function setDescription(string $description): static
144144
* @return static
145145
* @throws WrongArgumentException
146146
*/
147-
public function setDaterminer(string $daterminer): static
147+
public function setDaterminer(string $daterminer): OpenGraph
148148
{
149149
Assert::isTrue(
150150
empty($daterminer) || in_array($daterminer, self::ALLOWED_DATERMINE),
@@ -160,7 +160,7 @@ public function setDaterminer(string $daterminer): static
160160
* @return static
161161
* @throws WrongArgumentException
162162
*/
163-
public function setLocale(string $locale): static
163+
public function setLocale(string $locale): OpenGraph
164164
{
165165
Assert::isTrue(
166166
preg_match('/^[a-z]{2}_[A-Z]{2}$/iu', $locale) == 1,
@@ -176,7 +176,7 @@ public function setLocale(string $locale): static
176176
* @return static
177177
* @throws WrongArgumentException
178178
*/
179-
public function setLocaleAlternates(string $locale): static
179+
public function setLocaleAlternates(string $locale): OpenGraph
180180
{
181181
Assert::isTrue(
182182
preg_match('/^[a-z]{2}_[A-Z]{2}$/iu', $locale) == 1,
@@ -191,7 +191,7 @@ public function setLocaleAlternates(string $locale): static
191191
* @param string $siteName
192192
* @return static
193193
*/
194-
public function setSiteName(string $siteName): static
194+
public function setSiteName(string $siteName): OpenGraph
195195
{
196196
$this->siteName = $siteName;
197197

@@ -202,7 +202,7 @@ public function setSiteName(string $siteName): static
202202
* @param OpenGraphObject $type
203203
* @return static
204204
*/
205-
public function setType(OpenGraphObject $type): static
205+
public function setType(OpenGraphObject $type): OpenGraph
206206
{
207207
$this->type = $type;
208208

@@ -213,7 +213,7 @@ public function setType(OpenGraphObject $type): static
213213
* @param OpenGraphImage $image
214214
* @return static
215215
*/
216-
public function setImage(OpenGraphImage $image): static
216+
public function setImage(OpenGraphImage $image): OpenGraph
217217
{
218218
$this->image[] = $image;
219219

@@ -224,7 +224,7 @@ public function setImage(OpenGraphImage $image): static
224224
* @param mixed $appId
225225
* @return static
226226
*/
227-
public function setAppId(mixed $appId): static
227+
public function setAppId($appId): OpenGraph
228228
{
229229
$this->appId = (string)$appId;
230230

@@ -235,7 +235,7 @@ public function setAppId(mixed $appId): static
235235
* @param OpenGraphVideo $video
236236
* @return static
237237
*/
238-
public function setVideo(OpenGraphVideo $video): static
238+
public function setVideo(OpenGraphVideo $video): OpenGraph
239239
{
240240
$this->video = $video;
241241

@@ -246,7 +246,7 @@ public function setVideo(OpenGraphVideo $video): static
246246
* @param OpenGraphTwitterCard $twitterCard
247247
* @return static
248248
*/
249-
public function setTwitterCart(OpenGraphTwitterCard $twitterCard): static
249+
public function setTwitterCart(OpenGraphTwitterCard $twitterCard): OpenGraph
250250
{
251251
$this->twitterCard = $twitterCard;
252252

@@ -257,7 +257,7 @@ public function setTwitterCart(OpenGraphTwitterCard $twitterCard): static
257257
* @param OpenGraphAudio $audio
258258
* @return static
259259
*/
260-
public function setAudio(OpenGraphAudio $audio): static
260+
public function setAudio(OpenGraphAudio $audio): OpenGraph
261261
{
262262
$this->audio = $audio;
263263

@@ -268,7 +268,7 @@ public function setAudio(OpenGraphAudio $audio): static
268268
* @param string $url
269269
* @return static
270270
*/
271-
public function setUrl(string $url): static
271+
public function setUrl(string $url): OpenGraph
272272
{
273273
$this->url = $url;
274274

@@ -281,7 +281,7 @@ public function setUrl(string $url): static
281281
* @param string $vkImage
282282
* @return static
283283
*/
284-
public function setVkImage(string $vkImage): static
284+
public function setVkImage(string $vkImage): OpenGraph
285285
{
286286
$this->vkImage = $vkImage;
287287

@@ -359,8 +359,8 @@ function ($result, OpenGraphImage $image) {
359359
return array_merge($result, $image->getList());
360360
}, []
361361
),
362-
$this->audio?->getList() ?? [],
363-
$this->video?->getList() ?? [],
362+
$this->audio instanceof OpenGraphAudio ? $this->audio->getList() : [],
363+
$this->video instanceof OpenGraphVideo ? $this->video->getList() : [],
364364
empty($this->description) ? [] : [ ['og:description', $this->description] ],
365365
empty($this->determiner) ? [] : [ ['og:determiner', $this->description] ],
366366
empty($this->siteName) ? [] : [ ['og:site_name', $this->description] ],

src/Main/Markup/OGP/OpenGraphImage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class OpenGraphImage extends OpenGraphVideo
3838
* @param string $alt
3939
* @return static
4040
*/
41-
public function setAlt(string $alt): static
41+
public function setAlt(string $alt): OpenGraphImage
4242
{
4343
$this->alt = $alt;
4444

src/Main/Markup/OGP/OpenGraphMovie.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function __construct()
6262
* @return static
6363
* @throws WrongArgumentException
6464
*/
65-
public function set(string $name, mixed $value): static
65+
public function set(string $name, $value): OpenGraphMovie
6666
{
6767
if ($name == 'actor') {
6868
$count = count($this->items['actor']);

src/Main/Markup/OGP/OpenGraphObject.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ abstract class OpenGraphObject
3939
/**
4040
* @return static
4141
*/
42-
public static function create(): static
42+
public static function create(): OpenGraphObject
4343
{
4444
return new static;
4545
}
@@ -69,7 +69,7 @@ public function getList(): array
6969
* @return static
7070
* @throws WrongArgumentException
7171
*/
72-
public function set(string $name, mixed $value): static
72+
public function set(string $name, $value): OpenGraphObject
7373
{
7474
Assert::isIndexExists($this->items, $name, "there is no property {$name} in " . get_class($this));
7575

src/Main/Markup/OGP/OpenGraphProfile.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function __construct()
5151
* @return static
5252
* @throws WrongArgumentException
5353
*/
54-
public function set(string $name, mixed $value): static
54+
public function set(string $name, $value): OpenGraphProfile
5555
{
5656
if ($name == 'gender') {
5757
Assert::isTrue(

src/Main/Markup/OGP/OpenGraphSong.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function __construct()
5757
* @return static
5858
* @throws WrongArgumentException
5959
*/
60-
public function set(string $name, mixed $value): static
60+
public function set(string $name, $value): OpenGraphSong
6161
{
6262
if ($name == 'album') {
6363
$count = count($this->items['album']);

src/Main/Markup/OGP/OpenGraphSongObject.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ abstract class OpenGraphSongObject extends OpenGraphObject
4343
* @return static
4444
* @throws WrongArgumentException
4545
*/
46-
public function set(string $name, mixed $value): static
46+
public function set(string $name, $value): OpenGraphSongObject
4747
{
4848
if ($name == 'song') {
4949
$count = count($this->items['song']);

src/Main/Markup/OGP/OpenGraphStructure.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ abstract class OpenGraphStructure
4444
/**
4545
* @return static
4646
*/
47-
public static function create(): static
47+
public static function create(): OpenGraphStructure
4848
{
4949
return new static;
5050
}
@@ -54,7 +54,7 @@ public static function create(): static
5454
* @param bool $secureSame
5555
* @return static
5656
*/
57-
public function setUrl(string $url, bool $secureSame = true): static
57+
public function setUrl(string $url, bool $secureSame = true): OpenGraphStructure
5858
{
5959
$this->url = $url;
6060
if ($secureSame) {
@@ -68,7 +68,7 @@ public function setUrl(string $url, bool $secureSame = true): static
6868
* @param string $url
6969
* @return static
7070
*/
71-
public function setSecureUrl(string $url): static
71+
public function setSecureUrl(string $url): OpenGraphStructure
7272
{
7373
$this->secureUrl = $url;
7474

@@ -79,7 +79,7 @@ public function setSecureUrl(string $url): static
7979
* @param MimeType $type
8080
* @return static
8181
*/
82-
public function setType(MimeType $type): static
82+
public function setType(MimeType $type): OpenGraphStructure
8383
{
8484
$this->type = $type;
8585

src/Main/Markup/OGP/OpenGraphTwitterCard.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ abstract class OpenGraphTwitterCard
4141
/**
4242
* @return static
4343
*/
44-
public static function create(): static
44+
public static function create(): OpenGraphTwitterCard
4545
{
4646
return new static;
4747
}
@@ -67,7 +67,7 @@ public function getList(): array
6767
* @return static
6868
* @throws WrongArgumentException
6969
*/
70-
final public function set(string $name, mixed $value): static
70+
final public function set(string $name, $value): OpenGraphTwitterCard
7171
{
7272
Assert::isIndexExists($this->items, $name, "there is no property {$name} in " . get_class($this));
7373
$this->items[$name] = $value;

src/Main/Markup/OGP/OpenGraphVideo.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class OpenGraphVideo extends OpenGraphStructure
3636
* @param int $width
3737
* @return static
3838
*/
39-
public function setWidth(int $width): static
39+
public function setWidth(int $width): OpenGraphVideo
4040
{
4141
$this->width = $width;
4242

@@ -47,7 +47,7 @@ public function setWidth(int $width): static
4747
* @param int $height
4848
* @return static
4949
*/
50-
public function setHeight(int $height): static
50+
public function setHeight(int $height): OpenGraphVideo
5151
{
5252
$this->height = $height;
5353

0 commit comments

Comments
 (0)