Re: Patch for DataObject's class generator

From: Date: Mon, 20 Dec 2004 21:20:41 +0000
Subject: Re: Patch for DataObject's class generator
References: 1 2 3 4  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-35185@lists.php.net to get a copy of this message
"Alan Richmond" <alan@aardwolfweb.com> wrote in message news:200412201010.11172.alan@aardwolfweb.com... > On Monday 20 December 2004 05:34, Torsten Roehr wrote: > > my DO class generator patch has been only for a few days now (see links > > below). Are there any more comments? Alan? > > I just wanted to say I think this is a great addition it allows the easy use > of getters and setters when overload isn't available. I recently used a bug > fixed version of Lukas' MDB2_DataObject port on a project and made heavy use > of overloading for getters and setters. My client's web host took the PHP > 4.3.10 security warnings to heart, promptly upgraded and the overload bug [1] > killed the app. I was able to add these changes, regenerate the DOs and get > the site up again with minimal fuss. > > Bug Fix for Patch > ================= > _generateGetters() and _generateSetters() stristr results in false positives > in a couple of cases: > 1) When user methods use auto/overloaded getters/setters. > 2) When auto/overloaded getter/setter names are a substring of a user method > name. > function getClosedateUs() > ^^^^^^^^^^^^false match > { > return $this->_dateIsoToUs($this->getClosedate()); > ^^^^^^^^^^^^false match > } > > Fix > === > Just make the search a little more discriminating: > stristr($input, "function $methodName(") > > -Alan Hi Alan, thanks for your suggestion. Looking for "function getProperty" would not work in case the user has added an ampersand in front of the method name (function &getProperty) to return by reference - but including the opening bracket is good. I have also replaced stristr() with strstr() - because the search should be case-sensitive. The updated fix is online: Source code: http://www.zilleon.com/PEAR/DB/DataObject/Generator.php.txt Zip archive: http://www.zilleon.com/PEAR/DB/DataObject/Generator.zip Sample class: http://www.zilleon.com/PEAR/DB/DataObject/Person.php.txt Best regards, Torsten

« previous php.pear.dev (#35185) next »