经过相当激烈的讨论,扯淡,漫长的拉锯竞争后PHP7终于接受了int float string等scalar variables的type hittings. https://wiki.php.net/rfc/scalar_type_hints_v5 , 不论我多不喜欢strict types,PHP7的几大核心变更总算都已经尘埃落定了,特性冻结期也开始了。
转自鸟哥微博
转自鸟哥微博
|
1
然后应该跟一句:php依旧是最好的语言..?
|
|
66betaMar 17, 2015
2
这样下去,PHP8会不会变成Go呀
|
|
kslrMar 17, 2015
3
支持强类型。
|
|
haiyang416Mar 17, 2015
4
declare 又加新参数了
|
|
zkd8907Mar 17, 2015
5
已然不是世界上最好的语言
|
|
mahone3297Mar 17, 2015
6
支持强类型~
|
|
kisshereMar 17, 2015 via Android
7
完了,世界上最好的语言桂冠就这样没了,JavaScript才是世界上最好的语言
|
|
zts1993Mar 17, 2015
8
这样做还会向前兼容么
|
|
otakustayMar 17, 2015
9
ES strawman也准备上强类型了,大势所趋啊,随着系统规模的提升,强类型优势也就慢慢出来了
|
|
zhengkaiMar 17, 2015
11
如果人多活杂,各种约束是应该有的,PHP 是工业语言,也就不应该是自由的语言。其实就是本来应该编码规范、静态检查该做的事情,强制放到语言特性里
PHP 从 5.4 就想上常规数据类型的(string、integer)的 type hinting,但一直被推迟,可见开发组对此真的很犹豫。我是支持加 type hinting 的,以我在不同公司的工作经历来看,地球上绝大部分 php 代码都是如此的不堪入目 |
|
mcfogMar 17, 2015
12
5.4 5.5都推不开来,度娘上满是php4教程php5.1教程,PHPNG什么的只能先看着馋着了ˊ_>ˋ
|
|
msxcmsMar 17, 2015
13
不是强制的强类型
|
|
wdlthMar 17, 2015
14
这不是变成HACK了么……
|
|
youngMar 17, 2015
15
都是跑分惹的祸啊
|
|
reusForkMar 17, 2015
16
type hinting早就有了,只是之前只能用接口或者trait做,scalar type不能用。
这只不过让scalar type也能用于hinting而已,算不上什么大事。 hinting和强类型也是两个概念。 |
|
publicID001Mar 17, 2015
17
为了无缝转换成C++从而进一步编译为exe吧。
|
|
rainciousMar 17, 2015
18
|
|
xuwenmangMar 17, 2015
19
被facebook的hacklang逼的。。。
|
|
justfinduMar 17, 2015
20
不复制后面一段么...强类型是不默认开启, 以后也是不默认开启...
|
|
inviteMar 17, 2015
21
然后PHP就不是PHP了,被一帮人搞的越来越 "高大上" 了。
|
|
szopenMar 17, 2015
22
无语了,这叫类型提示,什么强类型
|
|
jookieMar 17, 2015
23
只用PHP52
|
|
br00kMar 17, 2015
24
确定这叫强类型?逗b了
|
|
yangffMar 17, 2015 via Android
25
This RFC further proposes the addition of a new optional per-file directive, declare(strict_types=1);, which makes all function calls and return statements within a file have “strict” type-checking for scalar type declarations, including for extension and built-in PHP functions.
Balabala...... 然后是... Behaviour of strict type checks A strictly type-checked call to an extension or built-in PHP function changes the behaviour of zend_parse_parameters. In particular, it will produce E_RECOVERABLE_ERROR rather than E_WARNING on failure, and it follows strict type checking rules for scalar typed parameters, rather than the traditional weak type checking rules. The strict type checking rules are quite straightforward: when the type of the value matches that specified by the type declaration it is accepted, otherwise it is not. These strict type checking rules are used for userland scalar type declarations, and for extension and built-in PHP functions. The one exception is that widening primitive conversion is allowed for int to float. This means that parameters that declare float can also accept int. @szopen @br00k JavaScript或成最大赢家 |
|
xuwenmangMar 18, 2015
26
|
|
xwsoulMar 18, 2015
27
我本身是不反对类型声明的, 毕竟没有定义类型的年代, 也注意到了返回类型的统一以及注释中类型的标注.
但是非要在代码头部加个 declare ... 感觉好恶劣啊, 如果使用第三方库 会受到 declare 影响么? 我...我...我还是去看Java吧... |
|
kn007Mar 18, 2015
28
要这个功能干嘛,,,
|
|
jokerzhApr 1, 2015
30
终于找到中文翻译了
http://www.lofter.com/tag/php7 |