PluginProbe ʕ •ᴥ•ʔ
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 25.9
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v25.9
27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 19.1 19.10 19.11 19.12 19.13 19.14 19.2 19.3 19.4 19.5 19.5.1 19.6 19.6.1 19.7 19.7.1 19.7.2 19.8 19.9 20.0 20.1 20.10 20.11 20.12 20.13 20.2 20.2.1 20.3 20.4 20.5 20.6 20.7 20.8 20.9 21.0 21.1 21.2 21.3 21.4 21.5 21.6 21.7 21.8 21.8.1 21.9 21.9.1 22.0 22.1 22.2 22.3 22.4 22.5 22.6 22.7 22.8 22.9 23.0 23.1 23.2 23.3 23.4 23.5 23.6 23.7 23.8 23.9 24.0 24.1 24.2 24.3 24.4 24.5 24.6 24.7 24.8 24.8.1 24.9 25.0 25.1 25.2 25.3 25.3.1 25.4 25.5 25.6 25.7 25.8 25.9 26.0 26.1 26.1.1 26.2 26.3 26.4 26.5 26.6 26.7 26.8 26.9 27.0 27.1 27.1.1 27.2 27.3 27.4
wordpress-seo / vendor_prefixed / guzzlehttp / psr7 / src / FnStream.php
wordpress-seo / vendor_prefixed / guzzlehttp / psr7 / src Last commit date
Exception 2 years ago AppendStream.php 2 years ago BufferStream.php 2 years ago CachingStream.php 2 years ago DroppingStream.php 2 years ago FnStream.php 2 years ago Header.php 2 years ago HttpFactory.php 2 years ago InflateStream.php 2 years ago LazyOpenStream.php 2 years ago LimitStream.php 2 years ago Message.php 2 years ago MessageTrait.php 2 years ago MimeType.php 2 years ago MultipartStream.php 2 years ago NoSeekStream.php 2 years ago PumpStream.php 2 years ago Query.php 2 years ago Request.php 2 years ago Response.php 2 years ago Rfc7230.php 2 years ago ServerRequest.php 2 years ago Stream.php 2 years ago StreamDecoratorTrait.php 2 years ago StreamWrapper.php 2 years ago UploadedFile.php 2 years ago Uri.php 2 years ago UriComparator.php 2 years ago UriNormalizer.php 2 years ago UriResolver.php 2 years ago Utils.php 2 years ago
FnStream.php
150 lines
1 <?php
2
3 declare (strict_types=1);
4 namespace YoastSEO_Vendor\GuzzleHttp\Psr7;
5
6 use YoastSEO_Vendor\Psr\Http\Message\StreamInterface;
7 /**
8 * Compose stream implementations based on a hash of functions.
9 *
10 * Allows for easy testing and extension of a provided stream without needing
11 * to create a concrete class for a simple extension point.
12 */
13 #[\AllowDynamicProperties]
14 final class FnStream implements \YoastSEO_Vendor\Psr\Http\Message\StreamInterface
15 {
16 private const SLOTS = ['__toString', 'close', 'detach', 'rewind', 'getSize', 'tell', 'eof', 'isSeekable', 'seek', 'isWritable', 'write', 'isReadable', 'read', 'getContents', 'getMetadata'];
17 /** @var array<string, callable> */
18 private $methods;
19 /**
20 * @param array<string, callable> $methods Hash of method name to a callable.
21 */
22 public function __construct(array $methods)
23 {
24 $this->methods = $methods;
25 // Create the functions on the class
26 foreach ($methods as $name => $fn) {
27 $this->{'_fn_' . $name} = $fn;
28 }
29 }
30 /**
31 * Lazily determine which methods are not implemented.
32 *
33 * @throws \BadMethodCallException
34 */
35 public function __get(string $name) : void
36 {
37 throw new \BadMethodCallException(\str_replace('_fn_', '', $name) . '() is not implemented in the FnStream');
38 }
39 /**
40 * The close method is called on the underlying stream only if possible.
41 */
42 public function __destruct()
43 {
44 if (isset($this->_fn_close)) {
45 ($this->_fn_close)();
46 }
47 }
48 /**
49 * An unserialize would allow the __destruct to run when the unserialized value goes out of scope.
50 *
51 * @throws \LogicException
52 */
53 public function __wakeup() : void
54 {
55 throw new \LogicException('FnStream should never be unserialized');
56 }
57 /**
58 * Adds custom functionality to an underlying stream by intercepting
59 * specific method calls.
60 *
61 * @param StreamInterface $stream Stream to decorate
62 * @param array<string, callable> $methods Hash of method name to a closure
63 *
64 * @return FnStream
65 */
66 public static function decorate(\YoastSEO_Vendor\Psr\Http\Message\StreamInterface $stream, array $methods)
67 {
68 // If any of the required methods were not provided, then simply
69 // proxy to the decorated stream.
70 foreach (\array_diff(self::SLOTS, \array_keys($methods)) as $diff) {
71 /** @var callable $callable */
72 $callable = [$stream, $diff];
73 $methods[$diff] = $callable;
74 }
75 return new self($methods);
76 }
77 public function __toString() : string
78 {
79 try {
80 /** @var string */
81 return ($this->_fn___toString)();
82 } catch (\Throwable $e) {
83 if (\PHP_VERSION_ID >= 70400) {
84 throw $e;
85 }
86 \trigger_error(\sprintf('%s::__toString exception: %s', self::class, (string) $e), \E_USER_ERROR);
87 return '';
88 }
89 }
90 public function close() : void
91 {
92 ($this->_fn_close)();
93 }
94 public function detach()
95 {
96 return ($this->_fn_detach)();
97 }
98 public function getSize() : ?int
99 {
100 return ($this->_fn_getSize)();
101 }
102 public function tell() : int
103 {
104 return ($this->_fn_tell)();
105 }
106 public function eof() : bool
107 {
108 return ($this->_fn_eof)();
109 }
110 public function isSeekable() : bool
111 {
112 return ($this->_fn_isSeekable)();
113 }
114 public function rewind() : void
115 {
116 ($this->_fn_rewind)();
117 }
118 public function seek($offset, $whence = \SEEK_SET) : void
119 {
120 ($this->_fn_seek)($offset, $whence);
121 }
122 public function isWritable() : bool
123 {
124 return ($this->_fn_isWritable)();
125 }
126 public function write($string) : int
127 {
128 return ($this->_fn_write)($string);
129 }
130 public function isReadable() : bool
131 {
132 return ($this->_fn_isReadable)();
133 }
134 public function read($length) : string
135 {
136 return ($this->_fn_read)($length);
137 }
138 public function getContents() : string
139 {
140 return ($this->_fn_getContents)();
141 }
142 /**
143 * @return mixed
144 */
145 public function getMetadata($key = null)
146 {
147 return ($this->_fn_getMetadata)($key);
148 }
149 }
150