Skip to content

Commit 298a3a1

Browse files
committed
fix: Serializable interface is deprecated in php 8.1
1 parent aed7838 commit 298a3a1

File tree

2 files changed

+32
-8
lines changed

2 files changed

+32
-8
lines changed

src/Obj/Traits/AutoConfigTrait.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,31 @@
77
/**
88
* trait AutoConfigTrait
99
*
10+
* ## Usage:
11+
*
12+
* ```php
13+
* class MyClass {
14+
* use AutoConfigTrait;
15+
* }
16+
* ```
17+
*
18+
* - Want call __construct:
19+
*
20+
* ```php
21+
* class MyClass {
22+
* use AutoConfigTrait{
23+
* __construct as supper;
24+
* }
25+
*
26+
* public function __construct(array $config = [])
27+
* {
28+
* $this->supper($config);
29+
*
30+
* // do something
31+
* }
32+
* }
33+
* ```
34+
*
1035
* @author inhere
1136
*/
1237
trait AutoConfigTrait

src/Std/Collection.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Countable;
88
use IteratorAggregate;
99
use JsonSerializable;
10-
use Serializable;
1110
use Traversable;
1211
use function count;
1312

@@ -16,7 +15,7 @@
1615
*
1716
* @author inhere
1817
*/
19-
class Collection implements IteratorAggregate, ArrayAccess, Serializable, Countable, JsonSerializable
18+
class Collection implements IteratorAggregate, ArrayAccess, Countable, JsonSerializable
2019
{
2120
/**
2221
* The data
@@ -392,19 +391,19 @@ public function jsonSerialize(): array
392391
*******************************************************************************/
393392

394393
/**
395-
* @return string
394+
* @return array
396395
*/
397-
public function serialize(): string
396+
public function __serialize(): array
398397
{
399-
return serialize($this->data);
398+
return $this->data;
400399
}
401400

402401
/**
403-
* @param string $data
402+
* @param array $data
404403
*/
405-
public function unserialize($data): void
404+
public function __unserialize(array $data): void
406405
{
407-
$this->data = unserialize($data, ['allowed_classes' => null]);
406+
$this->data = $data;
408407
}
409408

410409
/********************************************************************************

0 commit comments

Comments
 (0)