registerlocalnamespace.xml Fix typos and amend return type#5490
registerlocalnamespace.xml Fix typos and amend return type#5490mmalferov wants to merge 12 commits intophp:masterfrom
Conversation
|
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)
```
|
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) |
| <methodsynopsis> | ||
| <modifier>public</modifier> <type>void</type><methodname>Yaf_Loader::registerLocalNamespace</methodname> | ||
| <modifier>public</modifier> <type class="union"><type>Yaf_Loader</type><type>false</type></type><methodname>Yaf_Loader::registerLocalNamespace</methodname> | ||
| <methodparam><type>mixed</type><parameter>prefix</parameter></methodparam> |
There was a problem hiding this comment.
| <methodparam><type>mixed</type><parameter>prefix</parameter></methodparam> | |
| <methodparam><type class="union"><type>string</type><type>array</type>< | |
| /type><parameter>prefix</parameter></methodparam> |
There was a problem hiding this comment.
The function only accepts string or array at runtime. Other types trigger an E_WARNING and the function returns false. See here Aligns with the sibling registernamespace.xml which already uses string|array.
| <note> | ||
| <para> | ||
| Yaf still think underline as folder separator. | ||
| Yaf still think underscore as folder separator. |
There was a problem hiding this comment.
| Yaf still think underscore as folder separator. | |
| Yaf still thinks underscore as folder separator. |
| <listitem> | ||
| <para> | ||
| a string of path, it is better to use abosolute path here for performance | ||
| A &string; of path, it is better to use abosolute path here for performance. |
There was a problem hiding this comment.
| A &string; of path, it is better to use abosolute path here for performance. | |
| A &string; of path, it is better to use absolute path here for performance. |
| <modifier>public</modifier> <type>void</type><methodname>Yaf_Loader::registerLocalNamespace</methodname> | ||
| <modifier>public</modifier> <type class="union"><type>Yaf_Loader</type><type>false</type></type><methodname>Yaf_Loader::registerLocalNamespace</methodname> | ||
| <methodparam><type>mixed</type><parameter>prefix</parameter></methodparam> | ||
| </methodsynopsis> |
There was a problem hiding this comment.
| </methodsynopsis> | |
| <methodparam choice="opt"><type>string</type><parameter>path</parameter></methodparam> | |
| </methodsynopsis> |
There was a problem hiding this comment.
The function accepts a second optional $path parameter that isn't documented on this page. Per the zpp call "z|S" the function takes one required zval and one optional string, and the proto comment right above the method confirms:
proto public Yaf_Loader::registerLocalNamespace(mixed $namespace, string $path = NULL) Here
The sibling registernamespace.xml already documents $path, which makes sense since both methods are the same C function (PHP_MALIAS).
| All class prefix with these prefix will be loaded in local library path. | ||
| </para> | ||
| </listitem> | ||
| </varlistentry> |
There was a problem hiding this comment.
| </varlistentry> | |
| </varlistentry> | |
| <varlistentry> | |
| <term><parameter>path</parameter></term> | |
| <listitem> | |
| <simpara>A &string; of path, it is better to use absolute path here for performance.</simpara> | |
| </listitem> | |
| </varlistentry> |
| all class prefix with these prefix will be loaded in local library path. | ||
| A &string; or an &array; of class name prefix. | ||
| All class prefix with these prefix will be loaded in local library path. | ||
| </para> |
There was a problem hiding this comment.
| </para> | |
| </simpara> |
| @@ -49,8 +50,8 @@ | |||
| <term><parameter>prefix</parameter></term> | |||
| <listitem> | |||
| <para> | |||
There was a problem hiding this comment.
| <para> | |
| <simpara> |
| @@ -60,7 +61,7 @@ | |||
| <refsect1 role="returnvalues"> | |||
| &reftitle.returnvalues; | |||
| <para> | |||
There was a problem hiding this comment.
| <para> | |
| <simpara> |
| <para> | ||
| bool | ||
| Returns the <classname>Yaf_Loader</classname> instance on success,&return.falseforfailure;. | ||
| </para> |
There was a problem hiding this comment.
| </para> | |
| </simpara> |
No description provided.