HNHacker News
TopNewBestAskShowJobs

simast

93 karma · joined October 18, 2010

submissionscomments
simast··on New to PHP 5.4: Traits
I assume you are talking about fopen-type of functions that are nothing more but wrappers around C standard library functionality.

Use SplFileObject (part of SPL that is part of PHP core) for object-oriented way to manipulate files. On a failure (like your permission issue) it throws Exceptions and if not handled this will result in a "hard" error with a backtrace log.

simast··on New to PHP 5.4: Traits
What's wrong with singletons in general and why would an object could not assume single responsibility (consider an UIApplication singleton on iOS)? I thought, contrary to what you stated, they solve the issue of global variables rather than introducing new ones.

That class extends SPL ArrayObject class which provides array-like access syntax (operators). It does not mean it has to act like an in-memory array, it could read data from disk, session, database or whatever. Delegating this kind of functionality to a single array would simply not work without further abstraction.

simast··on New to PHP 5.4: Traits
Not sure of what kind of legacy features you would want to be removed but it's not like they are just building on top without thinking.

PHP 5.4 will also drop:

- safe mode

- register_globals

- allow_call_time_pass_reference/y2k_compliance and other legacy ini stuff

- "continue 123" syntax (can be replaced with goto). As far as I recall this is done since it's barely used and if removed would allow to implement some opcode performance optimizations.

Dropping some PHP 4 era syntax is obviously out of question due to already mentioned webhosting and backwards compatibility issues.