@@ -117,12 +117,12 @@ class Process
117117 /**
118118 * Constructor.
119119 *
120- * @param string $commandline The command line to run
121- * @param string $cwd The working directory
122- * @param array $env The environment variables or null to inherit
123- * @param string $stdin The STDIN content
124- * @param integer $timeout The timeout in seconds
125- * @param array $options An array of options for proc_open
120+ * @param string $commandline The command line to run
121+ * @param string|null $cwd The working directory or null to use the working dir of the current PHP process
122+ * @param array|null $env The environment variables or null to inherit
123+ * @param string|null $stdin The STDIN content
124+ * @param integer|float|null $timeout The timeout in seconds or null to disable
125+ * @param array $options An array of options for proc_open
126126 *
127127 * @throws RuntimeException When proc_open is not installed
128128 *
@@ -658,7 +658,7 @@ public function setCommandLine($commandline)
658658 /**
659659 * Gets the process timeout.
660660 *
661- * @return integer |null The timeout in seconds or null if it's disabled
661+ * @return float |null The timeout in seconds or null if it's disabled
662662 */
663663 public function getTimeout ()
664664 {
@@ -670,23 +670,19 @@ public function getTimeout()
670670 *
671671 * To disable the timeout, set this value to null.
672672 *
673- * @param float|null $timeout The timeout in seconds
673+ * @param integer| float|null $timeout The timeout in seconds
674674 *
675675 * @return self The current Process instance
676676 *
677677 * @throws InvalidArgumentException if the timeout is negative
678678 */
679679 public function setTimeout ($ timeout )
680680 {
681- if (null === $ timeout ) {
682- $ this ->timeout = null ;
683-
684- return $ this ;
685- }
686-
687681 $ timeout = (float ) $ timeout ;
688682
689- if ($ timeout < 0 ) {
683+ if (0.0 === $ timeout ) {
684+ $ timeout = null ;
685+ } elseif ($ timeout < 0 ) {
690686 throw new InvalidArgumentException ('The timeout value must be a valid positive integer or float number. ' );
691687 }
692688
@@ -698,11 +694,10 @@ public function setTimeout($timeout)
698694 /**
699695 * Gets the working directory.
700696 *
701- * @return string The current working directory
697+ * @return string|null The current working directory or null on failure
702698 */
703699 public function getWorkingDirectory ()
704700 {
705- // This is for BC only
706701 if (null === $ this ->cwd ) {
707702 // getcwd() will return false if any one of the parent directories does not have
708703 // the readable or search mode set, even if the current directory does
@@ -765,7 +760,7 @@ public function setEnv(array $env)
765760 /**
766761 * Gets the contents of STDIN.
767762 *
768- * @return string The current contents
763+ * @return string|null The current contents
769764 */
770765 public function getStdin ()
771766 {
@@ -775,7 +770,7 @@ public function getStdin()
775770 /**
776771 * Sets the contents of STDIN.
777772 *
778- * @param string $stdin The new contents
773+ * @param string|null $stdin The new contents
779774 *
780775 * @return self The current Process instance
781776 */
@@ -875,7 +870,7 @@ public function setEnhanceSigchildCompatibility($enhance)
875870 */
876871 public function checkTimeout ()
877872 {
878- if (0 < $ this ->timeout && $ this ->timeout < microtime (true ) - $ this ->starttime ) {
873+ if (null !== $ this ->timeout && $ this ->timeout < microtime (true ) - $ this ->starttime ) {
879874 $ this ->stop (0 );
880875
881876 throw new RuntimeException ('The process timed-out. ' );
0 commit comments