ZF-8333: Zend_Validate::is() should not fall back to Zend_Loader::loadClass

Description

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.

Comments

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.

I was referring to the case when autoloader is set by the Zend_Loader_Autoloader.

And when no autoloader is set then your case would no longer work because using namespaces is independently from a set autoloader.

Changed with r19026