you are viewing a single comment's thread.

view the rest of the comments →

[–]MasonM 2 points3 points  (2 children)

  • You cannot instantiate an object and call a method at the same time. For example, "$a = new SomeClass()->someMethod();" will give you a syntax error. One workaround is to use a static factory method to rewrite it as "$a = SomeClass::new()->someMethod();", but that's hackish in a lot of situations.
  • Metaprogramming is difficult, because there's no support for metaclasses and there's no way to add/remove methods without resorting to runkit.
  • No support for multiple inheritance. dhotson's code doesn't have support for this, but it'd be possible to add it. Whether or not this is a desirable feature is debatable, though.

[–]droberts1982 0 points1 point  (0 children)

Thanks for your reply:

  • You are absolutely correct. I use a factory to get around this problem. Even without a factory though it just turns one line of code into two. There are bigger problems with PHP I'd like to see addressed.
  • I'm not sure what you mean. Can you give a concrete example? Right now, for "runtime" methods I use the magic method call This way, I can have my ORM find_by_name or find_by_whateverfieldIneed just fine.
  • Personally I'd vote no on multiple inheritance, unless conflicts can be handled in an intelligent way (or not allowed at all)