A superset of PHP with extended syntax and runtime capabilities.

Related tags

Command-line pxp
Overview
Comments
  • [BUG] Some errors have detailed explanations: E0026, E0308, E0412, E0432, E0433, E0532, E0769.

    [BUG] Some errors have detailed explanations: E0026, E0308, E0412, E0432, E0433, E0532, E0769.

    Hi! I've tried to build pxp from https://pxplang.org/getting-started/installation.html#setup but I failed to issue. See log below:

    Some errors have detailed explanations: E0026, E0308, E0412, E0432, E0433, E0532, E0769.
    For more information about an error, try `rustc --explain E0026`.
    error: could not compile `pxp` due to 65 previous errors
    warning: build failed, waiting for other jobs to finish...
    error: failed to compile `pxp v0.0.0-b1 (https://github.com/pxp-lang/pxp#9f0adde0)`, intermediate artifacts can be found at `/tmp/cargo-installULorXc`  
    

    Here is my config

    ❯ cargo -V
    cargo 1.66.1 (ad779e08b 2023-01-10)
    
    ~ 
    ❯ uname -a
    Linux asus 5.18.19-051819-generic #202208211443 SMP PREEMPT_DYNAMIC Sun Aug 21 15:10:27 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
    
    ~
    ❯ cat /etc/*release
    DISTRIB_ID=Ubuntu
    DISTRIB_RELEASE=22.04
    DISTRIB_CODENAME=jammy
    DISTRIB_DESCRIPTION="Ubuntu 22.04.1 LTS"
    PRETTY_NAME="Ubuntu 22.04.1 LTS"
    NAME="Ubuntu"
    VERSION_ID="22.04"
    VERSION="22.04.1 LTS (Jammy Jellyfish)"
    VERSION_CODENAME=jammy
    ID=ubuntu
    ID_LIKE=debian
    
    openssl version
    OpenSSL 3.0.2 15 Mar 2022 (Library: OpenSSL 3.0.2 15 Mar 2022)
    

    What I'm doing wrong?

    opened by denisgolius 2
  • [Idea] Multiple return types

    [Idea] Multiple return types

    Great project. I really like it and I am looking forward to more momentum in this space.

    I don't know if you are already open for suggestions but I am going to post it anyway so it gets tracked. ;-)

    I know that you, @ryangjchandler, are also familiar with Go. One of the things I really like about golang is the possibility to define multiple return values, so I don't have to create a class for e.g. a min and a max value returned by a function.

    Current situation

    /**
    * Here could be some array shape
    */
    function calculate(): array {}
    

    The result of this function could be accessed by destructuring the resulting array.

    [$min, $max] = calculate();
    ['min' => $min, 'max' => $max] = calculate();
    

    Please note that the syntax might not be 100 % correct as I am only typing it out of my mind. However, you should be able to get the gist of it.

    Alternatively one could create a class containing only the both values like this:

    readonly class {
      public function __construct(
        public int $min,
        public int $max,
      )
    }
    

    However, this might become tedious as I don't want to create a new class (and a new file) for each simple return type.

    Proposed solution

    function calculate(): int, int {}
    
    $min, $max = calculate();
    $min2, _ = calculate();
    _, $max2 = calculate();
    

    This would/could transpile down to the following PHP code:

    // Here needs to be the correct array syntax for this
    function calculate(): array {}
    
    // Or take another var name
    $result = calculate();
    $min = $result[0];
    $max = $result[1];
    $result = calculate();
    $min2 = $result[0];
    $result = calculate();
    $max2 = $result[1];
    

    Please note that I made the array of the type array<int, mixed> to make it simpler. Other methods may also work.

    Conclusion

    I think this could be a nice addition to the syntax. You might also have already thought about this. Please let me know what you think.

    opened by Wulfheart 1
  • Editors: Correctly highlight heredocs and nowdocs

    Editors: Correctly highlight heredocs and nowdocs

    Highlighting them the same way as strings is fine for now. We could do some smarter stuff in the future with embedded languages, but not essential right now.

    editors/vscode 
    opened by ryangjchandler 0
  • Editors: Highlight HTML et al outside of `?>` tags

    Editors: Highlight HTML et al outside of `?>` tags

    Doesn't work right now. The PHP grammar file is overly complex and does a lot of contextual highlighting which I'm not bothered about right now, but would still be good to get HTML highlighting working.

    editors/vscode 
    opened by ryangjchandler 0
  • More Powerful Attributes (e.g. as function middleware)

    More Powerful Attributes (e.g. as function middleware)

    My suggestion is to improve upon PHP's current Attributes system (https://www.php.net/manual/en/language.attributes.overview.php) by allowing them access to manipulate the way a function is interacted with. This would allow an attribute to "wrap" or "be wrapped by" a function it is applied to.

    This would allow things like this to be possible: (Original idea by @enunomaduro on Twitter)

    #[Dd]
    public function foo() {
        return "bar";
    }
    

    This attribute would automatically dd the return value of the function it is applied to.

    A possible implementation of this could be as follows:

    #[Attribute]
    class Dd {
        public function __after($retval) {
            dd($retval);
        }
    }
    

    Here I present the __after method that is triggered after a function has been called and is provided with the return value of the function. This idea could be expanded to include a __before method that could allow mutating the input parameters to a function, or even conditionally avoid calling the function entirely. This could be useful for validation purposes.

    e.g.

    #[GreaterThan(4)]
    public function foo(int $a) {
        // Here I am certain that $a is > 4
        return $a + 2;
    }
    
    #[Attribute]
    class GreaterThan {
    
        protected $val;
    
        public function __construct($val) {
            $this->val = $val;
        }
    
        public function __before($params) {
            if($params[0] <= $this->val) {
                throw new ValidationException("...");
            }
            return $params;
        }
    }
    

    I'm quite sure there are better ways of accessing parameters in the __before function, as well as many other aspects of this that can be improved upon. All feedback is welcome.

    Original thread about this concept on Twitter: https://twitter.com/ryangjchandler/status/1614611643253530624

    opened by tobyselway 1
  • Match instanceof

    Match instanceof

    Somethig that I'm missing in current PHP is this:

    match ($a) {
        instanceof Admin => ...
        instanceof User => ...
    }
    

    Only way to do that in pxp is doing:

    match {
        $a instanceof Admin => ...
        $a instanceof User => ...
    }
    

    which feels a bit repetive.

    Another idea could be:

    match ($a instanceof) {
       Admin => ...
       User => ...
    }
    
    opened by ruudk 0
