经过相当激烈的讨论,扯淡,漫长的拉锯竞争后PHP7终于接受了int float string等scalar variables的type hittings. https://wiki.php.net/rfc/scalar_type_hints_v5 , 不论我多不喜欢strict types,PHP7的几大核心变更总算都已经尘埃落定了,特性冻结期也开始了。
转自鸟哥微博
转自鸟哥微博
1
582033 Mar 17, 2015 然后应该跟一句:php依旧是最好的语言..?
|
2
66beta Mar 17, 2015
这样下去,PHP8会不会变成Go呀
|
3
kslr Mar 17, 2015
支持强类型。
|
4
haiyang416 Mar 17, 2015
declare 又加新参数了
|
5
zkd8907 Mar 17, 2015
已然不是世界上最好的语言
|
6
mahone3297 Mar 17, 2015
支持强类型~
|
7
kisshere Mar 17, 2015 via Android
完了,世界上最好的语言桂冠就这样没了,JavaScript才是世界上最好的语言
|
8
zts1993 Mar 17, 2015
这样做还会向前兼容么
|
9
otakustay Mar 17, 2015
ES strawman也准备上强类型了,大势所趋啊,随着系统规模的提升,强类型优势也就慢慢出来了
|
11
zhengkai Mar 17, 2015
如果人多活杂,各种约束是应该有的,PHP 是工业语言,也就不应该是自由的语言。其实就是本来应该编码规范、静态检查该做的事情,强制放到语言特性里
PHP 从 5.4 就想上常规数据类型的(string、integer)的 type hinting,但一直被推迟,可见开发组对此真的很犹豫。我是支持加 type hinting 的,以我在不同公司的工作经历来看,地球上绝大部分 php 代码都是如此的不堪入目 |
12
mcfog Mar 17, 2015
5.4 5.5都推不开来,度娘上满是php4教程php5.1教程,PHPNG什么的只能先看着馋着了ˊ_>ˋ
|
13
msxcms Mar 17, 2015
不是强制的强类型
|
14
wdlth Mar 17, 2015
这不是变成HACK了么……
|
15
young Mar 17, 2015
都是跑分惹的祸啊
|
16
reusFork Mar 17, 2015
type hinting早就有了,只是之前只能用接口或者trait做,scalar type不能用。
这只不过让scalar type也能用于hinting而已,算不上什么大事。 hinting和强类型也是两个概念。 |
17
publicID001 Mar 17, 2015
为了无缝转换成C++从而进一步编译为exe吧。
|
18
raincious Mar 17, 2015
|
19
xuwenmang Mar 17, 2015
被facebook的hacklang逼的。。。
|
20
justfindu Mar 17, 2015
不复制后面一段么...强类型是不默认开启, 以后也是不默认开启...
|
21
invite Mar 17, 2015
然后PHP就不是PHP了,被一帮人搞的越来越 "高大上" 了。
|
22
szopen Mar 17, 2015
无语了,这叫类型提示,什么强类型
|
23
jookie Mar 17, 2015
只用PHP52
|
24
br00k Mar 17, 2015
确定这叫强类型?逗b了
|
25
yangff Mar 17, 2015 via Android
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或成最大赢家 |
26
xuwenmang Mar 18, 2015
|
27
xwsoul Mar 18, 2015
我本身是不反对类型声明的, 毕竟没有定义类型的年代, 也注意到了返回类型的统一以及注释中类型的标注.
但是非要在代码头部加个 declare ... 感觉好恶劣啊, 如果使用第三方库 会受到 declare 影响么? 我...我...我还是去看Java吧... |
28
kn007 Mar 18, 2015
要这个功能干嘛,,,
|
30
jokerzh Apr 1, 2015
终于找到中文翻译了
http://www.lofter.com/tag/php7 |