Skip to content

Commit

Permalink
Merge pull request #239 from it-can/stylefixes
Browse files Browse the repository at this point in the history
style fixes
  • Loading branch information
Steve "Uru" West committed Feb 26, 2015
2 parents 7af1d01 + 8fcc5e2 commit 9b59116
Show file tree
Hide file tree
Showing 18 changed files with 40 additions and 69 deletions.
25 changes: 11 additions & 14 deletions bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,15 @@
* @link http://fuelphp.com
*/


Autoloader::add_classes(array(
'Oil\\Cell' => __DIR__.'/classes/cell.php',
'Oil\\Command' => __DIR__.'/classes/command.php',
'Oil\\Console' => __DIR__.'/classes/console.php',
'Oil\\Exception' => __DIR__.'/classes/exception.php',
'Oil\\Generate' => __DIR__.'/classes/generate.php',
'Oil\\Generate_Migration_Actions' => __DIR__.'/classes/generate/migration/actions.php',
'Oil\\Generate_Admin' => __DIR__.'/classes/generate/admin.php',
'Oil\\Generate_Scaffold' => __DIR__.'/classes/generate/scaffold.php',
'Oil\\Package' => __DIR__.'/classes/package.php',
'Oil\\Refine' => __DIR__.'/classes/refine.php',
\Autoloader::add_classes(array(
'Oil\\Cell' => __DIR__.'/classes/cell.php',
'Oil\\Command' => __DIR__.'/classes/command.php',
'Oil\\Console' => __DIR__.'/classes/console.php',
'Oil\\Exception' => __DIR__.'/classes/exception.php',
'Oil\\Generate' => __DIR__.'/classes/generate.php',
'Oil\\Generate_Migration_Actions' => __DIR__.'/classes/generate/migration/actions.php',
'Oil\\Generate_Admin' => __DIR__.'/classes/generate/admin.php',
'Oil\\Generate_Scaffold' => __DIR__.'/classes/generate/scaffold.php',
'Oil\\Package' => __DIR__.'/classes/package.php',
'Oil\\Refine' => __DIR__.'/classes/refine.php',
));

/* End of file bootstrap.php */
4 changes: 1 addition & 3 deletions classes/cell.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ public static function search($name)
}
}


public static function uninstall($package)
{
// Check to see if this package is already installed
Expand Down Expand Up @@ -151,7 +150,7 @@ public static function info($cell = null)
throw new \FuelException('No response from the API. Perhaps check your internet connection?');
}

else if (empty($response['cell']))
elseif (empty($response['cell']))
{
throw new \FuelException('Could not find the cell "' . $cell . '".');
}
Expand Down Expand Up @@ -187,7 +186,6 @@ public static function help()

}


