Skip to content

Commit 5d28737

Browse files
committed
implemented Git2\TreeEntry
1 parent 0da4d4f commit 5d28737

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
Check for Git2\TreeEntry::construct
3+
--SKIPIF--
4+
<?php if (!extension_loaded("git2")) print "skip"; ?>
5+
--FILE--
6+
<?php
7+
$entry = new Git2\TreeEntry(array(
8+
"name" => "README.txt",
9+
"oid" => "63542fbea05732b78711479a31557bd1b0aa2116",
10+
"attributes" => 33188,
11+
));
12+
13+
echo $entry->name . PHP_EOL;
14+
echo $entry->oid . PHP_EOL;
15+
echo $entry->attributes . PHP_EOL;
16+
--EXPECT--
17+
README.txt
18+
63542fbea05732b78711479a31557bd1b0aa2116
19+
33188
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
Check for Git2\TreeBuilder::construct
3+
--SKIPIF--
4+
<?php if (!extension_loaded("git2")) print "skip"; ?>
5+
--FILE--
6+
<?php
7+
$bld = new Git2\TreeBuilder();
8+
9+
if ($bld instanceof Git2\TreeBuilder) {
10+
echo "OK";
11+
}
12+
--EXPECT--
13+
OK

tree_entry.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,52 @@ zend_object_value php_git2_tree_entry_new(zend_class_entry *ce TSRMLS_DC)
4444
return retval;
4545
}
4646

47+
ZEND_BEGIN_ARG_INFO_EX(arginfo_git2_tree_entry___construct, 0,0,1)
48+
ZEND_ARG_INFO(0, entry)
49+
ZEND_END_ARG_INFO()
50+
51+
/*
52+
{{{ proto: Git2\TreeEntry::__construct([array $entry])
53+
*/
54+
PHP_METHOD(git2_tree_entry, __construct)
55+
{
56+
zval *z_entry= NULL;
57+
58+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
59+
"|z", &z_entry) == FAILURE) {
60+
return;
61+
}
62+
63+
if (z_entry != NULL) {
64+
zval **zvalue = NULL;
65+
zval *zvaluep = NULL;
66+
67+
if (zend_hash_find(Z_ARRVAL_P(z_entry),"name",sizeof("name"),(void **)&zvalue) != FAILURE) {
68+
zvaluep = *zvalue;
69+
add_property_string_ex(getThis(), "name",sizeof("name"),Z_STRVAL_P(zvaluep) ,1 TSRMLS_CC);
70+
zvalue = NULL;
71+
zvaluep = NULL;
72+
}
73+
if (zend_hash_find(Z_ARRVAL_P(z_entry),"attributes",sizeof("attributes"),(void **)&zvalue) != FAILURE) {
74+
zvaluep = *zvalue;
75+
add_property_long_ex(getThis(), "attributes",sizeof("attributes"),Z_LVAL_P(zvaluep) TSRMLS_CC);
76+
zvalue = NULL;
77+
zvaluep = NULL;
78+
}
79+
if (zend_hash_find(Z_ARRVAL_P(z_entry),"oid",sizeof("oid"),(void **)&zvalue) != FAILURE) {
80+
zvaluep = *zvalue;
81+
add_property_string_ex(getThis(), "oid",sizeof("oid"),Z_STRVAL_P(zvaluep),1 TSRMLS_CC);
82+
zvalue = NULL;
83+
zvaluep = NULL;
84+
}
85+
}
86+
}
87+
/* }}} */
88+
89+
4790

4891
static zend_function_entry php_git2_tree_entry_methods[] = {
92+
PHP_ME(git2_tree_entry, __construct, arginfo_git2_tree_entry___construct, ZEND_ACC_PUBLIC)
4993
{NULL,NULL,NULL}
5094
};
5195

0 commit comments

Comments
 (0)