mirror of
https://github.com/php-win-ext/phpy.git
synced 2026-03-24 17:02:15 +01:00
21 lines
482 B
PHP
21 lines
482 B
PHP
<?php
|
|
|
|
PyCore::import('sys')->path->append('.');
|
|
|
|
$types = PyCore::import('types');
|
|
|
|
$Animal = PyCore::import('animal')->Animal;
|
|
$Dog = $types->new_class(
|
|
'Dog',
|
|
(PyCore::tuple([$Animal])),
|
|
[]
|
|
);
|
|
|
|
$dog = $Dog('狗', 1);
|
|
$dog->speak = $types->MethodType(function ($self, $name) use ($Animal, $Dog) {
|
|
PyCore::print("My name is {$self->name}, age is {$self->age}");
|
|
$super = PyCore::super($Dog, $self);
|
|
$super->speak('dog');
|
|
}, $dog);
|
|
$dog->speak('哈士奇');
|