Skip to content

Commit

Permalink
remove all reference to DS contant
Browse files Browse the repository at this point in the history
  • Loading branch information
antograssiot committed Feb 21, 2016
1 parent 25757f0 commit 2fb0343
Show file tree
Hide file tree
Showing 38 changed files with 111 additions and 111 deletions.
2 changes: 1 addition & 1 deletion src/Cache/CacheEngine.php
Expand Up @@ -251,7 +251,7 @@ public function key($key)
$prefix = vsprintf($this->_groupPrefix, $this->groups());
}

$key = preg_replace('/[\s]+/', '_', strtolower(trim(str_replace([DS, '/', '.'], '_', strval($key)))));
$key = preg_replace('/[\s]+/', '_', strtolower(trim(str_replace([DIRECTORY_SEPARATOR, '/', '.'], '_', strval($key)))));
return $prefix . $key;
}

Expand Down
16 changes: 8 additions & 8 deletions src/Cache/Engine/FileEngine.php
Expand Up @@ -91,16 +91,16 @@ public function init(array $config = [])
parent::init($config);

if ($this->_config['path'] === null) {
$this->_config['path'] = sys_get_temp_dir() . DS . 'cake_cache' . DS;
$this->_config['path'] = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'cake_cache' . DIRECTORY_SEPARATOR;
}
if (DS === '\\') {
if (DIRECTORY_SEPARATOR === '\\') {
$this->_config['isWindows'] = true;
}
if (substr($this->_config['path'], -1) !== DS) {
$this->_config['path'] .= DS;
if (substr($this->_config['path'], -1) !== DIRECTORY_SEPARATOR) {
$this->_config['path'] .= DIRECTORY_SEPARATOR;
}
if (!empty($this->_groupPrefix)) {
$this->_groupPrefix = str_replace('_', DS, $this->_groupPrefix);
$this->_groupPrefix = str_replace('_', DIRECTORY_SEPARATOR, $this->_groupPrefix);
}
return $this->_active();
}
Expand Down Expand Up @@ -279,7 +279,7 @@ public function clear($check)
continue;
}

$path = $path->getRealPath() . DS;
$path = $path->getRealPath() . DIRECTORY_SEPARATOR;
if (!in_array($path, $cleared)) {
$this->_clearDirectory($path, $now, $threshold);
$cleared[] = $path;
Expand Down Expand Up @@ -445,7 +445,7 @@ public function key($key)
}

