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
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: 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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 07:01:33 2025 UTC