|
namespace { |
|
// old: defines '\xhp_foo__bar' |
|
class :foo:bar extends :x:element {} |
|
// new: defines '\foo\bar', extending namespace\x\element which is \x\element |
|
xhp class foo:bar extends x:element {} |
|
// new: equivalent in the root namespace |
|
// defines '\foo\bar', extending \x\element |
|
xhp class foo:bar extends :x:element {} |
|
// parse error: reasonable enough in the root namespace, but not |
|
// in any other namespace. Ban for consistency. |
|
xhp class :foo:bar extends :x:element {} |
|
// new: defines \foo extending \x\element |
|
xhp class foo extends \x\element {} |
|
// new: defines \foo\bar extending \x\element |
|
xhp class foo:bar extends \x\element {} |
|
|
|
// old: instantiate \xhp_foo__bar |
|
// new: instantiate namespace\foo\bar, which is \foo\bar |
|
$_ = <foo:bar />; |
|
// old: parse error |
|
// new: instantiate \foo\bar |
|
$_ = <:foo:bar />; |
|
// old and new: instantiates namespace\foo, which is \foo |
|
$_ = <foo />; |
|
// old: parse error |
|
// new: instantiates \foo |
|
$_ = <:foo />; |
|
|
|
// old: defines `\xhp_foo__bar_baz' |
|
class :foo:bar-baz {} |
|
// new: parse error |
|
xhp class foo:bar-baz {} |
|
// new: defines \foo\bar_baz |
|
xhp class foo:bar_baz {} |
|
|
|
// old: takes a \xhp_foo |
|
// new: |
|
// - takes a \foo |
|
// - type error if \foo is not an XHP type |
|
function dostuff(:foo $_): void {} |
|
// new: takes a namespace\foo, which is a \foo |
|
function dostuff(foo $_): void {} |
|
// old and new: parse error |
|
// - `:` is only permitted in this context if fully-qualified |
|
function dostuff(foo:bar $_): void {} |
|
|
|
// parse error - not fully-qualified: |
|
use type foo:bar; |
|
// parse error: not permitted in use statements: |
|
use type :foo:bar; |
|
// parse error: |
|
use type :foo:{bar:baz, bat}; |
|
// ^ not permitted in use statements |
|
// ^ fragment is not fully-qualified |
|
// instantiate \foo\bar: |
|
use type foo\bar; |
|
$_ = <bar />; |
|
// error: |
|
use namespace facebook:xhp:html; |
|
// instantiate \facebook\xhp\html\p: |
|
use namespace facebook\xhp\html as h; |
|
$_ = <h:p />; |
|
} |
|
|
|
namespace myns { |
|
// old: no usable equivalent |
|
// new: defines '\myns\foo\bar` extending `\x\element` |
|
xhp class foo:bar extends :x:element {} |
|
xhp class foo:bar extends \x\element {} |
|
// new: defines '\myns\foo\bar` extending `\myns\x\element` |
|
// probably a mistake |
|
xhp class foo:bar extends x:element {} |
|
// old: no usable equivalent |
|
// new: parse error: would mean \foo\bar, which is not in \myns\ |
|
xhp class :foo:bar {} |
|
|
|
// old: uninstantiable but parsable |
|
// new: instantiate namespace\foo\bar, which is myns\foo\bar |
|
$_ = <foo:bar />; |
|
// old: parse error |
|
// new: instantiate \foo\bar |
|
$_ = <:foo:bar />; |
|
// old: no usable equivalent |
|
// new: instantiates namespace\foo, which is myns\foo |
|
$_ = <foo />; |
|
// old: parse error |
|
// new: instantiates \foo |
|
$_ = <:foo />; |
|
|
|
// \foo\bar [ |
|
// \myns\herp:derp [ |
|
// \p [ |
|
// "hello" |
|
// ] |
|
// ] |
|
// ] |
|
$_ = <:foo:bar><herp:derp><:p>hello</:p></herp:derp></:foo:bar>; |
|
|
|
// old: no usable equivalent |
|
// new: |
|
// - takes a \foo |
|
// - typechecker error if \foo is not an XHP type |
|
function dostuff(:foo $_): void {} |
|
// old and new: parse error |
|
// - `:` is only permitted in this context if fully-qualified |
|
function dostuff(foo:bar $_): void {} |
|
} |
|
|
|
|
|
// Old and new: file-level attribute bar |
|
<<File:Bar>> |
|
// Old and new: errors. Non-sensical context for XHP types |
|
<<:Foo:Bar>> |
|
<<File::Bar>> |
|
<<NotAFile:Bar>> |
|
<<x:element>>> |
|
<<:x:element>> |
|
new :x:element(); |