@@ -46,8 +46,8 @@ public function __construct($immutable)
4646 */
4747 public function get ($ name )
4848 {
49- if (!is_string ($ name )) {
50- throw new InvalidArgumentException ('Expected name to be a string. ' );
49+ if (!is_string ($ name ) || '' === $ name ) {
50+ throw new InvalidArgumentException ('Expected name to be a non-empty string. ' );
5151 }
5252
5353 return $ this ->getInternal ($ name );
@@ -56,7 +56,7 @@ public function get($name)
5656 /**
5757 * Get an environment variable.
5858 *
59- * @param string $name
59+ * @param non-empty- string $name
6060 *
6161 * @return string|null
6262 */
@@ -74,8 +74,8 @@ abstract protected function getInternal($name);
7474 */
7575 public function set ($ name , $ value = null )
7676 {
77- if (!is_string ($ name )) {
78- throw new InvalidArgumentException ('Expected name to be a string. ' );
77+ if (!is_string ($ name ) || '' === $ name ) {
78+ throw new InvalidArgumentException ('Expected name to be a non-empty string. ' );
7979 }
8080
8181 // Don't overwrite existing environment variables if we're immutable
@@ -91,8 +91,8 @@ public function set($name, $value = null)
9191 /**
9292 * Set an environment variable.
9393 *
94- * @param string $name
95- * @param string|null $value
94+ * @param non-empty- string $name
95+ * @param string|null $value
9696 *
9797 * @return void
9898 */
@@ -109,8 +109,8 @@ abstract protected function setInternal($name, $value = null);
109109 */
110110 public function clear ($ name )
111111 {
112- if (!is_string ($ name )) {
113- throw new InvalidArgumentException ('Expected name to be a string. ' );
112+ if (!is_string ($ name ) || '' === $ name ) {
113+ throw new InvalidArgumentException ('Expected name to be a non-empty string. ' );
114114 }
115115
116116 // Don't clear anything if we're immutable.
@@ -124,7 +124,7 @@ public function clear($name)
124124 /**
125125 * Clear an environment variable.
126126 *
127- * @param string $name
127+ * @param non-empty- string $name
128128 *
129129 * @return void
130130 */
@@ -139,7 +139,7 @@ abstract protected function clearInternal($name);
139139 */
140140 public function has ($ name )
141141 {
142- return is_string ($ name ) && $ this ->get ($ name ) !== null ;
142+ return is_string ($ name ) && $ name !== '' && $ this ->get ($ name ) !== null ;
143143 }
144144
145145 /**
0 commit comments