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
 [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-2019 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 12:01:25 2019 UTC