← All changes
|
vendor/symfony/http-foundation/Session/Storage/MockArraySessionStorage.php
+7
-10
3.0
→
3.5.10
View file →
| @@ -61,9 +61,9 @@ | ||
| 61 | 61 | * @var array|SessionBagInterface[] |
| 62 | 62 | */ |
| 63 | 63 | protected $bags = []; |
| 64 | 64 | |
| 65 | - public function __construct(string $name = 'MOCKSESSID', MetadataBag $metaBag = null) | |
| 65 | + public function __construct(string $name = 'MOCKSESSID', ?MetadataBag $metaBag = null) | |
| 66 | 66 | { |
| 67 | 67 | $this->name = $name; |
| 68 | 68 | $this->setMetadataBag($metaBag); |
| 69 | 69 | } |
| @@ -93,9 +93,9 @@ | ||
| 93 | 93 | |
| 94 | 94 | /** |
| 95 | 95 | * {@inheritdoc} |
| 96 | 96 | */ |
| 97 | - public function regenerate($destroy = false, $lifetime = null) | |
| 97 | + public function regenerate(bool $destroy = false, ?int $lifetime = null) | |
| 98 | 98 | { |
| 99 | 99 | if (!$this->started) { |
| 100 | 100 | $this->start(); |
| 101 | 101 | } |
| @@ -116,9 +116,9 @@ | ||
| 116 | 116 | |
| 117 | 117 | /** |
| 118 | 118 | * {@inheritdoc} |
| 119 | 119 | */ |
| 120 | - public function setId($id) | |
| 120 | + public function setId(string $id) | |
| 121 | 121 | { |
| 122 | 122 | if ($this->started) { |
| 123 | 123 | throw new \LogicException('Cannot set session ID after the session has started.'); |
| 124 | 124 | } |
| @@ -136,9 +136,9 @@ | ||
| 136 | 136 | |
| 137 | 137 | /** |
| 138 | 138 | * {@inheritdoc} |
| 139 | 139 | */ |
| 140 | - public function setName($name) | |
| 140 | + public function setName(string $name) | |
| 141 | 141 | { |
| 142 | 142 | $this->name = $name; |
| 143 | 143 | } |
| 144 | 144 | |
| @@ -182,9 +182,9 @@ | ||
| 182 | 182 | |
| 183 | 183 | /** |
| 184 | 184 | * {@inheritdoc} |
| 185 | 185 | */ |
| 186 | - public function getBag($name) | |
| 186 | + public function getBag(string $name) | |
| 187 | 187 | { |
| 188 | 188 | if (!isset($this->bags[$name])) { |
| 189 | 189 | throw new \InvalidArgumentException(sprintf('The SessionBagInterface "%s" is not registered.', $name)); |
| 190 | 190 | } |
| @@ -203,9 +203,9 @@ | ||
| 203 | 203 | { |
| 204 | 204 | return $this->started; |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - public function setMetadataBag(MetadataBag $bag = null) | |
| 207 | + public function setMetadataBag(?MetadataBag $bag = null) | |
| 208 | 208 | { |
| 209 | 209 | if (null === $bag) { |
| 210 | 210 | $bag = new MetadataBag(); |
| 211 | 211 | } |
| @@ -225,16 +225,13 @@ | ||
| 225 | 225 | |
| 226 | 226 | /** |
| 227 | 227 | * Generates a session ID. |
| 228 | 228 | * |
| 229 | - * This doesn't need to be particularly cryptographically secure since this is just | |
| 230 | - * a mock. | |
| 231 | - * | |
| 232 | 229 | * @return string |
| 233 | 230 | */ |
| 234 | 231 | protected function generateId() |
| 235 | 232 | { |
| 236 | - return hash('sha256', uniqid('ss_mock_', true)); | |
| 233 | + return bin2hex(random_bytes(16)); | |
| 237 | 234 | } |
| 238 | 235 | |
| 239 | 236 | protected function loadSession() |
| 240 | 237 | { |