[DOC-CVS] [doc-en] master: Document privateKey parameter in PharData::setSignatureAlgorithm (#5229)

[email protected] (Louis-Arnaud via GitHub)
Newsgroups php.doc.cvs
Message-ID <[email protected]>
Author: Louis-Arnaud (lacatoire)
Committer: GitHub (web-flow)
Pusher: lacatoire
Date: 2026-08-26T17:46:28+02:00

Commit: https://github.com/php/doc-en/commit/2cbc37d710751c33862709e622d0e928c9015c45
Raw diff: https://github.com/php/doc-en/commit/2cbc37d710751c33862709e622d0e928c9015c45.diff

Document privateKey parameter in PharData::setSignatureAlgorithm (#5229)

* Document privateKey parameter in PharData::setSignatureAlgorithm

The privateKey parameter was present in the method signature but
missing from the parameters documentation section.

Fixes https://github.com/php/doc-en/issues/3019

* Phar/PharData::setSignatureAlgorithm: make the OPENSSL example runnable

The example called $p->setSignatureAlgorithm() on a variable that was
never defined. Instantiate the archive first, on both pages, so the
snippet runs as written.

Changed paths:
  M  reference/phar/Phar/setSignatureAlgorithm.xml
  M  reference/phar/PharData/setSignatureAlgorithm.xml


Diff:

diff --git a/reference/phar/Phar/setSignatureAlgorithm.xml b/reference/phar/Phar/setSignatureAlgorithm.xml
index 5e97bb2b8aab..d92187c6d3fe 100644
--- a/reference/phar/Phar/setSignatureAlgorithm.xml
+++ b/reference/phar/Phar/setSignatureAlgorithm.xml
@@ -53,6 +53,7 @@
        <programlisting role="php">
         <![CDATA[
 <?php
+$p = new Phar('archive.phar');
 $private = openssl_get_privatekey(file_get_contents('private.pem'));
 $pkey = '';
 openssl_pkey_export($private, $pkey);
diff --git a/reference/phar/PharData/setSignatureAlgorithm.xml b/reference/phar/PharData/setSignatureAlgorithm.xml
index d99f3df368b1..b759b4b6e87c 100644
--- a/reference/phar/PharData/setSignatureAlgorithm.xml
+++ b/reference/phar/PharData/setSignatureAlgorithm.xml
@@ -37,6 +37,28 @@
       </para>
      </listitem>
     </varlistentry>
+    <varlistentry>
+     <term><parameter>privateKey</parameter></term>
+     <listitem>
+      <para>
+       The contents of an OpenSSL private key, as extracted from a certificate or
+       OpenSSL key file:
+       <programlisting role="php">
+        <![CDATA[
+<?php
+$p = new PharData('archive.tar');
+$private = openssl_get_privatekey(file_get_contents('private.pem'));
+$pkey = '';
+openssl_pkey_export($private, $pkey);
+$p->setSignatureAlgorithm(Phar::OPENSSL, $pkey);
+?>
+        ]]>
+       </programlisting>
+       See <link linkend="phar.using">phar introduction</link> for instructions on
+       naming and placement of the public key file.
+      </para>
+     </listitem>
+    </varlistentry>
    </variablelist>
   </para>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.