The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

There's really nothing to it: duck typing refers to fact that dynamic languages don't have types, and the only way to know if an object is of a certain type (class, superclass, or interface) is to check its properties. If it works as expected, it is of the required type.

Delegate and polymorphism

Hello firends

From Microsoft® Visual C#® .NET 2003 Kick Start

Delegate-Based Polymorphism
Delegates give you a new form of polymorphism, because you can assign a delegate variable different delegates at runtime. Your code stays the same, but different methods are called depending on which delegates you assign to the delegate variable. You can see an example of this in ch04_15.cs, Listing 4.15, where a single delegate variable, delegateVariable, is assigned two delegates and is used to call the corresponding methods at runtime.

You can easily build a StaticDelegate etc., and these classes can make for some nice stuff - couple them with an EventHandler object, for instance. Notice how Handle allows lazy loading objects so that they're only created when the Delegate is invoked.

This bug is fixed (this feature is broken, use whatever you want) in php 5. If you call non-static method statically, you'll get E_STRICT warning, if you declare a method as static, there's no $this. Applause.

The second example is also what you would expect, since the class method in question is static, it applies locally towards that class method is what I find. You could have for example the following instead I think?

I think the right question to ask is whether it's documented. If the behavior is not documented, it's not safe to use it. The fact that it's implemented that way and that one developer claims it's supposed to be that way is not convincing enough.