>I agree the use-cases are slightly weak. This is a draft RFC. It's supposed to 
>help identify 
> the areas where we can improve it. Help identify use-cases. Help dig it out.

I think Ralph has the right idea:
register_compatible_types($yourType, $myType);

A better name might be (only for interfaces):
register_instanceof($compatibleInterface, $interface);

e.g.
class ThirdParty {
  static foo(LoggerInterface $log) {}
}

class Bar implements My_Logging_Inferface {}

echo (Bar instanceof LoggerInterface); // false

register_instanceof('My_Logging_Inferface', 'LoggerInterface');

echo (Bar instanceof LoggerInterface); // true

ThirdParty::foo(new Bar); // no error since 'My_Logging_Interface' is 
compatible with LoggerInterface

In summary, it would allow for user-land registration of compatible interfaces 
to third party libraries.

There's definitely a couple of use cases where I would have liked to use 
something to this.

Advantages to wrapping the feature in a function:
- No extra syntax to support in core
- No 'new concept' for developers to learn 
- It can be disabled (which OO purists might like)
disable_functions = register_instanceof




--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to