Git Product home page Git Product logo

pythophant's Introduction

PythoPhant

An expermental php preprocessor, loosely inspired by python, rails etc. It's PHP without many braces and indentation marking the blocks.

Rules

  • Indentation counts, i.e. makes the blocks. Indentation is 4 spaces.
  • The semicolon is not required and should be omitted. A newline (PHP_EOL) ends a statement.

Variables and Constants

  • The leading dollar sign is not required for normal variables. Write one for dynamic variable access.
  • Variables cannot be named like constants, because uppercase strings are treated like constants.
  • String concatenation is implicit, do not use "." to concatenate string except on newlines.

Classes, Methods and Members

  • "class" or "interface" declarations have to be placed in the code.
  • The "->" operator should be written as "."
  • "@" is a shortcut for "$this->"
  • The explicit declaration "function" can be omitted if a visibility modifier is used or if the indentation level is one.
  • Opening and closing braces of a function's signature must on the same line.

Json (experimental)

  • Write native json using "[]" for arrays and "{}" for objects, ":" assigns values.
  • Json objects are casted from (associative) arrays.

Some Magic

  • the colon ":" following a string is treated as an opening brace, the closing brace is inserted at eol
  • use "!" and "?" for easily readable expressions like "myVar ctype_alnum?" or "myArray explode('.')!
  • "!" can also be written as "not"
  • the keyword "accessible" generates getters and setters for private class vars

Todo

  • multi-line args for if and similar conditionals

pythophant's People

Contributors

bonndan avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.