registerlocalnamespace.xml Fix typos and amend return type#5490
Open
mmalferov wants to merge 12 commits intophp:masterfrom
Open
registerlocalnamespace.xml Fix typos and amend return type#5490mmalferov wants to merge 12 commits intophp:masterfrom
mmalferov wants to merge 12 commits intophp:masterfrom
Conversation
Member
Author
|
Based on the actual behavior and the source code, the method returns <?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 ( 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;
} |
And the same:
```php
<?php
$loader = Yaf_Loader::getInstance();
$result = $loader->registerNamespace("App\Fake", "path");
var_dump($result); // object(Yaf_Loader)
$result = @$loader->registerNamespace(null, null);
var_dump($result); // bool(false)
```
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.