protected static function _use_git()
{
exec('which git', $output);
Expand Down
8 changes: 4 additions & 4 deletions classes/command.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static function init($args)
case 'g':
case 'generate':

$action = isset($args[2]) ? $args[2]: 'help';
$action = isset($args[2]) ? $args[2] : 'help';

$subfolder = 'orm';
if (is_int(strpos($action, '/')))
Expand Down Expand Up @@ -104,7 +104,7 @@ public static function init($args)
case 'p':
case 'package':

$action = isset($args[2]) ? $args[2]: 'help';
$action = isset($args[2]) ? $args[2] : 'help';

switch ($action)
{
Expand All @@ -130,7 +130,7 @@ public static function init($args)
case 'cell':
case 'cells':

$action = isset($args[2]) ? $args[2]: 'help';
$action = isset($args[2]) ? $args[2] : 'help';

switch ($action)
{
Expand Down Expand Up @@ -212,7 +212,7 @@ public static function init($args)
// Suppressing this because if the file does not exist... well thats a bad thing and we can't really check
// I know that supressing errors is bad, but if you're going to complain: shut up. - Phil
$phpunit_autoload_path = \Config::get('oil.phpunit.autoload_path', 'PHPUnit/Autoload.php' );
@include_once($phpunit_autoload_path);
@include_once $phpunit_autoload_path;

// Attempt to load PHUnit. If it fails, we are done.
if ( ! $is_phar and ! class_exists('PHPUnit_Framework_TestCase'))
Expand Down
5 changes: 2 additions & 3 deletions classes/console.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

class Console
{

public function __construct()
{
error_reporting(E_ALL | E_STRICT);
Expand All @@ -35,7 +34,7 @@ public function __construct()
ini_set("html_errors", 0);
ini_set("display_errors", 0);

while (ob_get_level ())
while (ob_get_level())
{
ob_end_clean();
}
Expand Down Expand Up @@ -165,7 +164,7 @@ private static function is_immediate($line)
'class', 'declare', 'die', 'echo', 'exit', 'for',
'foreach', 'function', 'global', 'if', 'include',
'include_once', 'print', 'require', 'require_once',
'return', 'static', 'switch', 'unset', 'while'
'return', 'static', 'switch', 'unset', 'while',
);

$okeq = array('===', '!==', '==', '!=', '<=', '>=');
Expand Down
1 change: 0 additions & 1 deletion classes/exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
*/
class Exception extends \Exception
{

// public function __toString()
// {
// \Cli::write('Error: ' . $this->message);
Expand Down
37 changes: 12 additions & 25 deletions classes/generate.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Generate
private static $_default_constraints = array(
'varchar' => 255,
'char' => 255,
'int' => 11
'int' => 11,
);

public static function config($args)
Expand Down Expand Up @@ -97,7 +97,7 @@ public static function config($args)
{
// strip the classes directory as we need the module root
// and construct the filename
$path = substr($path,0, -8).'config'.DS.$file.'.php';
$path = substr($path, 0, -8).'config'.DS.$file.'.php';
$path_name = "\\".ucfirst($module).'::';
}
elseif ( ! empty($module))
Expand Down Expand Up @@ -205,7 +205,6 @@ class {$prefix}{$class_name} extends {$extends}
// Write controller
static::create($filepath, $controller, 'controller');


// Do you want a presenter with that?
if ($with_presenter)
{
Expand Down Expand Up @@ -234,7 +233,6 @@ public function view()
$build and static::build();
}


public static function model($args, $build = true)
{
$singular = \Inflector::singularize(\Str::lower(array_shift($args)));
Expand Down Expand Up @@ -401,7 +399,6 @@ class Model_{$class_name} extends \Model_Crud
$args = array_merge(array($title.':varchar[50]'), $args);
}


$tree_id = \Cli::option('tree-id', false);

if ($tree_id)
Expand Down Expand Up @@ -741,7 +738,6 @@ class Model_{$class_name} extends \Orm\Model
$build and static::build();
}


public static function module($args)
{
if ( ! ($module_name = strtolower(array_shift($args)) ) )
Expand Down Expand Up @@ -792,7 +788,6 @@ public static function module($args)
static::$create_folders && static::build();
}


public static function views($args, $subfolder, $build = true)
{
$controller = strtolower(array_shift($args));
Expand Down Expand Up @@ -844,7 +839,6 @@ public static function views($args, $subfolder, $build = true)
$build and static::build();
}


public static function migration($args, $build = true)
{
// Get the migration name
Expand Down Expand Up @@ -874,7 +868,7 @@ public static function migration($args, $build = true)
foreach($migrations as $migration)
{
// check if it's really a duplicate
$part = explode('_', basename($migration->getFilename(), '.php'),2);
$part = explode('_', basename($migration->getFilename(), '.php'), 2);
if ($part[1] != $migration_name)
{
$part = substr($part[1], strlen($migration_name)+1);
Expand Down Expand Up @@ -952,38 +946,38 @@ public static function migration($args, $build = true)
}

// add_{field}_to_{table}
else if (count($matches) == 3 && $matches[1] == 'to')
elseif (count($matches) == 3 && $matches[1] == 'to')
{
$subjects = array($matches[0], $matches[2]);
}

// delete_{field}_from_{table}
else if (count($matches) == 3 && $matches[1] == 'from')
elseif (count($matches) == 3 && $matches[1] == 'from')
{
$subjects = array($matches[0], $matches[2]);
}

// rename_field_{field}_to_{field}_in_{table} (with underscores in field names)
else if (count($matches) >= 5 && in_array('to', $matches) && in_array('in', $matches))
elseif (count($matches) >= 5 && in_array('to', $matches) && in_array('in', $matches))
{
$subjects = array(
implode('_', array_slice($matches, array_search('in', $matches)+1)),
implode('_', array_slice($matches, 0, array_search('to', $matches))),
implode('_', array_slice($matches, array_search('to', $matches)+1, array_search('in', $matches)-array_search('to', $matches)-1))
implode('_', array_slice($matches, array_search('to', $matches)+1, array_search('in', $matches)-array_search('to', $matches)-1)),
);
}

// rename_table
else if ($method_name == 'rename_table')
elseif ($method_name == 'rename_table')
{
$subjects = array(
implode('_', array_slice($matches, 0, array_search('to', $matches))),
implode('_', array_slice($matches, array_search('to', $matches)+1))
implode('_', array_slice($matches, array_search('to', $matches)+1)),
);
}

// create_{table} or drop_{table} (with underscores in table name)
else if (count($matches) !== 0)
elseif (count($matches) !== 0)
{
$name = str_replace(array('create_', 'add_', 'drop_', '_to_'), array('create-', 'add-', 'drop-', '-to-'), $migration_name);

Expand Down Expand Up @@ -1045,7 +1039,7 @@ public static function migration($args, $build = true)
{
$type = 'varchar';
}
else if ($type === 'integer')
elseif ($type === 'integer')
{
$type = 'int';
}
Expand Down Expand Up @@ -1164,8 +1158,6 @@ public function down()
$build and static::build();
}



public static function task($args, $build = true)
{

Expand Down Expand Up @@ -1279,7 +1271,6 @@ class {$class_name}
$build and static::build();
}


public static function help()
{
$output = <<<HELP
Expand Down Expand Up @@ -1317,7 +1308,6 @@ public static function help()
\Cli::write($output);
}


public static function package($args, $build = true)
{
$name = str_replace(array('/', '_', '-'), '', \Str::lower(array_shift($args)));
Expand Down Expand Up @@ -1476,7 +1466,6 @@ public static function instance(\$instance = null)

static::create($path . 'classes' . DS . $name . '.php', $output);


$output = <<<DRIVER
<?php
Expand Down Expand Up @@ -1674,7 +1663,6 @@ public function set_config(\$key, \$value)
$build and static::build();
}


public static function create($filepath, $contents, $type = 'file')
{
$directory = dirname($filepath);
Expand All @@ -1701,11 +1689,10 @@ public static function create($filepath, $contents, $type = 'file')
static::$create_files[] = array(
'path' => $filepath,
'contents' => $contents,
'type' => $type
'type' => $type,
);
}


public static function build()
{
foreach (static::$create_folders as $folder)
Expand Down
7 changes: 3 additions & 4 deletions classes/generate/migration/actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
*/
class Generate_Migration_Actions
{

/**
* Each migration action should return an array with two items, 0 being the up and 1 the being down.
*/
Expand Down Expand Up @@ -167,7 +166,7 @@ public static function rename_field($subjects, $fields)

case 'enum':
case 'set':
$constraint = '"\''.implode('\',\'',$column['options']).'\'"';
$constraint = '"\''.implode('\',\'', $column['options']).'\'"';
break;
}
break;
Expand Down Expand Up @@ -233,7 +232,7 @@ public static function drop($subjects, $fields)

case 'enum':
case 'set':
$constraint = '"\''.implode('\',\'',$column['options']).'\'"';
$constraint = '"\''.implode('\',\'', $column['options']).'\'"';
break;
}
break;
Expand All @@ -247,7 +246,7 @@ public static function drop($subjects, $fields)
{
$primary_keys[] = "'{$column['name']}'";
}
else if ($column['key'] == 'MUL')
elseif ($column['key'] == 'MUL')
{
$indexes[] = $column['name'];
}
Expand Down
2 changes: 1 addition & 1 deletion classes/generate/scaffold.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static function forge($args, $subfolder)
$data['fields'][] = array(
'name' => \Str::lower($matches[1]),
'type' => isset($matches[2]) ? $matches[2] : 'string',
'constraint' => isset($matches[4]) ? $matches[4] : null
'constraint' => isset($matches[4]) ? $matches[4] : null,
);
}

Expand Down
2 changes: 0 additions & 2 deletions classes/package.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ public static function install($package = null)
throw new Exception('Could not find package "' . $package . '".');
}


public static function uninstall($package)
{
$package_folder = PKGPATH . $package;
Expand Down Expand Up @@ -132,7 +131,6 @@ public static function help()

}


private static function _use_git()
{
exec('which git', $output);
Expand Down
3 changes: 1 addition & 2 deletions config/oil.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@
*/

'autoload_path' => 'PHPUnit/Autoload.php' ,
'binary_path' => 'phpunit' ,
'binary_path' => 'phpunit' ,

),
);

3 changes: 1 addition & 2 deletions phpserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,5 @@
else
{
// route requests though the normal path
include($_SERVER['DOCUMENT_ROOT'].'/index.php');
include $_SERVER['DOCUMENT_ROOT'].'/index.php';
}

1 change: 0 additions & 1 deletion tasks/fromdb.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ public static function scaffold($tables = null)
}
}


/**
* Generate model for a database table.
*
Expand Down
Loading

0 comments on commit 9b59116

Please sign in to comment.