1 | <?php |
||
14 | class ValidatorHelpers |
||
15 | { |
||
16 | /** |
||
17 | * @param string $string |
||
18 | * |
||
19 | * @return array |
||
20 | */ |
||
21 | 18 | public static function getArgsFromString($string): array |
|
55 | |||
56 | /** |
||
57 | * Tests if an input is valid PHP serialized string. |
||
58 | * |
||
59 | * Checks if a string is serialized using quick string manipulation |
||
60 | * to throw out obviously incorrect strings. Unserialize is then run |
||
61 | * on the string to perform the final verification. |
||
62 | * |
||
63 | * Valid serialized forms are the following: |
||
64 | * <ul> |
||
65 | * <li>boolean: <code>b:1;</code></li> |
||
66 | * <li>integer: <code>i:1;</code></li> |
||
67 | * <li>double: <code>d:0.2;</code></li> |
||
68 | * <li>string: <code>s:4:"test";</code></li> |
||
69 | * <li>array: <code>a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}</code></li> |
||
70 | * <li>object: <code>O:8:"stdClass":0:{}</code></li> |
||
71 | * <li>null: <code>N;</code></li> |
||
72 | * </ul> |
||
73 | * |
||
74 | * @author Chris Smith <[email protected]> |
||
75 | * @copyright Copyright (c) 2009 Chris Smith (http://www.cs278.org/) |
||
76 | * @license http://sam.zoy.org/wtfpl/ WTFPL |
||
77 | * |
||
78 | * @param string $value Value to test for serialized form |
||
79 | * @param mixed $result Result of unserialize() of the $value |
||
80 | * |
||
81 | * @return boolean True if $value is serialized data, otherwise false |
||
82 | */ |
||
83 | 10 | public static function is_serialized($value, &$result = null): bool |
|
151 | } |
||
152 |