$key = Inflector::underscore(str_replace(
[DS, '/', '.', '<', '>', '?', ':', '|', '*', '"'],
[DIRECTORY_SEPARATOR, '/', '.', '<', '>', '?', ':', '|', '*', '"'],
'_',
strval($key)
));
Expand All @@ -467,7 +467,7 @@ public function clearGroup($group)
RecursiveIteratorIterator::CHILD_FIRST
);
foreach ($contents as $object) {
$containsGroup = strpos($object->getPathname(), DS . $group . DS) !== false;
$containsGroup = strpos($object->getPathname(), DIRECTORY_SEPARATOR . $group . DIRECTORY_SEPARATOR) !== false;
$hasPrefix = true;
if (strlen($this->_config['prefix']) !== 0) {
$hasPrefix = strpos($object->getBasename(), $this->_config['prefix']) === 0;
Expand Down
2 changes: 1 addition & 1 deletion src/Console/ConsoleOutput.php
Expand Up @@ -163,7 +163,7 @@ public function __construct($stream = 'php://stdout')
{
$this->_output = fopen($stream, 'w');

if ((DS === '\\' && !(bool)env('ANSICON') && env('ConEmuANSI') !== 'ON') ||
if ((DIRECTORY_SEPARATOR === '\\' && !(bool)env('ANSICON') && env('ConEmuANSI') !== 'ON') ||
(function_exists('posix_isatty') && !posix_isatty($this->_output))
) {
$this->_outputAs = self::PLAIN;
Expand Down
10 changes: 5 additions & 5 deletions src/Console/Shell.php
Expand Up @@ -762,7 +762,7 @@ public function error($title, $message = null, $exitCode = self::CODE_ERROR)
public function clear()
{
if (empty($this->params['noclear'])) {
if (DS === '/') {
if (DIRECTORY_SEPARATOR === '/') {
passthru('clear');
} else {
passthru('cls');
Expand All @@ -780,7 +780,7 @@ public function clear()
*/
public function createFile($path, $contents)
{
$path = str_replace(DS . DS, DS, $path);
$path = str_replace(DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, $path);

$this->_io->out();

Expand Down Expand Up @@ -826,9 +826,9 @@ public function createFile($path, $contents)
public function shortPath($file)
{
$shortPath = str_replace(ROOT, null, $file);
$shortPath = str_replace('..' . DS, '', $shortPath);
$shortPath = str_replace(DS, '/', $shortPath);
return str_replace('//', DS, $shortPath);
$shortPath = str_replace('..' . DIRECTORY_SEPARATOR, '', $shortPath);
$shortPath = str_replace(DIRECTORY_SEPARATOR, '/', $shortPath);
return str_replace('//', DIRECTORY_SEPARATOR, $shortPath);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/Component/RequestHandlerComponent.php
Expand Up @@ -564,11 +564,11 @@ public function renderAs(Controller $controller, $type, array $options = [])
$builder->className($viewClass);
} else {
if (empty($this->_renderType)) {
$builder->templatePath($builder->templatePath() . DS . $type);
$builder->templatePath($builder->templatePath() . DIRECTORY_SEPARATOR . $type);
} else {
$builder->templatePath(preg_replace(
"/([\/\\\\]{$this->_renderType})$/",
DS . $type,
DIRECTORY_SEPARATOR . $type,
$builder->templatePath()
));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Controller.php
Expand Up @@ -625,7 +625,7 @@ protected function _viewPath()
'Cake\Utility\Inflector::camelize',
explode('/', $this->request->params['prefix'])
);
$viewPath = implode(DS, $prefixes) . DS . $viewPath;
$viewPath = implode(DIRECTORY_SEPARATOR, $prefixes) . DIRECTORY_SEPARATOR . $viewPath;
}
return $viewPath;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Core/App.php
Expand Up @@ -186,9 +186,9 @@ public static function path($type, $plugin = null)
return (array)Configure::read('App.paths.templates');
}
if (!empty($plugin)) {
return [Plugin::classPath($plugin) . $type . DS];
return [Plugin::classPath($plugin) . $type . DIRECTORY_SEPARATOR];
}
return [APP . $type . DS];
return [APP . $type . DIRECTORY_SEPARATOR];
}

/**
Expand All @@ -207,6 +207,6 @@ public static function path($type, $plugin = null)
*/
public static function core($type)
{
return [CAKE . str_replace('/', DS, $type) . DS];
return [CAKE . str_replace('/', DIRECTORY_SEPARATOR, $type) . DIRECTORY_SEPARATOR];
}
}
6 changes: 3 additions & 3 deletions src/Core/ClassLoader.php
Expand Up @@ -53,8 +53,8 @@ public function addNamespace($prefix, $baseDir, $prepend = false)
{
$prefix = trim($prefix, '\\') . '\\';

$baseDir = rtrim($baseDir, '/') . DS;
$baseDir = rtrim($baseDir, DS) . '/';
$baseDir = rtrim($baseDir, '/') . DIRECTORY_SEPARATOR;
$baseDir = rtrim($baseDir, DIRECTORY_SEPARATOR) . '/';

if (!isset($this->_prefixes[$prefix])) {
$this->_prefixes[$prefix] = [];
Expand Down Expand Up @@ -108,7 +108,7 @@ protected function _loadMappedFile($prefix, $relativeClass)
}

foreach ($this->_prefixes[$prefix] as $baseDir) {
$file = $baseDir . str_replace('\\', DS, $relativeClass) . '.php';
$file = $baseDir . str_replace('\\', DIRECTORY_SEPARATOR, $relativeClass) . '.php';

if ($this->_requireFile($file)) {
return $file;
Expand Down
2 changes: 1 addition & 1 deletion src/Core/ConventionsTrait.php
Expand Up @@ -136,7 +136,7 @@ protected function _pluginPath($pluginName)
if (Plugin::loaded($pluginName)) {
return Plugin::path($pluginName);
}
return current(App::path('Plugin')) . $pluginName . DS;
return current(App::path('Plugin')) . $pluginName . DIRECTORY_SEPARATOR;
}

/**
Expand Down
16 changes: 8 additions & 8 deletions src/Core/Plugin.php
Expand Up @@ -135,10 +135,10 @@ public static function load($plugin, array $config = [])

if (empty($config['path'])) {
$paths = App::path('Plugin');
$pluginPath = str_replace('/', DS, $plugin);
$pluginPath = str_replace('/', DIRECTORY_SEPARATOR, $plugin);
foreach ($paths as $path) {
if (is_dir($path . $pluginPath)) {
$config['path'] = $path . $pluginPath . DS;
$config['path'] = $path . $pluginPath . DIRECTORY_SEPARATOR;
break;
}
}
Expand All @@ -148,9 +148,9 @@ public static function load($plugin, array $config = [])
throw new MissingPluginException(['plugin' => $plugin]);
}

$config['classPath'] = $config['path'] . $config['classBase'] . DS;
$config['classPath'] = $config['path'] . $config['classBase'] . DIRECTORY_SEPARATOR;
if (!isset($config['configPath'])) {
$config['configPath'] = $config['path'] . 'config' . DS;
$config['configPath'] = $config['path'] . 'config' . DIRECTORY_SEPARATOR;
}

static::$_plugins[$plugin] = $config;
Expand All @@ -162,11 +162,11 @@ public static function load($plugin, array $config = [])
}
static::$_loader->addNamespace(
str_replace('/', '\\', $plugin),
$config['path'] . $config['classBase'] . DS
$config['path'] . $config['classBase'] . DIRECTORY_SEPARATOR
);
static::$_loader->addNamespace(
str_replace('/', '\\', $plugin) . '\Test',
$config['path'] . 'tests' . DS
$config['path'] . 'tests' . DIRECTORY_SEPARATOR
);
}

Expand All @@ -185,9 +185,9 @@ protected static function _loadConfig()
if (Configure::check('plugins')) {
return;
}
$vendorFile = dirname(dirname(__DIR__)) . DS . 'cakephp-plugins.php';
$vendorFile = dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'cakephp-plugins.php';
if (!file_exists($vendorFile)) {
$vendorFile = dirname(dirname(dirname(dirname(__DIR__)))) . DS . 'cakephp-plugins.php';
$vendorFile = dirname(dirname(dirname(dirname(__DIR__)))) . DIRECTORY_SEPARATOR . 'cakephp-plugins.php';
if (!file_exists($vendorFile)) {
Configure::write(['plugins' => []]);
return;
Expand Down
2 changes: 1 addition & 1 deletion src/Filesystem/README.md
Expand Up @@ -20,7 +20,7 @@ Now you can loop through the files and read from or write/append to the contents

```php
foreach ($files as $file) {
$file = new File($dir->pwd() . DS . $file);
$file = new File($dir->pwd() . DIRECTORY_SEPARATOR . $file);
$contents = $file->read();
// $file->write('I am overwriting the contents of this file');
// $file->append('I am adding to the bottom of this file.');
Expand Down
8 changes: 4 additions & 4 deletions src/I18n/MessagesFileLoader.php
Expand Up @@ -160,20 +160,20 @@ public function translationsFolders()

$localePaths = App::path('Locale');
if (empty($localePaths)) {
$localePaths[] = APP . 'Locale' . DS;
$localePaths[] = APP . 'Locale' . DIRECTORY_SEPARATOR;
}
foreach ($localePaths as $path) {
foreach ($folders as $folder) {
$searchPaths[] = $path . $folder . DS;
$searchPaths[] = $path . $folder . DIRECTORY_SEPARATOR;
}
}

// If space is not added after slash, the character after it remains lowercased
$pluginName = Inflector::camelize(str_replace('/', '/ ', $this->_name));
if (Plugin::loaded($pluginName)) {
$basePath = Plugin::classPath($pluginName) . 'Locale' . DS;
$basePath = Plugin::classPath($pluginName) . 'Locale' . DIRECTORY_SEPARATOR;
foreach ($folders as $folder) {
$searchPaths[] = $basePath . $folder . DS;
$searchPaths[] = $basePath . $folder . DIRECTORY_SEPARATOR;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Log/Engine/ConsoleLog.php
Expand Up @@ -57,7 +57,7 @@ class ConsoleLog extends BaseLog
*/
public function __construct(array $config = [])
{
if ((DS === '\\' && !(bool)env('ANSICON') && env('ConEmuANSI') !== 'ON') ||
if ((DIRECTORY_SEPARATOR === '\\' && !(bool)env('ANSICON') && env('ConEmuANSI') !== 'ON') ||
(function_exists('posix_isatty') && !posix_isatty($this->_output))
) {
$this->_defaultConfig['outputAs'] = ConsoleOutput::PLAIN;
Expand Down
2 changes: 1 addition & 1 deletion src/Network/Http/Adapter/Stream.php
Expand Up @@ -232,7 +232,7 @@ protected function _buildSslContext(Request $request, $options)
'ssl_passphrase',
];
if (empty($options['ssl_cafile'])) {
$options['ssl_cafile'] = CORE_PATH . 'config' . DS . 'cacert.pem';
$options['ssl_cafile'] = CORE_PATH . 'config' . DIRECTORY_SEPARATOR . 'cacert.pem';
}
if (!empty($options['ssl_verify_host'])) {
$url = $request->url();
Expand Down
4 changes: 2 additions & 2 deletions src/Network/Request.php
Expand Up @@ -403,7 +403,7 @@ protected static function _base()
$base = dirname($base);
}

if ($base === DS || $base === '.') {
if ($base === DIRECTORY_SEPARATOR || $base === '.') {
$base = '';
}
$base = implode('/', array_map('rawurlencode', explode('/', $base)));
Expand All @@ -413,7 +413,7 @@ protected static function _base()
$file = '/' . basename($baseUrl);
$base = dirname($baseUrl);

if ($base === DS || $base === '.') {
if ($base === DIRECTORY_SEPARATOR || $base === '.') {
$base = '';
}
$webrootDir = $base . '/';
Expand Down
4 changes: 2 additions & 2 deletions src/Routing/Filter/AssetFilter.php
Expand Up @@ -110,8 +110,8 @@ protected function _getAssetFile($url)
$plugin = implode('/', $pluginPart);
if ($plugin && Plugin::loaded($plugin)) {
$parts = array_slice($parts, $i + 1);
$fileFragment = implode(DS, $parts);
$pluginWebroot = Plugin::path($plugin) . 'webroot' . DS;
$fileFragment = implode(DIRECTORY_SEPARATOR, $parts);
$pluginWebroot = Plugin::path($plugin) . 'webroot' . DIRECTORY_SEPARATOR;
return $pluginWebroot . $fileFragment;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Shell/CommandListShell.php
Expand Up @@ -56,8 +56,8 @@ public function main()
if (empty($this->params['xml'])) {
$this->out("<info>Current Paths:</info>", 2);
$this->out("* app: " . APP_DIR);
$this->out("* root: " . rtrim(ROOT, DS));
$this->out("* core: " . rtrim(CORE_PATH, DS));
$this->out("* root: " . rtrim(ROOT, DIRECTORY_SEPARATOR));
$this->out("* core: " . rtrim(CORE_PATH, DIRECTORY_SEPARATOR));
$this->out("");

$this->out("<info>Available Shells:</info>", 2);
Expand Down
6 changes: 3 additions & 3 deletions src/Shell/I18nShell.php
Expand Up @@ -89,9 +89,9 @@ public function init($language = null)
$this->_paths = [Plugin::classPath($plugin)];
}

$response = $this->in('What folder?', null, rtrim($this->_paths[0], DS) . DS . 'Locale');
$sourceFolder = rtrim($response, DS) . DS;
$targetFolder = $sourceFolder . $language . DS;
$response = $this->in('What folder?', null, rtrim($this->_paths[0], DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'Locale');
$sourceFolder = rtrim($response, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
$targetFolder = $sourceFolder . $language . DIRECTORY_SEPARATOR;
if (!is_dir($targetFolder)) {
mkdir($targetFolder, 0775, true);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Shell/ServerShell.php
Expand Up @@ -95,7 +95,7 @@ public function startup()
}

// For Windows
if (substr($this->_documentRoot, -1, 1) === DS) {
if (substr($this->_documentRoot, -1, 1) === DIRECTORY_SEPARATOR) {
$this->_documentRoot = substr($this->_documentRoot, 0, strlen($this->_documentRoot) - 1);
}
if (preg_match("/^([a-z]:)[\\\]+(.+)$/i", $this->_documentRoot, $m)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Shell/Task/AssetsTask.php
Expand Up @@ -93,7 +93,7 @@ protected function _list($name = null)
$namespaced = true;
$parts = explode('/', $link);
$link = array_pop($parts);
$dir = WWW_ROOT . implode(DS, $parts) . DS;
$dir = WWW_ROOT . implode(DIRECTORY_SEPARATOR, $parts) . DIRECTORY_SEPARATOR;
}

$plugins[$plugin] = [
Expand Down

0 comments on commit 2fb0343

Please sign in to comment.