PHP 8.4.0 RC3 available for testing

never

never işlevin sonlanmayacağı belirten bir dönüş türüdür. Yani ya exit() çağrısıyla bir istisna oluşturur ya da sonsuz döngüde kalır. Bu bakımdan union (birleşik) türün parçası olamaz. PHP 8.1.0 ve sonrasında kullanılabilir.

never tür teorisi tabiriyle en alt türdür. Yani diğer her türün alt türü olabilir ve kalıtım sırasında yerini başka bir tür alabilir.

add a note

User Contributed Notes 2 notes

up
20
ali1289445 at gmail dot com
1 year ago
<?php

function sayHello(string $name): never
{
echo
"Hello, $name";
exit();
// if we comment this line, php throws fatal error
}

sayHello("John"); // result: "Hello, John"
up
0
dcfynn at icloud dot com
10 days ago
I think the description should be corrected from return-only to non-return function since the context is now misleading
To Top