File tree Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change 1313
1414class Debug
1515{
16- public static function getRefCount ($ object ): string
16+ /**
17+ * Get object's ref count.
18+ */
19+ public static function getRefCount (object $ object ): string
1720 {
1821 ob_start ();
1922 debug_zval_dump ($ object );
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+ /**
5+ * This file is part of Hyperf.
6+ *
7+ * @link https://www.hyperf.io
8+ * @document https://hyperf.wiki
9+ 10+ * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
11+ */
12+ namespace HyperfTest \Testing ;
13+
14+ use Hyperf \Testing \Debug ;
15+ use PHPUnit \Framework \TestCase ;
16+
17+ /**
18+ * @internal
19+ * @coversNothing
20+ */
21+ class DebugTest extends TestCase
22+ {
23+ public function testGetRefCount ()
24+ {
25+ $ this ->assertSame ('1 ' , Debug::getRefCount (new \stdClass ()));
26+ $ obj = new \stdClass ();
27+ $ this ->assertSame ('2 ' , Debug::getRefCount ($ obj ));
28+ $ obj2 = new \stdClass ();
29+ $ obj2 ->obj = $ obj ;
30+ $ this ->assertSame ('2 ' , Debug::getRefCount ($ obj2 ));
31+ $ this ->assertSame ('3 ' , Debug::getRefCount ($ obj ));
32+ $ fun = static function () {};
33+ $ this ->assertSame ('2 ' , Debug::getRefCount ($ fun ));
34+ $ this ->assertSame ('1 ' , Debug::getRefCount (function () {}));
35+ }
36+ }
You can’t perform that action at this time.
0 commit comments