Skip to content

Commit

Permalink
#2111 - Fix and update for better detection of class name entries
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeckerson committed Mar 13, 2021
1 parent 81c1cd8 commit fd3bde0
Show file tree
Hide file tree
Showing 33 changed files with 275 additions and 79 deletions.
25 changes: 13 additions & 12 deletions Library/ClassMethod.php
Expand Up @@ -2557,11 +2557,12 @@ private function detectClassNameEntry(string $className, CompilationContext $com
// Continue below execution
}

$classNamespace = explode('\\', $className);

/**
* Full namespace with class name
*/
if (strpos($className, '\\') === 0) {
$classNamespace = explode('\\', $className);
$classNamespace = array_values(array_filter($classNamespace));

/**
Expand All @@ -2579,18 +2580,18 @@ private function detectClassNameEntry(string $className, CompilationContext $com
}

$className = end($classNamespace);
}

/**
* Check for partial namespace specification
* Example: Oo\Param, while namespace at the top is Stub
*/
$classNamespace = explode('\\', $className);
$className = end($classNamespace);
array_pop($classNamespace);
array_pop($classNamespace);
} else {
/**
* Check for partial namespace specification
* Example: Oo\Param, while namespace at the top is Stub
*/
$className = end($classNamespace);
array_pop($classNamespace);

if ($isAlias === false) {
array_unshift($classNamespace, $this->classDefinition->getNamespace());
if ($isAlias === false) {
array_unshift($classNamespace, $this->classDefinition->getNamespace());
}
}

$namespace = join('\\', $classNamespace);
Expand Down
4 changes: 3 additions & 1 deletion ext/config.m4
Expand Up @@ -105,6 +105,8 @@ if test "$PHP_STUB" = "yes"; then
stub/mcallinternal.zep.c
stub/methodabstract.zep.c
stub/methodargs.zep.c
stub/namespaces/a/b/sub.zep.c
stub/namespaces/classentry.zep.c
stub/nativearray.zep.c
stub/oo.zep.c
stub/oo/abstractclass.zep.c
Expand Down Expand Up @@ -215,7 +217,7 @@ if test "$PHP_STUB" = "yes"; then
stub/12__closure.zep.c "
PHP_NEW_EXTENSION(stub, $stub_sources, $ext_shared,, )
PHP_ADD_BUILD_DIR([$ext_builddir/kernel/])
for dir in "stub stub/bench stub/builtin stub/flow stub/globals stub/globals/session stub/integration/psr/http/message stub/interfaces stub/invokes stub/mcall stub/oo stub/oo/extend stub/oo/extend/db stub/oo/extend/db/query stub/oo/extend/db/query/placeholder stub/oo/extend/spl stub/oo/scopes stub/ooimpl stub/optimizers stub/properties stub/requires stub/router stub/typehinting"; do
for dir in "stub stub/bench stub/builtin stub/flow stub/globals stub/globals/session stub/integration/psr/http/message stub/interfaces stub/invokes stub/mcall stub/namespaces stub/namespaces/a/b stub/oo stub/oo/extend stub/oo/extend/db stub/oo/extend/db/query stub/oo/extend/db/query/placeholder stub/oo/extend/spl stub/oo/scopes stub/ooimpl stub/optimizers stub/properties stub/requires stub/router stub/typehinting"; do
PHP_ADD_BUILD_DIR([$ext_builddir/$dir])
done
PHP_SUBST(STUB_SHARED_LIBADD)
Expand Down
2 changes: 2 additions & 0 deletions ext/config.w32
Expand Up @@ -27,6 +27,8 @@ if (PHP_STUB != "no") {
ADD_SOURCES(configure_module_dirname + "/stub/globals", "env.zep.c post.zep.c server.zep.c serverrequestfactory.zep.c", "stub");
ADD_SOURCES(configure_module_dirname + "/stub/integration/psr/http/message", "messageinterfaceex.zep.c", "stub");
ADD_SOURCES(configure_module_dirname + "/stub/mcall", "caller.zep.c", "stub");
ADD_SOURCES(configure_module_dirname + "/stub/namespaces/a/b", "sub.zep.c", "stub");
ADD_SOURCES(configure_module_dirname + "/stub/namespaces", "classentry.zep.c", "stub");
ADD_SOURCES(configure_module_dirname + "/stub/oo/extend/db/query/placeholder", "exception.zep.c", "stub");
ADD_SOURCES(configure_module_dirname + "/stub/oo/extend/spl", "arrayobject.zep.c directoryiterator.zep.c doublylinkedlist.zep.c fileinfo.zep.c fileobject.zep.c filesystemiterator.zep.c fixedarray.zep.c globiterator.zep.c heap.zep.c maxheap.zep.c minheap.zep.c priorityqueue.zep.c queue.zep.c recursivedirectoryiterator.zep.c stack.zep.c tempfileobject.zep.c", "stub");
ADD_SOURCES(configure_module_dirname + "/stub/optimizers", "isscalar.zep.c acos.zep.c arraymerge.zep.c asin.zep.c cos.zep.c createarray.zep.c ldexp.zep.c sin.zep.c sqrt.zep.c strreplace.zep.c substr.zep.c tan.zep.c", "stub");
Expand Down
4 changes: 4 additions & 0 deletions ext/stub.c
Expand Up @@ -133,6 +133,8 @@ zend_class_entry *stub_mcalldynamic_ce;
zend_class_entry *stub_mcallinternal_ce;
zend_class_entry *stub_methodabstract_ce;
zend_class_entry *stub_methodargs_ce;
zend_class_entry *stub_namespaces_a_b_sub_ce;
zend_class_entry *stub_namespaces_classentry_ce;
zend_class_entry *stub_nativearray_ce;
zend_class_entry *stub_oo_abstractclass_ce;
zend_class_entry *stub_oo_ce;
Expand Down Expand Up @@ -342,6 +344,8 @@ static PHP_MINIT_FUNCTION(stub)
ZEPHIR_INIT(Stub_Mcall_Caller);
ZEPHIR_INIT(Stub_MethodAbstract);
ZEPHIR_INIT(Stub_MethodArgs);
ZEPHIR_INIT(Stub_Namespaces_A_B_Sub);
ZEPHIR_INIT(Stub_Namespaces_ClassEntry);
ZEPHIR_INIT(Stub_NativeArray);
ZEPHIR_INIT(Stub_Oo);
ZEPHIR_INIT(Stub_Oo_AbstractClass);
Expand Down
2 changes: 2 additions & 0 deletions ext/stub.h
Expand Up @@ -100,6 +100,8 @@
#include "stub/mcallinternal.zep.h"
#include "stub/methodabstract.zep.h"
#include "stub/methodargs.zep.h"
#include "stub/namespaces/a/b/sub.zep.h"
#include "stub/namespaces/classentry.zep.h"
#include "stub/nativearray.zep.h"
#include "stub/oo.zep.h"
#include "stub/oo/abstractclass.zep.h"
Expand Down
1 change: 1 addition & 0 deletions ext/stub/issettest.zep.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions ext/stub/namespaces/a/b/sub.zep.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions ext/stub/namespaces/a/b/sub.zep.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 74 additions & 0 deletions ext/stub/namespaces/classentry.zep.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions ext/stub/namespaces/classentry.zep.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ext/stub/nativearray.zep.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 16 additions & 14 deletions ext/stub/oo/oodestruct.zep.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ext/stub/oo/scopes/privatescopetester.zep.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ext/stub/optimizers/strreplace.zep.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ext/stub/properties/extendspublicproperties.zep.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fd3bde0

Please sign in to comment.