Changeset 10835
- Timestamp:
- 08/13/08 13:58:38 (11 months ago)
- Files:
-
- branches/1.2/UPGRADE_TO_1_2 (modified) (1 diff)
- branches/1.2/lib/util/sfParameterHolder.class.php (modified) (2 diffs)
- branches/1.2/test/unit/util/sfParameterHolderTest.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.2/UPGRADE_TO_1_2
r10834 r10835 172 172 173 173 The `redirect()` method already have this feature. 174 175 sfParameterHolder 176 ----------------- 177 178 The `has()` method of `sfParameterHolder` has been changed to be more 179 semantically correct. 180 181 It now returns `true` even if the value is `null`: 182 183 [php] 184 $ph = new sfParameterHolder(); 185 $ph->set('foo', 'bar'); 186 $ph->set('bar', null); 187 188 $ph->has('foo') === true; 189 $ph->has('bar') === true; // returns false under symfony 1.0 or 1.1 190 191 The `sfParameterHolder::has()` method is used by the `hasParameter()` and 192 `hasAttribute()` methods available for a large number of core classes. branches/1.2/lib/util/sfParameterHolder.class.php
r9051 r10835 51 51 public function & get($name, $default = null) 52 52 { 53 if ( isset($this->parameters[$name]))53 if (array_key_exists($name, $this->parameters)) 54 54 { 55 55 $value = & $this->parameters[$name]; … … 92 92 public function has($name) 93 93 { 94 if ( isset($this->parameters[$name]))94 if (array_key_exists($name, $this->parameters)) 95 95 { 96 96 return true; branches/1.2/test/unit/util/sfParameterHolderTest.php
r9143 r10835 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(2 7, new lime_output_color());13 $t = new lime_test(28, new lime_output_color()); 14 14 15 15 // ->clear() … … 30 30 $t->is($ph->get('bar'), null, '->get() returns null if the key does not exist'); 31 31 32 // checks that get return es reference32 // checks that get returns reference 33 33 $ref = 'foobar'; 34 $ph->set('ref',$ref); 35 $ref2 &= $ph->get('ref'); //obtain the very same reference and modify it 34 $ph->set('ref', $ref); 35 $ref2 = null; 36 $ref2 &= $ph->get('ref'); // obtain the very same reference and modify it 36 37 $ref2 &= 'barfoo'; 37 38 $t->is($ref2 , $ref, '->get() returns a reference for the given key'); 38 39 39 40 40 $ph = new sfParameterHolder(); … … 62 62 $t->is($ph->has('foo'), true, '->has() returns true if the key exists'); 63 63 $t->is($ph->has('bar'), false, '->has() returns false if the key does not exist'); 64 $ph->set('bar', null); 65 $t->is($ph->has('bar'), true, '->has() returns true if the key exist, even if the value is null'); 64 66 65 67 // ->remove()

