Download src/php/php-src/Zend/tests/asymmetric_visibility/cpp_private.phpt from meddyrat/dis-bench: direct link, hf CLI and curl.
- Browser
- Download file 515 Bytes
-
https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/Zend/tests/asymmetric_visibility/cpp_private.phpt
- Command line
-
hf download hf://datasets/meddyrat/dis-bench/src/php/php-src/Zend/tests/asymmetric_visibility/cpp_private.phpt
-
curl -L -o cpp_private.phpt https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/Zend/tests/asymmetric_visibility/cpp_private.phpt
515 Bytes
| --TEST-- | |
| Asymmetric visibility private(set) CPP | |
| --FILE-- | |
| class Foo { | |
| public function __construct( | |
| public private(set) string $bar, | |
| ) {} | |
| public function setBar($bar) { | |
| $this->bar = $bar; | |
| } | |
| } | |
| $foo = new Foo('bar'); | |
| var_dump($foo->bar); | |
| try { | |
| $foo->bar = 'baz'; | |
| } catch (Error $e) { | |
| echo $e->getMessage(), "\n"; | |
| } | |
| $foo->setBar('baz'); | |
| var_dump($foo->bar); | |
| --EXPECT-- | |
| string(3) "bar" | |
| Cannot modify private(set) property Foo::$bar from global scope | |
| string(3) "baz" | |