Page MenuHomePhabricator

Document WebIDL binding for PHP
Open, MediumPublic

Description

Part of the DoDo porting work (see T217867) should be to write a (hopefully brief!) document giving a WebIDL binding for PHP. See:

This would document how types are mapped, how methods are (re)named, etc. The ECMAScript binding is the canonical standard binding, but we will *not* go into as much detail & corner cases as that does! See https://github.com/phpv8/v8js#javascript-api and https://github.com/phpv8/v8js#mapping-rules to set more reasonable expectations. See also https://www.w3.org/TR/2007/WD-DOM-Bindings-20071017/#java-binding -- back when that was part of the standard. Somewhere there was a list of other 'community' IDL bindings, which in my memory included Python (at least).

Basically this document would provide the information necessary to know that (for example):

interface Element : Node {
  ...
  DOMString? getAttribute(DOMString qualifiedName);
}

from https://dom.spec.whatwg.org/#interface-element corresponds to:

public \Wikimedia\Dodo\Element::getAttribute( string $qualifiedName ) : ?string

Note that documenting this allows us to see that https://www.php.net/manual/en/domelement.getattribute.php (for example) is incorrect (!) since the type signature given in the PHP \DOMElement::getAttribute() docs doesn't allow for the null return type which is present in the WebIDL spec.