PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.18.0
GiveWP – Donation Plugin and Fundraising Platform v4.18.0
4.18.0.1 4.18.0 4.17.0 4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 All 258 releases
give / vendor / vendor-prefixed / nyholm / psr7 / src / StreamTrait.php

StreamTrait.php in GiveWP – Donation Plugin and Fundraising Platform 4.18.0, at vendor/vendor-prefixed/nyholm/psr7/src/StreamTrait.php

58 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Give\Vendors\Nyholm\Psr7;
6
7 use Give\Vendors\Psr\Http\Message\StreamInterface;
8 use Symfony\Component\Debug\ErrorHandler as SymfonyLegacyErrorHandler;
9 use Symfony\Component\ErrorHandler\ErrorHandler as SymfonyErrorHandler;
10
11 if (\PHP_VERSION_ID >= 70400 || (new \ReflectionMethod(StreamInterface::class, '__toString'))->hasReturnType()) {
12 /**
13 * @internal
14 */
15 trait StreamTrait
16 {
17 public function __toString(): string
18 {
19 if ($this->isSeekable()) {
20 $this->seek(0);
21 }
22
23 return $this->getContents();
24 }
25 }
26 } else {
27 /**
28 * @internal
29 */
30 trait StreamTrait
31 {
32 /**
33 * @return string
34 */
35 public function __toString()
36 {
37 try {
38 if ($this->isSeekable()) {
39 $this->seek(0);
40 }
41
42 return $this->getContents();
43 } catch (\Throwable $e) {
44 if (\is_array($errorHandler = \set_error_handler('var_dump'))) {
45 $errorHandler = $errorHandler[0] ?? null;
46 }
47 \restore_error_handler();
48
49 if ($e instanceof \Error || $errorHandler instanceof SymfonyErrorHandler || $errorHandler instanceof SymfonyLegacyErrorHandler) {
50 return \trigger_error((string) $e, \E_USER_ERROR);
51 }
52
53 return '';
54 }
55 }
56 }
57 }
58