-
Notifications
You must be signed in to change notification settings - Fork 863
registerlocalnamespace.xml Fix typos and amend return type #5490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
2e60096
b88761b
c566582
14e57a5
ab2f653
9bf4b84
d821078
7a5fce7
191fba8
d627fa9
24c9751
55074ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -10,13 +10,13 @@ | |||||||||||||||||
| <refsect1 role="description"> | ||||||||||||||||||
| &reftitle.description; | ||||||||||||||||||
| <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> | ||||||||||||||||||
| </methodsynopsis> | ||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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: The sibling registernamespace.xml already documents |
||||||||||||||||||
| <para> | ||||||||||||||||||
| Register local class prefix name, <classname>Yaf_Loader</classname> search | ||||||||||||||||||
| Register local class prefix name, <classname>Yaf_Loader</classname> searches | ||||||||||||||||||
| classes in two library directories, the one is configured via <link | ||||||||||||||||||
| linkend="configuration.yaf.library">application.library.directory</link>(in | ||||||||||||||||||
| linkend="configuration.yaf.library">application.library.directory</link> (in | ||||||||||||||||||
| application.ini) which is called local library directory; the other is | ||||||||||||||||||
| configured via <link linkend="ini.yaf.library">yaf.library</link> (in | ||||||||||||||||||
| php.ini) which is called global library directory, since it can be shared | ||||||||||||||||||
|
|
@@ -27,17 +27,18 @@ | |||||||||||||||||
| determine which library directory should be searched in by examining the prefix | ||||||||||||||||||
| name of the missed classname. | ||||||||||||||||||
|
|
||||||||||||||||||
| If the prefix name is registered as a localnamespack then look for it in | ||||||||||||||||||
| If the prefix name is registered as a local namespace then look for it in | ||||||||||||||||||
| local library directory, otherwise look for it in global library directory. | ||||||||||||||||||
| <note> | ||||||||||||||||||
| <para> | ||||||||||||||||||
| If yaf.library is not configured, then the global library directory is | ||||||||||||||||||
| assumed to be the local library directory. in that case, all autoloading | ||||||||||||||||||
| will look for local library directory. | ||||||||||||||||||
|
|
||||||||||||||||||
| <simpara> | ||||||||||||||||||
| If <literal>yaf.library</literal> is not configured, then the global library directory is | ||||||||||||||||||
| assumed to be the local library directory. In that case, all autoloading | ||||||||||||||||||
| will look for local library directory. | ||||||||||||||||||
| </simpara> | ||||||||||||||||||
| <simpara> | ||||||||||||||||||
| But if you want your Yaf application be strong, then always register your | ||||||||||||||||||
| own classes as local classes. | ||||||||||||||||||
| </para> | ||||||||||||||||||
| </simpara> | ||||||||||||||||||
| </note> | ||||||||||||||||||
| </para> | ||||||||||||||||||
| </refsect1> | ||||||||||||||||||
|
|
@@ -49,8 +50,8 @@ | |||||||||||||||||
| <term><parameter>prefix</parameter></term> | ||||||||||||||||||
| <listitem> | ||||||||||||||||||
| <para> | ||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
| a string or an array of class name prefix. | ||||||||||||||||||
| 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> | ||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
| </listitem> | ||||||||||||||||||
| </varlistentry> | ||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
|
|
@@ -60,7 +61,7 @@ | |||||||||||||||||
| <refsect1 role="returnvalues"> | ||||||||||||||||||
| &reftitle.returnvalues; | ||||||||||||||||||
| <para> | ||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
| bool | ||||||||||||||||||
| Returns the <classname>Yaf_Loader</classname> instance on success,&return.falseforfailure;. | ||||||||||||||||||
| </para> | ||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
| </refsect1> | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
@@ -71,7 +72,9 @@ | |||||||||||||||||
| <programlisting role="php"> | ||||||||||||||||||
| <![CDATA[ | ||||||||||||||||||
| <?php | ||||||||||||||||||
|
|
||||||||||||||||||
| $loader = Yaf_Loader::getInstance('/local/library/', '/global/library'); | ||||||||||||||||||
|
|
||||||||||||||||||
| $loader->registerLocalNamespace("Baidu"); | ||||||||||||||||||
| $loader->registerLocalNamespace(array("Sina", "Weibo")); | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -10,20 +10,20 @@ | |||||
| <refsect1 role="description"> | ||||||
| &reftitle.description; | ||||||
| <methodsynopsis> | ||||||
| <modifier>public</modifier> <type>bool</type><methodname>Yaf_Loader::registerNamespace</methodname> | ||||||
| <methodparam><type class="union"><type>string</type><type>array</type></type><parameter>namespaces</parameter></methodparam> | ||||||
| <modifier>public</modifier> <type class="union"><type>Yaf_Loader</type><type>false</type></type><methodname>Yaf_Loader::registerNamespace</methodname> | ||||||
| <methodparam><type class="union"><type>string</type><type>array</type></type><parameter>namespace</parameter></methodparam> | ||||||
| <methodparam choice="opt"><type>string</type><parameter>path</parameter></methodparam> | ||||||
| </methodsynopsis> | ||||||
| <para> | ||||||
| Register a namespace with searching path, <classname>Yaf_Loader</classname> | ||||||
| searchs classes under this namespace in path, the one is also could be | ||||||
| configureded via <link linkend="configuration.yaf.library.namespace"> | ||||||
| application.library.directory.namespace</link>(in application.ini); | ||||||
| searches classes under this namespace in path, the one is also could be | ||||||
| configured via <link linkend="configuration.yaf.library.namespace"> | ||||||
| application.library.namespace</link> (in <literal>application.ini</literal>). | ||||||
| </para> | ||||||
| <para> | ||||||
| <note> | ||||||
| <para> | ||||||
| Yaf still think underline as folder separator. | ||||||
| Yaf still think underscore as folder separator. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| </para> | ||||||
| </note> | ||||||
| </para> | ||||||
|
|
@@ -36,15 +36,15 @@ | |||||
| <term><parameter>namespace</parameter></term> | ||||||
| <listitem> | ||||||
| <para> | ||||||
| a string of namespace, or an array of namespaces with paths. | ||||||
| A &string; of namespace, or an &array; of namespaces with paths. | ||||||
| </para> | ||||||
| </listitem> | ||||||
| </varlistentry> | ||||||
| <varlistentry> | ||||||
| <term><parameter>path</parameter></term> | ||||||
| <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. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| </para> | ||||||
| </listitem> | ||||||
| </varlistentry> | ||||||
|
|
@@ -54,7 +54,7 @@ | |||||
| <refsect1 role="returnvalues"> | ||||||
| &reftitle.returnvalues; | ||||||
| <para> | ||||||
| bool | ||||||
| Returns the <classname>Yaf_Loader</classname> instance on success,&return.falseforfailure;. | ||||||
| </para> | ||||||
| </refsect1> | ||||||
|
|
||||||
|
|
@@ -65,16 +65,18 @@ | |||||
| <programlisting role="php"> | ||||||
| <![CDATA[ | ||||||
| <?php | ||||||
|
|
||||||
| $loader = Yaf_Loader::getInstance(); | ||||||
|
|
||||||
| $loader->registerNamespace("\Vendor\PHP", "/var/lib/php"); | ||||||
| $loader->registerNamespace(array( | ||||||
| "\Vendor\ASP" => "/var/lib/asp", | ||||||
| "\Vendor\JSP" => "/usr/lib/vendor/", | ||||||
| )); | ||||||
|
|
||||||
| $loader->autoload("\Vendor\PHP\Dummy"); //load '/var/lib/php/Dummy.php' | ||||||
| $loader->autoload("\Vendor\PHP\Foo_Bar"); //load '/var/lib/php/Foo/Bar.php' | ||||||
| $loader->autoload("\Vendor\JSP\Dummy"); //load '/usr/lib/vendor/Dummy.php' | ||||||
| $loader->autoload("\Vendor\PHP\Dummy"); // Load '/var/lib/php/Dummy.php' | ||||||
| $loader->autoload("\Vendor\PHP\Foo_Bar"); // Load '/var/lib/php/Foo/Bar.php' | ||||||
| $loader->autoload("\Vendor\JSP\Dummy"); // Load '/usr/lib/vendor/Dummy.php' | ||||||
|
|
||||||
| ?> | ||||||
| ]]> | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.xmlwhich already uses string|array.