• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

jbboehr / php-mustache / 33930512929

04 Sep 2026 11:42PM UTC coverage: 83.707% (-0.5%) from 84.197%
33930512929

push

github

jbboehr
Propagate module initialization failures

Abort extension startup when INI registration or any component initializer fails. This prevents PHP from exposing a partially initialized Mustache module.

7 of 14 new or added lines in 1 file covered. (50.0%)

1007 of 1203 relevant lines covered (83.71%)

3298.84 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

45.0
/php_mustache.cpp
1

2
#ifdef HAVE_CONFIG_H
3
#include "config.h"
4
#endif
5

6
#include <string>
7
#include <php.h>
8
#include <php_ini.h>
9
#include <ext/standard/info.h>
10
#include "php_mustache.h"
11
#include "mustache_ast.hpp"
12
#include "mustache_exceptions.hpp"
13
#include "mustache_mustache.hpp"
14
#include "mustache_data.hpp"
15
#include "mustache_template.hpp"
16
#include "mustache_lambda_helper.hpp"
17

18

19
/* {{{ prototypes */
20
ZEND_DECLARE_MODULE_GLOBALS(mustache)
21
/* }}} */
22

23
/* {{{ php.ini directive registration */
24
PHP_INI_BEGIN()
25
  STD_PHP_INI_BOOLEAN("mustache.default_escape", "1", PHP_INI_ALL, OnUpdateBool, default_escape_by_default, zend_mustache_globals, mustache_globals)
26
  STD_PHP_INI_ENTRY("mustache.default_start", "{{", PHP_INI_ALL, OnUpdateStringUnempty, default_start_sequence, zend_mustache_globals, mustache_globals)
27
  STD_PHP_INI_ENTRY("mustache.default_stop", "}}", PHP_INI_ALL, OnUpdateStringUnempty, default_stop_sequence, zend_mustache_globals, mustache_globals)
28
PHP_INI_END()
29
/* }}} */
30

31
/* {{{ PHP_MINIT_FUNCTION */
32
static PHP_MINIT_FUNCTION(mustache)
814 ✔
33
{
34
  if( REGISTER_INI_ENTRIES() == FAILURE ) {
814 ✔
NEW
35
    return FAILURE;
×
36
  }
37

38
  if( PHP_MINIT(mustache_ast)(INIT_FUNC_ARGS_PASSTHRU) == FAILURE ) {
814 ✔
NEW
39
    return FAILURE;
×
40
  }
41

42
  if( PHP_MINIT(mustache_mustache)(INIT_FUNC_ARGS_PASSTHRU) == FAILURE ) {
814 ✔
NEW
43
    return FAILURE;
×
44
  }
45

46
  if( PHP_MINIT(mustache_data)(INIT_FUNC_ARGS_PASSTHRU) == FAILURE ) {
814 ✔
NEW
47
    return FAILURE;
×
48
  }
49

50
  if( PHP_MINIT(mustache_template)(INIT_FUNC_ARGS_PASSTHRU) == FAILURE ) {
814 ✔
NEW
51
    return FAILURE;
×
52
  }
53

54
  if( PHP_MINIT(mustache_exceptions)(INIT_FUNC_ARGS_PASSTHRU) == FAILURE ) {
814 ✔
NEW
55
    return FAILURE;
×
56
  }
57

58
  if( PHP_MINIT(mustache_lambda_helper)(INIT_FUNC_ARGS_PASSTHRU) == FAILURE ) {
814 ✔
NEW
59
    return FAILURE;
×
60
  }
61

62
  return SUCCESS;
814 ✔
63
}
64
/* }}} */
65

66
/* {{{ PHP_MSHUTDOWN_FUNCTION */
67
static PHP_MSHUTDOWN_FUNCTION(mustache)
814 ✔
68
{
69
  UNREGISTER_INI_ENTRIES();
814 ✔
70

71
  return SUCCESS;
814 ✔
72
}
73
/* }}} */
74

75
/* {{{ PHP_MINFO_FUNCTION */
76
const char *PHP_MUSTACHE_MOTD =
77
        "Think not that I am come to send peace on earth: I came not to send peace, but a sword. Matthew 10:34";
78

79
static PHP_MINFO_FUNCTION(mustache)
×
80
{
81
  php_info_print_table_start();
×
82
  php_info_print_table_row(2, "Version", PHP_MUSTACHE_VERSION);
×
83
  php_info_print_table_row(2, "Released", PHP_MUSTACHE_RELEASE);
×
84
  php_info_print_table_row(2, "Revision", PHP_MUSTACHE_BUILD);
×
85
  php_info_print_table_row(2, "Authors", PHP_MUSTACHE_AUTHORS);
×
86
  php_info_print_table_row(2, "Spec Version", PHP_MUSTACHE_SPEC);
×
87
  php_info_print_table_row(2, "Libmustache Version", mustache_version());
×
88
#if MUSTACHE_HAVE_CXX11
89
  php_info_print_table_row(2, "c++11 unordered map support", "enabled");
×
90
#else
91
  php_info_print_table_row(2, "c++11 unordered map support", "disabled");
92
#endif
93
  php_info_print_table_end();
×
94

95
  DISPLAY_INI_ENTRIES();
×
96

97
  php_info_print_box_start(0);
×
98
  PUTS(PHP_MUSTACHE_MOTD);
×
99
  php_info_print_box_end();
×
100
}
×
101
/* }}} */
102

103
/* {{{ PHP_GINIT_FUNCTION */
104
static PHP_GINIT_FUNCTION(mustache)
814 ✔
105
{
106
  mustache_globals->default_escape_by_default = 1;
814 ✔
107
  mustache_globals->default_start_sequence = (char *) "{{";
814 ✔
108
  mustache_globals->default_stop_sequence = (char *) "}}";
814 ✔
109
}
814 ✔
110
/* }}} */
111

112
/* {{{ mustache_module_entry */
113
zend_module_entry mustache_module_entry = {
114
  STANDARD_MODULE_HEADER,
115
  (char *) PHP_MUSTACHE_NAME,    /* Name */
116
  NULL,                          /* Functions */
117
  PHP_MINIT(mustache),           /* MINIT */
118
  PHP_MSHUTDOWN(mustache),       /* MSHUTDOWN */
119
  NULL,                          /* RINIT */
120
  NULL,                          /* RSHUTDOWN */
121
  PHP_MINFO(mustache),           /* MINFO */
122
  (char *) PHP_MUSTACHE_VERSION, /* Version */
123
  PHP_MODULE_GLOBALS(mustache),  /* Globals */
124
  PHP_GINIT(mustache),           /* GINIT */
125
  NULL,
126
  NULL,
127
  0, 0, NULL, 0, (char *) ZEND_MODULE_BUILD_ID /* STANDARD_MODULE_PROPERTIES_EX */
128
};
129
/* }}} */
130

131
#ifdef COMPILE_DL_MUSTACHE
132
extern "C" {
133
  ZEND_GET_MODULE(mustache)      // Common for all PHP extensions which are build as shared modules
818 ✔
134
}
135
#endif
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc