Skip to content

Commit

Permalink
Fixes for PHP 7.4 and 8.0 compatibility
Browse files Browse the repository at this point in the history
- ZEND_ACC_DTOR and ZEND_ACC_SHADOW can be undefined
- Run nix tests against PHP 7.3
- Nix derivation needs pname parameter

Closes #55
Closes #56
  • Loading branch information
jbboehr committed May 27, 2019
1 parent c7cb735 commit a60393d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ matrix:
env:
- NIX_CHANNEL=18.09
- NIX_PHP_ATTR=php72
- language: nix
env:
- NIX_CHANNEL=19.03
- NIX_PHP_ATTR=php73
- language: nix
env:
- NIX_CHANNEL=unstable
Expand Down
1 change: 1 addition & 0 deletions derivation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ let
in

buildPecl rec {
pname = "mustache";
name = "mustache-${version}";
version = orDefault phpMustacheVersion "v0.7.4";
src = orDefault phpMustacheSrc (fetchurl {
Expand Down
19 changes: 15 additions & 4 deletions mustache_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,14 @@ static zend_always_inline bool is_invokable_object(const zend_class_entry * ce)
/* {{{ is_valid_function */
static zend_always_inline bool is_valid_function(const zend_function * f)
{
return (f->common.fn_flags & ZEND_ACC_CTOR) == 0 &&
return (f->common.fn_flags & ZEND_ACC_STATIC) == 0 &&
#ifdef ZEND_ACC_CTOR
(f->common.fn_flags & ZEND_ACC_CTOR) == 0 &&
#endif
#ifdef ZEND_ACC_DTOR
(f->common.fn_flags & ZEND_ACC_DTOR) == 0 &&
(f->common.fn_flags & ZEND_ACC_STATIC) == 0 &&
#endif

(f->common.fn_flags & ZEND_ACC_PROTECTED) == 0 &&
(f->common.fn_flags & ZEND_ACC_PRIVATE) == 0;
}
Expand All @@ -118,8 +123,10 @@ static zend_always_inline bool is_valid_function(const zend_function * f)
/* {{{ is_valid_property */
static zend_always_inline bool is_valid_property(const zend_property_info * prop)
{
return (prop->flags & ZEND_ACC_SHADOW) == 0 &&
(prop->flags & ZEND_ACC_PROTECTED) == 0 &&
return (prop->flags & ZEND_ACC_PROTECTED) == 0 &&
#ifdef ZEND_ACC_SHADOW
(prop->flags & ZEND_ACC_SHADOW) == 0 &&
#endif
(prop->flags & ZEND_ACC_PRIVATE) == 0;
}
/* }}} */
Expand Down Expand Up @@ -237,7 +244,11 @@ static zend_always_inline void mustache_data_from_object_properties_zval(mustach
node->type = mustache::Data::TypeNone;

if( Z_OBJ_HT_P(current)->get_properties != NULL ) {
#if PHP_VERSION_ID >= 80000
data_hash = Z_OBJ_HT_P(current)->get_properties(Z_OBJ_P(current));
#else
data_hash = Z_OBJ_HT_P(current)->get_properties(current);
#endif
}
if( data_hash != NULL && zend_hash_num_elements(data_hash) > 0 ) {
#if PHP_VERSION_ID < 70300
Expand Down
2 changes: 1 addition & 1 deletion package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
<required>
<php>
<min>7.0.0</min>
<max>7.3.99</max>
<max>7.4.99</max>
</php>
<pearinstaller>
<min>1.4.1</min>
Expand Down

0 comments on commit a60393d

Please sign in to comment.