Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Checks if the class has been defined
<?php class_exists(string $class, bool $autoload = true): bool
<?php {
class_exists('Composer\Util\Platform');
class_exists('Composer\Downloader\FilesystemException');
$config = Factory::createConfig();
<?php class_exists('Composer\Util\Platform');
class_exists('Composer\Downloader\FilesystemException');
$config = Factory::createConfig();
<?php $hints[] = "<warning>ocramius/package-versions only provides support for Composer 2 in 1.8+, which requires PHP 7.4.</warning>\nIf you can not upgrade PHP you can require <info>composer/package-versions-deprecated</info> to resolve this with PHP 7.0+.";
}
if (!class_exists('PHPUnit\Framework\TestCase', false)) {
if (strpos($text, 'found composer-plugin-api[2.0.0] but it does not match')) {
$hints[] = "You are using Composer 2, which some of your plugins seem to be incompatible with. Make sure you update your plugins or report a plugin-issue to ask them to support Composer 2.";
}
<?php $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
}
if (!class_exists('RarArchive')) {
$iniMessage = IniHelper::getMessage();
<?php }
if (null === self::$hasZipArchive) {
self::$hasZipArchive = class_exists('ZipArchive');
}
if (!self::$hasZipArchive && !self::$unzipCommands) {
<?php $className = substr($callable, 0, strpos($callable, '::'));
$methodName = substr($callable, strpos($callable, '::') + 2);
if (!class_exists($className)) {
$this->io->writeError('<warning>Class '.$className.' is not autoloadable, can not call '.$event->getName().' script</warning>', true, IOInterface::QUIET);
continue;
}
<?php $io->loadConfiguration($config);
if (!class_exists('Composer\InstalledVersions', false) && file_exists($installedVersionsPath = $config->get('vendor-dir').'/composer/InstalledVersions.php')) {
include $installedVersionsPath;
}
}
<?php private function compressionAvailable()
{
return class_exists('ZipArchive');
}
}
<?php public function hasClass($class)
{
return class_exists($class, false);
}
<?php }
foreach ($classes as $class) {
if (class_exists($class, false)) {
$class = trim($class, '\\');
$path = $classLoader->findFile($class);
$code = file_get_contents($path);
<?php $installer = new $class($this->io, $this->composer);
$this->composer->getInstallationManager()->addInstaller($installer);
$this->registeredPlugins[$package->getName()] = $installer;
} elseif (class_exists($class)) {
$plugin = new $class();
$this->addPlugin($plugin, $isGlobalPlugin, $package);
$this->registeredPlugins[$package->getName()] = $plugin;
<?php public function getPluginCapability(PluginInterface $plugin, $capabilityClassName, array $ctorArgs = array())
{
if ($capabilityClass = $this->getCapabilityImplementationClassName($plugin, $capabilityClassName)) {
if (!class_exists($capabilityClass)) {
throw new \RuntimeException("Cannot instantiate Capability, as class $capabilityClass from plugin ".get_class($plugin)." does not exist.");
}
<?php $loader->add('Pearlike_', __DIR__ . '/Fixtures');
$loader->addPsr4('ShinyVendor\\ShinyPackage\\', __DIR__ . '/Fixtures');
$loader->loadClass($class);
$this->assertTrue(class_exists($class, false), "->loadClass() loads '$class'");
}
<?php private function checkIfFinderIsAvailable()
{
if (!class_exists('Symfony\\Component\\Finder\\Finder')) {
$this->markTestSkipped('Finder component is not available');
}
}
<?php public function testErrorMessages()
{
if (!class_exists('ZipArchive')) {
$this->markTestSkipped('zip extension missing');
}