Code Monkey home page Code Monkey logo

Comments (3)

scottchiefbaker avatar scottchiefbaker commented on July 28, 2024

Interesting. I'm not familiar with non-initialized objects. I will gladly work on some code to address this if you create a small testcase that recreates this issue.

from krumo.

scottchiefbaker avatar scottchiefbaker commented on July 28, 2024

I'm probably due to get a new version of Krumo out to address some PHP 8.2 stuff anyway, so now is a decent time to look at it.

from krumo.

ggieling avatar ggieling commented on July 28, 2024

The issue is actually with any non-initialised property.
In the below example:

<?php

include_once ($_SERVER['DOCUMENT_ROOT'].'/includes_2018/krumo-master/class.krumo.php');

class dummy {

public string $teststring = 'test';
public array $fib = [1,2,3,5,8,13];
public ?string $emptystring;

}

$test = new dummy();
// $test->emptystring = null;
krumo($test);

echo 'krumo display succesfully completed';

?>

The above code generates an error message with the following content:

:  Uncaught Error: Typed property dummy::$emptystring must not be accessed before initialization in /srv/http/ipdev/includes_2018/krumo-master/class.krumo.php:1083
Stack trace:
#0 /srv/http/ipdev/includes_2018/krumo-master/class.krumo.php(1083): ReflectionProperty->getValue()
#1 /srv/http/ipdev/includes_2018/krumo-master/class.krumo.php(1285): Krumo::_vars()
#2 /srv/http/ipdev/includes_2018/krumo-master/class.krumo.php(888): Krumo::_object()
#3 /srv/http/ipdev/includes_2018/krumo-master/class.krumo.php(530): Krumo::_dump()
#4 /srv/http/ipdev/includes_2018/krumo-master/class.krumo.php(1640): Krumo::dump()
#5 /srv/http/ipdev/test/krumotest.php(15): krumo()
#6 {main}
  thrown in /srv/http/ipdev/includes_2018/krumo-master/class.krumo.php on line 1083

The error message is not visible in the browser, you have to go into the source code for the page to find it in the krumo structure.

After uncommenting the line:

// $test->emptystring = null;

The page succesfully displays the object structure and displays the success message below it.

Request in increasing level of desirability:
option 1) make krumo skip uninitialised properties to prevent the situation that the krumo result is not visible. Krumo is mostly used in debugging, so it is desirable that it always produces a legible result.
option 2) make krumo not simply skip the uninitialised property, but include it with the remark that it is uninitialised.
option 3) make krumo include the uninitialised property with a warning below the krumo result that this property is uninitialised

from krumo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.