a tiny mvc framework for php using php-activerecord
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Gh98 - squash PHP warning "Indirect modification of overloaded property ... has no effect". Cause probably is that PHP 5.3 __get is no longer by reference (by default).

Benjamin 64bed32c 476255e5

+46 -3
+2 -2
lib/php-activerecord/lib/Model.php
··· 199 199 * 200 200 * This is the opposite of {@link attr_accessible $attr_accessible} and the format 201 201 * for defining these are exactly the same. 202 - * 202 + * 203 203 * If the attribute is both accessible and protected, it is treated as protected. 204 204 * 205 205 * @var array ··· 503 503 $to = $item['to']; 504 504 if ($this->$to) 505 505 { 506 - $val =& $this->$to->$delegated_name; 506 + $val =& $this->$to->__get($delegated_name); 507 507 return $val; 508 508 } 509 509 else
+23 -1
lib/php-activerecord/test/ActiveRecordTest.php
··· 365 365 $this->assert_null($event->state); 366 366 } 367 367 368 - public function test_delegate_setter() 368 + public function test_delegate_set_attribute() 369 369 { 370 370 $event = Event::first(); 371 371 $event->state = 'MEXICO'; 372 372 $this->assert_equals('MEXICO',$event->venue->state); 373 + } 374 + 375 + public function test_delegate_getter_gh_98() 376 + { 377 + Venue::$use_custom_get_state_getter = true; 378 + 379 + $event = Event::first(); 380 + $this->assert_equals('ny', $event->venue->state); 381 + $this->assert_equals('ny', $event->state); 382 + 383 + Venue::$use_custom_get_state_getter = false; 384 + } 385 + 386 + public function test_delegate_setter_gh_98() 387 + { 388 + Venue::$use_custom_set_state_setter = true; 389 + 390 + $event = Event::first(); 391 + $event->state = 'MEXICO'; 392 + $this->assert_equals('MEXICO#',$event->venue->state); 393 + 394 + Venue::$use_custom_set_state_setter = false; 373 395 } 374 396 375 397 public function test_table_name_with_underscores()
+21
lib/php-activerecord/test/models/Venue.php
··· 1 1 <?php 2 2 class Venue extends ActiveRecord\Model 3 3 { 4 + static $use_custom_get_state_getter = false; 5 + static $use_custom_set_state_setter = false; 6 + 7 + 4 8 static $has_many = array( 5 9 'events', 6 10 array('hosts', 'through' => 'events') ··· 12 16 'marquee' => 'name', 13 17 'mycity' => 'city' 14 18 ); 19 + 20 + public function get_state() 21 + { 22 + if (self::$use_custom_get_state_getter) 23 + return strtolower($this->read_attribute('state')); 24 + else 25 + return $this->read_attribute('state'); 26 + } 27 + 28 + public function set_state($value) 29 + { 30 + if (self::$use_custom_set_state_setter) 31 + return $this->assign_attribute('state', $value . '#'); 32 + else 33 + return $this->assign_attribute('state', $value); 34 + } 35 + 15 36 }; 16 37 ?>