Skip to content

Commit

Permalink
Fixed syntax errors in more examples
Browse files Browse the repository at this point in the history
  • Loading branch information
derickr committed Feb 7, 2025
1 parent 7541512 commit 2258375
Show file tree
Hide file tree
Showing 20 changed files with 116 additions and 91 deletions.
2 changes: 1 addition & 1 deletion appendices/filters.xml
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ fclose($fp);
//decrypt...
$fp = fopen('encrypted-file.enc', 'rb');
$iv = fread($fp, $iv_size = mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_CBC));
$opts = array('mode'=>'cbc','iv'=>$iv, 'key'=>$key)
$opts = array('mode'=>'cbc','iv'=>$iv, 'key'=>$key);
stream_filter_append($fp, 'mdecrypt.blowfish', STREAM_FILTER_READ, $opts);
$data = rtrim(stream_get_contents($fp));//trims off null padding
fclose($fp);
Expand Down
4 changes: 2 additions & 2 deletions appendices/migration70/incompatible/error-handling.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@
<![CDATA[
<?php
// PHP 5 era code that will break.
function handler(Exception $e) { ... }
function handler(Exception $e) { /* ... */ }
set_exception_handler('handler');
// PHP 5 and 7 compatible.
function handler($e) { ... }
// PHP 7 only.
function handler(Throwable $e) { ... }
function handler(Throwable $e) { /* ... */ }
?>
]]>
</programlisting>
Expand Down
14 changes: 9 additions & 5 deletions appendices/migration74/new-features.xml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ $fruits = ['banana', 'orange', ...$parts, 'watermelon'];
</informalexample>
</para>
</sect3>

<sect3 xml:id="migration74.new-features.core.weakreference">
<title>Weak references</title>

Expand All @@ -162,7 +162,7 @@ $fruits = ['banana', 'orange', ...$parts, 'watermelon'];

<sect2 xml:id="migration74.new-features.curl">
<title>CURL</title>

<para>
<classname>CURLFile</classname> now supports stream wrappers in addition
to plain file names, if the extension has been built against libcurl &gt;= 7.56.0.
Expand All @@ -171,7 +171,7 @@ $fruits = ['banana', 'orange', ...$parts, 'watermelon'];

<sect2 xml:id="migration74.new-features.filter">
<title>Filter</title>

<para>
The <constant>FILTER_VALIDATE_FLOAT</constant> filter now supports the
<literal>min_range</literal> and <literal>max_range</literal>
Expand Down Expand Up @@ -314,10 +314,14 @@ $fruits = ['banana', 'orange', ...$parts, 'watermelon'];
<![CDATA[
<?php
// Returns array containing all the necessary state of the object.
public function __serialize(): array;
public function __serialize(): array
{
}
// Restores the object state from the given data array.
public function __unserialize(array $data): void;
public function __unserialize(array $data): void
{
}
?>
]]>
</programlisting>
Expand Down
2 changes: 1 addition & 1 deletion appendices/migration84/new-features.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class Example
$initializer = static function (Example $ghost): void {
// Fetch data or dependencies
$data = ...;
$data = getData();
// Initialize
$ghost->__construct($data);
};
Expand Down
2 changes: 1 addition & 1 deletion language/control-structures/alternative-syntax.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ endif;
<![CDATA[
<?php switch ($foo): ?>
<?php case 1: ?>
...
// ...
<?php endswitch; ?>
]]>
</programlisting>
Expand Down
8 changes: 7 additions & 1 deletion language/control-structures/elseif.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,14 @@ if ($a > $b):
else if ($a == $b): // Will not compile.
echo "The above line causes a parse error.";
endif;
]]>
</programlisting>
</informalexample>

<informalexample>
<programlisting role="php">
<![CDATA[
<?php
/* Correct Method: */
if ($a > $b):
echo $a." is greater than ".$b;
Expand Down
4 changes: 2 additions & 2 deletions language/control-structures/match.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ string(8) "Teenager"
<![CDATA[
<?php
$result = match ($x) {
foo() => ...,
$this->bar() => ..., // $this->bar() isn't called if foo() === $x
foo() => 'value',
$this->bar() => 'value', // $this->bar() isn't called if foo() === $x
$this->baz => beep(), // beep() isn't called unless $x === $this->baz
// etc.
};
Expand Down
2 changes: 1 addition & 1 deletion language/oop5/autoload.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Fatal error: Interface 'ITest' not found in ...
<?php
require __DIR__ . '/vendor/autoload.php';
$uuid = new Ramsey\Uuid\Uuid::uuid7();
$uuid = Ramsey\Uuid\Uuid::uuid7();
echo "Generated new UUID -> ", $uuid->toString(), "\n";
?>
Expand Down
Loading

0 comments on commit 2258375

Please sign in to comment.