Tales of an IT Nobody

devbox:~$ iptables -A OUTPUT -j DROP

Interfaces in PHP are worthless. Blasphemy? yes. June 6, 2011

What is the purpose of an interface? One would simply say “they’re a contract, etc.”, and you’d be right.

Long story short, all PHP interfaces do – is enforce:

– What methods are implemented
– What their signatures look like

However there’s one HUGE (in my book) fundamental lack: RETURN TYPES.

Thus, I will call interfaces ‘half a contract’.

The PHP developers and contributors often examine other ‘big brother’ languages to determine some direction for the PHP OO offerings. I think this is where this half-assed implementation came from – an aspiration of the language trying too hard to implement features of strongly typed langauges.

Need examples?

http://en.wikipedia.org/wiki/Interface_(Java)
http://msdn.microsoft.com/en-us/library/64syzecx.aspx

PHP misses a very important component of the ‘contract’, return types. In Java / C#  you can define your methods as such:

public string foo() {}

Now, if you’re willing to shell out for the honor system of implementation or to add some spice to your inductive reasoning – go for it. For what little an interface really does for you, it’s not worth the added complexity and lack of piece of mind interfaces in PHP bring to the table.

I believe that in the current state of PHP, developers will end up implementing additional checks and balances to ensure interface implementors are still behaving correctly.

No Comments on Interfaces in PHP are worthless. Blasphemy? yes.
Categories: php programming

/usr/bin/chage – Sending emails when a pasword expires, or is about to

There’s a lot of scripts out there that do this but they either don’t revolve around /etc/shadow enough or they’re sloppy.

Here’s my spin on a script for nightly cron that will parse /etc/shadow and send out emails based on the per-user values. It’s resistant to garbage dates (99999 ‘expiration’ dates).

Below is my best attempt at making the script ‘cohesive’ in this layout, however you can find the script here as well.

No Comments on /usr/bin/chage – Sending emails when a pasword expires, or is about to
Categories: linux security servers