Skip to content

Remove some solr definition in functionMap #4219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 8, 2025

Conversation

VincentLanglet
Copy link
Contributor

@VincentLanglet VincentLanglet commented Aug 8, 2025

For Solr, there is so many stub, so for an easier review I'll split the PR. This is the first part
Also, after JetBrains/phpstorm-stubs#1777 i'll be able to remove more.

Reflection changes are

1) PHPStan\Reflection\ReflectionProviderGoldenTest::test with data set "METHOD SolrDocument::serialize" ('METHOD SolrDocument::serialize', 'Is built-in: Yes\nHas side-ef... mixed')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 'Is built-in: Yes
 Has side-effects: Maybe
+Throw type: Exception
 Visibility: public
 Variants: 1
     /**

/home/runner/work/phpstan-src/phpstan-src/tests/PHPStan/Reflection/ReflectionProviderGoldenTest.php:73

Seems ok

2) PHPStan\Reflection\ReflectionProviderGoldenTest::test with data set "METHOD SolrClient::system" ('METHOD SolrClient::system', 'Is built-in: Yes\nHas side-ef... mixed')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 'Is built-in: Yes
-Has side-effects: Yes
+Has side-effects: Maybe
 Throw type: SolrClientException|SolrServerException
 Visibility: public
 Variants: 1
     /**
-     * @return void
+     * @return SolrGenericResponse
      */
     function system(): mixed'

/home/runner/work/phpstan-src/phpstan-src/tests/PHPStan/Reflection/ReflectionProviderGoldenTest.php:73

In https://www.php.net/manual/en/solrclient.system.php
it say "Returns a SolrGenericResponse object on success."

3) PHPStan\Reflection\ReflectionProviderGoldenTest::test with data set "METHOD SolrDocument::getFieldCount" ('METHOD SolrDocument::getFieldCount', 'Is built-in: Yes\nHas side-ef... mixed')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 Visibility: public
 Variants: 1
     /**
-     * @return int
+     * @return (int|false)
      */
     function getFieldCount(): mixed'

/home/runner/work/phpstan-src/phpstan-src/tests/PHPStan/Reflection/ReflectionProviderGoldenTest.php:73

In https://www.php.net/manual/en/solrdocument.getfieldcount.php it say Returns an integer on success and [false](https://www.php.net/manual/en/reserved.constants.php#constant.false) on failure.

I used a benevolent union since it previously was int.

4) PHPStan\Reflection\ReflectionProviderGoldenTest::test with data set "METHOD SolrDocument::offsetSet" ('METHOD SolrDocument::offsetSet', 'Is built-in: Yes\nHas side-ef... mixed')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 'Is built-in: Yes
-Has side-effects: Yes
+Has side-effects: Maybe
 Visibility: public
 Variants: 1
     /**
      * @param string $fieldName
      * @param string $fieldValue
-     * @return void
+     * @return bool
      */
     function offsetSet(mixed $fieldName, mixed $fieldValue): mixed'

/home/runner/work/phpstan-src/phpstan-src/tests/PHPStan/Reflection/ReflectionProviderGoldenTest.php:73

Docs say https://www.php.net/manual/fr/solrdocument.offsetset.php true on success, false on failure

5) PHPStan\Reflection\ReflectionProviderGoldenTest::test with data set "METHOD SolrModifiableParams::__destruct" ('METHOD SolrModifiableParams::...struct', 'Is built-in: Yes\nHas side-ef... mixed')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 'Is built-in: Yes
-Has side-effects: Maybe
+Has side-effects: Yes
 Visibility: public
 Variants: 1
     /**
-     * @return mixed
+     * @return void
      */
     function __destruct(): mixed'

/home/runner/work/phpstan-src/phpstan-src/tests/PHPStan/Reflection/ReflectionProviderGoldenTest.php:73

6) PHPStan\Reflection\ReflectionProviderGoldenTest::test with data set "METHOD SolrQuery::__destruct" ('METHOD SolrQuery::__destruct', 'Is built-in: Yes\nHas side-ef... mixed')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 'Is built-in: Yes
-Has side-effects: Maybe
+Has side-effects: Yes
 Visibility: public
 Variants: 1
     /**
-     * @return mixed
+     * @return void
      */
     function __destruct(): mixed'

/home/runner/work/phpstan-src/phpstan-src/tests/PHPStan/Reflection/ReflectionProviderGoldenTest.php:73

7) PHPStan\Reflection\ReflectionProviderGoldenTest::test with data set "METHOD SolrGenericResponse::__destruct" ('METHOD SolrGenericResponse::__destruct', 'Is built-in: Yes\nHas side-ef... mixed')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 'Is built-in: Yes
-Has side-effects: Maybe
+Has side-effects: Yes
 Visibility: public
 Variants: 1
     /**
-     * @return mixed
+     * @return void
      */
     function __destruct(): mixed'

