xref: /PHP-8.2/Zend/tests/gh14009_005.phpt (revision 7a9e0fb3)
1--TEST--
2GH-14009: Traits inherit prototype
3--FILE--
4<?php
5
6trait T {
7    private function test($s) {
8        echo $s . " -> ". __CLASS__ . "::" . __METHOD__ . "\n";
9    }
10}
11
12class A {
13	use T;
14	public function foo() {
15		$this->test(__METHOD__);
16	}
17	public function bar() {
18		$this->test(__METHOD__);
19	}
20}
21
22class B extends A {
23    use T;
24	public function foo() {
25		$this->test(__METHOD__);
26	}
27}
28
29(new A)->foo();
30(new A)->bar();
31(new B)->foo();
32(new B)->bar();
33?>
34--EXPECT--
35A::foo -> A::T::test
36A::bar -> A::T::test
37B::foo -> B::T::test
38A::bar -> A::T::test
39