药占比什么意思| 梦到吃蛇肉预示着什么| 油烟机没有吸力是什么原因| 蔻驰和古驰有什么区别| 胃发胀是什么原因| 5月15日是什么星座| 吃什么补气补血最见效| 1993年属鸡是什么命| 吃什么降尿酸最有效食物| 乐不思蜀什么意思| 福寿螺有什么寄生虫| 总是心慌是什么原因| 眼睛经常充血是什么原因引起的| 闺蜜是什么样的关系| 十月一日是什么星座| 献出什么| 捡肥皂什么意思| 11楼五行属什么| 古代新疆叫什么| 2月25日什么星座| 农历六月十七是什么星座| 2003年的羊是什么命| 肝肾阴虚是什么原因引起的| 下焦湿热阴囊潮湿吃什么药| 头昏吃什么药效果最好| 犹太人为什么聪明| 咽拭子是检查什么的| 手术室为什么在三楼| 驳斥是什么意思| 死后是什么感觉| 什么是黑户| 文雅什么意思| 燕子进屋来有什么兆头| 吃什么降三高最好| 什么动物最厉害| 千娇百媚是什么意思| 炖排骨汤放什么调料| 疝气是什么意思| 0tc是什么意思| 脑梗是什么引起的| 果酱样大便见于什么病| 燃气泄露是什么味道| 调和油是什么意思| 夷是什么意思| 米西米西是什么意思| 湿疹是什么病| 济南为什么叫泉城| 祛湿气喝什么茶| 乳房发烫胀痛什么原因| 女性hpv阳性是什么意思| 咋啦是什么意思| 男人喜欢什么罩杯| 梦见枕头是什么意思| 束手无策是什么意思| 心服口服的意思是什么| 绝什么意思| 五大仙家什么仙最厉害| 观音菩萨原名叫什么名| 暮春是什么时候| 什么什么千山| 月亮发红是什么原因| 一念之间什么意思| 台阶是什么意思| 胆结石是什么原因导致的| 幽门螺旋杆菌什么症状| 为什么润月| 护手霜什么牌子的效果好| 5月25号是什么星座| 奥氮平片治疗什么病| 弯刀裤适合什么人穿| 胃溃疡是什么原因导致的| 血压低头晕吃什么药| 排骨炖什么汤好喝| 睡觉被憋醒是什么原因| 粘假牙用什么胶| 解离是什么意思| 梦见卖衣服是什么意思| 邂逅什么意思| 真实写照的意思是什么| 霍启刚家族做什么生意| zeiss是什么意思| 乡和镇有什么区别| 梳子断了有什么预兆| 一个歹一个殇读什么| 张良和刘邦是什么关系| 排便困难拉不出来是什么原因| 打耳洞医院挂什么科| 小孩肚子疼吃什么药好| 牙龈肿是什么原因引起的| 成都人民公园有什么好玩的| 血小板比积偏高是什么意思| 吃什么可以止咳化痰| 什么是执念| 什么叫刑事拘留| 阑尾炎是什么原因引起的| 忧郁什么意思| 舐犊是什么意思| vogue什么意思| 高锰酸钾在药店叫什么| 七年是什么婚| 5月5日什么星座| 泛滥成灾是什么意思| 金字是什么部首| 乳腺增生吃什么好| 什么运动可以长高| lsa是什么意思| 长颈鹿吃什么树叶| 乾隆和康熙是什么关系| 什么原因引起痛风| 祖坟冒青烟是什么意思| 鼻干眼干口干属于什么症状| 最聪明的动物是什么| 丝瓜络是什么| 妊娠线什么时候长| 吃什么有助睡眠| 猩红热是什么病| 淋巴细胞百分比低是什么意思| 纳豆是什么豆| 什么样的女人容易出轨| 地图舌吃什么好得快| 女人肝胆湿热吃什么药| 水瓶座和什么座最配| 小人难防前一句是什么| 佟丽娅为什么离婚| 脖子上长痘痘是什么原因| 626什么意思| 豆腐和什么不能一起吃| 廿是什么意思| kobe是什么意思| 李亚男为什么选王祖蓝| 龙葵是什么| 女人颧骨高有什么说法| 脸上长疙瘩是什么原因| 女人湿气重吃什么药效果好| 牙出血是什么病的前兆| 小辣椒是什么意思| 小孩发烧可以吃什么水果| 艾灸是什么| 孕妇多吃什么食物好| 身上起痘痘是什么原因| 云南白药气雾剂保险液有什么作用| 宫颈炎盆腔炎吃什么药效果最好| 黄瓜是什么科| 心火旺吃什么药效果最好| 决明子是什么| 出去玩带什么| 什么水果败火| 脉弦滑是什么意思| a型和o型生的孩子是什么血型| 金牛座和什么星座最配| n代表什么| 世界第一大河是什么河| 孕妇缺营养吃什么补| 丹字五行属什么| 经期吃什么让血量增加| 风湿性关节炎用什么药| biubiubiu是什么意思| 知了在树上干什么| 灰棕色是什么颜色| 瓜田李下什么意思| 五行缺金是什么意思| 肌张力障碍是什么病| 预防医学是干什么的| em什么意思| 于无声处是什么意思| 电饭煲煮粥为什么会溢出来| 草字头加叔念什么| 维生素e吃多了有什么副作用| 坐东朝西是什么意思| 梅毒和艾滋病有什么区别| 腾空是什么意思| 货号是什么| logo是什么| 五心烦热失眠手脚心发热吃什么药| 多囊是什么病| 一个月一个太念什么| 历程是什么意思| 空调综合征有什么症状| 慢性胃炎能吃什么水果| 天天都需要你爱是什么歌| nt和唐筛有什么区别| 台卡是什么| 眼球突出是什么原因| 叶黄素什么时间吃最好| 蜗牛什么梗| 紫色属于五行属什么| 咳嗽能吃什么水果| 高温丝假发是什么材质| 鲤鱼最爱吃什么食物| 买手店是什么意思| 百合有什么功效和作用| 云的五行属性是什么| 宿主是什么意思| 维生素c十一什么意思| 虚有其表的意思是什么| 去美容院洗脸有什么好处| 女性备孕吃什么养卵泡| 浆水是什么| 飞机杯什么意思| 处暑吃什么| but什么意思| 学生近视配什么镜片好| 法图麦在回族什么意思| 芸字五行属什么| 新生儿便秘怎么办什么方法最有效| 拐子是什么鱼| 土生土长是什么生肖| 待字闺中什么意思| 香菇炒什么菜好吃| 什么食物增加血管弹性| 充电宝100wh是什么意思| 胎心胎芽是什么意思| 青灰色是什么颜色| 十月初一是什么节| 什么叫活检| 八0年属什么生肖| 眼睛总有眼屎是什么原因| 女性尿路感染吃什么药| 丨是什么意思| 屁股疼挂什么科| 收官是什么意思| 善字五行属什么| 毛拉是什么意思| 下巴长硬包是什么原因| 跪乳的动物是什么生肖| 外阴裂口什么原因| 湿热便秘吃什么中成药| 疝气有什么症状| 龟龟是什么意思| 耳堵耳闷是什么原因| 开门见什么最吉利| 什么是pc| mlb是什么档次| 心律不齐吃什么药效果好| 清宫和刮宫有什么区别| 烟酰胺有什么作用| 青榄配什么煲汤止咳做法| 生吃苦瓜有什么好处和坏处| soho是什么意思| 补体c1q偏高说明什么| 奥美拉唑与雷贝拉唑有什么区别| 百什么争鸣成语| 旅游需要带什么东西| 低密度脂蛋白胆固醇高吃什么药| 免疫力低吃什么好| 小孩肚脐眼上面疼是什么原因| 121是什么意思| 蔻依属于什么档次| 拔了牙吃什么消炎药| 党内警告处分有什么影响| 狂鸟读什么| 女性胃炎有什么症状| 熳是什么意思| 7个月的宝宝吃什么辅食| 孕吐严重是什么原因| 女士内裤用什么洗最好| 腊肠和什么菜炒最佳| 2月11日什么星座| 上海话小赤佬是什么意思| 二月十八是什么星座| 冷暖自知上一句是什么| 生日送什么礼物最好| 结核t细胞阳性说明什么| 吲达帕胺片是什么药| 百度
rfc:arithmetic_operator_type_checks

