[PHP-NOTES] note 130289 added to fiber.getcurrent

[email protected] ("[email protected]")
Newsgroups php.notes
Message-ID <[email protected]>
Fiber::getCurrent() will only return true if you call it from within a Fiber while it is running.

<?php
$fiber = new Fiber(function () {
    echo "Inside Fiber. getCurrent: ";
    var_dump(Fiber::getCurrent()); // Here is object(Fiber)#1 (0) { }

    Fiber::suspend();

    echo "Inside Fiber again after resume(). getCurrent: ";
    var_dump(Fiber::getCurrent()); // object(Fiber)#1 (0) { } again
});

echo "Before Fiber launch. getCurrent: ";
var_dump($fiber->getCurrent()); // Here is NULL 

$fiber->start();

echo "After suspend. getCurrent: ";
var_dump($fiber->getCurrent()); // Here is NULL 

$fiber->resume();

echo "After resume. getCurrent: ";
var_dump($fiber->getCurrent()); // Here is NULL 
?>

Result:
Before Fiber launch. getCurrent: NULL
Inside Fiber. getCurrent: object(Fiber)#1 (0) {}
After suspend. getCurrent: NULL
Inside Fiber again after resume(). getCurrent: object(Fiber)#1 (0) {}
After resume. getCurrent: NULL
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.137 (proxied: 88.156.209.253)
----
Manual Page -- https://php.net/manual/en/fiber.getcurrent.php
Edit        -- https://main.php.net/note/edit/130289
Del: integrated  -- https://main.php.net/note/delete/130289/integrated
Del: useless     -- https://main.php.net/note/delete/130289/useless
Del: bad code    -- https://main.php.net/note/delete/130289/bad+code
Del: spam        -- https://main.php.net/note/delete/130289/spam
Del: non-english -- https://main.php.net/note/delete/130289/non-english
Del: in docs     -- https://main.php.net/note/delete/130289/in+docs
Del: other reasons-- https://main.php.net/note/delete/130289
Reject      -- https://main.php.net/note/reject/130289
Search      -- https://main.php.net/manage/user-notes.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.