Browse Source

Another round of global functions purging.

ADmad 11 years ago
parent
commit
138134436a
2 changed files with 0 additions and 143 deletions
  1. 0 82
      src/basics.php
  2. 0 61
      tests/TestCase/BasicsTest.php

+ 0 - 82
src/basics.php

@@ -121,41 +121,6 @@ if (!function_exists('stackTrace')) {
 
 }
 
-if (!function_exists('sortByKey')) {
-
-/**
- * Sorts given $array by key $sortBy.
- *
- * @param array &$array Array to sort
- * @param string $sortBy Sort by this key
- * @param string $order Sort order asc/desc (ascending or descending).
- * @param int $type Type of sorting to perform
- * @return mixed Sorted array
- * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#sortByKey
- */
-	function sortByKey(&$array, $sortBy, $order = 'asc', $type = SORT_NUMERIC) {
-		if (!is_array($array)) {
-			return null;
-		}
-
-		foreach ($array as $key => $val) {
-			$sa[$key] = $val[$sortBy];
-		}
-
-		if ($order === 'asc') {
-			asort($sa, $type);
-		} else {
-			arsort($sa, $type);
-		}
-
-		foreach ($sa as $key => $val) {
-			$out[] = $array[$key];
-		}
-		return $out;
-	}
-
-}
-
 if (!function_exists('h')) {
 
 /**
@@ -273,28 +238,6 @@ if (!function_exists('pr')) {
 
 }
 
-if (!function_exists('am')) {
-
-/**
- * Merge a group of arrays, accepts an unlimited amount of parameters
- *
- * @return array All array parameters merged into one
- * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#am
- */
-	function am() {
-		$r = array();
-		$args = func_get_args();
-		foreach ($args as $a) {
-			if (!is_array($a)) {
-				$a = array($a);
-			}
-			$r = array_merge($r, $a);
-		}
-		return $r;
-	}
-
-}
-
 if (!function_exists('env')) {
 
 /**
@@ -627,28 +570,3 @@ if (!function_exists('__x')) {
 	}
 
 }
-
-if (!function_exists('fileExistsInPath')) {
-
-/**
- * Searches include path for files.
- *
- * @param string $file File to look for
- * @return bool|string Full path to file if exists, otherwise false
- * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#fileExistsInPath
- */
-	function fileExistsInPath($file) {
-		$paths = explode(PATH_SEPARATOR, ini_get('include_path'));
-		foreach ($paths as $path) {
-			$fullPath = $path . DS . $file;
-
-			if (file_exists($fullPath)) {
-				return $fullPath;
-			} elseif (file_exists($file)) {
-				return $file;
-			}
-		}
-		return false;
-	}
-
-}

+ 0 - 61
tests/TestCase/BasicsTest.php

@@ -245,21 +245,6 @@ class BasicsTest extends TestCase {
 	}
 
 /**
- * Test am()
- *
- * @return void
- */
-	public function testAm() {
-		$result = am(array('one', 'two'), 2, 3, 4);
-		$expected = array('one', 'two', 2, 3, 4);
-		$this->assertEquals($expected, $result);
-
-		$result = am(array('one' => array(2, 3), 'two' => array('foo')), array('one' => array(4, 5)));
-		$expected = array('one' => array(4, 5), 'two' => array('foo'));
-		$this->assertEquals($expected, $result);
-	}
-
-/**
  * test __()
  *
  * @return void
@@ -678,52 +663,6 @@ class BasicsTest extends TestCase {
 	}
 
 /**
- * test fileExistsInPath()
- *
- * @return void
- */
-	public function testFileExistsInPath() {
-		if (!function_exists('ini_set')) {
-			$this->markTestSkipped('%s ini_set function not available');
-		}
-
-		$_includePath = ini_get('include_path');
-
-		$path = TMP . 'basics_test';
-		$folder1 = $path . DS . 'folder1';
-		$folder2 = $path . DS . 'folder2';
-		$file1 = $path . DS . 'file1.php';
-		$file2 = $folder1 . DS . 'file2.php';
-		$file3 = $folder1 . DS . 'file3.php';
-		$file4 = $folder2 . DS . 'file4.php';
-
-		new Folder($path, true);
-		new Folder($folder1, true);
-		new Folder($folder2, true);
-		touch($file1);
-		touch($file2);
-		touch($file3);
-		touch($file4);
-
-		ini_set('include_path', $path . PATH_SEPARATOR . $folder1);
-
-		$this->assertEquals(fileExistsInPath('file1.php'), $file1);
-		$this->assertEquals(fileExistsInPath('file2.php'), $file2);
-		$this->assertEquals(fileExistsInPath('folder1' . DS . 'file2.php'), $file2);
-		$this->assertEquals(fileExistsInPath($file2), $file2);
-		$this->assertEquals(fileExistsInPath('file3.php'), $file3);
-		$this->assertEquals(fileExistsInPath($file4), $file4);
-
-		$this->assertFalse(fileExistsInPath('file1'));
-		$this->assertFalse(fileExistsInPath('file4.php'));
-
-		$Folder = new Folder($path);
-		$Folder->delete();
-
-		ini_set('include_path', $_includePath);
-	}
-
-/**
  * test debug()
  *
  * @return void