<commit_before><?php

namespace CftfBundle\Controller;

use CftfBundle\Entity\LsDoc;
use CftfBundle\Entity\LsItem;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

/**
 * Editor controller.
 *
 * @Route("/cf")
 */
class EditorController extends Controller
{
    /**
     * @Route("/", defaults={"_format"="html"}, name="editor_index")
     * @Method("GET")
     *
     * @return array
     */
    public function indexAction()
    {
        return $this->forward('CftfBundle:LsDoc:index', []);
    }

    /**
     * @Route("/lsdoc/{id}.{_format}", defaults={"_format" = "html"}, name="editor_lsdoc")
     * @Method("GET")
     * @Template()
     *
     * @param \CftfBundle\Entity\LsDoc $lsDoc
     * @param string $_format
     *
     * @return array
     */
    public function viewDocAction(LsDoc $lsDoc, $_format)
    {
        if ('json' === $_format) {
            return $this->forward('CftfBundle:LsDoc:export', ['lsDoc' => $lsDoc]);
        }

        return ['lsDoc'=>$lsDoc];
    }

    /**
     * @Route("/lsitem/{id}.{_format}", defaults={"_format" = "html"}, name="editor_lsitem")
     * @Method("GET")
     * @Template()
     *
     * @param \CftfBundle\Entity\LsItem $lsItem
     * @param string $_format
     *
     * @return array
     */
    public function viewItemAction(LsItem $lsItem, $_format)
    {
        if ('json' === $_format) {
            return $this->forward('CftfBundle:LsItem:export', ['lsItem' => $lsItem]);
        }

        return ['lsItem'=>$lsItem];
    }

    /**
     * @Route("/render/{id}.{_format}", defaults={"highlight"=null, "_format"="html"}, name="editor_render_document_only")
     * @Route("/render/{id}/{highlight}.{_format}", defaults={"highlight"=null, "_format"="html"}, name="editor_render")
     * @Method("GET")
     * @Template()
     *
     * @param \CftfBundle\Entity\LsDoc $lsDoc
     * @param int $highlight
     *
     * @return array
     */
    public function renderDocumentAction(LsDoc $lsDoc, $highlight = null, $_format = 'html')
    {
        $repo = $this->getDoctrine()->getRepository('CftfBundle:LsDoc');

        $items = $repo->findAllChildrenArray($lsDoc);
        $haveParents = $repo->findAllItemsWithParentsArray($lsDoc);
        $topChildren = $repo->findTopChildrenIds($lsDoc);

        $orphaned = $items;
        /* This list is now found in the $haveParents list
        foreach ($lsDoc->getTopLsItemIds() as $id) {
            // Not an orphan
            if (!empty($orphaned[$id])) {
                unset($orphaned[$id]);
            }
        }
        */
        foreach ($haveParents as $child) {
            // Not an orphan
            $id = $child['id'];
            if (!empty($orphaned[$id])) {
                unset($orphaned[$id]);
            }
        }

        return [
            'topItemIds'=>$topChildren,
            'lsDoc'=>$lsDoc,
            'items'=>$items,
            'highlight' => $highlight,
            'orphaned' => $orphaned,
        ];
    }
}
<commit_msg>fix return types in phpdoc<commit_after><?php

namespace CftfBundle\Controller;

use CftfBundle\Entity\LsDoc;
use CftfBundle\Entity\LsItem;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

/**
 * Editor controller.
 *
 * @Route("/cf")
 */
class EditorController extends Controller
{
    /**
     * @Route("/", defaults={"_format"="html"}, name="editor_index")
     * @Method("GET")
     *
     * @return \Symfony\Component\HttpFoundation\Response
     */
    public function indexAction()
    {
        return $this->forward('CftfBundle:LsDoc:index', []);
    }

    /**
     * @Route("/lsdoc/{id}.{_format}", defaults={"_format" = "html"}, name="editor_lsdoc")
     * @Method("GET")
     * @Template()
     *
     * @param \CftfBundle\Entity\LsDoc $lsDoc
     * @param string $_format
     *
     * @return array
     */
    public function viewDocAction(LsDoc $lsDoc, $_format)
    {
        if ('json' === $_format) {
            return $this->forward('CftfBundle:LsDoc:export', ['lsDoc' => $lsDoc]);
        }

        return ['lsDoc'=>$lsDoc];
    }

    /**
     * @Route("/lsitem/{id}.{_format}", defaults={"_format" = "html"}, name="editor_lsitem")
     * @Method("GET")
     * @Template()
     *
     * @param \CftfBundle\Entity\LsItem $lsItem
     * @param string $_format
     *
     * @return array|\Symfony\Component\HttpFoundation\Response
     */
    public function viewItemAction(LsItem $lsItem, $_format)
    {
        if ('json' === $_format) {
            return $this->forward('CftfBundle:LsItem:export', ['lsItem' => $lsItem]);
        }

        return ['lsItem'=>$lsItem];
    }

    /**
     * @Route("/render/{id}.{_format}", defaults={"highlight"=null, "_format"="html"}, name="editor_render_document_only")
     * @Route("/render/{id}/{highlight}.{_format}", defaults={"highlight"=null, "_format"="html"}, name="editor_render")
     * @Method("GET")
     * @Template()
     *
     * @param \CftfBundle\Entity\LsDoc $lsDoc
     * @param int $highlight
     * @param string $_format
     *
     * @return array
     */
    public function renderDocumentAction(LsDoc $lsDoc, $highlight = null, $_format = 'html')
    {
        $repo = $this->getDoctrine()->getRepository('CftfBundle:LsDoc');

        $items = $repo->findAllChildrenArray($lsDoc);
        $haveParents = $repo->findAllItemsWithParentsArray($lsDoc);
        $topChildren = $repo->findTopChildrenIds($lsDoc);

        $orphaned = $items;
        /* This list is now found in the $haveParents list
        foreach ($lsDoc->getTopLsItemIds() as $id) {
            // Not an orphan
            if (!empty($orphaned[$id])) {
                unset($orphaned[$id]);
            }
        }
        */
        foreach ($haveParents as $child) {
            // Not an orphan
            $id = $child['id'];
            if (!empty($orphaned[$id])) {
                unset($orphaned[$id]);
            }
        }

        return [
            'topItemIds'=>$topChildren,
            'lsDoc'=>$lsDoc,
            'items'=>$items,
            'highlight' => $highlight,
            'orphaned' => $orphaned,
        ];
    }
}

{'fraction_non_alphanumeric': 0.17086358720840414, 'fraction_numerical': 0.0, 'mean_word_length': 2.454642475987193, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5135698', 'n_tokens_mistral': 2046, 'n_tokens_neox': 2012, 'n_words': 335}