/home/runner/work/phpstan-src/phpstan-src/tests/PHPStan/Reflection/ReflectionProviderGoldenTest.php:73

Seems ok to me, destructor has a void return type by default

8) PHPStan\Reflection\ReflectionProviderGoldenTest::test with data set "METHOD SolrDocument::merge" ('METHOD SolrDocument::merge', 'Is built-in: Yes\nHas side-ef... mixed')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 Visibility: public
 Variants: 1
     /**
-     * @param solrdocument $sourceDoc
+     * @param SolrInputDocument $sourceDoc
      * @param bool $overwrite
      * @return bool
      */
     function merge(SolrInputDocument $sourceDoc, mixed $overwrite = true): mixed'

/home/runner/work/phpstan-src/phpstan-src/tests/PHPStan/Reflection/ReflectionProviderGoldenTest.php:73

Ok

9) PHPStan\Reflection\ReflectionProviderGoldenTest::test with data set "METHOD SolrDocumentField::__destruct" ('METHOD SolrDocumentField::__destruct', 'Is built-in: Yes\nHas side-ef... mixed')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 'Is built-in: Yes
-Has side-effects: Maybe
+Has side-effects: Yes
 Visibility: public
 Variants: 1
     /**
-     * @return mixed
+     * @return void
      */
     function __destruct(): mixed'

/home/runner/work/phpstan-src/phpstan-src/tests/PHPStan/Reflection/ReflectionProviderGoldenTest.php:73

10) PHPStan\Reflection\ReflectionProviderGoldenTest::test with data set "METHOD SolrQueryResponse::__destruct" ('METHOD SolrQueryResponse::__destruct', 'Is built-in: Yes\nHas side-ef... mixed')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 'Is built-in: Yes
-Has side-effects: Maybe
+Has side-effects: Yes
 Visibility: public
 Variants: 1
     /**
-     * @return mixed
+     * @return void
      */
     function __destruct(): mixed'

/home/runner/work/phpstan-src/phpstan-src/tests/PHPStan/Reflection/ReflectionProviderGoldenTest.php:73

11) PHPStan\Reflection\ReflectionProviderGoldenTest::test with data set "METHOD SolrClient::__destruct" ('METHOD SolrClient::__destruct', 'Is built-in: Yes\nHas side-ef... mixed')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 'Is built-in: Yes
-Has side-effects: Maybe
+Has side-effects: Yes
 Visibility: public
 Variants: 1
     /**
-     * @return mixed
+     * @return void
      */
     function __destruct(): mixed'

/home/runner/work/phpstan-src/phpstan-src/tests/PHPStan/Reflection/ReflectionProviderGoldenTest.php:73

12) PHPStan\Reflection\ReflectionProviderGoldenTest::test with data set "METHOD SolrUpdateResponse::__destruct" ('METHOD SolrUpdateResponse::__destruct', 'Is built-in: Yes\nHas side-ef... mixed')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 'Is built-in: Yes
-Has side-effects: Maybe
+Has side-effects: Yes
 Visibility: public
 Variants: 1
     /**
-     * @return mixed
+     * @return void
      */
     function __destruct(): mixed'

/home/runner/work/phpstan-src/phpstan-src/tests/PHPStan/Reflection/ReflectionProviderGoldenTest.php:73

13) PHPStan\Reflection\ReflectionProviderGoldenTest::test with data set "METHOD SolrInputDocument::__destruct" ('METHOD SolrInputDocument::__destruct', 'Is built-in: Yes\nHas side-ef... mixed')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 'Is built-in: Yes
-Has side-effects: Maybe
+Has side-effects: Yes
 Visibility: public
 Variants: 1
     /**
-     * @return mixed
+     * @return void
      */
     function __destruct(): mixed'

/home/runner/work/phpstan-src/phpstan-src/tests/PHPStan/Reflection/ReflectionProviderGoldenTest.php:73

Ok to me

14) PHPStan\Reflection\ReflectionProviderGoldenTest::test with data set "METHOD SolrDocument::getField" ('METHOD SolrDocument::getField', 'Is built-in: Yes\nHas side-ef... mixed')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 Variants: 1
     /**
      * @param string $fieldName
-     * @return SolrDocumentField
+     * @return (SolrDocumentField|false)
      */
     function getField(mixed $fieldName): mixed'

/home/runner/work/phpstan-src/phpstan-src/tests/PHPStan/Reflection/ReflectionProviderGoldenTest.php:73

https://www.php.net/manual/en/solrdocument.getfield.php say it can return false

