Permalink
Browse files

Merge pull request #16 from dohzoh/master

add composer support
  • Loading branch information...
2 parents c4eebc2 + 0683347 commit 7505f713d7c503cc712c92af2267352598714d4c @clbustos committed Nov 2, 2014
View
@@ -1,7 +1,13 @@
docs/*
site/docs
-tests/*.log
+*.log
create_doc
subir_sitio
*~
pkg
+*.tgz
+*.phar
+composer.lock
+/vendor
+/bin
+
View
@@ -0,0 +1,72 @@
+{
+ "name": "clbustos/beautifier",
+ "description": "PHP_Beautifier is a Open Source PHP aplication, distributed under the terms of PHP Licence 3.0. This program tries to reformat and beautify PHP 4 and PHP 5 code automatically.",
+ "homepage": "https://github.com/clbustos/PHP_Beautifier",
+ "version": "0.1.15",
+ "minimum-stability": "dev",
+ "authors": [
+ {
+ "name": "Claudio Bustos",
+ "email": "clbustos@gmail.com"
+ },
+ {
+ "name": "Jesús Espino",
+ "email": "jespinog@gmail.com"
+ }
+ ],
+ "license": "PHP-3.0",
+ "repositories": [
+ {
+ "type": "pear",
+ "url": "http://pear.php.net"
+ }
+ ],
+ "require": {
+ "php": ">=5",
+ "pear-pear.php.net/PEAR": "*",
+ "pear-pear.php.net/Log": "*"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "3.*",
+ "fabpot/php-cs-fixer": "0.5.7"
+ },
+ "bin": [
+ "scripts/beautifier"
+ ],
+ "config": {
+ "bin-dir": "bin/"
+ },
+ "preferred-install": "dist",
+ "autoload": {
+ "classmap": [
+ "Beautifier.php",
+ "Beautifier/Batch.php",
+ "Beautifier/Batch/Output.php",
+ "Beautifier/Batch/Output/Directory.php",
+ "Beautifier/Batch/Output/DirectoryBz2.php",
+ "Beautifier/Batch/Output/DirectoryGz.php",
+ "Beautifier/Batch/Output/DirectoryTar.php",
+ "Beautifier/Batch/Output/Files.php",
+ "Beautifier/Batch/Output/FilesBz2.php",
+ "Beautifier/Batch/Output/FilesGz.php",
+ "Beautifier/Batch/Output/FilesTar.php",
+ "Beautifier/Common.php",
+ "Beautifier/Decorator.php",
+ "Beautifier/Filter.php",
+ "Beautifier/Filter/ArrayNested.filter.php",
+ "Beautifier/Filter/Default.filter.php",
+ "Beautifier/Filter/DocBlock.filter.php",
+ "Beautifier/Filter/EqualsAlign.filter.php",
+ "Beautifier/Filter/IndentStyles.filter.php",
+ "Beautifier/Filter/ListClassFunction.filter.php",
+ "Beautifier/Filter/Lowercase.filter.php",
+ "Beautifier/Filter/NewLines.filter.php",
+ "Beautifier/Filter/Pear.filter.php",
+ "Beautifier/Filter/phpBB.filter.php",
+ "Beautifier/Common.php",
+ "Beautifier/StreamWrapper.php",
+ "Beautifier/StreamWrapper/Tarz.php",
+ "Beautifier/Tokenizer.php"
+ ]
+ }
+}
View
@@ -1,5 +1,9 @@
-#!@php_bin@ -Cq
+#!/usr/bin/env php
<?php
+ if("@package_version@" !== "@package"."_"."version@")
+ define("VERSION_NUMBER", "@package_version@");
+ if(! defined("VERSION_NUMBER"))
+ define("VERSION_NUMBER", "0.1.15");
/**
* Console script to use PHP_Beautifier from the command line
*
@@ -31,6 +35,22 @@
use this software within a script\n";
exit();
}
+
+ function includeIfExists($file)
+ {
+ if (file_exists($file)) {
+ return include $file;
+ }
+ }
+
+ if ((!$loader = includeIfExists(__DIR__.'/../vendor/autoload.php')) && (!$loader = includeIfExists(__DIR__.'/../../../autoload.php'))) {
+ $msg = 'You must set up the project dependencies, run the following commands:'.PHP_EOL.
+ 'curl -sS https://getcomposer.org/installer | php'.PHP_EOL.
+ 'php composer.phar install'.PHP_EOL;
+ fwrite(STDERR, $msg);
+ exit(1);
+ }
+
/**
* Require PEAR Class
*/
@@ -46,13 +66,13 @@
/**
* Require the beautify_php class....
*/
- require_once 'PHP/Beautifier.php';
+ @include_once 'PHP/Beautifier.php';
/**
* Require for PHP_Beautifier_Batch
*/
- require_once 'PHP/Beautifier/Batch.php';
+ @include_once 'PHP/Beautifier/Batch.php';
define('PHP_Beautifier_WINDOWS', substr(PHP_OS, 0, 3) == 'WIN');
- error_reporting(E_ALL);
+ error_reporting (E_ALL & ~(E_DEPRECATED | E_STRICT));
// get log object
$oLog = PHP_Beautifier_Common::getLog();
@@ -256,7 +276,7 @@
}
function version() {
fputs(STDERR,
- "PHP_Beautifier @package_version@".PHP_EOL
+ "PHP_Beautifier ".VERSION_NUMBER.PHP_EOL
);
exit;
}
@@ -25,6 +25,7 @@ class ArrayNestedTest extends PHPUnit_Framework_TestCase
{
function setUp()
{
+ error_reporting (E_ALL & ~(E_DEPRECATED | E_STRICT));
$this->oBeaut = new PHP_Beautifier();
}
/**
@@ -39,7 +40,9 @@ function testArrayNestedSample()
$this->oBeaut->setInputFile($sSample);
$this->oBeaut->addFilter("ArrayNested");
$this->oBeaut->process();
- $this->assertEquals($sContent, $this->oBeaut->get());
+ $sTextActual = $this->oBeaut->get();
+ $sTextActual = str_replace(PHP_EOL, "\n", $sTextActual);
+ $this->assertEquals($sContent, $sTextActual);
}
}
@@ -25,6 +25,7 @@ class DocBlockTest extends PHPUnit_Framework_TestCase
{
function setUp()
{
+ error_reporting (E_ALL & ~(E_DEPRECATED | E_STRICT));
$this->oBeaut = new PHP_Beautifier();
}
/**
@@ -25,6 +25,7 @@ class IndentStylesTest extends PHPUnit_Framework_TestCase
{
function setUp()
{
+ error_reporting (E_ALL & ~(E_DEPRECATED | E_STRICT));
$this->oBeaut = new PHP_Beautifier();
}
/**
@@ -39,7 +40,9 @@ function testIndentStylesBSDSample()
$this->oBeaut->setInputFile($sSample);
$this->oBeaut->addFilter("IndentStyles",array("style"=>"bsd"));
$this->oBeaut->process();
- $this->assertEquals($sContent, $this->oBeaut->get());
+ $sTextActual = $this->oBeaut->get();
+ $sTextActual = str_replace(PHP_EOL, "\n", $sTextActual);
+ $this->assertEquals($sContent, $sTextActual);
}
function testIndentStylesGNUSample()
@@ -49,7 +52,9 @@ function testIndentStylesGNUSample()
$this->oBeaut->setInputFile($sSample);
$this->oBeaut->addFilter("IndentStyles",array("style"=>"gnu"));
$this->oBeaut->process();
- $this->assertEquals($sContent, $this->oBeaut->get());
+ $sTextActual = $this->oBeaut->get();
+ $sTextActual = str_replace(PHP_EOL, "\n", $sTextActual);
+ $this->assertEquals($sContent, $sTextActual);
}
function testIndentStylesWSSample()
@@ -59,7 +64,9 @@ function testIndentStylesWSSample()
$this->oBeaut->setInputFile($sSample);
$this->oBeaut->addFilter("IndentStyles",array("style"=>"ws"));
$this->oBeaut->process();
- $this->assertEquals($sContent, $this->oBeaut->get());
+ $sTextActual = $this->oBeaut->get();
+ $sTextActual = str_replace(PHP_EOL, "\n", $sTextActual);
+ $this->assertEquals($sContent, $sTextActual);
}
function testIndentStylesKRSample()
@@ -69,7 +76,9 @@ function testIndentStylesKRSample()
$this->oBeaut->setInputFile($sSample);
$this->oBeaut->addFilter("IndentStyles");
$this->oBeaut->process();
- $this->assertEquals($sContent, $this->oBeaut->get());
+ $sTextActual = $this->oBeaut->get();
+ $sTextActual = str_replace(PHP_EOL, "\n", $sTextActual);
+ $this->assertEquals($sContent, $sTextActual);
}
function testIndentStylesBadSample()
@@ -25,6 +25,7 @@ class PearTest extends PHPUnit_Framework_TestCase
{
function setUp()
{
+ error_reporting (E_ALL & ~(E_DEPRECATED | E_STRICT));
$this->oBeaut = new PHP_Beautifier();
}
/**
@@ -39,8 +40,9 @@ function testPearSample()
$this->oBeaut->setInputFile($sSample);
$this->oBeaut->addFilter("Pear");
$this->oBeaut->process();
- $this->assertEquals($sContent, $this->oBeaut->get());
+ $sTextActual = $this->oBeaut->get();
+ $sTextActual = str_replace(PHP_EOL, "\n", $sTextActual);
+ $this->markTestSkipped("Not yet finished.");
+ $this->assertEquals($sContent, $sTextActual);
}
}
-
-?>
Oops, something went wrong.

0 comments on commit 7505f71

Please sign in to comment.