てきとうなさいと べぇたばん

PHP7.0.1にアップデートしました

TOP > てきとうにこらむ > このサイトについて。 > PHP7.0.1にアップデートしました

あっ、やっべ、X-Powerd-Byヘッダそのまんまにしてたわーうっかりしてたわーこれやっべーわー

PHP 7.0.1 Released

PHP 7.0.1がリリースされました。というわけで、このサイトもPHP 7.0.1になりました。

おもろいアップデート

こんな書き方するヤツいるのか!?と思うようなものばかりですが、おもしろいので。

Fixed bug #70944 (try{ } finally{} can create infinite chains of exceptions).

https://bugs.php.net/bug.php?id=70944

Description:
------------
try{ } finally{} can create infinite chains of exceptions

Test script:
---------------
<?php
$e = new Exception("Bar");
try {
  throw new Exception("Foo", 0, $e);
} finally {
      throw $e;
}

Expected result:
----------------
exit normally 

Actual result:
--------------
script hangs

ハングするというか、ずーっとスクリプトが止まらないですね。ふむふむ。PHP Version 5.6.15となっているので、PHP5でも再現できました。楽しいですねヽ(^。^)ノ

`yield from` incorrectly marks valid generator as finished

https://bugs.php.net/bug.php?id=70904

Test script:
---------------
<?php

function g1() {
  yield 1;
  yield 2;
}

function g2($g1) {
  yield from $g1;
  echo "!\n";
  yield 3;
}

$g1 = g1();
$g2 = g2($g1);

while ($g2->valid()) {
  var_dump($g2->current());
  $g1->next();
}

Expected result:
----------------
I would expect the following:

int(1)
int(2)
NULL
NULL
NULL
...(infinite loop)

I say this because g2 got primed to the yield from statement, so it should be returning for current whatever g1 is returning for current. For a finished generator, this would be NULL.

Actual result:
--------------
int(1)
int(2)

ジェネレーター、よくわかっていませんが、このスクリプトを走らせるとint(2)が走り続けるので、以下のphptファイルをのぞいて確認したところ、正常に動いているようです?

http://git.php.net/?p=php-src.git;a=blob;f=Zend/tests/generators/bug70904.phpt;h=cd00e0bb3473f1eda9f0c7e8df6450bd6217c27f;hb=80d9dcafe0ee130c52ed2eb33b302e02b93620d4

# php hoge.php
bool(true)
int(1)
bool(false)
bool(true)
int(1)
reached!
bool(true)
int(2)
bool(false)
NULL

2015/12/18 2:24