什么的果实

Introduction

百度 其实思考前面例子中提到的问题,其实就是潜在地帮助老板解决问题,你习惯性地多帮上级想一步,上级就能腾出一些时间和心思来思考怎样培养你跳一级。

This RFC proposes to throw a TypeError when an arithmetic or bitwise operator is applied to an array, resource or (non-overloaded) object. The behavior of scalar operands (like null) remains unchanged

I think we can all agree that this is not reasonable behavior:

var_dump([] % [42]);
// int(0)
// WTF?

Let's fix it.

Proposal

Current Behavior

This section describes the current behavior, limited only to the cases where one operand is an array, resource or object. The object cases always assume that no operator or cast overloading is involved. If operator/cast overloading is used, then those overloads apply.

Operators +, -, *, /, **:

  • Throw Error exception on array operand. (Excluding + if both operands are array.)
  • Silently convert a resource operand to the resource ID as an integer.
  • Convert an object operand to integer one, while throwing a notice.

Operators %, <<, >>, &, |, ^:

  • Silently convert an array operand to integer zero if empty or integer one if non-empty.
  • Silently convert a resource operand to the resource ID as an integer.
  • Convert an object operand to integer one, while throwing a notice.

Operator ~:

  • Throw an Error exception for array, resource and object operands.

Operators ++ and --:

  • Silently do nothing if the operand is an array, resource or object.

Proposed Behavior

The proposed behavior is the same for all the arithmetic/bitwise operators +, -, *, /, **, %, <<, >>, &, |, ^, ~, ++, --:

  • Throw a TypeError exception for array, resource and object operands.

