952 days continuous production uptime, 40k+ tp/s single node. Original corpo Bitbucket history not included — clean archive commit.
61 lines
1.4 KiB
PHP
61 lines
1.4 KiB
PHP
<?php
|
|
/*
|
|
* aryInit.php -- test stub
|
|
*
|
|
* The point of this test stub is to test the initialization of member arrays. Since declared arrays cannot be set
|
|
* to null without generating a warning, this stub tests initializing an array using the empty bracket shorthand and
|
|
* then calls a method to add a line of text to the array.
|
|
*
|
|
* What we want to see, and we do, is that the initialization of the array doesn't create a blank/null first record
|
|
* and that the newly assigned string is set to element 0 of the array.
|
|
*
|
|
* OUTPUT:
|
|
* =======
|
|
* On init:
|
|
* testArray::__set_state(array(
|
|
* 'foo' =>
|
|
* array (
|
|
* ),
|
|
* ))
|
|
* On insert:
|
|
* testArray::__set_state(array(
|
|
* 'foo' =>
|
|
* array (
|
|
* 0 => 'This is a test',
|
|
* ),
|
|
* ))
|
|
* Execution ends.
|
|
*
|
|
*
|
|
* 01-08-20 mks DB-150: original coding
|
|
*
|
|
*/
|
|
class testArray {
|
|
public array $foo;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->foo = [];
|
|
}
|
|
|
|
public function addString(string $newLine): bool
|
|
{
|
|
if (!is_string($newLine)) return false;
|
|
$this->foo[] = $newLine;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
$objTest = new testArray();
|
|
echo 'On init: ' . PHP_EOL;
|
|
var_export($objTest);
|
|
echo PHP_EOL;
|
|
if ($objTest->addString('This is a test')) {
|
|
echo 'On insert: ' . PHP_EOL;
|
|
var_export($objTest);
|
|
echo PHP_EOL;
|
|
} else {
|
|
echo 'Failed to insert string!' . PHP_EOL;
|
|
}
|
|
echo 'Execution ends.' . PHP_EOL;
|