Use a backtrace to search for the origins of the query.

@return array
554240
protected function findSource()
    {
        $stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS | DEBUG_BACKTRACE_PROVIDE_OBJECT);

        $sources = [];

        foreach ($stack as $index => $trace) {
            $sources[] = $this->parseTrace($index, $trace);
        }

        return array_filter($sources);
    }
899257
protected function getCallPaths(): array
    {
        $paths = [];
        $backTrace = \debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
        foreach ($backTrace as $value) {
            if (isset($value['file'])) {
                $paths[] = $value['file'];
            }
        }

        return $paths;
    }
1119502
public function getFallbackIds()
    {
        $fallbackIds = $this->scopeConfig->getValue(
            self::XML_PATH_FALLBACK_PRODUCTS_ITEMS
        );
        if ($fallbackIds) {
            return explode(
                ',',
                $this->scopeConfig->getValue(
                    self::XML_PATH_FALLBACK_PRODUCTS_ITEMS
                )
            );
        }

        return [];
    }
106197
public function locateSources(): array
    {
        if (!$this->container->has(ClassesInterface::class)) {
            return [];
        }

        /**
         * @var ClassesInterface $classes
         */
        $classes = $this->container->get(ClassesInterface::class);

        $result = [];
        foreach ($classes->getClasses(RecordSource::class) as $class) {
            $source = $class['name'];
            if ($class['abstract'] || empty($source::RECORD)) {
                continue;
            }

            $result[$source::RECORD] = $source;
        }

        return $result;
    }
880264
public function getTrackRestoreCodes()
    {
        $select = $this->_getRestoreSelect();
        $select->where('(grc_for_tracks = 1 OR grc_for_surveys = ?)', self::APPLY_STOP);

        return $this->_translateAndSort($this->db->fetchPairs($select));
    }
990918
public function back()
    {

        // If there aren't enough breadcrumbs for a back URL, report false
        if (count($this->links) < 2) {
            return;
        }

        // Get the URL from two back from the end in the breadcrumbs array
        $urls = array_keys($this->links);

        return $urls[count($urls) - 2];
    }
833930
public function getNbResults()
    {
        if (isset($this->nbResults)) {
            return $this->nbResults;
        }

        $countQuery = clone $this->query;
        $countQuery->limit = 0;

        return $this->nbResults = $this->searchService->findLocations($countQuery)->totalCount;
    }
1241252
public function __trace()
    {
        $info['_attributes'] = $this->_attributes;
        $info['_changes'] = $this->_changes;
        $info['_checked'] = $this->_checked;
//        $info['_proto'] = $this->_proto;
//        $info['_parent'] = $this->_parent;
        $info['_children'] = $this->_children;

//        if ($this->_errors) $info['_errors'] = $this->_errors->toArrayCompact(false);
        return $info;
    }
1109204
public function getQueries()
    {
        return array_merge(
            $this->getDropSequenceQueries(),
            $this->getDropViewQueries(),
            $this->getRenameTableQueries(),
            $this->getDropCheckQueries(),
            $this->getDropForeignKeyQueries(),
            $this->getDropIndexQueries(),
            $this->getDropPrimaryKeyQueries(),
            $this->getDropTableQueries(),
            $this->getDropColumnQueries(),
            $this->getAlterColumnQueries(),
            $this->getCreateColumnQueries(),
            $this->getCreateTableQueries(),
            $this->getCreatePrimaryKeyQueries(),
            $this->getCreateIndexQueries(),
            $this->getCreateForeignKeyQueries(),
            $this->getCreateCheckQueries(),
            $this->getCreateViewQueries(),
            $this->getCreateSequenceQueries(),
            $this->getRenameSchemaQueries()
        );
    }
270513
public function back()
    {
        do {
            $request = $this->history->back();
        } while (\array_key_exists(serialize($request), $this->redirects));

        return $this->requestFromRequest($request, false);
    }
946842
public function getLastQueryStrings() {
    $result = [];
    foreach ($this->queries as $query) {
      $result[] = $query->getLastQueryString();
    }
    return $result;
  }
8452
public function getFallbackLocales()
    {
        if ($this->translator instanceof Translator || method_exists($this->translator, 'getFallbackLocales')) {
            return $this->translator->getFallbackLocales();
        }

        return [];
    }
850181
public function origins()
    {
        if (is_null($this->originRequests)) {
            $this->originRequests = new OriginRequests($this->client);
        }

        return $this->originRequests;
    }
1339288
protected function findSource()
    {
        $traces = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS | DEBUG_BACKTRACE_PROVIDE_OBJECT);
        foreach ($traces as $trace) {
            if (isset($trace['class']) && isset($trace['file']) && strpos(
                    $trace['file'],
                    DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR
                ) === false
            ) {
                $file = $trace['file'];
                $line = isset($trace['line']) ? $trace['line'] : '?';

                return $this->normalizeFilename($file).':'.$line;
            } elseif (isset($trace['function']) && $trace['function'] == 'Illuminate\Routing\{closure}') {
                return 'Route binding';
            }
        }
    }
785857
public function getSearchDefaults()
    {
        if (! $this->defaultSearchData) {
            $from = new \MUtil_Date();
            $from->subWeek(2);

            $until = new \MUtil_Date();
            $until->addDay(1);

            $this->defaultSearchData = array(
                'datefrom'         => $from,
                'dateuntil'        => $until,
                'dateused'         => 'gla_created',
                );
        }

        return parent::getSearchDefaults();
    }
195527
public function getDefaultSearchContext()
    {
        $context = parent::getDefaultSearchContext();
        $fields = $context->getSearchFields();

        $fields->removeByName('Gateway');
        $fields->removeByName('Created');

        $fields->insertAfter('Money', DropdownField::create(
            'Gateway',
            $this->fieldLabel('Gateway'),
            GatewayInfo::getSupportedGateways()
        )->setHasEmptyDefault(true));

        // create a localized status dropdown for the search-context
        $fields->insertAfter('Gateway', DropdownField::create(
            'Status',
            $this->fieldLabel('Status'),
            $this->getStatusValues()
        )->setHasEmptyDefault(true));

        $context->addFilter(new PartialMatchFilter('Gateway'));

        return $context;
    }
271651
public function getRootAliases()
    {
        $aliases = [];

        foreach ($this->dqlParts['from'] as &$fromClause) {
            if (is_string($fromClause)) {
                $spacePos = strrpos($fromClause, ' ');
                $from     = substr($fromClause, 0, $spacePos);
                $alias    = substr($fromClause, $spacePos + 1);

                $fromClause = new Query\Expr\From($from, $alias);
            }

            $aliases[] = $fromClause->getAlias();
        }

        return $aliases;
    }