1 |
fbb66ca6
|
Assos Assos
|
Polyfill unserialize [![Build Status](https://travis-ci.org/dbrumann/polyfill-unserialize.svg?branch=master)](https://travis-ci.org/dbrumann/polyfill-unserialize)
|
2 |
|
|
===
|
3 |
|
|
|
4 |
|
|
Backports unserialize options introduced in PHP 7.0 to older PHP versions.
|
5 |
|
|
This was originally designed as a Proof of Concept for Symfony Issue [#21090](https://github.com/symfony/symfony/pull/21090).
|
6 |
|
|
|
7 |
|
|
You can use this package in projects that rely on PHP versions older than PHP 7.0.
|
8 |
|
|
In case you are using PHP 7.0+ the original `unserialize()` will be used instead.
|
9 |
|
|
|
10 |
|
|
From the [documentation](https://secure.php.net/manual/en/function.unserialize.php):
|
11 |
|
|
|
12 |
|
|
> Warning: Do not pass untrusted user input to unserialize(). Unserialization can
|
13 |
|
|
> result in code being loaded and executed due to object instantiation
|
14 |
|
|
> and autoloading, and a malicious user may be able to exploit this.
|
15 |
|
|
|
16 |
|
|
This warning holds true even when `allowed_classes` is used.
|
17 |
|
|
|
18 |
|
|
Requirements
|
19 |
|
|
------------
|
20 |
|
|
|
21 |
|
|
- PHP 5.3+
|
22 |
|
|
|
23 |
|
|
Installation
|
24 |
|
|
------------
|
25 |
|
|
|
26 |
|
|
You can install this package via composer:
|
27 |
|
|
|
28 |
|
|
```
|
29 |
|
|
composer require brumann/polyfill-unserialize "^1.0"
|
30 |
|
|
```
|
31 |
|
|
|
32 |
|
|
Known Issues
|
33 |
|
|
------------
|
34 |
|
|
|
35 |
|
|
There is a mismatch in behavior when `allowed_classes` in `$options` is not
|
36 |
|
|
of the correct type (array or boolean). PHP 7.1 will issue a warning, whereas
|
37 |
|
|
PHP 7.0 will not. I opted to copy the behavior of the former.
|
38 |
|
|
|
39 |
|
|
Tests
|
40 |
|
|
-----
|
41 |
|
|
|
42 |
|
|
You can run the test suite using PHPUnit. It is intentionally not bundled as
|
43 |
|
|
dev dependency to make sure this package has the lowest restrictions on the
|
44 |
|
|
implementing system as possible.
|
45 |
|
|
|
46 |
|
|
Please read the [PHPUnit Manual](https://phpunit.de/manual/current/en/installation.html)
|
47 |
|
|
for information how to install it on your system.
|
48 |
|
|
|
49 |
|
|
You can run the test suite as follows:
|
50 |
|
|
|
51 |
|
|
```
|
52 |
|
|
phpunit -c phpunit.xml.dist tests/
|
53 |
|
|
```
|
54 |
|
|
|
55 |
|
|
Contributing
|
56 |
|
|
------------
|
57 |
|
|
|
58 |
|
|
This package is considered feature complete. As such I will likely not update it
|
59 |
|
|
unless there are security issues.
|
60 |
|
|
|
61 |
|
|
Should you find any bugs or have questions, feel free to submit an Issue or a Pull Request. |