app/Report/ReportParserGenerate.php
private function addDescendancy(&$list, $pid, $parents = false, $generations = -1): void
    {
        $person = Individual::getInstance($pid, $this->tree);
        if ($person === null) {
            return;
        }
        if (!isset($list[$pid])) {
            $list[$pid] = $person;
        }
        if (!isset($list[$pid]->generation)) {
            $list[$pid]->generation = 0;
        }
        foreach ($person->spouseFamilies() as $family) {
            if ($parents) {
                $husband = $family->husband();
                $wife    = $family->wife();
                if ($husband) {
                    $list[$husband->xref()] = $husband;
                    if (isset($list[$pid]->generation)) {
                        $list[$husband->xref()]->generation = $list[$pid]->generation - 1;
                    } else {
                        $list[$husband->xref()]->generation = 1;
                    }
                }
                if ($wife) {
                    $list[$wife->xref()] = $wife;
                    if (isset($list[$pid]->generation)) {
                        $list[$wife->xref()]->generation = $list[$pid]->generation - 1;
                    } else {
                        $list[$wife->xref()]->generation = 1;
                    }
                }
            }

            $children = $family->children();

            foreach ($children as $child) {
                if ($child) {
                    $list[$child->xref()] = $child;

                    if (isset($list[$pid]->generation)) {
                        $list[$child->xref()]->generation = $list[$pid]->generation + 1;
                    } else {
                        $list[$child->xref()]->generation = 2;
                    }
                }
            }
            if ($generations == -1 || $list[$pid]->generation + 1 < $generations) {
                foreach ($children as $child) {
                    $this->addDescendancy($list, $child->xref(), $parents, $generations); // recurse on the childs family
                }
            }
        }
    }
private function addDescendancy(&$list, $pid, $parents = false, $generations = -1): void
    {
        $person = Individual::getInstance($pid, $this->tree);
        if ($person === null) {
            return;
        }
        if (!isset($list[$pid])) {
            $list[$pid] = $person;
        }
        if (!isset($list[$pid]->generation)) {
            $list[$pid]->generation = 0;
        }
        foreach ($person->spouseFamilies() as $family) {
            if ($parents) {
                $husband = $family->husband();
                $wife    = $family->wife();
                if ($husband) {
                    $list[$husband->xref()] = $husband;
                    if (isset($list[$pid]->generation)) {
                        $list[$husband->xref()]->generation = $list[$pid]->generation - 1;
                    } else {
                        $list[$husband->xref()]->generation = 1;
                    }
                }
                if ($wife) {
                    $list[$wife->xref()] = $wife;
                    if (isset($list[$pid]->generation)) {
                        $list[$wife->xref()]->generation = $list[$pid]->generation - 1;
                    } else {
                        $list[$wife->xref()]->generation = 1;
                    }
                }
            }

            $children = $family->children();

            foreach ($children as $child) {
                if ($child) {
                    $list[$child->xref()] = $child;

                    if (isset($list[$pid]->generation)) {
                        $list[$child->xref()]->generation = $list[$pid]->generation + 1;
                    } else {
                        $list[$child->xref()]->generation = 2;
                    }
                }
            }
            if ($generations == -1 || $list[$pid]->generation + 1 < $generations) {
                foreach ($children as $child) {
                    $this->addDescendancy($list, $child->xref(), $parents, $generations); // recurse on the childs family
                }
            }
        }
    }
private function addDescendancy ( & $ list , $ pid , $ parents = false , $ generations = - 1 ) : void { $ person = Individual :: getInstance ( $ pid , $ this -> tree ) ; if ( $ person === null ) { return ; } if ( ! isset ( $ list [ $ pid ] ) ) { $ list [ $ pid ] = $ person ; } if ( ! isset ( $ list [ $ pid ] -> generation ) ) { $ list [ $ pid ] -> generation = 0 ; } foreach ( $ person -> spouseFamilies ( ) as $ family ) { if ( $ parents ) { $ husband = $ family -> husband ( ) ; $ wife = $ family -> wife ( ) ; if ( $ husband ) { $ list [ $ husband -> xref ( ) ] = $ husband ; if ( isset ( $ list [ $ pid ] -> generation ) ) { $ list [ $ husband -> xref ( ) ] -> generation = $ list [ $ pid ] -> generation - 1 ; } else { $ list [ $ husband -> xref ( ) ] -> generation = 1 ; } } if ( $ wife ) { $ list [ $ wife -> xref ( ) ] = $ wife ; if ( isset ( $ list [ $ pid ] -> generation ) ) { $ list [ $ wife -> xref ( ) ] -> generation = $ list [ $ pid ] -> generation - 1 ; } else { $ list [ $ wife -> xref ( ) ] -> generation = 1 ; } } } $ children = $ family -> children ( ) ; foreach ( $ children as $ child ) { if ( $ child ) { $ list [ $ child -> xref ( ) ] = $ child ; if ( isset ( $ list [ $ pid ] -> generation ) ) { $ list [ $ child -> xref ( ) ] -> generation = $ list [ $ pid ] -> generation + 1 ; } else { $ list [ $ child -> xref ( ) ] -> generation = 2 ; } } } if ( $ generations == - 1 || $ list [ $ pid ] -> generation + 1 < $ generations ) { foreach ( $ children as $ child ) { $ this -> addDescendancy ( $ list , $ child -> xref ( ) , $ parents , $ generations ) ; // recurse on the childs family } } } }
Create a list of all descendants.

@param string[] $list
@param string   $pid
@param bool     $parents
@param int      $generations

@return void
Create a list of all descendants .