Skip to content

Improve solr signatures#1777

Merged
isfedorov merged 8 commits intoJetBrains:masterfrom
VincentLanglet:solr
Aug 25, 2025
Merged

Improve solr signatures#1777
isfedorov merged 8 commits intoJetBrains:masterfrom
VincentLanglet:solr

Conversation

@VincentLanglet
Copy link
Copy Markdown
Contributor

@VincentLanglet VincentLanglet commented Aug 8, 2025

Mainly improving optional param signature by adding a default value.
cf https://www.php.net/manual/en/class.solrdismaxquery.php for instance

And a missing @return void

* Returns a SolrInputDocument equivalent of the object
* @link https://php.net/manual/en/solrdocument.getinputdocument.php
* @return SolrInputDocument <p>
* @return SolrInputDocument|null <p>
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It say Returns a SolrInputDocument on success and <b>NULL</b> on failure.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VincentLanglet I suppose it's just a bug in docs text since the very same page shows return type as SolrInputDocument. Also a simple code that causes error

 <?php
declare(strict_types=1);

if (!extension_loaded('solr')) {
    fwrite(STDERR, "The solr extension is not loaded.\n");
    exit(1);
}

$doc = new SolrDocument();
$doc->unserialize('<not-a-valid-solr-document></not-a-valid-solr-document>');

$result = $doc->getInputDocument();
var_dump($result);
if ($result === null) {
    echo "OK: getInputDocument() returned null on failure.\n";
} else {
    echo "Unexpected: getInputDocument() did not return null.\n";
    var_dump($result);
}

actually shows that the method returns SolrInputDocument

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted this change then.

* Returns a SolrInputDocument equivalent of the object
* @link https://php.net/manual/en/solrdocument.getinputdocument.php
* @return SolrInputDocument <p>
* @return SolrInputDocument|null <p>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VincentLanglet I suppose it's just a bug in docs text since the very same page shows return type as SolrInputDocument. Also a simple code that causes error

 <?php
declare(strict_types=1);

if (!extension_loaded('solr')) {
    fwrite(STDERR, "The solr extension is not loaded.\n");
    exit(1);
}

$doc = new SolrDocument();
$doc->unserialize('<not-a-valid-solr-document></not-a-valid-solr-document>');

$result = $doc->getInputDocument();
var_dump($result);
if ($result === null) {
    echo "OK: getInputDocument() returned null on failure.\n";
} else {
    echo "Unexpected: getInputDocument() did not return null.\n";
    var_dump($result);
}

actually shows that the method returns SolrInputDocument

* The value to use.
* </p>
* @param string $field_override <p>
* @param string $field_override [Optional] <p>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Optional] can be removed here, actually. Optionality of a parameter is obvious from its default value. Stubs use [optional] in some other places because due to some reasons it's impossible to add a default value in signature, but it's not a case here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed it then.

@isfedorov isfedorov merged commit 6a57901 into JetBrains:master Aug 25, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants