Skip to content

Commit

Permalink
Remove the need for AllowDynamicProperties in CurlMultiHandler (#3158)
Browse files Browse the repository at this point in the history
  • Loading branch information
TimWolla committed Aug 3, 2023
1 parent cd634c2 commit 21314fd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
10 changes: 10 additions & 0 deletions phpstan-baseline.neon
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
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
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

0 comments on commit 21314fd

Please sign in to comment.