ささやかな日々記

日々過ごす中で感じたことや培ったことが誰かの役に立てられたらと思うSEの雑記

PHP 7.2.x から PHP 7.3.x への移行の勝手な日本語訳 後方互換のない変更③

PHP 7.2.x から PHP 7.3.x への移行の日本語訳がないので勝手に翻訳して備忘録にする。
 https://www.php.net/manual/ja/migration73.incompatible.php
 

 Continue Targeting Switch issues Warning 

 スイッチの問題をターゲットにし続ける警告

 

continue statements targeting switch control flow structures will now generate a warning. In PHP such continue statements are equivalent to break, while they behave as continue 2 in other languages.

スイッチ制御フロー構造を対象としたcontinueステートメントは、警告を生成します。 PHPでは、このようなcontinueステートメントはbreakと同等ですが、他の言語ではcontinue 2のように動作します。


<?php
while ($foo) {
    switch ($bar) {
      case "baz":
         continue;
         // Warning: "continue" targeting switch is equivalent to
         //          "break". Did you mean to use "continue 2"?
   }
}
?>


つづいて。

Strict Interpretation of Integer String Keys on ArrayAccess

ArrayAccessでの整数文字列キーの厳密な解釈

 

Array accesses of type $obj["123"], where $obj implements ArrayAccess and "123" is an integer string literal will no longer result in an implicit conversion to integer, i.e., $obj->offsetGet("123") will be called instead of $obj->offsetGet(123). This matches existing behavior for non-literals. The behavior of arrays is not affected in any way, they continue to implicitly convert integeral string keys to integers.

$ obj ["123"]型の配列アクセス。$ objはArrayAccessを実装し、 "123"は整数文字列リテラルであるため、暗黙的に整数に変換されることはなくなりました。つまり、$ obj-> offsetGet( "123")は $ obj-> offsetGet(123)の代わりに呼び出されます。 これは非リテラルの既存の動作と一致します。 配列の振る舞いは何の影響も受けず、暗黙のうちに整数文字列キーを整数に変換し続けます。

[商品価格に関しましては、リンクが作成された時点と現時点で情報が変更されている場合がございます。]

気づけばプロ並みPHP 改訂版ーーゼロから作れる人になる! [ 谷藤賢一 ]
価格:2916円(税込、送料無料) (2019/6/9時点)

楽天で購入