Implement __SoftLateInit
commit1f0d00ce91bbeb15f2ff1b642b0fb54f35f7c180
authorRick Lavoie <rlavoie@fb.com>
Mon, 17 Dec 2018 00:22:19 +0000 (16 16:22 -0800)
committerHhvm Bot <hhvm-bot@users.noreply.github.com>
Mon, 17 Dec 2018 00:40:02 +0000 (16 16:40 -0800)
treefbf37db38a0399bb1b989fb6bcaba29ba18b26e5
parentbd8b3c49abe5542c91f41c76f88bab1988802f16
Implement __SoftLateInit

Summary:
Implement a new property attribute called __SoftLateInit. This attribute is
similar to __LateInit, except instead of throwing, it raises a notice and sets
the property to a configerable default value. Since the property is set, another
access will silently just return that value, as if it had been set manually to
that.

Add a builtin called HH\set_late_init_default_value() to configure what
__SoftLateInit should use.

Reviewed By: markw65

Differential Revision: D13472371

fbshipit-source-id: 1bab7a196b98f025872c32ce5e9578bf7e7c6ba7
56 files changed:
hphp/hack/src/hhbc/emit_property.ml
hphp/hack/src/hhbc/hhas_attribute.ml
hphp/hack/src/hhbc/hhas_parser.mly
hphp/hack/src/hhbc/hhas_property.ml
hphp/hack/src/hhbc/hhbc_hhas.ml
hphp/hhbbc/analyze.cpp
hphp/hhbbc/index.cpp
hphp/runtime/base/apc-object.cpp
hphp/runtime/base/attr.h
hphp/runtime/base/builtin-functions.cpp
hphp/runtime/base/builtin-functions.h
hphp/runtime/base/execution-context-inl.h
hphp/runtime/base/execution-context.cpp
hphp/runtime/base/execution-context.h
hphp/runtime/base/object-data.cpp
hphp/runtime/base/variable-serializer.cpp
hphp/runtime/ext/std/ext_std_errorfunc.cpp
hphp/runtime/ext/std/ext_std_errorfunc.php
hphp/runtime/ext/thrift/binary.cpp
hphp/runtime/ext/thrift/compact.cpp
hphp/runtime/vm/as-shared.cpp
hphp/runtime/vm/class.cpp
hphp/runtime/vm/jit/irgen-create.cpp
hphp/runtime/vm/jit/irgen-inlining.cpp
hphp/runtime/vm/jit/irgen-minstr.cpp
hphp/runtime/vm/jit/irgen-sprop-global.cpp
hphp/runtime/vm/preclass-emitter.cpp
hphp/runtime/vm/preclass.cpp
hphp/runtime/vm/verifier/fuzzer/fuzzer.ml
hphp/test/slow/late-init-soft/apc.php [new file with mode: 0644]
hphp/test/slow/late-init-soft/apc.php.expect [new file with mode: 0644]
hphp/test/slow/late-init-soft/basic-static.php [new file with mode: 0644]
hphp/test/slow/late-init-soft/basic-static.php.expect [new file with mode: 0644]
hphp/test/slow/late-init-soft/basic-static.php.opts [new file with mode: 0644]
hphp/test/slow/late-init-soft/basic.php [new file with mode: 0644]
hphp/test/slow/late-init-soft/basic.php.expect [new file with mode: 0644]
hphp/test/slow/late-init-soft/compare.php [new file with mode: 0644]
hphp/test/slow/late-init-soft/compare.php.expect [new file with mode: 0644]
hphp/test/slow/late-init-soft/no-initial1.php [new file with mode: 0644]
hphp/test/slow/late-init-soft/no-initial1.php.expectf [new file with mode: 0644]
hphp/test/slow/late-init-soft/no-initial2.php [new file with mode: 0644]
hphp/test/slow/late-init-soft/no-initial2.php.expectf [new file with mode: 0644]
hphp/test/slow/late-init-soft/redeclare1.php [new file with mode: 0644]
hphp/test/slow/late-init-soft/redeclare1.php.expectf [new file with mode: 0644]
hphp/test/slow/late-init-soft/redeclare2.php [new file with mode: 0644]
hphp/test/slow/late-init-soft/redeclare2.php.expectf [new file with mode: 0644]
hphp/test/slow/late-init-soft/redeclare3.php [new file with mode: 0644]
hphp/test/slow/late-init-soft/redeclare3.php.expect [new file with mode: 0644]
hphp/test/slow/late-init-soft/redeclare4.php [new file with mode: 0644]
hphp/test/slow/late-init-soft/redeclare4.php.expectf [new file with mode: 0644]
hphp/test/slow/late-init-soft/redeclare5.php [new file with mode: 0644]
hphp/test/slow/late-init-soft/redeclare5.php.expectf [new file with mode: 0644]
hphp/test/slow/late-init-soft/serialize.php [new file with mode: 0644]
hphp/test/slow/late-init-soft/serialize.php.expect [new file with mode: 0644]
hphp/test/slow/late-init-soft/to-array.php [new file with mode: 0644]
hphp/test/slow/late-init-soft/to-array.php.expect [new file with mode: 0644]