Skip to content
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

Remove the need for AllowDynamicProperties in CurlMultiHandler #3158

Merged
merged 1 commit into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,16 @@ parameters:
count: 1
path: src/Handler/CurlMultiHandler.php

-
message: "#^Property GuzzleHttp\\\\Handler\\\\CurlMultiHandler\\:\\:\\$_mh \\(CurlMultiHandle\\|resource\\) in isset\\(\\) is not nullable\\.$#"
count: 1
path: src/Handler/CurlMultiHandler.php

-
message: "#^Property GuzzleHttp\\\\Handler\\\\CurlMultiHandler\\:\\:\\$_mh has unknown class CurlMultiHandle as its type\\.$#"
count: 1
path: src/Handler/CurlMultiHandler.php

-
message: "#^Property GuzzleHttp\\\\Handler\\\\EasyHandle\\:\\:\\$handle has unknown class CurlHandle as its type\\.$#"
count: 1
Expand Down
12 changes: 7 additions & 5 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@
<ArgumentTypeCoercion occurrences="1">
<code>$this-&gt;timeToNext()</code>
</ArgumentTypeCoercion>
<PossiblyInvalidArgument occurrences="7">
<PossiblyInvalidArgument occurrences="8">
<code>$this-&gt;_mh</code>
<code>$this-&gt;_mh</code>
<code>$this-&gt;_mh</code>
<code>$this-&gt;_mh</code>
Expand All @@ -89,15 +90,16 @@
<code>$this-&gt;_mh</code>
<code>$this-&gt;_mh</code>
</PossiblyInvalidArgument>
<RedundantPropertyInitializationCheck occurrences="1">
<code>isset($this-&gt;_mh)</code>
</RedundantPropertyInitializationCheck>
<TooManyArguments occurrences="1">
<code>trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing an integer to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__)</code>
</TooManyArguments>
<UndefinedDocblockClass occurrences="1">
<UndefinedDocblockClass occurrences="2">
<code>resource|\CurlMultiHandle</code>
<code>resource|\CurlMultiHandle</code>
</UndefinedDocblockClass>
<UndefinedThisPropertyAssignment occurrences="1">
<code>$this-&gt;_mh</code>
</UndefinedThisPropertyAssignment>
</file>
<file src="src/Handler/EasyHandle.php">
<UndefinedDocblockClass occurrences="1">
Expand Down
10 changes: 7 additions & 3 deletions src/Handler/CurlMultiHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@
* associative array of curl option constants mapping to values in the
* **curl** key of the provided request options.
*
* @property resource|\CurlMultiHandle $_mh Internal use only. Lazy loaded multi-handle.
*
* @final
*/
#[\AllowDynamicProperties]
class CurlMultiHandler
{
/**
Expand Down Expand Up @@ -56,6 +53,9 @@ class CurlMultiHandler
*/
private $options = [];

/** @var resource|\CurlMultiHandle */
private $_mh;

/**
* This handler accepts the following options:
*
Expand All @@ -79,6 +79,10 @@ public function __construct(array $options = [])
}

$this->options = $options['options'] ?? [];

// unsetting the property forces the first access to go through
// __get().
unset($this->_mh);
}

/**
Expand Down