Skip to content

Commit 6c555ce

Browse files
committed
fix doc for class extends class
1 parent 4b29427 commit 6c555ce

File tree

1 file changed

+7
-3
lines changed
  • phper-doc/doc/_06_module/_06_register_class

1 file changed

+7
-3
lines changed

phper-doc/doc/_06_module/_06_register_class/index.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,19 @@ class Foo {}
3838

3939
## Extends & implements
4040

41-
To allow a class to extend another, you can either use `ClassEntity.extends(StateClass<T>)` for classes implemented
42-
in your module.
41+
To allow a class to extend another, you can use `ClassEntity.extends(StateClass<T>)` for classes implemented
42+
in your module. A StateClass can either be obtained by registering your own class against the module, or
43+
by looking up the class by name (for example, for PHP built-in classes like `Exception`).
4344

4445
If you want class `Foo` extends `Bar`, and implements interface `Stringable`:
4546

4647
```rust,no_run
4748
use phper::classes::{ClassEntity, ClassEntry, Interface};
49+
use phper::{modules::Module, php_get_module};
4850
49-
let mut bar = ClassEntity::new("Bar").bind_class();
51+
let mut module = Module::new("test", "0.1", "");
52+
53+
let bar = module.add_class(ClassEntity::new("Bar"));
5054
let mut foo = ClassEntity::new("Foo");
5155
foo.extends(bar);
5256
foo.implements(Interface::from_name("Stringable"));

0 commit comments

Comments
 (0)