@@ -39,54 +39,41 @@ final class SourceFactory implements SourceFactoryInterface
39
39
*/
40
40
public const DEFAULT_TEMP_STREAM = 'php://memory ' ;
41
41
42
- /**
43
- * @var non-empty-string
44
- *
45
- * @psalm-readonly-allow-private-mutation
46
- */
47
- public string $ algo = self ::DEFAULT_HASH_ALGO ;
48
-
49
- /**
50
- * @var non-empty-string
51
- *
52
- * @psalm-readonly-allow-private-mutation
53
- */
54
- public string $ temp = self ::DEFAULT_TEMP_STREAM ;
55
-
56
- /**
57
- * @var int<1, max>
58
- *
59
- * @psalm-readonly-allow-private-mutation
60
- */
61
- public int $ chunkSize = self ::DEFAULT_CHUNK_SIZE ;
62
-
63
42
/**
64
43
* @var list<SourceProviderInterface>
65
44
*/
66
45
private array $ providers = [];
67
46
68
47
/**
69
- * @param non-empty-string $algo hashing algorithm for the sources
70
- * @param non-empty-string $temp the name of the temporary stream, which is
71
- * used as a resource during the reading of the source
72
- * @param int<1, max> $chunkSize the chunk size used while non-blocking
73
- * reading the file inside the {@see \Fiber} context
74
48
* @param list<SourceProviderInterface> $providers list of source providers
75
49
*/
76
50
public function __construct (
77
- string $ algo = self ::DEFAULT_HASH_ALGO ,
78
- string $ temp = self ::DEFAULT_TEMP_STREAM ,
79
- int $ chunkSize = self ::DEFAULT_CHUNK_SIZE ,
51
+ /**
52
+ * Hashing algorithm for the sources.
53
+ *
54
+ * @var non-empty-string
55
+ */
56
+ public readonly string $ algo = self ::DEFAULT_HASH_ALGO ,
57
+ /**
58
+ * The name of the temporary stream, which is used as a resource
59
+ * during the reading of the source.
60
+ *
61
+ * @var non-empty-string
62
+ */
63
+ public readonly string $ temp = self ::DEFAULT_TEMP_STREAM ,
64
+ /**
65
+ * The chunk size used while non-blocking reading the file
66
+ * inside the {@see \Fiber} context.
67
+ *
68
+ * @var int<1, max>
69
+ */
70
+ public readonly int $ chunkSize = self ::DEFAULT_CHUNK_SIZE ,
80
71
iterable $ providers = []
81
72
) {
82
73
assert ($ algo !== '' , 'Hashing algorithm name must not be empty ' );
83
74
assert ($ temp !== '' , 'Temporary stream name must not be empty ' );
84
75
assert ($ chunkSize >= 1 , 'Chunk size must be greater than 0 ' );
85
76
86
- $ this ->chunkSize = $ chunkSize ;
87
- $ this ->temp = $ temp ;
88
- $ this ->algo = $ algo ;
89
-
90
77
$ this ->providers = [
91
78
...$ providers ,
92
79
new PsrStreamSourceProvider ($ this ),
@@ -122,7 +109,7 @@ public function withPrependedProvider(SourceProviderInterface $provider): self
122
109
return $ self ;
123
110
}
124
111
125
- public function create ($ source ): ReadableInterface
112
+ public function create (mixed $ source ): ReadableInterface
126
113
{
127
114
foreach ($ this ->providers as $ provider ) {
128
115
$ readable = $ provider ->create ($ source );
@@ -166,7 +153,7 @@ public function createFromFile(string $filename): FileInterface
166
153
/**
167
154
* @throws NotReadableException
168
155
*/
169
- public function createFromStream ($ stream , ?string $ name = null ): ReadableInterface
156
+ public function createFromStream (mixed $ stream , ?string $ name = null ): ReadableInterface
170
157
{
171
158
assert ($ name !== '' , 'Name must not be empty ' );
172
159
0 commit comments