Skip to content

Commit 4a51e5d

Browse files
committed
Fixup
1 parent b8348fc commit 4a51e5d

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

src/args.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl<'a> Arg<'a> {
8787
{
8888
self.zval
8989
.as_mut()
90-
.and_then(|zv| T::from_zval_mut(zv))
90+
.and_then(|zv| T::from_zval_mut(zv.dereference_mut()))
9191
.ok_or(self)
9292
}
9393

@@ -98,7 +98,7 @@ impl<'a> Arg<'a> {
9898
where
9999
T: FromZvalMut<'a>,
100100
{
101-
self.zval.as_mut().and_then(|zv| T::from_zval_mut(zv))
101+
self.zval.as_mut().and_then(|zv| T::from_zval_mut(zv.dereference_mut()))
102102
}
103103

104104
/// Attempts to return a reference to the arguments internal Zval.

src/types/zval.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,26 @@ impl Zval {
5151
}
5252
}
5353

54+
/// Dereference the zval, if it is a reference.
55+
pub fn dereference(&self) -> &Self {
56+
return self
57+
.reference()
58+
.or_else(|| self.indirect())
59+
.or(Some(self))
60+
.unwrap();
61+
}
62+
63+
/// Dereference the zval mutable, if it is a reference.
64+
pub fn dereference_mut(&mut self) -> &mut Self {
65+
if self.is_reference() {
66+
return self.reference_mut().unwrap();
67+
}
68+
if self.is_indirect() {
69+
return self.indirect_mut().unwrap();
70+
}
71+
return self;
72+
}
73+
5474
/// Returns the value of the zval if it is a long.
5575
pub fn long(&self) -> Option<ZendLong> {
5676
if self.is_long() {

tests/src/integration/closure.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
<?php
22

3+
var_dump(get_declared_classes);
4+
/*
5+
die;
36
require('_utils.php');
47
8+
$v = test_closure();
9+
510
// Closure
6-
assert(test_closure()('works') === 'works');
11+
assert($closure('works') === 'works');
712
813
// Closure once
914
$closure = test_closure_once('test');
1015
1116
assert(call_user_func($closure) === 'test');
1217
assert_exception_thrown($closure);
18+
*/

0 commit comments

Comments
 (0)