diff --git a/Zend/tests/inheritance/bug70957.phpt b/Zend/tests/inheritance/bug70957.phpt
index 9341fcd288d95..6e5a51d9edea4 100644
--- a/Zend/tests/inheritance/bug70957.phpt
+++ b/Zend/tests/inheritance/bug70957.phpt
@@ -19,4 +19,4 @@ class B extends Foo
 }
 ?>
 --EXPECTF--
-Fatal error: Declaration of T::bar() must be compatible with Foo::bar($a = 'Foo') in %s on line %d
+Fatal error: Declaration of B::bar() must be compatible with Foo::bar($a = 'Foo') in %s on line %d
diff --git a/Zend/tests/traits/bug78776.phpt b/Zend/tests/traits/bug78776.phpt
index 3696d955a3a3e..feecfeb8fddd4 100644
--- a/Zend/tests/traits/bug78776.phpt
+++ b/Zend/tests/traits/bug78776.phpt
@@ -25,4 +25,4 @@ B::createApp();
 
 ?>
 --EXPECTF--
-Fatal error: Cannot make non static method A::createApp() static in class C in %s on line %d
+Fatal error: Cannot make non static method A::createApp() static in class B in %s on line %d
diff --git a/Zend/tests/traits/bug81192.phpt b/Zend/tests/traits/bug81192.phpt
index 00f6f1d2fbf71..268df826ddfde 100644
--- a/Zend/tests/traits/bug81192.phpt
+++ b/Zend/tests/traits/bug81192.phpt
@@ -17,4 +17,4 @@ class B extends A {
 
 ?>
 --EXPECTF--
-Fatal error: Declaration of T::foo(): string must be compatible with A::foo(): int in %sbug81192_trait.inc on line 4
+Fatal error: Declaration of B::foo(): string must be compatible with A::foo(): int in %sbug81192_trait.inc on line 4
diff --git a/Zend/tests/traits/bugs/abstract-methods05.phpt b/Zend/tests/traits/bugs/abstract-methods05.phpt
index 96619eae910b8..e0ffc60c14921 100644
--- a/Zend/tests/traits/bugs/abstract-methods05.phpt
+++ b/Zend/tests/traits/bugs/abstract-methods05.phpt
@@ -22,4 +22,4 @@ class TraitsTest1 {
 
 ?>
 --EXPECTF--
-Fatal error: Declaration of THelloB::hello() must be compatible with THelloA::hello($a) in %s on line %d
+Fatal error: Declaration of TraitsTest1::hello() must be compatible with THelloA::hello($a) in %s on line %d
diff --git a/Zend/tests/traits/bugs/abstract-methods06.phpt b/Zend/tests/traits/bugs/abstract-methods06.phpt
index 8e2f25b048e0b..82ad805aed538 100644
--- a/Zend/tests/traits/bugs/abstract-methods06.phpt
+++ b/Zend/tests/traits/bugs/abstract-methods06.phpt
@@ -23,4 +23,4 @@ class TraitsTest1 {
 
 ?>
 --EXPECTF--
-Fatal error: Declaration of THelloB::hello() must be compatible with THelloA::hello($a) in %s on line %d
+Fatal error: Declaration of TraitsTest1::hello() must be compatible with THelloA::hello($a) in %s on line %d
diff --git a/Zend/tests/traits/gh18295.phpt b/Zend/tests/traits/gh18295.phpt
new file mode 100644
index 0000000000000..438431a5b4eec
--- /dev/null
+++ b/Zend/tests/traits/gh18295.phpt
@@ -0,0 +1,21 @@
+--TEST--
+GH-18295: Parent self is substitutable with child self through trait
+--FILE--
+<?php
+
+class A {
+    public function create(): ?A {}
+}
+
+trait T {
+    public function create(): self {}
+}
+
+class B extends A {
+    use T;
+}
+
+?>
+===DONE===
+--EXPECT--
+===DONE===
diff --git a/Zend/tests/traits/inheritance003.phpt b/Zend/tests/traits/inheritance003.phpt
index 1e630eef61d88..1826a084c5a01 100644
--- a/Zend/tests/traits/inheritance003.phpt
+++ b/Zend/tests/traits/inheritance003.phpt
@@ -35,4 +35,4 @@ $o->sayHello(array());
 --EXPECTF--
 World!
 
-Fatal error: Declaration of SayWorld::sayHello(Base $d) must be compatible with Base::sayHello(array $a) in %s on line %d
+Fatal error: Declaration of MyHelloWorld::sayHello(Base $d) must be compatible with Base::sayHello(array $a) in %s on line %d
diff --git a/Zend/tests/type_declarations/variance/trait_error.phpt b/Zend/tests/type_declarations/variance/trait_error.phpt
index 667b177a5b931..dd4ac59d8e7e8 100644
--- a/Zend/tests/type_declarations/variance/trait_error.phpt
+++ b/Zend/tests/type_declarations/variance/trait_error.phpt
@@ -17,4 +17,4 @@ class U extends X {
 
 ?>
 --EXPECTF--
-Fatal error: Could not check compatibility between T::method($r): B and X::method($a): A, because class B is not available in %s on line %d
+Fatal error: Could not check compatibility between U::method($r): B and X::method($a): A, because class B is not available in %s on line %d
diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c
index 090b1049418d2..e718eb5684e65 100644
--- a/Zend/zend_inheritance.c
+++ b/Zend/zend_inheritance.c
@@ -3608,6 +3608,11 @@ ZEND_API zend_class_entry *zend_do_link_class(zend_class_entry *ce, zend_string
 			zend_do_traits_method_binding(ce, traits_and_interfaces, trait_exclude_tables, trait_aliases, false, &trait_contains_abstract_methods);
 			zend_do_traits_constant_binding(ce, traits_and_interfaces);
 			zend_do_traits_property_binding(ce, traits_and_interfaces);
+
+			zend_function *fn;
+			ZEND_HASH_MAP_FOREACH_PTR(&ce->function_table, fn) {
+				zend_fixup_trait_method(fn, ce);
+			} ZEND_HASH_FOREACH_END();
 		}
 		if (parent) {
 			if (!(parent->ce_flags & ZEND_ACC_LINKED)) {
@@ -3618,6 +3623,13 @@ ZEND_API zend_class_entry *zend_do_link_class(zend_class_entry *ce, zend_string
 		if (ce->num_traits) {
 			if (trait_contains_abstract_methods) {
 				zend_do_traits_method_binding(ce, traits_and_interfaces, trait_exclude_tables, trait_aliases, true, &trait_contains_abstract_methods);
+
+				/* New abstract methods may have been added, make sure to add
+				 * ZEND_ACC_IMPLICIT_ABSTRACT_CLASS to ce. */
+				zend_function *fn;
+				ZEND_HASH_MAP_FOREACH_PTR(&ce->function_table, fn) {
+					zend_fixup_trait_method(fn, ce);
+				} ZEND_HASH_FOREACH_END();
 			}
 
 			if (trait_exclude_tables) {
@@ -3634,11 +3646,6 @@ ZEND_API zend_class_entry *zend_do_link_class(zend_class_entry *ce, zend_string
 			if (trait_aliases) {
 				efree(trait_aliases);
 			}
-
-			zend_function *fn;
-			ZEND_HASH_MAP_FOREACH_PTR(&ce->function_table, fn) {
-				zend_fixup_trait_method(fn, ce);
-			} ZEND_HASH_FOREACH_END();
 		}
 		if (ce->num_interfaces) {
 			/* Also copy the parent interfaces here, so we don't need to reallocate later. */