Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.2.0

Bug #3031 Cannot re-assign $this in :\php\PEAR\RDF\Store\MDB.php on line 209
Submitted: 2004-12-26 23:30 UTC Modified: 2006-12-26 23:55 UTC
From: doconnor Assigned: lsmith
Status: Closed Package: RDF
PHP Version: 5.0.3 OS:
Roadmaps: (Not assigned)    
Subscription  


 [2004-12-26 23:30 UTC] doconnor
Description: ------------ function close() { $this->dbConn->disconnect(); $this = null;// PHP5 Doesn't like that at all :/ } Reproduce code: --------------- <?php /** * Thing class */ require_once 'RDF.php'; require_once 'RDF/Store/MDB.php'; class Thing { public $db; /** * Create a new Thing */ function __construct() { $this->db =& new RDF_Store_MDB( array(/*Stuff*/), array()); } function createTables() { $this->db->createTables(); } } ?> <?php //Sale class class Sale extends Thing { private $items; private $customer; private $total; function __construct() { } function addProduct($product, $quantity) { $this->items[] = array('product' => $product, 'quantity' => $quantity); $this->total += ($product->getCost() * $quantity); return true; } function getProductList() { return $this->items; } function setCustomer($customer) { $this->customer =& $customer; } function getCustomer() { return $this->customer; } function getTotal() { return $this->total; } } ?> <?php //Test Driver header('content-type: text/plain'); //Expected Results $products[] = array('product' => new Product('laminate'), 'quantity' => 3); $products[] = array('product' => new Product('toast'), 'quantity' => 4); $products[] = array('product' => new Product('monkies'), 'quantity' => 657); $customer =& new Customer('ahs'); //Test $s = new Sale(); $s->setCustomer($customer); print "CUSTOMER:\n"; print $s->getCustomer()->__toString() . "\n\n"; $s->addProduct($products[0]["product"], $products[0]["quantity"]); $s->addProduct($products[1]["product"], $products[1]["quantity"]); $s->addProduct($products[2]["product"], $products[2]["quantity"]); if ($products != $s->getProductList()) { print_r($s->getProductList()); die("Failed, Sale::getProductList()"); } else { print "ITEMS:\n"; print_r($s->getProductList()); } print "TOTAL:\n"; print "$" . $s->getTotal(); ?> Expected result: ---------------- Object initialises and is all fine and dandy Actual result: -------------- <br /> <b>Fatal error</b>: Cannot re-assign $this in <b>c:\php\PEAR\RDF\Store\MDB.php</b> on line <b>209</b><br />

Comments

 [2004-12-28 10:38 UTC] smith at backendmedia dot com
This bug has been fixed in CVS. In case this was a documentation problem, the fix will show up at the end of next Sunday (CET) on pear.php.net. In case this was a pear.php.net website problem, the change will show up on the website in short time. Thank you for the report, and for helping us make PEAR better.