php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77727 Unable to extend client and change query method
Submitted: 2019-03-12 10:27 UTC Modified: -
From: grzegorz dot drozd at gmail dot com Assigned:
Status: Open Package: solr (PECL)
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2019-03-12 10:27 UTC] grzegorz dot drozd at gmail dot com
Description:
------------
Hi.

I am trying to add list of queries into some legacy system to see what is sent to solr server. I replaced all Client instances with my own instance. I am trying to change query method to inject some query statistics gathering. I think there is an issue with function declaration that prevents me from making it work.
I tried various combinations of method declaration:
\SolrParams $query
\SolrParams &$query

// this obviously does not work because it seeks for a class in current namespace
SolrParams $query
SolrParams &$query

use \SolrParams as SolrParams;
SolrParams $query
SolrParams &$query

Please fix function declaration.


Test script:
---------------
<?php 
namespace \Api\Solr;
class Client extends \SolrClient {

    public function __construct($options){
        $options['secure']=false;
        parent::__construct($options);
    }

    public function query(\SolrParams &$query){
        return parent::query($query);
    }
}


Expected result:
----------------
Ability to change query method.

Actual result:
--------------
Declaration of \Api\Solr\Client::query() should be compatible with & SolrClient::query(SolrParams &$query)

Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 22:01:25 2019 UTC