88use Phplrt \Contracts \Source \ReadableInterface ;
99use Phplrt \Contracts \Source \SourceExceptionInterface ;
1010use Phplrt \Contracts \Source \SourceFactoryInterface ;
11- use Psr \Http \Message \StreamInterface ;
1211
1312trait SourceFactoryTrait
1413{
@@ -32,13 +31,11 @@ public static function getSourceFactory(): SourceFactoryInterface
3231 * : ReadableInterface)
3332 * )
3433 * @throws SourceExceptionInterface
34+ *
35+ * @psalm-suppress NoValue : Allow any value
3536 */
3637 public static function new (mixed $ source ): ReadableInterface
3738 {
38- if ($ source instanceof StreamInterface) {
39- return static ::fromPsrStream ($ source );
40- }
41-
4239 $ factory = self ::getSourceFactory ();
4340
4441 return $ factory ->create ($ source );
@@ -49,7 +46,6 @@ public static function new(mixed $source): ReadableInterface
4946 * @param non-empty-string|null $pathname
5047 *
5148 * @return ($pathname is null ? ReadableInterface : FileInterface)
52- * @throws SourceExceptionInterface
5349 */
5450 public static function empty (?string $ pathname = null ): ReadableInterface
5551 {
@@ -61,7 +57,6 @@ public static function empty(?string $pathname = null): ReadableInterface
6157 * @param non-empty-string|null $pathname
6258 *
6359 * @return ($pathname is null ? ReadableInterface : FileInterface)
64- * @throws SourceExceptionInterface
6560 */
6661 public static function fromSources (string $ sources , ?string $ pathname = null ): ReadableInterface
6762 {
@@ -102,24 +97,6 @@ public static function fromPathname(string $pathname): FileInterface
10297 return new File ($ pathname );
10398 }
10499
105- /**
106- * @param non-empty-string|null $pathname
107- *
108- * @return ($pathname is null ? ReadableInterface : FileInterface)
109- * @throws SourceExceptionInterface
110- *
111- * @deprecated since phplrt 3.4 and will be removed in 4.0, use {@see fromResource()} instead.
112- */
113- public static function fromPsrStream (StreamInterface $ stream , ?string $ pathname = null ): ReadableInterface
114- {
115- trigger_deprecation ('phplrt/source ' , '3.4 ' , <<<'MSG'
116- Using "%s::fromPsrStream($stream)" with %s argument is deprecated,
117- use "%1$s::fromResource($stream->detach())" instead.
118- MSG, static ::class, $ stream ::class);
119-
120- return static ::fromResource ($ stream ->detach (), $ pathname );
121- }
122-
123100 /**
124101 * @param resource $resource
125102 * @param non-empty-string|null $pathname
0 commit comments