From c66643a6a59dd74e98296adb7b7dcd3bc24b4750 Mon Sep 17 00:00:00 2001 From: Anton Andriyevskyy Date: Thu, 1 Dec 2011 10:02:03 +0200 Subject: [PATCH 1/3] Remove reduntant session existence check --- Session.php | 52 +++++++++++----------------------------------------- 1 file changed, 11 insertions(+), 41 deletions(-) diff --git a/Session.php b/Session.php index 721a6c724..e2809bbd7 100644 --- a/Session.php +++ b/Session.php @@ -109,10 +109,7 @@ public function get($name, $default = null) */ public function set($name, $value) { - if (false === $this->started) { - $this->start(); - } - + $this->start(); $this->attributes[$name] = $value; } @@ -137,10 +134,7 @@ public function all() */ public function replace(array $attributes) { - if (false === $this->started) { - $this->start(); - } - + $this->start(); $this->attributes = $attributes; } @@ -153,9 +147,7 @@ public function replace(array $attributes) */ public function remove($name) { - if (false === $this->started) { - $this->start(); - } + $this->start(); if (array_key_exists($name, $this->attributes)) { unset($this->attributes[$name]); @@ -169,9 +161,7 @@ public function remove($name) */ public function clear() { - if (false === $this->started) { - $this->start(); - } + $this->start(); $this->attributes = array(); $this->flashes = array(); @@ -208,10 +198,7 @@ public function migrate() */ public function getId() { - if (false === $this->started) { - $this->start(); - } - + $this->start(); return $this->storage->getId(); } @@ -232,10 +219,7 @@ public function getFlashes() */ public function setFlashes($values) { - if (false === $this->started) { - $this->start(); - } - + $this->start(); $this->flashes = $values; $this->oldFlashes = array(); } @@ -261,10 +245,7 @@ public function getFlash($name, $default = null) */ public function setFlash($name, $value) { - if (false === $this->started) { - $this->start(); - } - + $this->start(); $this->flashes[$name] = $value; unset($this->oldFlashes[$name]); } @@ -278,10 +259,7 @@ public function setFlash($name, $value) */ public function hasFlash($name) { - if (false === $this->started) { - $this->start(); - } - + $this->start(); return array_key_exists($name, $this->flashes); } @@ -292,10 +270,7 @@ public function hasFlash($name) */ public function removeFlash($name) { - if (false === $this->started) { - $this->start(); - } - + $this->start(); unset($this->flashes[$name]); } @@ -304,19 +279,14 @@ public function removeFlash($name) */ public function clearFlashes() { - if (false === $this->started) { - $this->start(); - } - + $this->start(); $this->flashes = array(); $this->oldFlashes = array(); } public function save() { - if (false === $this->started) { - $this->start(); - } + $this->start(); $this->flashes = array_diff_key($this->flashes, $this->oldFlashes); From 7406b6094e773ccc605cb32e8d762232eae1d7d7 Mon Sep 17 00:00:00 2001 From: Anton Andriyevskyy Date: Thu, 1 Dec 2011 10:03:46 +0200 Subject: [PATCH 2/3] Remove reduntant isset() before calling unset() --- Session.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Session.php b/Session.php index e2809bbd7..54ad4cb9d 100644 --- a/Session.php +++ b/Session.php @@ -148,10 +148,7 @@ public function replace(array $attributes) public function remove($name) { $this->start(); - - if (array_key_exists($name, $this->attributes)) { - unset($this->attributes[$name]); - } + unset($this->attributes[$name]); } /** From cb112fc92198d222d6abc8d5ed2dac3b89c57950 Mon Sep 17 00:00:00 2001 From: Anton Andriyevskyy Date: Thu, 1 Dec 2011 10:07:04 +0200 Subject: [PATCH 3/3] Fix phpdoc for constructor of Session.php 1. Use full namespace notations (for IDEs like PHPSTORM, even latest version 3.0 does not recognize relative names for namespaces) 2. Add @return --- Session.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Session.php b/Session.php index 54ad4cb9d..072287799 100644 --- a/Session.php +++ b/Session.php @@ -32,7 +32,9 @@ class Session implements \Serializable /** * Constructor. * - * @param SessionStorageInterface $storage A SessionStorageInterface instance + * @param \Symfony\Component\HttpFoundation\SessionStorage\SessionStorageInterface $storage A SessionStorageInterface instance + * @return \Symfony\Component\HttpFoundation\Session + * */ public function __construct(SessionStorageInterface $storage) {