Issue Type: Improvement Created: 2009-11-19T01:49:02.000+0000 Last Updated: 2009-11-19T03:13:40.000+0000 Status: Resolved Fix version(s): - 1.10.0 (27/Jan/10)
Reporter: ChieftainY2k (chieftainy2k) Assignee: Thomas Weidner (thomas) Tags: - Zend_Validate
Related issues: Attachments:
Currently Zend_Validate::is() checks if validator class exists using class_exists($className). If it doesn't then Zend_Validate::is() falls back to the Zend_Loader::loadClass($className). This behavior generates "Failed opening" warnings if multiple namespaces are used.
Sample code: Zend_Validate::is("2009-01-01", 'Date', array(),array('FirstNamespace', 'SecondNamespace'))
Result: Warning: include() [function.include]: Failed opening 'FirstNamespace/Date.php' for inclusion (include_path='...') in ZendFramework-1.9.5/library/Zend/Loader.php on line 83
My opinion is that Zend_Validate::is() should not fall back to the Zend_Loader::loadClass, since all namespaces (since ZF 1.8 as far as I remember) must have all respective namespace loaders registered via the Zend_Loader_Autoloader->pushAutoloader method.
When the validator class is not defined after all namespaces are checked then "Validate class not found from basename '$classBaseName'" exception sould be generated.
To sum up: In my opinion it's class_exists (via namespace loaders) job to load desired validator class.
Posted by Thomas Weidner (thomas) on 2009-11-19T02:38:03.000+0000
class_exists does not load files when no autoloader is set.
It is a php method which just checks if a given class exists or not. When you think that PHP itself should add class loading within class_exists then please fill in an issue at PHP.
Additionally we should and will not duplicate Zend_Loader within Zend_Validate.
Posted by ChieftainY2k (chieftainy2k) on 2009-11-19T03:03:08.000+0000
I was referring to the case when autoloader is set by the Zend_Loader_Autoloader.
Posted by Thomas Weidner (thomas) on 2009-11-19T03:12:32.000+0000
And when no autoloader is set then your case would no longer work because using namespaces is independently from a set autoloader.
Posted by Thomas Weidner (thomas) on 2009-11-19T03:13:15.000+0000
Changed with r19026
Have you found an issue?
See the Overview section for more details.