Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Implement, test and document namespace support
Browse files Browse the repository at this point in the history
  • Loading branch information
jvoisin committed Sep 26, 2017
1 parent 4dc382c commit 3c14dba
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions doc/source/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ Details
The ``function`` filter is able to do various dereferencing:

- ``function("AwesomeClass::my_method")`` will match in the method ``my_method`` in the class ``AwesomeClass``
- ``function("AwesomeNamespace\\my_function")`` will match in the function ``my_function`` in the namespace ``AwesomeNamespace``

The ``param`` filter is also able to do some dereferencing:

Expand Down
3 changes: 2 additions & 1 deletion src/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ LDFLAGS="$LDFLAGS -lpcre"

if test "$PHP_DEBUG" = "yes"; then
AC_DEFINE(SP_DEBUG, 1, [Wether you want to enable debug messages])
CFLAGS="$CFLAGS -g -ggdb -O0"
fi

AC_CHECK_LIB(pcre, pcre_compile, AC_DEFINE(HAVE_PCRE, 1, [have pcre]))

if test "$PHP_SNUFFLEUPAGUS" = "yes"; then
if test "$PHP_COVERAGE" = "yes"; then
CFLAGS="$CFLAGS -g --coverage -lgcov -O1 -g"
CFLAGS="$CFLAGS --coverage -lgcov -O1 -g"
fi
PHP_NEW_EXTENSION(snuffleupagus, $sources, $ext_shared,-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
fi
2 changes: 1 addition & 1 deletion src/tests/config/config_disabled_functions_namespace.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
sp.disable_functions.function("strcmp").drop();
sp.disable_functions.function("my_super_namespace::my_function").drop();
sp.disable_functions.function("my_super_namespace\\my_function").drop();
14 changes: 8 additions & 6 deletions src/tests/disabled_functions_namespace.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
Disable functions: namespaces support isn't implemented now
Disable functions in namespaces
--SKIPIF--
<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
--INI--
Expand All @@ -8,24 +8,26 @@ sp.configuration_file={PWD}/config/config_disabled_functions_namespace.ini
<?php
namespace my_super_namespace {
function my_function() {
echo "1\n";
echo "Should not be printed\n";
}
}
namespace my_second_namespace {
function my_function() {
echo "2\n";
echo "Second namespace\n";
}
}
namespace {
function my_function() {
echo "3\n";
echo "Anonymous namespace\n";
}
\strcmp("1", "2");
\my_super_namespace\my_function();
\my_second_namespace\my_function();
my_function();
}
?>
--XFAIL--
--EXPECTF--
[snuffleupagus] The call to the function 'strcmp' in %a/tests/disabled_functions_namespace.php:%d has been disabled.
[snuffleupagus][0.0.0.0][disabled_function][drop] The call to the function 'strcmp' in %a/disabled_functions_namespace.php:%d has been disabled.
[snuffleupagus][0.0.0.0][disabled_function][drop] The call to the function 'my_super_namespace\my_function' in %a/disabled_functions_namespace.php:%d has been disabled.
Second namespace
Anonymous namespace

0 comments on commit 3c14dba

Please sign in to comment.