php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #69026 conflict between documentation and behaviour on finally
Submitted: 2015-02-11 09:41 UTC Modified: 2015-02-19 23:53 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: nicolas dot sitbon at gmail dot com Assigned: aharvey (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: all
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: nicolas dot sitbon at gmail dot com
New email:
PHP Version: OS:

 

 [2015-02-11 09:41 UTC] nicolas dot sitbon at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/language.exceptions
---
Quoting the manual: 
- "Each try must have at least one corresponding catch block"
- "a finally block may also be specified after the catch blocks"

so the manual states that each try block must have at least one catch block.
But the implementation currently allows the omission of the catch block if there is a finally block.

<?php 
try {
    echo 'in try';
} finally {
   echo 'in finally';
}

is perfectly valid on all versions of PHP > 5.5 and on HHVM.
Can we rely on this behaviour or we should trust the manual ?


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-02-15 02:42 UTC] cmbecker69 at gmx dot de
According to the language specification[1]:

| try-statement:
|   try  compound-statement   catch-clauses
|   try  compound-statement   finally-clause
|   try  compound-statement   catch-clauses   finally-clause

[1] <https://github.com/php/php-langspec/blob/master/spec/11-statements.md#the-try-statement>
 [2015-02-15 12:31 UTC] nicolas dot sitbon at gmail dot com
Thanks for your comment
the specification is in WIP state so I don't know if the manual is incorrect or the specification.
 [2015-02-19 23:52 UTC] aharvey@php.net
Automatic comment from SVN on behalf of aharvey
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=335965
Log: Clarify when a catch block is required in conjunction with finally.

I've added entities for throw, try, catch and finally so that they can be more
easily used and linked to the right sections. This has resulted in a
considerable amount of code churn in exceptions.xml, as everything is now in a
simplesect or sect1 (and the sect1 had to be moved ahead of the simplesects,
which has no impact on formatting, but is required for the document to be
well-formed).

Fixes doc bug #69026 (conflict between documentation and behaviour on finally).
 [2015-02-19 23:53 UTC] aharvey@php.net
The manual was incorrect, which is my fault: I didn't update the exceptions page thoroughly enough for that case when I added documentation for finally.

Fixed in SVN. Thanks for the report!
 [2015-02-19 23:53 UTC] aharvey@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: aharvey
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 13:00:02 2026 UTC