@@ -55,7 +55,7 @@ class Processes implements ArrayAccess, Countable
5555REGEXP ;
5656
5757 /**
58- * @var array<int|string, array<mixed> >
58+ * @var array<int|string, array>
5959 */
6060 private $ processes = [];
6161
@@ -83,6 +83,32 @@ public function __construct(?bool $all = null, ?bool $multi = null)
8383 $ this ->setScanOptions ($ all , $ multi )->scan ();
8484 }
8585
86+ /**
87+ * @param null|bool $all
88+ * @param null|bool $multi
89+ * @return array
90+ */
91+ public static function asArray (?bool $ all , ?bool $ multi ): array
92+ {
93+ return (new self ($ all , $ multi ))->get ();
94+ }
95+
96+ /**
97+ * @return Processes
98+ */
99+ public static function all (): Processes
100+ {
101+ return new self (true );
102+ }
103+
104+ /**
105+ * @return Processes
106+ */
107+ public static function multi (): Processes
108+ {
109+ return new self (null , true );
110+ }
111+
86112 /**
87113 * @return Processes
88114 */
@@ -92,15 +118,15 @@ public function rescan(): Processes
92118 }
93119
94120 /**
95- * @return array<int|string, array<mixed> >
121+ * @return array<int|string, array>
96122 */
97123 public function get (): array
98124 {
99125 return $ this ->processes ;
100126 }
101127
102128 /**
103- * @return array<int|string, array<mixed> >
129+ * @return array<int|string, array>
104130 */
105131 public function toArray (): array
106132 {
@@ -142,10 +168,10 @@ public function offsetExists($offset): bool
142168
143169 /**
144170 * @param mixed $offset
145- * @return null|mixed
171+ * @return null|array
146172 */
147173 #[\ReturnTypeWillChange]
148- public function offsetGet ($ offset )
174+ public function offsetGet ($ offset ): ? array
149175 {
150176 return $ this ->processes [$ offset ] ?? null ;
151177 }
@@ -465,7 +491,7 @@ private function unixMultiCall(bool $all = false): void
465491 }
466492
467493 /**
468- * @param array<int, array<mixed> > $processes
494+ * @param array<int, array> $processes
469495 * @param string $type
470496 * @return void
471497 */
@@ -476,7 +502,7 @@ private function setProcesses(array $processes, string $type): void
476502 }
477503
478504 /**
479- * @param array<int, array<mixed> > $processes
505+ * @param array<int, array> $processes
480506 * @param int $pid
481507 * @param int $ppid
482508 * @param int $uid
@@ -507,7 +533,7 @@ private function fillProcessValues(
507533 }
508534
509535 /**
510- * @param array<int, array<mixed> > $processes
536+ * @param array<int, array> $processes
511537 * @param string $cmd
512538 * @param int $pid
513539 * @param mixed $val
0 commit comments