Re: can't reflection on DateTime properties?

From: Date: Sat, 04 Jun 2016 21:10:47 +0000
Subject: Re: can't reflection on DateTime properties?
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-93785@lists.php.net to get a copy of this message
On 6/4/2016 11:05 PM, Rasmus Schultz wrote: > I know that things like internal state and read-only properties are > possible for classes written in C, but those features aren't possible in > PHP code - classes that behave this way are inconsistent with classes > written in the language, and it becomes a problem in cases such as this. > > That is no help at all, when you're implementing a JSON serializer. > > You can see the class in question here: > > > https://github.com/mindplay-dk/jsonfreeze/blob/master/mindplay/jsonfreeze/JsonSerializer.php > > Because DateTime does not behave like other classes, the only work-around > is to explicitly handle DateTime with an if/instanceof-statement and handle > that particular class explicitly. > > There are plenty of work-arounds - the point is that this class doesn't > behave consistently with any other PHP class. > I have to fully agree with Rasmus here. This is one of those unnecessary WTF moments for users that forces them to implement work arounds instead of simply writing good software. -- Richard "Fleshgrinder" Fussenegger

Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc
« previous php.internals (#93785) next »