Skip to content
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

[WIP][autoload] use composer classmap and deprecate sfAutoload #369

Draft
wants to merge 16 commits into
base: master
Choose a base branch
from
Draft
5 changes: 0 additions & 5 deletions autoload.php

This file was deleted.

3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"psr/log": "*"
},
"autoload": {
"files": ["autoload.php"]
"classmap": ["lib/"],
"exclude-from-classmap": ["lib/task/generator/skeleton/", "lib/plugins/sfDoctrinePlugin/test/"]
},
"suggest": {
"friendsofsymfony1/doctrine1": "Doctrine plugin",
Expand Down
29 changes: 2 additions & 27 deletions data/bin/symfony
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,9 @@
/*
* This file is part of the symfony package.
* (c) Fabien Potencier <[email protected]>
*
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

// project exists?
if (file_exists('config/ProjectConfiguration.class.php'))
{
require_once('config/ProjectConfiguration.class.php');
$dir = sfCoreAutoload::getInstance()->getBaseDir();
}
else
{
if (is_readable(__DIR__.'/../../lib/autoload/sfCoreAutoload.class.php'))
{
// SVN
$dir = realpath(__DIR__.'/../../lib');
}
else
{
// PEAR
$dir = '@PEAR-DIR@/symfony';

if (!is_dir($dir))
{
throw new Exception('Unable to find symfony libraries');
}
}
}

include($dir.'/command/cli.php');
include(__DIR__.'/../../lib/command/cli.php');
46 changes: 9 additions & 37 deletions lib/autoload/sfAutoload.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@
*/

/**
* sfAutoload class.
*
* This class is a singleton as PHP seems to be unable to register 2 autoloaders that are instances
* of the same class (why?).
*
* @author Fabien Potencier <[email protected]>
* @deprecated
*/
class sfAutoload
{
Expand All @@ -29,9 +24,7 @@ protected function __construct()
}

/**
* Retrieves the singleton instance of this class.
*
* @return sfAutoload a sfAutoload implementation instance
* @deprecated
*/
public static function getInstance()
{
Expand All @@ -43,9 +36,7 @@ public static function getInstance()
}

/**
* Register sfAutoload in spl autoloader.
*
* @throws sfException
* @deprecated
*/
public static function register()
{
Expand All @@ -57,18 +48,15 @@ public static function register()
}

/**
* Unregister sfAutoload from spl autoloader.
* @deprecated
*/
public static function unregister()
{
spl_autoload_unregister([self::getInstance(), 'autoload']);
}

/**
* Sets the path for a particular class.
*
* @param string $class A PHP class name
* @param string $path An absolute path
* @deprecated
*/
public function setClassPath($class, $path)
{
Expand All @@ -80,11 +68,7 @@ public function setClassPath($class, $path)
}

/**
* Returns the path where a particular class can be found.
*
* @param string $class A PHP class name
*
* @return string|null An absolute path
* @deprecated
*/
public function getClassPath($class)
{
Expand All @@ -94,11 +78,7 @@ public function getClassPath($class)
}

/**
* Reloads the autoloader.
*
* @param bool $force Whether to force a reload
*
* @return bool True if the reload was successful, otherwise false
* @deprecated
*/
public function reloadClasses($force = false)
{
Expand Down Expand Up @@ -139,11 +119,7 @@ public function reloadClasses($force = false)
}

/**
* Handles autoloading of classes that have been specified in autoload.yml.
*
* @param string $class a class name
*
* @return bool Returns true if the class has been loaded
* @deprecated
*/
public function autoload($class)
{
Expand All @@ -156,11 +132,7 @@ public function autoload($class)
}

/**
* Tries to load a class that has been specified in autoload.yml.
*
* @param string $class a class name
*
* @return bool Returns true if the class has been loaded
* @deprecated
*/
public function loadClass($class)
{
Expand Down
24 changes: 7 additions & 17 deletions lib/autoload/sfAutoloadAgain.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
*/

/**
* Autoload again for dev environments.
*
* @author Kris Wallsmith <[email protected]>
* @deprecated
*/
class sfAutoloadAgain
{
Expand All @@ -21,16 +19,14 @@ class sfAutoloadAgain
protected $reloaded = false;

/**
* Constructor.
* @deprecated
*/
protected function __construct()
{
}

/**
* Returns the singleton autoloader.
*
* @return sfAutoloadAgain
* @deprecated
*/
public static function getInstance()
{
Expand All @@ -42,11 +38,7 @@ public static function getInstance()
}

/**
* Reloads the autoloader.
*
* @param string $class
*
* @return bool
* @deprecated
*/
public function autoload($class)
{
Expand Down Expand Up @@ -87,17 +79,15 @@ public function autoload($class)
}

/**
* Returns true if the autoloader is registered.
*
* @return bool
* @deprecated
*/
public function isRegistered()
{
return $this->registered;
}

/**
* Registers the autoloader function.
* @deprecated
*/
public function register()
{
Expand All @@ -108,7 +98,7 @@ public function register()
}

/**
* Unregisters the autoloader function.
* @deprecated
*/
public function unregister()
{
Expand Down
Loading
Loading