Re: [PHP] Enforce a constant in a class.

2010-01-22 Thread Richard Quadling
2010/1/22 Jochem Maas : > defined() Sits. Ponders. Find's gun. Shoots self! -- - Richard Quadling "Standing on the shoulders of some very clever giants!" EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engin

Re: [PHP] Enforce a constant in a class.

2010-01-22 Thread Jochem Maas
Op 1/22/10 5:19 PM, Richard Quadling schreef: > 2010/1/22 Jochem Maas : >> constants in interfaces are not meant for this. a class constant doesn't >> constitute an interface. I believe constants in interfaces are allowed purely >> because it is helpful to have them defined outside of the global sp

Re: [PHP] Enforce a constant in a class.

2010-01-22 Thread Richard Quadling
2010/1/22 Ashley Sheridan > Constants are there for things that should never change. If you ever need to > change them, then whoever created the base class either didn't think things > through properly, or you're not. Imagine  a class that sets the value of π > (as is the erstwhile example for

Re: [PHP] Enforce a constant in a class.

2010-01-22 Thread Richard Quadling
2010/1/22 Jochem Maas : > constants in interfaces are not meant for this. a class constant doesn't > constitute an interface. I believe constants in interfaces are allowed purely > because it is helpful to have them defined outside of the global space and > somewhere where all implementors of said

Re: [PHP] Enforce a constant in a class.

2010-01-22 Thread Jochem Maas
Op 1/22/10 4:55 PM, Richard Quadling schreef: > 2010/1/22 Ashley Sheridan >> Constants are there for things that should never change. If you ever need to >> change them, then whoever created the base class either didn't think things >> through properly, or you're not. Imagine a class that sets

Re: [PHP] Enforce a constant in a class.

2010-01-22 Thread Richard Quadling
2010/1/22 Darren Karstens : > One way to do it would be to use getter functions in your interface > that return the value of the constant (or a member variable) in your > implemented class. For example: > > interface SetKillSwitch { >       public function getKillSwitchNotes(); > } > > Then in your

Re: [PHP] Enforce a constant in a class.

2010-01-22 Thread Ashley Sheridan
On Fri, 2010-01-22 at 11:33 +, Richard Quadling wrote: > Hello, > > One of the aspects of an interface is to enforce a public view of a > class (as I see it). > > Within PHP, interfaces are allowed to have constants, but you cannot > override them in a class implementing that interface. > >

Re: [PHP] Enforce a constant in a class.

2010-01-22 Thread Darren Karstens
One way to do it would be to use getter functions in your interface that return the value of the constant (or a member variable) in your implemented class. For example: interface SetKillSwitch { public function getKillSwitchNotes(); } Then in your class implement your getKillSwitchNotes fu

[PHP] Enforce a constant in a class.

2010-01-22 Thread Richard Quadling
Hello, One of the aspects of an interface is to enforce a public view of a class (as I see it). Within PHP, interfaces are allowed to have constants, but you cannot override them in a class implementing that interface. This seems wrong. The interface shouldn't define the value, just like it doe