15) PHPStan\Reflection\ReflectionProviderGoldenTest::test with data set "METHOD SolrDocument::getFieldNames" ('METHOD SolrDocument::getFieldNames', 'Is built-in: Yes\nHas side-ef... mixed')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 Visibility: public
 Variants: 1
     /**
-     * @return array
+     * @return (array|false)
      */
     function getFieldNames(): mixed'

/home/runner/work/phpstan-src/phpstan-src/tests/PHPStan/Reflection/ReflectionProviderGoldenTest.php:73

same idea

16) PHPStan\Reflection\ReflectionProviderGoldenTest::test with data set "METHOD SolrClient::commit" ('METHOD SolrClient::commit', 'Is built-in: Yes\nHas side-ef... mixed')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 Visibility: public
 Variants: 1
     /**
-     * @param int $softCommit
+     * @param bool $softCommit
      * @param bool $waitSearcher
      * @param bool $expungeDeletes
      * @return SolrUpdateResponse
      */
     function commit(mixed $softCommit = false, mixed $waitSearcher = true, mixed $expungeDeletes = false): mixed'

/home/runner/work/phpstan-src/phpstan-src/tests/PHPStan/Reflection/ReflectionProviderGoldenTest.php:73

cf https://www.php.net/manual/en/solrclient.commit.php

17) PHPStan\Reflection\ReflectionProviderGoldenTest::test with data set "METHOD SolrPingResponse::__destruct" ('METHOD SolrPingResponse::__destruct', 'Is built-in: Yes\nHas side-ef... mixed')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 'Is built-in: Yes
-Has side-effects: Maybe
+Has side-effects: Yes
 Visibility: public
 Variants: 1
     /**
-     * @return mixed
+     * @return void
      */
     function __destruct(): mixed'

/home/runner/work/phpstan-src/phpstan-src/tests/PHPStan/Reflection/ReflectionProviderGoldenTest.php:73

Seems ok to me

18) PHPStan\Reflection\ReflectionProviderGoldenTest::test with data set "METHOD SolrDocument::__unset" ('METHOD SolrDocument::__unset', 'Is built-in: Yes\nHas side-ef... mixed')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 'Is built-in: Yes
-Has side-effects: Maybe
+Has side-effects: Yes
 Visibility: public
 Variants: 1
     /**
      * @param string $fieldName
-     * @return bool
+     * @return void
      */
     function __unset(mixed $fieldName): mixed'

/home/runner/work/phpstan-src/phpstan-src/tests/PHPStan/Reflection/ReflectionProviderGoldenTest.php:73

Not ok, I made a commit to fix this.

19) PHPStan\Reflection\ReflectionProviderGoldenTest::test with data set "METHOD SolrDocument::__destruct" ('METHOD SolrDocument::__destruct', 'Is built-in: Yes\nHas side-ef... mixed')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 'Is built-in: Yes
-Has side-effects: Maybe
+Has side-effects: Yes
 Visibility: public
 Variants: 1
     /**
-     * @return mixed
+     * @return void
      */
     function __destruct(): mixed'

/home/runner/work/phpstan-src/phpstan-src/tests/PHPStan/Reflection/ReflectionProviderGoldenTest.php:73

Seems ok to me

21) PHPStan\Reflection\ReflectionProviderGoldenTest::test with data set "METHOD SolrDocument::getInputDocument" ('METHOD SolrDocument::getInputDocument', 'Is built-in: Yes\nHas side-ef... mixed')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 Visibility: public
 Variants: 1
     /**
-     * @return SolrInputDocument
+     * @return (SolrInputDocument|null)
      */
     function getInputDocument(): mixed'

/home/runner/work/phpstan-src/phpstan-src/tests/PHPStan/Reflection/ReflectionProviderGoldenTest.php:73

Same idea with https://www.php.net/manual/en/solrdocument.getinputdocument.php

22) PHPStan\Reflection\ReflectionProviderGoldenTest::test with data set "METHOD SolrClient::threads" ('METHOD SolrClient::threads', 'Is built-in: Yes\nHas side-ef... mixed')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 'Is built-in: Yes
-Has side-effects: Yes
+Has side-effects: Maybe
 Throw type: SolrClientException|SolrServerException
 Visibility: public
 Variants: 1
     /**
-     * @return void
+     * @return SolrGenericResponse
      */
     function threads(): mixed'

/home/runner/work/phpstan-src/phpstan-src/tests/PHPStan/Reflection/ReflectionProviderGoldenTest.php:73

same idea with https://www.php.net/manual/en/solrclient.threads.php

@VincentLanglet VincentLanglet marked this pull request as ready for review August 8, 2025 14:41
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

@ondrejmirtes ondrejmirtes merged commit 98d927a into phpstan:2.1.x Aug 8, 2025
449 of 453 checks passed
@ondrejmirtes
Copy link
Member

Thank you

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.

3 participants