Update to proposed PSR-1 coding standard.

* 4 space (no tab) indent
 * K&R-style braces
This commit is contained in:
Justin Hileman
2012-05-01 22:03:39 -07:00
parent be5cfb3e9e
commit 2448992cc8
57 changed files with 3283 additions and 3009 deletions
+33 -33
View File
@@ -38,10 +38,10 @@ define('EXAMPLE_PATH', realpath(dirname(__FILE__) . '/../test/fixtures/examples'
* @return string
*/
function getLowerCaseName($name) {
return preg_replace_callback("/([A-Z])/", create_function (
'$match',
'return "_" . strtolower($match[1]);'
), lcfirst($name));
return preg_replace_callback("/([A-Z])/", create_function (
'$match',
'return "_" . strtolower($match[1]);'
), lcfirst($name));
}
/**
@@ -57,10 +57,10 @@ function getLowerCaseName($name) {
* @return string
*/
function getUpperCaseName($name) {
return preg_replace_callback("/_([a-z])/", create_function (
'$match',
'return strtoupper($match{1});'
), ucfirst($name));
return preg_replace_callback("/_([a-z])/", create_function (
'$match',
'return strtoupper($match{1});'
), ucfirst($name));
}
@@ -72,8 +72,8 @@ function getUpperCaseName($name) {
* @return mixed
*/
function out($value) {
echo $value . "\n";
return $value;
echo $value . "\n";
return $value;
}
/**
@@ -89,8 +89,8 @@ function out($value) {
* @return string
*/
function buildPath($directory, $filename = null, $extension = null) {
return out(EXAMPLE_PATH . '/' . $directory.
($extension !== null && $filename !== null ? '/' . $filename. "." . $extension : ""));
return out(EXAMPLE_PATH . '/' . $directory.
($extension !== null && $filename !== null ? '/' . $filename. "." . $extension : ""));
}
/**
@@ -102,9 +102,9 @@ function buildPath($directory, $filename = null, $extension = null) {
* @return void
*/
function createDirectory($directory) {
if(!@mkdir(buildPath($directory))) {
die("FAILED to create directory\n");
}
if(!@mkdir(buildPath($directory))) {
die("FAILED to create directory\n");
}
}
/**
@@ -119,13 +119,13 @@ function createDirectory($directory) {
* @return void
*/
function createFile($directory, $filename, $extension, $content = "") {
$handle = @fopen(buildPath($directory, $filename, $extension), "w");
if($handle) {
fwrite($handle, $content);
fclose($handle);
} else {
die("FAILED to create file\n");
}
$handle = @fopen(buildPath($directory, $filename, $extension), "w");
if($handle) {
fwrite($handle, $content);
fclose($handle);
} else {
die("FAILED to create file\n");
}
}
@@ -143,12 +143,12 @@ function createFile($directory, $filename, $extension, $content = "") {
* @return void
*/
function main($example_name) {
$lowercase = getLowerCaseName($example_name);
$uppercase = getUpperCaseName($example_name);
createDirectory($lowercase);
createFile($lowercase, $lowercase, "mustache");
createFile($lowercase, $lowercase, "txt");
createFile($lowercase, $uppercase, "php", <<<CONTENT
$lowercase = getLowerCaseName($example_name);
$uppercase = getUpperCaseName($example_name);
createDirectory($lowercase);
createFile($lowercase, $lowercase, "mustache");
createFile($lowercase, $lowercase, "txt");
createFile($lowercase, $uppercase, "php", <<<CONTENT
<?php
class {$uppercase} {
@@ -156,16 +156,16 @@ class {$uppercase} {
}
CONTENT
);
);
}
// check if enougth arguments are given
if(count($argv) > 1) {
// get the name of the example
$example_name = $argv[1];
// get the name of the example
$example_name = $argv[1];
main($example_name);
main($example_name);
} else {
echo USAGE;
echo USAGE;
}