Of course, the case of addition with two array operands remains legal.

Unchanged Behavior

The behavior of operands of type null, bool, int, float and string remains the same.

While it is questionable whether true / 17 really is a sensible operation, the handling of scalar values in general can likely not be changed unconditionally, and as such is left to a proposal like the strict operators directive.

The changes proposed here are intended to be entirely uncontroversial.

Backward Incompatible Changes

Using an array, resource or object in an arithmetic/bitwise operation will now consistently throw, while it previously produced a non-sensical value.

Future Scope

In the future, we may wish to go one step further:

  • Make non-numeric string operands throwing. Non-numeric here means not starting with a digit (optionally preceded by whitespace). This would not apply to operators that have special behavior for strings (string increment and bitwise and/or/xor).
  • Make overflowing float values throwing for operators that expect an integer (%, <<, >>, &, |, ^).

This would have the advantage of aligning the semantics with parameter type checks in coercive mode, for the types int and int|float depending on operator. The only discrepancy would be in the handling of null, which is already not as strictly enforced.

I'm leaving this potential improvement out of this RFC, because it requires more consideration regarding backwards compatibility and overall language integration.

Vote

Voting started 2025-08-07 and ends 2025-08-07.

Add stricter type checks for arithmetic/bitwise operators?
Real name yes no
ajf (ajf)  
alcaeus (alcaeus)  
asgrim (asgrim)  
ashnazg (ashnazg)  
brzuchal (brzuchal)  
bwoebi (bwoebi)  
carusogabriel (carusogabriel)  
cmb (cmb)  
colinodell (colinodell)  
daverandom (daverandom)  
derick (derick)  
dmitry (dmitry)  
duncan3dc (duncan3dc)  
duodraco (duodraco)  
ekin (ekin)  
galvao (galvao)  
gasolwu (gasolwu)  
girgias (girgias)  
jasny (jasny)  
jbnahan (jbnahan)  
jhdxr (jhdxr)  
jmcastagnetto (jmcastagnetto)  
kelunik (kelunik)  
kguest (kguest)  
klaussilveira (klaussilveira)  
kocsismate (kocsismate)  
lcobucci (lcobucci)  
malukenho (malukenho)  
marandall (marandall)  
marcio (marcio)  
mariano (mariano)  
mbeccati (mbeccati)  
mcmic (mcmic)  
mike (mike)  
narf (narf)  
nicolasgrekas (nicolasgrekas)  
nikic (nikic)  
ocramius (ocramius)  
petk (petk)  
pmmaga (pmmaga)  
pollita (pollita)  
rasmus (rasmus)  
reywob (reywob)  
royopa (royopa)  
ruudboon (ruudboon)  
salathe (salathe)  
sammyk (sammyk)  
sebastian (sebastian)  
sergey (sergey)  
sirsnyder (sirsnyder)  
stas (stas)  
svpernova09 (svpernova09)  
tandre (tandre)  
trowski (trowski)  
wyrihaximus (wyrihaximus)  
yunosh (yunosh)  
zimt (zimt)  
Final result: 57 0
This poll has been closed.
rfc/arithmetic_operator_type_checks.txt · Last modified: by 127.0.0.1

?
叫床是什么意思 三只手是什么意思 什么叫丁克 鞑虏是什么意思 梅毒是什么症状图片
夏天适合喝什么茶 小鸟进屋有什么预兆吗 手比脸白是什么原因 县长是什么级别 枸杞不能和什么一起吃
头痛看什么科 什么止咳最好 茹字五行属什么 属狗男和什么属相最配 打擦边球是什么意思
胃ca是什么意思 为什么口臭 人的脾脏起什么作用 四个鱼念什么 孕妇贫血吃什么药
二月初二是什么星座hcv9jop2ns5r.cn 憋尿有什么危害hcv7jop7ns2r.cn 手足口病是什么症状hcv9jop6ns7r.cn 哈密瓜什么时候成熟hcv9jop4ns1r.cn 妊高症是什么意思hcv7jop9ns2r.cn
hpv疫苗是什么hcv8jop6ns9r.cn 白玫瑰花语是什么意思gangsutong.com 大便有酸味是什么原因hcv9jop1ns6r.cn 木字旁加差是什么字hcv7jop4ns6r.cn 1943年属什么生肖hcv9jop7ns3r.cn
走马观花是什么生肖hcv7jop4ns6r.cn 同房有点痛什么原因hcv8jop9ns2r.cn 早上起床口苦口干是什么原因hcv7jop6ns5r.cn 什么时hcv7jop9ns9r.cn 纹理是什么意思inbungee.com
列席人员什么意思jinxinzhichuang.com 血管狭窄吃什么药hcv8jop3ns5r.cn 廉租房和公租房有什么区别hcv8jop2ns3r.cn cd是什么牌子hcv8jop0ns2r.cn 早上吃什么减肥hcv8jop7ns7r.cn
百度