GithubHelp home page GithubHelp logo

rozhnev / phpas Goto Github PK

View Code? Open in Web Editor NEW

This project forked from basemax/phpas

0.0 1.0 0.0 185 KB

PHP Auto Style: A tool for format and beautify the style of PHP code with my style.

Home Page: https://www.phpclasses.org/package/11216-PHP-Beautify-PHP-source-code-fixing-its-style.html

License: GNU General Public License v3.0

PHP 100.00%

phpas's Introduction

PHP AS(Auto Style), PHP Beautifier

A tool for format and beautify the style of PHP code with my style.

Purpose

We waste our time to format the code. So it will be a fantastic tool.

Anyway, I hope this tool can help you for format a PHP code easily and fast.

Story

I developed this tool for myself, not for money, not for a special company.

Although it used in some software of a company in India.

Also it used as PHP snippet formate on PHPize.online

Main purpose

  • Remove extra space after "for", "while", "if" words...
  • Ident cleaning and auto tab for {} and statements...
  • Make clean the comment text
  • ...

Demo

Left: Output, Right: Input

ScreenShot

Usage

<?php
/* Include Class */
include "PHPAS.php"

/* Create Class Instance with default options */
$autoStyle = new AutoStyle();

/* or with optional configuratoin */
$options = [
	'identation' => '    ' // 4 spaces (default Tab)
];

$autoStyle = new AutoStyle($options);

/* Format code from file */
print $AS->loadFile("test.php") ."\n";

/* Format code from string */
print $AS->loadString("<?php\nprint 'hi';\n") ."\n";

Class Methods

Method Goal
setOptions($options) Change formatter options...
loadFile($fileName) Auto Style, format a file and display output...
loadString($codeString) Auto Style, format a string code and display output...

Input

<?php
/* inline comment */
for ($v = 7;$v <= 100 / 10;$v++) {
$b = $v;
$x = [];
for ($i = 1;$i <= $v;$i++) {
$x[] = $i;
}
for ($k = 3;$k <= ((floor($v - 1) / 2) + 1);$k++) {
$r = $k;
solve($x, $v, $b, $k, $r);
}
}

Output

<?php
/* inline comment */
for($v=7;$v<=100/10;$v++) {
	$b=$v;
	$x=[];
	for($i=1;$i<=$v;$i++) {
		$x[]=$i;
	}

	for($k=3;$k<=((floor($v-1)/2)+1);$k++) {
		$r=$k;
		solve($x,$v,$b,$k,$r);
	}

}

Input

<?php
/*      	 	 	 inline comment */
for ($v = 7;$v <= 100 / 10;$v++) { $b = $v; $x = []; for ($i = 1;$i <= $v;$i++) {$x[] = $i;
}
for ($k = 3;$k <= ((floor($v - 1) / 2) + 1);$k++) { $r = $k;
solve($x, $v, $b, $k, $r); } }
$str
	=
		"hello world!";

Output

<?php
/* inline comment */
for($v = 7;$v <= 100 / 10;$v++) {
	$b=$v;
	$x=[];
	for($i = 1;$i <= $v;$i++) {
		$x[]=$i;
	}

	for($k = 3;$k <= ((floor($v - 1) / 2) + 1);$k++) {
		$r=$k;
		solve($x, $v, $b, $k, $r);
	}
}

$str="hello world!";

Partnership and development

Please send issue or pull request if you found a bug or problem. Feel free to discuss or send pull...

License

PHPBeautifier is licensed under the GNU General Public License.

phpas's People

Contributors

rozhnev avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.