Skip to content

Instantly share code, notes, and snippets.

It's useful trick in situation when you need to sort certain groups of data. Preserve chronological order of items inserted in Heap. Good use-case is php_error_log. Each log entry has own majority of error. And it's usefull to sort file using max heap.

The soulution is - override default SplPriorityQueue

<?php
class OrderedPriority extends SplPriorityQueue
{
@diwms
diwms / read-private-properties.php
Created August 7, 2019 13:28
Read private properties in PHP without reflection
<?php
function inspect($object, $property) {
return (function () use ($property) {
return $this->$property;
})->call($object);
}