@@ -40,31 +40,23 @@ class Serve extends Command
4040
4141 /**
4242 * Le décalage de port actuel.
43- *
44- * @var int
4543 */
46- protected $ portOffset = 0 ;
44+ protected int $ portOffset = 0 ;
4745
4846 /**
4947 * Le nombre maximum de ports à partir desquels tenter de servir
50- *
51- * @var int
5248 */
53- protected $ tries = 10 ;
49+ protected int $ tries = 10 ;
5450
5551 /**
5652 * Chemin de base dans lequel sera lancer le server
57- *
58- * @var string
5953 */
60- protected $ rootDirectory = WEBROOT ;
54+ protected string $ rootDirectory = WEBROOT ;
6155
6256 /**
6357 * Liste des messages des taches
64- *
65- * @var array
6658 */
67- protected $ taskMessages = [
59+ protected array $ taskMessages = [
6860 'demarrage ' => '' , // Message a afficher lors du demarrage du serveur
6961 'demarrer ' => '' , // Message a afficher lorsque le serveur a demarré
7062 ];
@@ -74,25 +66,10 @@ class Serve extends Command
7466 */
7567 public function handle ()
7668 {
77- $ options = [
78- 'php ' => PHP_BINARY ,
79- 'host ' => 'localhost ' ,
80- 'port ' => 3300 ,
81- ];
82-
83- if (isset ($ this ->options ['--php ' ])) {
84- $ options ['php ' ] = $ this ->options ['--php ' ][1 ] ?? PHP_BINARY ;
85- }
86- if (isset ($ this ->options ['--host ' ])) {
87- $ options ['host ' ] = $ this ->options ['--host ' ][1 ] ?? 'localhost ' ;
88- }
89- if (isset ($ this ->options ['--port ' ])) {
90- $ options ['port ' ] = $ this ->options ['--port ' ][1 ] ?? 3300 ;
91- }
92-
93- $ php = escapeshellarg ($ params ['php ' ] ?: $ options ['php ' ]);
94- $ host = $ params ['host ' ] ?: $ options ['host ' ];
95- $ port = (int ) ($ params ['port ' ] ?: $ options ['port ' ]) + $ this ->portOffset ;
69+ $ binary = $ this ->option ('php ' , PHP_BINARY );
70+ $ php = escapeshellarg ($ binary === 'PHP_BINARY ' ? PHP_BINARY : $ binary );
71+ $ host = $ this ->option ('host ' , 'localhost ' );
72+ $ port = (int ) ($ this ->option ('port ' , 3300 )) + $ this ->portOffset ;
9673
9774 $ this ->task ($ this ->taskMessages ['demarrage ' ] ?: 'Demarrage du serveur de developpement ' );
9875 sleep (2 );
0 commit comments