Search found 8 matches
- Fri Sep 30, 2011 6:39 pm
- Forum: PHP - Code
- Topic: What is the best PHP equivalent of the "transient" keyword?
- Replies: 21
- Views: 8870
Re: What is the best PHP equivalent of the "transient" keywo
I took "write a class that cannot be serialized" to mean "write a wrapper class that prevents a value from being serialized". Here's the implementation <?php class SerializationProofWrapper { public $value; public function __construct($value) { $this->value = $value; } public fun...
- Thu Sep 29, 2011 11:15 am
- Forum: PHP - Code
- Topic: What is the best PHP equivalent of the "transient" keyword?
- Replies: 21
- Views: 8870
Re: What is the best PHP equivalent of the "transient" keywo
@Benjamin: Hi, this is exactly the kind of response I was looking for. Brainstorming is fine. Here's the problem (I discovered this by trying it): PHP works up the class hierarchy until it encounters a definition of __sleep() (this is just standard inheritance). This _sleep() method cannot return an...
- Thu Sep 29, 2011 8:50 am
- Forum: PHP - Code
- Topic: What is the best PHP equivalent of the "transient" keyword?
- Replies: 21
- Views: 8870
Re: What is the best PHP equivalent of the "transient" keywo
@Benjamin: I don't mind discussing things, I'd just like to keep this topic on topic. We can discuss other things in a new topic or by email. As for context, the context is finding the closest PHP equivalent of "transient". Transient is used to avoid serializing an object member. Why would...
- Thu Sep 29, 2011 6:40 am
- Forum: PHP - Code
- Topic: What is the best PHP equivalent of the "transient" keyword?
- Replies: 21
- Views: 8870
Re: What is the best PHP equivalent of the "transient" keywo
I'm not interested in solutions to other problems Implying that all problems have the same solution in every language. No, the only thing it implies is that, for the purposes of this post, I'm only interested in an answer to the question I posted. (such as: how do I avoid serializing a variable whe...
- Wed Sep 28, 2011 7:48 pm
- Forum: PHP - Code
- Topic: What is the best PHP equivalent of the "transient" keyword?
- Replies: 21
- Views: 8870
Re: What is the best PHP equivalent of the "transient" keywo
@Christopher: __sleep and __wakeup won't work unless all your variables are public, all the way up and down the class hierarchy. Why are you protecting those properties from children? Private is popular in other languages, not so in PHP. One could maybe say that object oriented programming is not as...
- Wed Sep 28, 2011 6:35 pm
- Forum: PHP - Code
- Topic: What is the best PHP equivalent of the "transient" keyword?
- Replies: 21
- Views: 8870
Re: What is the best PHP equivalent of the "transient" keywo
@Benjamin: Actually, I confess I failed to search the php.net bug list to see if transient was discussed. I see that there is an enhancement request at https://bugs.php.net/bug.php?id=39635 which points to the patch you just posted. This was submitted in 2006 and the last comment was from 2009. I gu...
- Wed Sep 28, 2011 5:00 pm
- Forum: PHP - Code
- Topic: What is the best PHP equivalent of the "transient" keyword?
- Replies: 21
- Views: 8870
Re: What is the best PHP equivalent of the "transient" keywo
Hi, Christopher, I suspect that the first thing you need to do is stop thinking in Java and start thinking in PHP. Exactly! That's what I want—the Official PHP Thinker's "transient" equivalent. Second thing, why are you serializing objects? Is this a bad thing or are you just wondering? In...
- Wed Sep 28, 2011 12:45 pm
- Forum: PHP - Code
- Topic: What is the best PHP equivalent of the "transient" keyword?
- Replies: 21
- Views: 8870
What is the best PHP equivalent of the "transient" keyword?
The Question PHP doesn't have a "transient" keyword. What is the best equivalent of "transient"? The answer should have the following characteristics: Performance: It should perform as well or better than serializing all variables. Encapsulation: It should not require any change...