public function save($path, $signatureAlgo)
    {
        $pos = $this->determineSignatureBegin();

        $algos = array(
            \Phar::MD5 => 'md5',
            \Phar::SHA1 => 'sha1',
            \Phar::SHA256 => 'sha256',
            \Phar::SHA512 => 'sha512',
        );

        if (!isset($algos[$signatureAlgo])) {
            throw new \UnexpectedValueException('Invalid hash algorithm given: '.$signatureAlgo.' expected one of Phar::MD5, Phar::SHA1, Phar::SHA256 or Phar::SHA512');
        }
        $algo = $algos[$signatureAlgo];

        // re-sign phar
        //           signature
        $signature = hash($algo, substr($this->contents, 0, $pos), true)
            // sig type
            . pack('L', $signatureAlgo)
            // ohai Greg & Marcus
            . 'GBMB';

        $this->contents = substr($this->contents, 0, $pos) . $signature;

        return file_put_contents($path, $this->contents);
    }
public function save($path, $signatureAlgo)
    {
        $pos = $this->determineSignatureBegin();

        $algos = array(
            \Phar::MD5 => 'md5',
            \Phar::SHA1 => 'sha1',
            \Phar::SHA256 => 'sha256',
            \Phar::SHA512 => 'sha512',
        );

        if (!isset($algos[$signatureAlgo])) {
            throw new \UnexpectedValueException('Invalid hash algorithm given: '.$signatureAlgo.' expected one of Phar::MD5, Phar::SHA1, Phar::SHA256 or Phar::SHA512');
        }
        $algo = $algos[$signatureAlgo];

        // re-sign phar
        //           signature
        $signature = hash($algo, substr($this->contents, 0, $pos), true)
            // sig type
            . pack('L', $signatureAlgo)
            // ohai Greg & Marcus
            . 'GBMB';

        $this->contents = substr($this->contents, 0, $pos) . $signature;

        return file_put_contents($path, $this->contents);
    }
public function save ( $ path , $ signatureAlgo ) { $ pos = $ this -> determineSignatureBegin ( ) ; $ algos = array ( \ Phar :: MD5 => 'md5' , \ Phar :: SHA1 => 'sha1' , \ Phar :: SHA256 => 'sha256' , \ Phar :: SHA512 => 'sha512' , ) ; if ( ! isset ( $ algos [ $ signatureAlgo ] ) ) { throw new \ UnexpectedValueException ( 'Invalid hash algorithm given: ' . $ signatureAlgo . ' expected one of Phar::MD5, Phar::SHA1, Phar::SHA256 or Phar::SHA512' ) ; } $ algo = $ algos [ $ signatureAlgo ] ; // re-sign phar //           signature $ signature = hash ( $ algo , substr ( $ this -> contents , 0 , $ pos ) , true ) // sig type . pack ( 'L' , $ signatureAlgo ) // ohai Greg & Marcus . 'GBMB' ; $ this -> contents = substr ( $ this -> contents , 0 , $ pos ) . $ signature ; return file_put_contents ( $ path , $ this -> contents ) ; }
Saves the updated phar file, optionally with an updated signature.

@param  string $path
@param  int $signatureAlgo One of Phar::MD5, Phar::SHA1, Phar::SHA256 or Phar::SHA512
@return bool
Saves the updated phar file optionally with an updated signature .