function ClassDiscovery::safeClassExists
We need a "safe" version of PHP's "class_exists" because Magento has a bug (or they call it a "feature"). Magento is throwing an exception if you do class_exists() on a class that ends with "Factory" and if that file does not exits.
This function catches all potential exceptions and makes sure to always return a boolean.
Parameters
string $class:
Return value
bool
7 calls to ClassDiscovery::safeClassExists()
- ClassDiscovery::evaluateCondition in vendor/
php-http/ discovery/ src/ ClassDiscovery.php - Evaluates conditions to boolean.
- ClassDiscovery::findOneByType in vendor/
php-http/ discovery/ src/ ClassDiscovery.php - Finds a class.
- CommonClassesStrategy::getPsr18Candidates in vendor/
php-http/ discovery/ src/ Strategy/ CommonClassesStrategy.php - Plugin::getMissingRequires in vendor/
php-http/ discovery/ src/ Composer/ Plugin.php - Plugin::postUpdate in vendor/
php-http/ discovery/ src/ Composer/ Plugin.php
File
-
vendor/
php-http/ discovery/ src/ ClassDiscovery.php, line 247
Class
- ClassDiscovery
- Registry that based find results on class existence.
Namespace
Http\DiscoveryCode
public static function safeClassExists($class) {
try {
return class_exists($class) || interface_exists($class);
} catch (\Exception $e) {
return false;
}
}