예제 #1
0
$classExample->addValue(5);
assert($classExample->value, 10);
assert($classExample->getArrayValue(), 6);
assert($classExample->getArrayValueWithIndex(), 6);
$classExample->testStatic();
$classExample->testStatic();
$result = $classExample->testStatic();
//Called two times, but value is only incremented twice
assert($result, 2);
$privateAccessed = false;
$exceptionCaught = false;
try {
    //Yes IDE - I know this isn't allowed.
    ///** @noinspection PhpIllegalArrayKeyTypeInspection */
    // @SuppressWarnings
    $classExample->privateFunction();
    $privateAccessed = true;
} catch (Exception $error) {
    //This correct - the private function should not be callable.
    $exceptionCaught = true;
}
assert($privateAccessed, false);
assert($exceptionCaught, true);
$value = $classExample->publicAccess();
assert($value, 5);
$classExample->testFunctionStatic();
$classExample->testFunctionStatic();
$classExample->testFunctionStatic();
$value = $classExample->testFunctionStatic();
assert($value, 4);
testEnd();