interface requirements : new lang feature [1/2]
commit4e3fca7607a212962ba87a16ecd7d0b18df69486
authorEugene Letuchy <eletuchy@fb.com>
Tue, 17 Jun 2014 00:16:39 +0000 (16 17:16 -0700)
committerfacebook-github-bot <githubbot@fb.com>
Fri, 20 Jun 2014 22:00:21 +0000 (20 15:00 -0700)
treebb04ca43d118f0138da7538ca5ee6e7844b13280
parent8c0d37ec6603457954843858fa4110fb737ad120
interface requirements : new lang feature [1/2]

Summary: This is the logical extension of trait requirements necessary
 to capture the "marker interface" pattern, wherein an interface is
 implicitly tied to a type hierarachy as with the following code:

   class Super {
      ...
      if ($this instanceof IMarker) {
        $this->methodOfMarker();
      }
      ...
   }
   ...
   function marked(IMarker $inst) {
     $inst->methodOfSuper();
   }
   ...
   interface IMarker {
     ...
     // new syntax to indicate that IMarker is only for children of Super
     require extends Super;
     ...
   }

 This diff ensures that the syntax is supported in the parser, but
 does not enforce the requirements (left to next diff).

Reviewed By: @paroski

Differential Revision: D1387181
26 files changed:
hphp/compiler/analysis/alias_manager.cpp
hphp/compiler/analysis/analysis_result.cpp
hphp/compiler/analysis/class_scope.cpp
hphp/compiler/analysis/class_scope.h
hphp/compiler/analysis/control_flow.cpp
hphp/compiler/analysis/emitter.cpp
hphp/compiler/analysis/emitter.h
hphp/compiler/parser/parser.cpp
hphp/compiler/parser/parser.h
hphp/compiler/statement/class_require_statement.cpp [moved from hphp/compiler/statement/trait_require_statement.cpp with 66% similarity]
hphp/compiler/statement/class_require_statement.h [moved from hphp/compiler/statement/trait_require_statement.h with 85% similarity]
hphp/compiler/statement/class_statement.cpp
hphp/compiler/statement/statement.h
hphp/hhbbc/emit.cpp
hphp/hhbbc/parse.cpp
hphp/hhbbc/representation.h
hphp/parser/hphp.tab.cpp
hphp/parser/hphp.y
hphp/runtime/vm/class.cpp
hphp/runtime/vm/class.h
hphp/runtime/vm/preclass-emitter.cpp
hphp/runtime/vm/preclass-emitter.h
hphp/test/slow/traits/require_constraint_iface.php [new file with mode: 0644]
hphp/test/slow/traits/require_constraint_iface.php.expect [new file with mode: 0644]
hphp/test/slow/traits/require_constraint_iface_implements_error.php [new file with mode: 0644]
hphp/test/slow/traits/require_constraint_iface_implements_error.php.expectf [new file with mode: 0644]