[Phpmyadmin-devel] Overriding functions

Ayush Chaudhary ayushchd at gmail.com
Tue Jun 18 14:13:28 CEST 2013


Hi,

On Tuesday, 18 June 2013 at 5:46 PM, Madhura Jayaratne wrote:  
>  
>  
>  
> On Tue, Jun 18, 2013 at 2:04 PM, Ayush Chaudhary <ayushchd at gmail.com (mailto:ayushchd at gmail.com)> wrote:
> > Hi,   
> >  
> > I was writing some unit tests for the native string functions. However, since some of the functions are declared twice (with different implementations), for e.g., PMA_strlen, PMA_strpos, etc. have different implementations in string_mb.lib.php and string_native.lib.php, it causes phpunit to throw fatal errors of the form "Cannot redeclare function … already declared in …"  
> >  
> > Possible solutions could be to use namespaces or to use polymorphism in some way.
> >  
> How do you plan to use polymorphism to overcome this?  
> Another way around would be to put these functions into classes and instantiate an object of the correct type.  
>  
>  
>  
>  
>  

>  
> I'd like to know opinion from others as well.
>  
>  
> --  
> Thanks and Regards,
>  
> Madhura Jayaratne
>  
> ------------------------------------------------------------------------------
> This SF.net (http://SF.net) email is sponsored by Windows:
>  
> Build for Windows Store.
>  
> http://p.sf.net/sfu/windows-dev2dev
> _______________________________________________
> Phpmyadmin-devel mailing list
> Phpmyadmin-devel at lists.sourceforge.net (mailto:Phpmyadmin-devel at lists.sourceforge.net)
> https://lists.sourceforge.net/lists/listinfo/phpmyadmin-devel
>  
>  

We could perhaps make a common class, and have either the mb or the native functions execute based on the same detecting mechanism that is used right now, i.e. checking if mb_strlen function exists. However, your suggestion seems better. We can instantiate the respective object in string.lib.php as that is the only place these files are included. And then use that object to call string functions.

--  
Ayush Chaudhary

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.phpmyadmin.net/pipermail/developers/attachments/20130618/cbcf117f/attachment.html>


More information about the Developers mailing list