Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix refpurpose of PharData::copy(), amend the code examples and replace wrong output in the Phar::copy() #4229

Merged
merged 4 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions reference/phar/Phar/copy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,23 @@
<programlisting role="php">
<![CDATA[
<?php

try {
$phar = new Phar('myphar.phar');

$phar['a'] = 'hi';
$phar->copy('a', 'b');
echo $phar['b']; // outputs "hi"

echo $phar['b']; // Outputs "phar://myphar.phar/b"
} catch (Exception $e) {
// handle error
// Handle error
}

// the stream wrapper equivalent of the above code.
// E_WARNINGS are triggered on error rather than exceptions.
// The stream wrapper equivalent of the above code.
// E_WARNING are triggered on error rather than exceptions
copy('phar://myphar.phar/a', 'phar//myphar.phar/c');
echo file_get_contents('phar://myphar.phar/c'); // outputs "hi"
echo file_get_contents('phar://myphar.phar/c'); // Outputs "hi"

?>
]]>
</programlisting>
Expand Down
16 changes: 10 additions & 6 deletions reference/phar/PharData/copy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<refentry xml:id="phardata.copy" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>PharData::copy</refname>
<refpurpose>Copy a file internal to the phar archive to another new file within the phar</refpurpose>
<refpurpose>Copy a file internal to the tar/zip archive to another new file within the same archive</refpurpose>
</refnamediv>

<refsect1 role="description">
Expand Down Expand Up @@ -74,19 +74,23 @@
<programlisting role="php">
<![CDATA[
<?php

try {
$phar = new PharData('myphar.tar');

$phar['a'] = 'hi';
$phar->copy('a', 'b');
echo $phar['b']; // outputs "phar://myphar.tar/b"

echo $phar['b']; // Outputs "phar://myphar.tar/b"
} catch (Exception $e) {
// handle error
// Handle error
}

// the stream wrapper equivalent of the above code.
// E_WARNINGS are triggered on error rather than exceptions.
// The stream wrapper equivalent of the above code.
// E_WARNING are triggered on error rather than exceptions
copy('phar://myphar.tar/a', 'phar//myphar.tar/c');
echo file_get_contents('phar://myphar.tar/c'); // outputs "hi"
echo file_get_contents('phar://myphar.tar/c'); // Outputs "hi"

?>
]]>
</programlisting>
Expand Down
Loading