@@ -16,32 +16,35 @@ final class Redirection extends AbstractCollection
1616 * @return $this
1717 * @throws ShellBuilderException
1818 */
19- public function redirectOutput ($ value , bool $ append ): self
19+ public static function redirectOutput ($ value , bool $ append ): self
2020 {
21- $ this ->tuple = CollectionTuple::create ($ value , $ append ? RedirectOperator::STDOUT_LEFT_APPEND : RedirectOperator::STDOUT_LEFT_INSERT );
22- return $ this ;
21+ $ redirect = new self ();
22+ $ redirect ->tuple = CollectionTuple::create ($ value , $ append ? RedirectOperator::STDOUT_LEFT_APPEND : RedirectOperator::STDOUT_LEFT_INSERT );
23+ return $ redirect ;
2324 }
2425
2526 /**
2627 * @param string|ShellInterface $value
2728 * @return $this
2829 * @throws ShellBuilderException
2930 */
30- public function redirectInput ($ value ): self
31+ public static function redirectInput ($ value ): self
3132 {
32- $ this ->tuple = CollectionTuple::create ($ value , RedirectOperator::STDIN_RIGHT );
33- return $ this ;
33+ $ redirect = new self ();
34+ $ redirect ->tuple = CollectionTuple::create ($ value , RedirectOperator::STDIN_RIGHT );
35+ return $ redirect ;
3436 }
3537
3638 /**
3739 * @param string|ShellInterface $value
3840 * @return $this
3941 * @throws ShellBuilderException
4042 */
41- public function redirectError ($ value ): self
43+ public static function redirectError ($ value ): self
4244 {
43- $ this ->tuple = CollectionTuple::create ($ value , RedirectOperator::FILE_DESCRIPTOR_ERR . RedirectOperator::STDOUT_LEFT_INSERT );
44- return $ this ;
45+ $ redirect = new self ();
46+ $ redirect ->tuple = CollectionTuple::create ($ value , RedirectOperator::FILE_DESCRIPTOR_ERR . RedirectOperator::STDOUT_LEFT_INSERT );
47+ return $ redirect ;
4548 }
4649
4750 /**
@@ -50,15 +53,17 @@ public function redirectError($value): self
5053 * @return $this
5154 * @throws ShellBuilderException
5255 */
53- public function redirectBetweenFiles ($ value , bool $ toLeft ): self
56+ public static function redirectBetweenFiles ($ value , bool $ toLeft ): self
5457 {
55- $ this ->tuple = CollectionTuple::create ($ value , $ toLeft ? RedirectOperator::REDIRECT_LEFT : RedirectOperator::REDIRECT_RIGHT );
56- return $ this ;
58+ $ redirect = new self ();
59+ $ redirect ->tuple = CollectionTuple::create ($ value , $ toLeft ? RedirectOperator::REDIRECT_LEFT : RedirectOperator::REDIRECT_RIGHT );
60+ return $ redirect ;
5761 }
5862
59- public function redirectErrorToOutput (): self
63+ public static function redirectErrorToOutput (): self
6064 {
61- $ this ->tuple = CollectionTuple::create ('' , RedirectOperator::ERR_TO_OUT_REDIRECT );
62- return $ this ;
65+ $ redirect = new self ();
66+ $ redirect ->tuple = CollectionTuple::create ('' , RedirectOperator::ERR_TO_OUT_REDIRECT );
67+ return $ redirect ;
6368 }
6469}
0 commit comments