# php-unparser

> Unparse the AST produced by glayzzle/php-parser back to code.

Latest version **0.2.9** (published 2018-04-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install php-unparser
pnpm add php-unparser
yarn add php-unparser
bun add php-unparser
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.9 |
| Published | 2018-04-30 |
| First published | 2016-11-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 165.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 34 |
| Author | Christopher Luna |
| Maintainers | chris-l |
| Keywords | unparser, php, ast |

## Links

- npm: https://www.npmjs.com/package/php-unparser
- Repository: https://github.com/chris-l/php-unparser
- Homepage: https://github.com/chris-l/php-unparser#readme
- Issues: https://github.com/chris-l/php-unparser/issues
- npm.io page: https://npm.io/package/php-unparser

## Alternatives

- [update-check](https://npm.io/package/update-check.md) — 4.0M weekly downloads
- [react-native-onesignal](https://npm.io/package/react-native-onesignal.md) — 134.5K weekly downloads
- [react-redux-toastr](https://npm.io/package/react-redux-toastr.md) — 33.7K weekly downloads
- [@nocobase/plugin-notification-manager](https://npm.io/package/@nocobase/plugin-notification-manager.md) — 2.0K weekly downloads
- [react-simple-toasts](https://npm.io/package/react-simple-toasts.md) — 1.9K weekly downloads

## Recent versions

- 0.2.9 (latest) — 2018-04-30
- 0.2.8 — 2018-03-14
- 0.2.7 — 2018-03-08
- 0.2.6 — 2018-03-08
- 0.2.5 — 2018-03-07
- 0.2.4 — 2018-03-01
- 0.2.3 — 2017-10-29
- 0.2.2 — 2017-10-06
- 0.2.1 — 2017-07-28
- 0.2.0 — 2017-07-17
- 0.1.4 — 2016-12-23
- 0.1.3 — 2016-11-27
- 0.1.2 — 2016-11-26
- 0.1.1 — 2016-11-25
- 0.1.0 — 2016-11-22

## README

php-unparser
============

[![Build Status](https://travis-ci.org/glayzzle/php-unparser.svg?branch=master)](https://travis-ci.org/glayzzle/php-unparser)
[![Coverage Status](https://coveralls.io/repos/github/glayzzle/php-unparser/badge.svg?branch=master)](https://coveralls.io/github/glayzzle/php-unparser?branch=master)

This project is a JavaScript based [unparser](https://en.wikipedia.org/wiki/Unparser) for the AST produced by glayzzle's [php-parser](https://github.com/glayzzle/php-parser).

It aims to produce code that uses the style format recommended by PSR-1 and PSR-2.

It's at an early development stage, but it is already able to generate code for most of the produced AST.

It has __no dependencies__.

## How to use

```javascript
var unparse = require('php-unparser');

var options = {
  indent: true,
  dontUseWhitespaces: false,
  shortArray: true,
  bracketsNewLine: true,
  forceNamespaceBrackets: false,
  collapseEmptyLines: true
};

var ast = {
  "kind": "program",
  "children": [
    {
      "kind": "echo",
      "arguments": [
        {
          "kind": "string",
          "value": "hello world",
          "isDoubleQuote": true
        }
      ]
    }
  ],
  "errors": []
};

// Will output -> echo "hello world";
console.log(unparse(ast, options));
```

## Options

| option                 | value   | default  | description |
|------------------------|---------|----------|-------------|
| indent                 | string  |          | The indentation size, default is four white spaces. |
| dontUseWhitespaces     | boolean | `false`  | If enabled removes all the whitespaces between stuff. |
| shortArray             | boolean | `false`  | If enabled write arrays in short array syntax enabled since PHP 5.4.0 |
| bracketsNewLine        | boolean | `true`   | If enabled will put brackets on new line. |
| forceNamespaceBrackets | boolean | `false`  | Force the namespace bracketed syntax (_recommended for combining namespaces_) |
| collapseEmptyLines     | boolean | `true`   | If enabled it will remove all empty lines between sections and properties. |

## Demo

[See it working](https://chris-l.github.io/php-unparser/)

## License

MIT License, Copyright 2016 Christopher Luna

---
_Source: https://npm.io/package/php-unparser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
