Bug #79380 [NEW]: define() function not working with typecasting

From: Date: Fri, 13 Mar 2020 13:29:43 +0000
Subject: Bug #79380 [NEW]: define() function not working with typecasting
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-226089@lists.php.net to get a copy of this message
From:             amit000790 at gmail dot com
Operating system: Ubuntu 18.04
PHP version:      7.4.3
Package:          Unknown/Other Function
Bug Type:         Bug
Bug description:define() function not working with typecasting

Description:
------------
define() function not working with typecasting

For Ex.
define("BLANK_OBJECT", (object) [] );

var_dump( BLANK_OBJECT );

---------------
Output
---------------
Warning: Constants may only evaluate to scalar values, arrays or
resources in [...][...] on line 4

Warning: Use of undefined constant BLANK_OBJECT - assumed 'BLANK_OBJECT'
(this will throw an Error in a future version of PHP) in [...][...] on
line 6
string(12) "BLANK_OBJECT"

Test script:
---------------
define("BLANK_OBJECT", (object) [] );
var_dump( BLANK_OBJECT );

Expected result:
----------------
stdClass Object
(
)

Actual result:
--------------
Warning: Constants may only evaluate to scalar values, arrays or
resources in [...][...] on line 4

Warning: Use of undefined constant BLANK_OBJECT - assumed 'BLANK_OBJECT'
(this will throw an Error in a future version of PHP) in [...][...] on
line 6
string(12) "BLANK_OBJECT"

-- 
Edit bug report at https://bugs.php.net/bug.php?id=79380&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=79380&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=79380&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=79380&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=79380&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=79380&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=79380&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=79380&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=79380&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=79380&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=79380&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79380&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=79380&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=79380&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=79380&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=79380&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=79380&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=79380&r=mysqlcfg


Thread (2 messages)

« previous php.bugs (#226089) next »