php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52401 throw construct invalid within conditional
Submitted: 2010-07-22 12:17 UTC Modified: 2010-07-23 11:37 UTC
From: andrew at ajohnstone dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.3.2 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: andrew at ajohnstone dot com
New email:
PHP Version: OS:

 

 [2010-07-22 12:17 UTC] andrew at ajohnstone dot com
Description:
------------
The following is a valid:

(!array_key_exists($class, $this->_data)) AND new InvalidArgumentException("Class does not exist");

However the following is not:

(!array_key_exists($class, $this->_data)) AND throw new InvalidArgumentException("Class does not exist");

Test script:
---------------
(!array_key_exists($class, $this->_data)) AND throw new InvalidArgumentException("Class does not exist");

Expected result:
----------------
No syntax error

Actual result:
--------------
Parse error: syntax error, unexpected

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-07-23 11:37 UTC] aharvey@php.net
-Status: Open +Status: Bogus
 [2010-07-23 11:37 UTC] aharvey@php.net
By design; you can only use an expression in that context, not a
statement or control structure. Note that return wouldn't work there
either.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 10:01:28 2024 UTC