Skip to content

Commit

Permalink
Add a typed property test
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Feb 8, 2019
1 parent 80be160 commit 4370781
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/typed_prop.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
--TEST--
Success parameters should respect property types
--SKIPIF--
<?php
require_once(dirname(__FILE__) . '/skipif.inc');
version_compare(PHP_VERSION, '7.4.0dev', '>=') or die('skip Requires PHP >= 7.4');
?>
--INI--
apc.enabled=1
apc.enable_cli=1
--FILE--
<?php

class Test {
public bool $bool = false;
public array $array = [];
}

$test = new Test;
apcu_store('foo', 'bar');
apcu_fetch('foo', $test->bool);
var_dump($test->bool);
try {
apcu_fetch('foo', $test->array);
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
var_dump($test->array);

?>
--EXPECT--
bool(true)
Cannot assign bool to reference held by property Test::$array of type array
array(0) {
}

0 comments on commit 4370781

Please sign in to comment.