Bug #77287 [Com]: Fatal error: Uncaught TypeError
| From: | peehaa@php.net | Date: | Wed, 12 Dec 2018 09:11:07 +0000 |
| Subject: | Bug #77287 [Com]: Fatal error: Uncaught TypeError | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-218411@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=77287&edit=1
ID: 77287
Comment by: peehaa@php.net
Reported by: someone dot is dot alive at gmail dot com
Summary: Fatal error: Uncaught TypeError
Status: Feedback
Type: Bug
Package: Unknown/Other Function
Operating System: Windows
PHP Version: 7.3.0
Block user comment: N
Private report: N
New Comment:
Can you limit it to the actual problem code?
There are a lot of random (and seemingly unrelated) things going on in the code. If all that code is
actually needed to reproduce please say so. If need please provide the minimal code to reproduce the
problem.
Previous Comments:
------------------------------------------------------------------------
[2018-12-12 08:58:46] someone dot is dot alive at gmail dot com
Test script (below) is copied from zip file.
<?php
namespace PHPDemo;
class TestConst {
const STEP_1 = 1;
const STEP_2 = 2;
public static $persistent = true;
private static $instance = null;
private $currentStep = self::STEP_1;
private function __construct() { }
public function wasPreviousStepCompleted(int $currentStep) : bool {
return $this->currentStep >= $currentStep;
}
public static function &instance() {
if (session_id() == '') {
session_start();
}
if (is_null(self::$instance)) {
self::$instance = new TestConst();
}
if (self::$persistent) {
$_SESSION['TestConst'] = self::$instance;
} else {
unset($_SESSION['TestConst']);
}
return self::$instance;
}
public static function destroyInstance() {
self::$instance = null;
}
public function __wakeup() {
self::$instance =& $this;
}
}
class Utils {
public static function testInput(string $name, int $step = TestConst::STEP_1) {
var_dump(func_get_args());
if (empty($name)) {
return;
}
echo 'Hello world! ' . $name . ' > ' . $step . '<br
/>';
$test = TestConst::instance();
if ($test->wasPreviousStepCompleted($step)) {
echo 'yes';
} else {
echo 'no';
}
echo '<br />';
}
}
TestConst::instance();
Utils::testInput('abc 1');
Utils::testInput('abc 2', TestConst::STEP_2);
Utils::testInput('abc 3');
------------------------------------------------------------------------
[2018-12-12 08:48:29] peehaa@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.
A proper reproducing script starts with <?php,
is max. 10-20 lines long and does not require any external
resources such as databases, etc. If the script requires a
database to demonstrate the issue, please make sure it creates
all necessary tables, stored procedures etc.
Please avoid embedding huge scripts into the report.
------------------------------------------------------------------------
[2018-12-12 08:33:08] someone dot is dot alive at gmail dot com
Description:
------------
Function has 2 arguments. 2nd has a default value. When calling a function it returns an fatal error
instead passing second argument as a default value.
Test script:
---------------
Test case is available in zip https://www.jerc.si/wp-content/uploads/2018/12/php7.3.zip
Contains:
- index.php
- init.php (load files)
- PHPDemo/Utils.php (echo's few lines)
- PHPDemo/TestConst.php (simple class instance)
Short preview:
public static function testInput(string $name, int $step = TestConst::STEP_1)
Utils::testInput('abc 1');
Utils::testInput('abc 2', TestConst::STEP_2);
Utils::testInput('abc 3');
Expected result:
----------------
Based on a code in ZIP file.
"Hello world! abc 3 > 1
yes"
Actual result:
--------------
TypeError: Argument 2 passed to PHPDemo\Utils::testInput() must be of the type int, unknown given,
called in D:\www\index.php on line 10 in D:\www\PHPDemo\Utils.php on line 6
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77287&edit=1