|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-11-25 17:17 UTC] nikic@php.net
-Type: Bug
+Type: Feature/Change Request
-Package: PHP Language Specification
+Package: Scripting Engine problem
[2016-11-25 17:17 UTC] nikic@php.net
[2016-11-25 17:57 UTC] stas@php.net
[2019-02-15 03:36 UTC] carusogabriel@php.net
-Summary: Excplicit type cast for class constants produces
error
+Summary: Explicit type cast for class constants produces error
[2021-10-26 13:30 UTC] cmb@php.net
[2021-10-27 09:14 UTC] anatoly dot pashin at gmail dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 05:00:02 2025 UTC |
Description: ------------ Interpreter produces `PHP Fatal error: Constant expression contains invalid operations in…` because of explicit const value type cast. But implicit is allowed and works as expected. Yes, I undestand difference between `+` and `(int)` that `int` will cast to integer and drop past-float part. But question why that's now allowed is still present. Casting plain value rather than array value doesn't work too. Even if you cast integer to integer. Test script: --------------- class Barcode { const BARCODE_TYPES = [ (int)\Stickers::BARCODE_TYPE_MEGAORDER, +\Stickers::BARCODE_TYPE_SHOP_ORDER, ]; } Expected result: ---------------- All is OK and array value became int casted. Actual result: -------------- PHP Fatal error: Constant expression contains invalid operations in…