0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PHPの型宣言のObjectタイプヒントはPHP7.2.0からだった…

Last updated at Posted at 2019-03-06

PHPの型宣言でObjectタイプヒントがうまくいかない!

gettypeメソッドで間違いなくobject型で有ることを確認

public function hoge(object $object) {
    // 何かの処理
}

エラーになる

local.ERROR: Type error: Argument 1 passed to ...

何故だ!!
型宣言したいのに!

PHP7.2.0から対応だった

php -vで確認すると7.0系だった。

PHP7.2リリース情報

原文

PHP 7.2.0 comes with numerous improvements and new features such as

  • Convert numeric keys in object/array casts
  • Counting of non-countable objects
  • Object typehint
  • HashContext as Object
  • Argon2 in password hash
  • Improve TLS constants to sane values
  • Mcrypt extension removed
  • New sodium extension

Google翻訳

PHP 7.2.0には、次のような多数の改良と新機能が付属しています。

  • オブジェクト/配列キャストの数値キーを変換する
  • カウント不能オブジェクトのカウント
  • オブジェクトタイプヒント
  • オブジェクトとしてのHashContext
  • パスワードハッシュ内のArgon2
  • TLS定数を正しい値に改善
  • Mcryptエクステンションを削除
  • 新しいナトリウム増量
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?