Owner
PXP
A superset of PHP with extended syntax and runtime capabilities.
PXP
Fast, minimal, feature-rich, extended formatting syntax for Rust!

Formatting Tools Fast, minimal, feature-rich, extended formatting syntax for Rust! Features include: Arbitrary expressions inside the formatting brace

Casper 58 Dec 26, 2022
Count your code by tokens, types of syntax tree nodes, and patterns in the syntax tree. A tokei/scc/cloc alternative.

tcount (pronounced "tee-count") Count your code by tokens, types of syntax tree nodes, and patterns in the syntax tree. Quick Start Simply run tcount

Adam P. Regasz-Rethy 48 Dec 7, 2022
A opinionated and fast static analyzer for PHP.

TLDR; A static analyzer for PHP. It helps you catch common mistakes in your PHP code. These are the current checks implemented. Extending undefined cl

Denzyl Dick 11 Mar 6, 2023
A small subset of PHP implemented in Rust. 🐘

microphp A small subset of PHP implemented in Rust. About This project aims to implement a small subset of PHP's feature-set using a Rust powered pars

Ryan Chandler 5 Feb 7, 2022
Generate PHP code from Rust using a fluent API 🐘 πŸ¦€

PHP-Codegen Generate PHP code from Rust using a fluent API ?? ?? Rust PHP Usage To bring this crate into your repository, either add php_codegen to yo

