[Hmm... No answer in several days. Let's try this again with a
different subject]
I'm in the middle of clarifying the Overloading section of the manual,
http://docs.php.net/manual/en/language.oop5.overloading.php. Some issues
and questions have come up and your insights will be helpful, please.
-
The docs say "All overloading methods must be defined as public." At
this point (in 5.2.1 and 5.3.0 snapshot) all visibility declarations are
ignored:class bug_43924 {
private function __call($name, $arguments) {
echo $name . "\n";
}
}$obj = new bug_43924;
$obj->ObjectContext();
Is this an oversight in the engine? Are there plans to have the parser
enforce the public declaration?
-
Along these lines, it would be an interesting new feature if one could
declare any visibility for the overloading methods and have the engine
observe them. This could allow people to use overloading for internal
calls but skip them for external calls. -
Some user comments say they find it helpful to have their __get()
methods return by reference. Doing so is allowed at this point. Is this
kosher? Will it remain so? -
The value of $name in __call() is case sensitive, but in the newly
added __callStatic() $name is lower case. Is this intentional? It seems
the two methods should have the same behavior. -
The new __callStatic() is neat. Thanks. Is there consideration of
adding Static versions of the other overloading methods?
Thanks,
--Dan
--
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
data intensive web and database programming
http://www.AnalysisAndSolutions.com/
4015 7th Ave #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409
Hello Daniel,
Saturday, April 5, 2008, 3:27:33 PM, you wrote:
[Hmm... No answer in several days. Let's try this again with a
different subject]
I'm in the middle of clarifying the Overloading section of the manual,
http://docs.php.net/manual/en/language.oop5.overloading.php. Some issues
and questions have come up and your insights will be helpful, please.
- The docs say "All overloading methods must be defined as public." At
this point (in 5.2.1 and 5.3.0 snapshot) all visibility declarations are
ignored:
class bug_43924 { private function __call($name, $arguments) { echo $name . "\n"; } }
$obj = new bug_43924; $obj->ObjectContext();
Is this an oversight in the engine? Are there plans to have the parser
enforce the public declaration?
We experimented with visibility and ran into trouble.
And just to confirm this:
[marcus@zaphod PHP_5_3]$ php -r 'class T{public function __call($n, $a){var_dump($n);}} $o=new T; $o->foo(); ReflectionMethod::export("T","__call");'
make: `sapi/cli/php' is up to date.
string(3) "foo"
Method [ <user> public method __call ] {
@@ Command line code 1 - 1
- Parameters [2] {
Parameter #0 [ <required> $n ]
Parameter #1 [ <required> $a ]
}
}
[marcus@zaphod PHP_5_3]$ php -r 'class T{protected function __call($n, $a){var_dump($n);}} $o=new T; $o->foo(); ReflectionMethod::export("T","__call");'
make: `sapi/cli/php' is up to date.
string(3) "foo"
Method [ <user> protected method __call ] {
@@ Command line code 1 - 1
- Parameters [2] {
Parameter #0 [ <required> $n ]
Parameter #1 [ <required> $a ]
}
}
So we in fact note the visibility but then ignore it.
I think we either need to respect the visibility or issue an error if it
is not public. Please file a but report.
- Along these lines, it would be an interesting new feature if one could
declare any visibility for the overloading methods and have the engine
observe them. This could allow people to use overloading for internal
calls but skip them for external calls.
As said there were issues with this approach. Issues as in it wouldn't be
working as expected under all circumstances. So making ti possible would
eventually only increase the WTF factor.
- Some user comments say they find it helpful to have their __get()
methods return by reference. Doing so is allowed at this point. Is this
kosher? Will it remain so?
I think it is a bug. But iirc it was designed to either allow &__get() or
__get() for all derived classes. Does anyone remember?
- The value of $name in __call() is case sensitive, but in the newly
added __callStatic() $name is lower case. Is this intentional? It seems
the two methods should have the same behavior.
It isn't for function calls so this is the correct behavior.
- The new __callStatic() is neat. Thanks. Is there consideration of
adding Static versions of the other overloading methods?
Sara maybe?
Thanks,
--Dan
--
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
data intensive web and database programming
http://www.AnalysisAndSolutions.com/
4015 7th Ave #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409
Best regards,
Marcus
Hi Marcus:
Saturday, April 5, 2008, 3:27:33 PM, you wrote:
We experimented with visibility and ran into trouble.
...
So we in fact note the visibility but then ignore it.I think we either need to respect the visibility or issue an error if it
is not public. Please file a but report.
Turns out, one already exists: http://bugs.php.net/bug.php?id=44769
- The value of $name in __call() is case sensitive, but in the newly
added __callStatic() $name is lower case. Is this intentional? It seems
the two methods should have the same behavior.It isn't for function calls so this is the correct behavior.
I don't understand your response. Can you please clarify?
Thanks,
--Dan
--
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
data intensive web and database programming
http://www.AnalysisAndSolutions.com/
4015 7th Ave #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409
Hello Daniel,
Sunday, May 25, 2008, 4:30:32 PM, you wrote:
Hi Marcus:
Saturday, April 5, 2008, 3:27:33 PM, you wrote:
We experimented with visibility and ran into trouble.
...
So we in fact note the visibility but then ignore it.I think we either need to respect the visibility or issue an error if it
is not public. Please file a but report.
Turns out, one already exists: http://bugs.php.net/bug.php?id=44769
- The value of $name in __call() is case sensitive, but in the newly
added __callStatic() $name is lower case. Is this intentional? It seems
the two methods should have the same behavior.It isn't for function calls so this is the correct behavior.
I don't understand your response. Can you please clarify?
Oh, actually it is my fault - I've read this part wrong. So infact __call
is case sensitive. This is becasue the engine is indeed case sensitive up
to the final lookup all over the place. We do that so that we can produce
case sensitive error messages. So not doing a down case just enables the
same behavior for the user. The other reason for making __call case
sensitive is that an overloaded object might need the correct casing
information. That said there is a bug in __callStatic which we need to
report and assign to Sara.
--Dan
--
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
data intensive web and database programming
http://www.AnalysisAndSolutions.com/
4015 7th Ave #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409
Best regards,
Marcus
Hi Marcus (and Sara):
That said there is a bug in __callStatic which we need to
report and assign to Sara.
http://bugs.php.net/bug.php?id=45089
Thanks,
--Dan
--
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
data intensive web and database programming
http://www.AnalysisAndSolutions.com/
4015 7th Ave #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409
Hi Daniel,
- The new __callStatic() is neat. Thanks. Is there consideration of
adding Static versions of the other overloading methods?
It is part of the proposal for real static classes
(http://wiki.php.net/rfc/static-classes) to complete them accordingly
with __setStatic(), __getStatic() and so on. However this feature could
be implemented separatly.
cu, Lars
Hi Lars:
- The new __callStatic() is neat. Thanks. Is there consideration of
adding Static versions of the other overloading methods?It is part of the proposal for real static classes
(http://wiki.php.net/rfc/static-classes) to complete them accordingly
with __setStatic(), __getStatic() and so on.
Cool. It would be nice if the __*Static() magic methods could exist
in regular classes, not just the proposed static classes.
A question regarding this part of your RFC:
Static classes may not have a constructor, destructor,
dynamic interceptors or __toString()
What do you mean by dynamic interceptors?
Thanks,
--Dan
--
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
data intensive web and database programming
http://www.AnalysisAndSolutions.com/
4015 7th Ave #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409
Hi,
Am Sonntag, den 25.05.2008, 20:35 -0400 schrieb Daniel Convissor:
[...]
What do you mean by dynamic interceptors?
They might not have __get()/__set(), etc. pp. But at the end it is just
a clarification as static classes might not have non-static members
anyway.
cu, Lars
Hi Lars:
They might not have __get()/__set(), etc. pp. But at the end it is just
a clarification as static classes might not have non-static members
anyway.
Ah. May I encourage you to edit the RFC to explicitly name which methods
will exist and be prohibited?
Thanks,
--Dan
--
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
data intensive web and database programming
http://www.AnalysisAndSolutions.com/
4015 7th Ave #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409
Hello Lars,
Sunday, May 25, 2008, 7:07:01 PM, you wrote:
Hi Daniel,
- The new __callStatic() is neat. Thanks. Is there consideration of
adding Static versions of the other overloading methods?
It is part of the proposal for real static classes
(http://wiki.php.net/rfc/static-classes) to complete them accordingly
with __setStatic(), __getStatic() and so on. However this feature could
be implemented separatly.
cu, Lars
I would like to have your proposal implemented with these restrictions:
- No non static member whatsoever
- No inheritance (autmoatically marked as final)
- No abstract members (fonal classes cannot have abstract members)
Best regards,
Marcus
Hi!
I would like to have your proposal implemented with these restrictions:
If we are going to discuss some RFC, isn't it better to have topic that
at least mentions this RFC? Specific call for discussion would be nice
too...
Stanislav Malyshev, Zend Software Architect
stas@zend.com http://www.zend.com/
(408)253-8829 MSN: stas@zend.com
Hi Stas,
Am Montag, den 26.05.2008, 21:45 -0500 schrieb Stanislav Malyshev:
[...]
I would like to have your proposal implemented with these restrictions:
If we are going to discuss some RFC, isn't it better to have topic that
at least mentions this RFC? Specific call for discussion would be nice
too...
the proposal is not yet ready, so there can't be a decision or valuable
discussion at this point. Please leave me some time to finish it :)
Thanks, Lars
Hi!
the proposal is not yet ready, so there can't be a decision or valuable
discussion at this point. Please leave me some time to finish it :)
OK, no problem. I was just surprised it's being discussed, and yet in
non-related topic :)
Stanislav Malyshev, Zend Software Architect
stas@zend.com http://www.zend.com/
(408)253-8829 MSN: stas@zend.com