473,799 Members | 3,149 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

conditional "implements "

Hi there!

Currently i'm thinking about how to solve this problem:

if (t3lib_div::int _from_ver(phpve rsion())<500000 0) {
// php4
class tx_lib_object extends tx_lib_selfAwar eness {...}
//
} else {
// php5
class tx_lib_object extends tx_lib_selfAwar eness implements ArrayAccess, Iterator {...}
//
}

The question is now how to make this conditional "implements " in php?
Of cause i do not want to copy the code for both php versions and then
switch between the whole classes.

--
MfG, Christian Welzel aka Gawain@Regenbog en

GPG-Key: http://www.camlann.de/key.asc
Fingerprint: 4F50 19BF 3346 36A6 CFA9 DBDC C268 6D24 70A1 AD15
Jun 28 '07 #1
1 1852
On Jun 28, 3:36 pm, Christian Welzel <gaw...@camlann .dewrote:
Hi there!

Currently i'm thinking about how to solve this problem:

if (t3lib_div::int _from_ver(phpve rsion())<500000 0) {
// php4
class tx_lib_object extends tx_lib_selfAwar eness {...}
//} else {

// php5
class tx_lib_object extends tx_lib_selfAwar eness implements ArrayAccess, Iterator {...}
//

}

The question is now how to make this conditional "implements " in php?
Of cause i do not want to copy the code for both php versions and then
switch between the whole classes.

--
MfG, Christian Welzel aka Gawain@Regenbog en

GPG-Key: http://www.camlann.de/key.asc
Fingerprint: 4F50 19BF 3346 36A6 CFA9 DBDC C268 6D24 70A1 AD15
Create two different classes (the PHP5 version which extends the PHP4
version and implements the interfaces) then instantiate the proper one
using some sort of factory method. Other than the fact that the PHP5
version implements your interfaces, the classes will behave in exactly
the same way. For example:

class tx_lib_object extends tx_lib_selfAwar eness {
//All the tX_lib_object methods

//The factory:
public static factory() {
if(t3lib_div::i nt_from_ver(php version())<5000 000)
return new tx_lib_object() ;
else
return new tx_lib_object_p hp5();
}
}

if(t3lib_div::i nt_from_ver(php version())>=500 0000) {
class tx_lib_object_p hp5 extends tx_lib_object implements
ArrayAccess, Iterator {
//all the methods to implement ArrayAccess and Iterator
}
}

Jun 28 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2724
by: Stacey | last post by:
I hate to start the email with the "I'm new to this clause", but there it is. I am understanding how the xsd files work and how the castor SourceGenerator works. What I am not understanding is how the binding of a complexType to another package in java works. Basically I have in my .xsd file: <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> .. ..
11
2220
by: Antony | last post by:
I know this sounds stupid but I am going to carry on anyway. I want to create an interface that implements all methods of a form, plus another one or two. But I need to know if there is an interface that defines all a forms methods etc. In the example below "System.Windows.Forms.Form" isn't an interface, but it gets my point across. Is there an interface for a form that I can substitute here? Thank you again Tony
0
1924
by: maitrepoy | last post by:
Hello I have to create a small addin which works on Powerpoint, Word, Outlook, and Excel on Office 2000, XP, and 2003. This addin consists in adding 2 new Buttons in the "File" Menu of office. This is properly done, but the events which should be triggered with the button.click method are not triggered in Word. I don't understand because it properly works in the 3 others host applications. If someone has an issue, I would be most grateful....
13
2577
by: eman1000 | last post by:
I was recently looking at the prototype library (http://prototype.conio.net/) and I noticed the author used the following syntax: Object.extend(MyObj.prototype, { my_meth1: function(){}, my_meth2: function(){} }); to define new methods on the MyObj prototype object. Object.extend
2
2860
by: dkmd_nielsen | last post by:
I have two rather simple class methods coded in Ruby...my own each iterator: The iterator is used internally within the class/namespace, and be available externally. That way I can keep everything hidden about the "instructions table." # Loop through each instruction in the block, yielding the result from # the specified code block. def each(&logic) @instructions.each {|instr| yield instr} end
11
9410
by: Wojciech Gryc | last post by:
Hi, I recently started using Python and am extremely happy with how productive it's made me, even as a new user. I'm hoping to continue using the language for my research, and have come across a bit of a stumbling block. I'm a seasoned Java programmer and quite a big fan of interfaces... i.e. The idea that if I make a number of distinct classes that implement interface X, I can pass them all as parameters to functions
3
1615
balabaster
by: balabaster | last post by:
Hey, I've been trawling documentation for this, but can't figure out what it's called so I'm running short of answers: In VB say you build some interface: Interface IDemoInterface Sub MyFirstMethod(ByVal Param1 As String) Sub MySecondMethod(ByVal Param1 As String) Sub MyThirdMethod(ByVal Param1 As Integer) End Interface
4
2275
by: Tom P. | last post by:
What would the difference be between the following two: public class Foo : IList<string> { .... } public class Foo : List<string>
2
3819
by: Lionel B | last post by:
I frequently seem to run into the following annoyance regarding template class specialisation: I have a template class which implements, for a general template parameter, some basic functionality (i.e. set of methods). But either: 1) For one (or a few) particular methods, the implementation will be specialised for many possible template parameters, or 2) For one particular template parameter, one (or a few) methods will have a...
0
9687
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9541
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10484
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10251
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10228
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7565
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.