PHP Rust Tools 7 Dec 24, 2022
Lapce plugin for the Php language.

lapce-php-intelephense Lapce plugin for the Php language. Prerequisites Install Intelephense, typically by running: $ npm i intelephense -g Settings S

null 3 Jan 9, 2023
PHP++ short for redditlang is a language created by the r/ProgrammerHumor subreddit discord members

RedditLang PHL ( ProgrammerHumor language ) or RedditLang is a language created by the r/ProgrammerHumor discord! The spec is avaliable here Why Reddi

elijah629 10 Jun 23, 2023
Use any async Rust library from PHP!

php-tokio - Use any async Rust library from PHP! Created by Daniil Gentili (@danog). This library allows you to use any async rust library from PHP, a

Daniil Gentili 242 Sep 7, 2023
rpsc is a *nix command line tool to quickly search for file systems items matching varied criterions like permissions, extended attributes and much more.

rpsc rpsc is a *nix command line tool to quickly search for file systems items matching varied criterions like permissions, extended attributes and mu

null 3 Dec 15, 2022
Compiler for an "extended" version of the Mindustry logic language

Minblur Compiler Minblur is a compiler for a superset of "logic" programming language in the game Mindustry. It helps reduce code-duplication, making

Binder News 15 May 2, 2022
A cat(1) clone with syntax highlighting and Git integration.

A cat(1) clone with syntax highlighting and Git integration. Key Features β€’ How To Use β€’ Installation β€’ Customization β€’ Project goals, alternatives [δΈ­

David Peter 38.9k Jan 8, 2023
A syntax-highlighting pager for git, diff, and grep output

Get Started Install delta and add this to your ~/.gitconfig: [core] pager = delta [interactive] diffFilter = delta --color-only [delta]

Dan Davison 16k Dec 31, 2022
Valq - macros for querying and extracting value from structured data by JavaScript-like syntax

valq   valq provides a macro for querying and extracting value from structured data in very concise manner, like the JavaScript syntax. Look & Feel: u

Takumi Fujiwara 24 Dec 21, 2022
Shellharden is a syntax highlighter and a tool to semi-automate the rewriting of scripts to ShellCheck conformance, mainly focused on quoting

Shellharden is a syntax highlighter and a tool to semi-automate the rewriting of scripts to ShellCheck conformance, mainly focused on quoting

Andreas Nordal 4.3k Dec 28, 2022
Simple calculator REPL, similar to bc(1), with syntax highlighting and persistent history

eva simple calculator REPL, similar to bc(1), with syntax highlighting and persistent history installation Homebrew $ brew install eva crates.io $ car

Akshay 632 Jan 4, 2023
A standalone code editor with syntax highlighting and themes.

CodeEditor A standalone code (and text) editor for people like me who write their own user interfaces utilizing crates like pixels. CodeEditor renders

Markus Moenig 8 Nov 25, 2022
🏭 Convert Markdown documents into themed HTML pages with support for code syntax highlighting, LaTeX and Mermaid diagrams.

Marky Markdown Magician ?? Features Hot reload previewing ?? Conversion to HTML / PDF ?? Themes! ✨ Extensions - Math, diagrams, syntax-highlighting ??

Vadim 12 Feb 19, 2023
Build Abstract Syntax Trees and tree-walking models quickly in Rust.

astmaker Build Abstract Syntax Trees and tree-walking models quickly in Rust. Example This example creates an AST for simple math expressions, and an

David Delassus 100 Jun 5, 2023
Rust Server Components. JSX-like syntax and async out of the box.

RSCx - Rust Server Components RSCx is a server-side HTML rendering engine library with a neat developer experience and great performance. Features: al

Antonio Pitasi 21 Sep 19, 2023