forked from laruence/php-lua
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/laruence/php-lua into ups…
…tream * 'master' of https://github.com/laruence/php-lua: added more test php version Renamed test to prevent merge conflict add some more table magic add more tests make lua_obj optional fix crashes when printing tables fix incorrect type alloc that causes memory corruption Fixed issue laruence#40 Make test finally stable fixed test Fixed test Demangle name of a property when assigning an object into Lua
- Loading branch information
Showing
3 changed files
with
69 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,10 @@ addons: | |
|
||
php: | ||
- 7.0 | ||
- 7.1 | ||
- 7.2 | ||
- 7.3 | ||
- 7.4 | ||
|
||
notifications: | ||
email: false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--TEST-- | ||
PHP Object to lua | ||
--SKIPIF-- | ||
<?php if (!extension_loaded("lua")) print "skip"; ?> | ||
--FILE-- | ||
<?php | ||
class T { | ||
private $v; | ||
private $s; | ||
|
||
public function __construct($v) | ||
{ | ||
$this->v = $v; | ||
$this->s = "string = $v"; | ||
} | ||
|
||
static function create($arg) | ||
{ | ||
return new self($arg); | ||
} | ||
} | ||
|
||
|
||
$l = new lua(); | ||
$l->registerCallback('create_object', [T::class, 'create']); | ||
|
||
$l->eval(<<<CODE | ||
local t = create_object(2) | ||
local keys = {} | ||
for k, _ in pairs(t) do | ||
table.insert(keys, k) | ||
end | ||
table.sort(keys) | ||
for _,k in ipairs(keys) do | ||
print(k, " -> ", t[k], ",") | ||
end | ||
CODE | ||
); | ||
|
||
?> | ||
--EXPECTF-- | ||
s -> string = 2,v -> 2, |