Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

registerlocalnamespace.xml Fix typos and amend return type#5490

Open
mmalferov wants to merge 22 commits into
php:masterphp/doc-en:masterfrom
mmalferov:patch-58mmalferov/doc-en:patch-58Copy head branch name to clipboard
Open

registerlocalnamespace.xml Fix typos and amend return type#5490
mmalferov wants to merge 22 commits into
php:masterphp/doc-en:masterfrom
mmalferov:patch-58mmalferov/doc-en:patch-58Copy head branch name to clipboard

Conversation

@mmalferov
Copy link
Copy Markdown
Member

No description provided.

@mmalferov mmalferov changed the title registerlocalnamespace.xml Fix typo registerlocalnamespace.xml Fix typo and amend return type Apr 13, 2026
@mmalferov
Copy link
Copy Markdown
Member Author

mmalferov commented Apr 13, 2026

Based on the actual behavior and the source code, the method returns Yaf_Loader|false.

<?php

$loader = Yaf_Loader::getInstance();

// Returns Yaf_Loader instance
$result = $loader->registerLocalNamespace("Prefix");
var_dump($result); // object(Yaf_Loader)

// Returns false on invalid input
$result = @$loader->registerLocalNamespace(null);
var_dump($result); // bool(false)

Source code (yaf_loader.c):

PHP_METHOD(yaf_loader, registerLocalNamespace) {
	zval *namespaces;
	zend_string *path = NULL;

	if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|S", &namespaces, &path) == FAILURE) {
		return;
	}

	if (IS_STRING == Z_TYPE_P(namespaces)) {
		if (yaf_loader_register_namespace(Z_YAFLOADEROBJ_P(getThis()), Z_STR_P(namespaces), path)) {
			RETURN_ZVAL(getThis(), 1, 0);
		}
	} else if (IS_ARRAY == Z_TYPE_P(namespaces)) {
		if (yaf_loader_register_namespace_multi(Z_YAFLOADEROBJ_P(getThis()), namespaces)) {
			RETURN_ZVAL(getThis(), 1, 0);
		}
	} else {
		php_error_docref(NULL, E_WARNING, "Invalid parameters provided, must be a string, or an array");
	}

	RETURN_FALSE;
}

@mmalferov
Copy link
Copy Markdown
Member Author

And the same:

<?php

$loader = Yaf_Loader::getInstance();

$result = $loader->registerNamespace(namespace: "App\Fake", path: "path"); // Not 'namespaces' that lead to the fatal error
var_dump($result); // object(Yaf_Loader)

$result = @$loader->registerNamespace(null, null);
var_dump($result); // bool(false)

@mmalferov mmalferov changed the title registerlocalnamespace.xml Fix typo and amend return type registerlocalnamespace.xml Fix typos and amend return type Apr 14, 2026
Comment thread reference/yaf/yaf_loader/registerlocalnamespace.xml Outdated
Comment thread reference/yaf/yaf_loader/registernamespace.xml Outdated
Comment thread reference/yaf/yaf_loader/registernamespace.xml Outdated
Comment thread reference/yaf/yaf_loader/registerlocalnamespace.xml
Comment thread reference/yaf/yaf_loader/registerlocalnamespace.xml
Comment thread reference/yaf/yaf_loader/registerlocalnamespace.xml Outdated
Comment thread reference/yaf/yaf_loader/registerlocalnamespace.xml Outdated
Comment thread reference/yaf/yaf_loader/registerlocalnamespace.xml Outdated
Comment thread reference/yaf/yaf_loader/registerlocalnamespace.xml Outdated
mmalferov and others added 5 commits April 26, 2026 15:35
Co-authored-by: Louis-Arnaud <la.catoire@gmail.com>
Co-authored-by: Louis-Arnaud <la.catoire@gmail.com>
Co-authored-by: Louis-Arnaud <la.catoire@gmail.com>
Co-authored-by: Louis-Arnaud <la.catoire@gmail.com>
Co-authored-by: Louis-Arnaud <la.catoire@gmail.com>
mmalferov and others added 5 commits April 26, 2026 15:36
Co-authored-by: Louis-Arnaud <la.catoire@gmail.com>
Co-authored-by: Louis-Arnaud <la.catoire@gmail.com>
Co-authored-by: Louis-Arnaud <la.catoire@gmail.com>
Co-authored-by: Louis-Arnaud <la.catoire@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.