@@ -117,13 +117,8 @@ class PharCommand extends CLICommand
117117 'p ' => array (
118118 'typ ' => 'loader ' ,
119119 'val ' => NULL ,
120- 'inf ' => '<loader> Location of PHP_Archive class file (pear list-files PHP_Archive). '
121- .'You can use \'0 \' or \'1 \' to locate it automatically using the mentioned '
122- .'pear command. When using \'0 \' the command does not error out when the '
123- .'class file cannot be located. This switch also adds some code around the '
124- .'stub so that class PHP_Archive gets registered as phar:// stream wrapper '
125- .'if necessary. And finally this switch will add the file phar.inc from '
126- .'this package and load it to ensure class Phar is present. '
120+ 'inf ' => '<loader> Used to be used for PHP_Archive class file which is no longer '
121+ .'supported. '
127122 ,
128123 ),
129124 's ' => array (
@@ -213,53 +208,11 @@ class PharCommand extends CLICommand
213208 static function cli_arg_typ_loader ($ arg , $ cfg , $ key )
214209 {
215210 if (($ arg == '0 ' || $ arg == '1 ' ) && !file_exists ($ arg ) && substr (PHP_OS , 0 , 3 ) != 'WIN ' ) {
216- $ found = NULL ;
217- $ apiver = false ;
218- $ path = explode (PATH_SEPARATOR , $ _ENV ['PATH ' ]);
219- $ pear = false ;
220- foreach ($ path as $ component ) {
221- if (file_exists ($ component . DIRECTORY_SEPARATOR . 'pear ' )
222- && is_executable ($ component . DIRECTORY_SEPARATOR . 'pear ' )) {
223- $ pear = true ;
224- break ;
225- }
226- }
227- if ($ pear ) {
228- $ apiver = (string ) shell_exec ("pear -q info PHP_Archive 2>/dev/null|grep 'API Version' " );
229- $ apiver = trim (substr ($ apiver , strlen ('API Version ' )));
230- }
231- if ($ apiver ) {
232- self ::notice ("PEAR package PHP_Archive: API Version: $ apiver. \n" );
233- $ files = explode ("\n" , (string ) shell_exec ("pear list-files PHP_Archive " ));
234- $ phpdir = (string ) shell_exec ("pear config-get php_dir 2>/dev/null " );
235- $ phpdir = trim ($ phpdir );
236- self ::notice ("PEAR package PHP_Archive: $ phpdir. \n" );
237- if (is_dir ($ phpdir )) {
238- foreach ($ files as $ ent ) {
239- $ matches = NULL ;
240- if (preg_match (",^php[ \t]+([^ \t].*[ \\\\/]PHP[ \\\\/]Archive\.php)$, " , $ ent , $ matches )) {
241- $ sub = $ matches [1 ];
242- if (strpos ($ sub , $ phpdir ) !== 0 ) {
243- $ found = NULL ;
244- break ;
245- }
246- $ found = $ sub ;
247- break ;
248- }
249- }
250- } else {
251- self ::notice ("PEAR package PHP_Archive: corrupt or inaccessible base dir: $ phpdir. \n" );
252- }
253- }
254- if (isset ($ found )) {
255- self ::notice ("PEAR package PHP_Archive: $ found. \n" );
211+ $ msg = "PEAR package PHP_Archive is no longer supported: generated phar requires PHP's phar extension enabled \n" ;
212+ if ($ arg == '0 ' ) {
213+ self ::notice ($ msg );
256214 } else {
257- $ msg = "PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled. \n" ;
258- if ($ arg == '0 ' ) {
259- self ::notice ($ msg );
260- } else {
261- self ::error ($ msg );
262- }
215+ self ::error ($ msg );
263216 }
264217 return null ;
265218 }
@@ -454,9 +407,7 @@ class PharCommand extends CLICommand
454407 {
455408 return "Pack files into a PHAR archive. \n" .
456409 "When using -s <stub>, then the stub file is being " .
457- "excluded from the list of input files/dirs. " .
458- "To create an archive that contains PEAR class PHP_Archive " .
459- "then point -p argument to PHP/Archive.php. \n" ;
410+ "excluded from the list of input files/dirs. \n" ;
460411 }
461412 // }}}
462413 // {{{ static function cli_cmd_arg_pack
@@ -483,7 +434,7 @@ class PharCommand extends CLICommand
483434 /**
484435 * Set the stub
485436 */
486- public function phar_set_stub_begin (Phar $ phar , $ stub , $ loader = NULL , $ hashbang = NULL )
437+ public function phar_set_stub_begin (Phar $ phar , $ stub , $ hashbang = NULL )
487438 {
488439 if (isset ($ stub )) {
489440 $ c = file_get_contents ($ stub );
@@ -512,46 +463,12 @@ class PharCommand extends CLICommand
512463 } else {
513464 $ hashbang = "" ;
514465 }
515-
516- if (isset ($ loader )) {
517- $ s = "<?php if (!class_exists('PHP_Archive')) { \n?> " ;
518- if (is_file ($ loader )) {
519- $ s .= file_get_contents ($ loader );
520- }
521- $ s .= "<?php \n" ;
522- $ s .= "} \n" ;
523- $ s .= "if (!in_array('phar', stream_get_wrappers())) { \n" ;
524- $ s .= "\tstream_wrapper_register('phar', 'PHP_Archive'); \n" ;
525- $ s .= "} \n" ;
526- $ s .= "if (!class_exists('Phar',0)) { \n" ;
527- $ s .= "\tinclude 'phar://'.__FILE__.'/phar.inc'; \n" ;
528- $ s .= "} \n" ;
529- $ s .= '?> ' ;
530- $ s .= $ c ;
531-
532- $ phar ->setStub ($ hashbang . $ s );
533- } else {
534466 $ phar ->setStub ($ hashbang . $ c );
535- }
536467 return new SplFileInfo ($ stub );
537468 }
538469 return NULL ;
539470 }
540471 // }}}
541- // {{{ function phar_set_stub_end
542- /**
543- * Set stub end
544- */
545- public function phar_set_stub_end (Phar $ phar , $ stub , $ loader = NULL )
546- {
547- if (isset ($ stub ) && isset ($ loader )) {
548- if (substr (__FILE__ , -15 ) == 'pharcommand.inc ' ) {
549- self ::phar_add_file ($ phar , 0 , 'phar.inc ' , 'phar:// ' .__FILE__ .'/phar.inc ' , NULL );
550- } else {
551- self ::phar_add_file ($ phar , 0 , 'phar.inc ' , dirname (__FILE__ ).'/phar/phar.inc ' , NULL );
552- }
553- }
554- }
555472 // }}}
556473 // {{{ function cli_cmd_run_pack
557474 /**
@@ -578,7 +495,6 @@ class PharCommand extends CLICommand
578495 $ privkey = $ this ->args ['y ' ]['val ' ] ?? null ;
579496 $ regex = $ this ->args ['i ' ]['val ' ];
580497 $ level = $ this ->args ['l ' ]['val ' ];
581- $ loader = $ this ->args ['p ' ]['val ' ];
582498 $ stub = $ this ->args ['s ' ]['val ' ];
583499 $ invregex = $ this ->args ['x ' ]['val ' ];
584500 $ input = $ this ->args ['' ]['val ' ];
@@ -599,8 +515,6 @@ class PharCommand extends CLICommand
599515 }
600516 }
601517
602- $ this ->phar_set_stub_end ($ phar , $ stub , $ loader );
603-
604518 switch ($ this ->args ['c ' ]['val ' ]) {
605519 case 'gz ' :
606520 case 'gzip ' :
@@ -685,9 +599,9 @@ class PharCommand extends CLICommand
685599 $ entry = substr ($ entry , $ p +1 );
686600 }
687601
688- if ($ noloader && $ entry == 'phar.inc ' ) {
689- return ;
690- }
602+ if ($ noloader && $ entry == 'phar.inc ' ) {
603+ return ;
604+ }
691605
692606 echo "$ entry \n" ;
693607
@@ -1063,10 +977,8 @@ class PharCommand extends CLICommand
1063977 $ hashbang = $ this ->args ['b ' ]['val ' ];
1064978 $ phar = $ this ->args ['f ' ]['val ' ];
1065979 $ stub = $ this ->args ['s ' ]['val ' ];
1066- $ loader = $ this ->args ['p ' ]['val ' ];
1067980
1068- $ this ->phar_set_stub_begin ($ phar , $ stub , $ loader , $ hashbang );
1069- $ this ->phar_set_stub_end ($ phar , $ stub , $ loader );
981+ $ this ->phar_set_stub_begin ($ phar , $ stub , $ hashbang );
1070982 }
1071983 // }}}
1072984 // {{{ public function cli_cmd_inf_stub_get
0 commit comments