Prettier PHP Plugin

Overview
Prettier PHP

Prettier PHP Plugin

GitHub Workflow Status npm version Codecov Coverage Status code style: prettier Gitter Follow+Prettier+on+Twitter

Intro

Prettier is an opinionated code formatter. It enforces a consistent style by parsing your code and re-printing it with its own rules that take the maximum line length into account, wrapping code when necessary.

This plugin adds support for the PHP language to Prettier.

Can this be used in production?

We're considering the plugin to be stable when pure PHP files are formatted. Formatting of files that contain mixed PHP and HTML is still considered unstable - please see open issues with the tag "inline" for details.

If you want to use the plugin in production, we recommend limiting its scope to pure PHP files.

Input

<?php
array_map(function($arg1,$arg2) use ( $var1, $var2 ) {
    return $arg1+$arg2/($var+$var2);
}, array("complex"=>"code","with"=>
    function() {return "inconsistent";}
,"formatting"=>"is", "hard" => "to", "maintain"=>true));

Output

<?php

array_map(
    function ($arg1, $arg2) use ($var1, $var2) {
        return $arg1 + $arg2 / ($var + $var2);
    },
    [
        "complex" => "code",
        "with" => function () {
            return "inconsistent";
        },
        "formatting" => "is",
        "hard" => "to",
        "maintain" => true,
    ]
);

Playground

You can give the plugin a try in our playground!

Install

yarn:

yarn add --dev prettier @prettier/plugin-php
# or globally
yarn global add prettier @prettier/plugin-php

npm:

npm install --save-dev prettier @prettier/plugin-php
# or globally
npm install --global prettier @prettier/plugin-php

Use

With Node.js

If you installed prettier as a local dependency, you can add prettier as a script in your package.json,

{
  "scripts": {
    "prettier": "prettier"
  }
}

and then run it via

yarn run prettier path/to/file.php --write
# or
npm run prettier -- path/to/file.php --write

If you installed globally, run

prettier path/to/file.php --write

In the Browser

This package exposes a standalone.js that can be used alongside Prettier's own standalone.js to make the PHP plugin work in browsers without a compile step.

First, grab both standalone scripts from an npm CDN like unpkg:

<script src="https://unpkg.com/prettier/standalone.js"></script>
<script src="https://unpkg.com/@prettier/plugin-php/standalone.js"></script>

Then use Prettier with PHP, just like this:

prettier.format(YOUR_CODE, {
  plugins: prettierPlugins,
  parser: "php"
});

See this code in action in this basic demo.

With Bundlers

Bundlers like webpack, Rollup or browserify automatically recognize how to handle the PHP plugin. Remember that even when using a bundler, you still have to use the standalone builds:

import prettier from "prettier/standalone";
import phpPlugin from "@prettier/plugin-php/standalone";

prettier.format(YOUR_CODE, {
  plugins: [phpPlugin],
  parser: "php"
});

Configuration

Prettier for PHP supports the following options. We recommend that all users set the phpVersion option.

Name Default Description
phpVersion "5.4" Allows specifying the PHP version you're using. If you're using PHP 7.1 or later, setting this option will make use of modern language features in the printed output. If you're using PHP 5.3 or lower, you'll have to set this option or Prettier will generate incompatible code.
printWidth 80 Same as in Prettier (see prettier docs)
tabWidth 4 Same as in Prettier (see prettier docs)
useTabs false Same as in Prettier (see prettier docs)
singleQuote false If set to "true", strings that use double quotes but do not rely on the features they add, will be reformatted. Example: "foo" -> 'foo', "foo $bar" -> "foo $bar".
trailingCommaPHP true If set to true, trailing commas will be added wherever possible.
If set to false, no trailing commas are printed.
braceStyle "psr-2" If set to "psr-2", prettier will move open brace for code blocks (classes, functions and methods) onto new line.
If set to "1tbs", prettier will move open brace for code blocks (classes, functions and methods) onto same line.
requirePragma false Same as in Prettier (see prettier docs)
insertPragma false Same as in Prettier (see prettier docs)

Ignoring code

A comment // prettier-ignore will exclude the next node in the abstract syntax tree from formatting.

For example:

matrix(
  1, 0, 0,
  0, 1, 0,
  0, 0, 1
);

// prettier-ignore
matrix(
  1, 0, 0,
  0, 1, 0,
  0, 0, 1
);

will be transformed to

matrix(1, 0, 0, 0, 1, 0, 0, 0, 1);

// prettier-ignore
matrix(
  1, 0, 0,
  0, 1, 0,
  0, 0, 1
)

Editor integration

Atom

The official prettier plugin for atom supports plugins.

VScode

The official prettier plugin for vscode supports plugins since Version 1.10.0. To enable it, install the extension and make sure the plugin is installed locally (in your project folder). After restarting VScode the plugin should work as expected.

PhpStorm / IntelliJ / Jetbrains IDE

  • Install prettier and plugin locally yarn add -D prettier @prettier/plugin-php
  • Open Settings (File, Settings)
  • Go to Plugins Section, Select Marketplace, Search for Prettier, Install Plugin, Restart IDE
  • Open Settings, Search for Prettier, select Prettier in left settings navigation
  • Check prettier package has auto-detected, should be something like myproject/node_modules/prettier
  • Update Run for Files to include .php, eg: {**/*,*}.{js,ts,jsx,tsx,php,json,scss,vue,md}
  • Tick the On Save button, if you want your files formatting updated on file save
  • Clock OK to save settings

Note: Just pressing save does not reformat your current file unless the file has been modified in some way, alternatively you can use the Prettier shortcut Ctrl+Alt+Shift+P

Sublime Text

Sublime Text support is available through Package Control and the JsPrettier plugin.

Vim

Regarding plugin support in the official plugin vim-prettier see this issue.

ALE

The linting plugin ALE has built-in support for prettier and its plugins. Just add prettier to your list of fixers. For example:

let g:ale_fixers={
  \'javascript': ['prettier'],
  \'json': ['prettier'],
  \'php': ['prettier'],
\}

Custom

Alternatively, adding the following to .vimrc will define a custom command :PrettierPhp that runs the plugin while preserving the cursor position and run it on save.

" Prettier for PHP
function PrettierPhpCursor()
  let save_pos = getpos(".")
  %! prettier --stdin --parser=php
  call setpos('.', save_pos)
endfunction
" define custom command
command PrettierPhp call PrettierPhpCursor()
" format on save
autocmd BufwritePre *.php PrettierPhp

Integration for other tools

PHP-CS-Fixer

See docs/recipes/php-cs-fixer for integration help, code can also be found in https://gist.github.com/Billz95/9d5fad3af728b88540fa831b73261733

Contributing

If you're interested in contributing to the development of Prettier for PHP, you can follow the CONTRIBUTING guide from Prettier, as it all applies to this repository too.

To test it out on a PHP file:

  • Clone this repository.
  • Run yarn.
  • Create a file called test.php.
  • Run yarn prettier test.php to check the output.

Maintainers


Christian Zosel

Evilebot Tnawi
Comments
  • Option for opening brace

    Option for opening brace

    1st off I want to be clear - I think the default should still be to follow PSR2-like formatting standards

    With that in mind, from my own experience and now starting to look through other open-source php projects, it seems like one of the biggest differences in formatting standards is putting the opening brace for functions, classes, etc on a new line vs same line. I'm a little worried that not having this option might scare people off from using prettier/plugin-php.

    I was thinking of starting to work on a PR for adding an option to do this (defaulting to the PSR2 format of putting it on a new line), but wanted to open for discussion first.

    openingBraceNewLine = true (default)
    
    class Test
    {
      public function testMethod()
      {
      }
    }
    
    function testFunction()
    {
    }
    
    openingBraceNewLine = false
    
    
    class Test {
      public function testMethod() {
      }
    }
    
    function testFunction() {
    }
    
    enhancement 
    opened by mgrip 62
  • Tracking Issue: PHP 8 Support

    Tracking Issue: PHP 8 Support

    Released with v0.17.0:

    • [x] nullsafepropertylookup
    • [x] named arguments
    • [x] match expression
    • [x] union types
    • [x] promoted properties

    Released with v0.17.4:

    • [x] attributes

    8.1 Support:

    • [x] enum:
    enum Suit {
        case Clubs;
        case Diamonds;
        case Hearts;
        case Spades;
    }
    
    • [x] readonly class parameters
    class ImutableData {
        public function __construct(
            public readonly string $key,
        ) {}
    }
    
    • [x] first class callable syntax - eg array_filter($in, trim(...));
    • [x] Intersection Types in function parameters:
    function generateSlug(HasTitle&HasId $post) {
        return strtolower($post->getTitle()) . $post->getId();
    }
    
    opened by czosel 39
  • Add build step for standalone version, resolves #842

    Add build step for standalone version, resolves #842

    This pull request resolves #842, adding a standalone build to the Prettier PHP plugin.

    Build

    The standalone.js in the root of the package is generated through running:

    yarn run build-standalone
    

    Usage

    The standalone.js is "standalone" in the sense that it is bundled into one file with no Node.js-specific dependencies left. It does however not include Prettier itself. Prettier's standalone version has to be included on its own first (order matters):

    <script src="https://unpkg.com/prettier/standalone.js"></script>
    <script src="https://unpkg.com/@prettier/plugin-php/standalone.js"></script> <!-- does not exist yet -->
    

    The plugin registers as a global variable named prettier_pluginPhp. Using Prettier with it look like this:

    prettier.format(YOUR_CODE, {
      plugins: [prettier_pluginPhp],
      parser: ["php"]
    });
    

    Here's a demo.

    Transformations

    Things I instructed Rollup to do:

    • Mark the prettier module as external, so essentially all require("prettier") are replaced with the prettier global variable.
    • Add a shim for Node's assert module. I'm not sure why the strictEqual method should do nothing, but that's how it's done in Prettier.
    • Add a shim for Buffer.isBuffer() (used by the php-parser dependency).
    • Set process.arch to x32 (relevant for maximum float size).

    ToDo

    • [x] Write tests
    • [x] Add documentation to readme

    Considerations

    • [x] Name of the global? prettier_pluginPhp is not that catchy, suggestions are welcome.

      ✅ Resolved: Like Prettier's built-in plugins, the plugin is registered on the global prettierPlugins object as prettierPlugins.php.

    • [x] Minify? Prettier doesn't do it, therefore this pull request currently doesn't either.

      ✅ Resolved: Prettier does actually apply minification, not to their standalone.js, but to each of their plugins. This PR matches this behavior and minifies the standalone plugin.

    • [x] Add the generated standalone.js to the repo? Prettier does so.

      ❌ Rejected: I was wrong, Prettier actually does not.

    • [x] Is it reasonable to hardcode process.arch to x32? Doing a quick search, I found no way to detect a machine's architecture with browser-side JS with a reasonable amount of confidence. x32 should be a safe bet.

    • [x] Add documentation about how to use this plugin in bundlers? The standalone.js is not really suited for usage with bundlers. To avoid confusion, an additional section about using bundlers in the readme (i.e. "rewrite all prettier calls to prettier/standalone") could be reasonable.

      ✅ Resolved: No weird tips for bundler usage needed as this PR now also includes a pretty fool-proof way to integrate with bundlers.

    opened by loilo 38
  • Alpha release?

    Alpha release?

    https://github.com/prettier/plugin-php/issues/174#issuecomment-371190371

    Wanted to start a discussion on where people think the quality of this plugin is currently, and plans for rolling out more widely.

    For myself I've been running --debug-check on a codebase of ~1000 php files, and as of this morning am not getting any breaking errors 🎉

    Do people think its time to start publishing this as an alpha/beta release to encourage more people to start using and finding edge cases? I'm guessing that would mostly just entail bumping our package version to 0.1.0 and updating our README.md + documentation

    question 
    opened by mgrip 34
  • Proper support for flexible heredoc/nowdoc syntax

    Proper support for flexible heredoc/nowdoc syntax

    Currently, the new flexible heredoc/nowdoc syntax is "destroyed" during formatting:

    $php73FlexibleNowdoc = <<<'EOD'
          Example of string
          spanning multiple lines
          using nowdoc syntax.
          EOD;
    

    is printed as

    $php73FlexibleNowdoc = <<<'EOD'
    Example of string
    spanning multiple lines
    using nowdoc syntax.
    turns into
    
    EOD;
    

    Also, there seems to be an extra linebreak before the end.

    Concerning expected behavior, I'd propose to leave the indentation the same way we find it. Thoughts?

    cc @evilebottnawi @loilo

    enhancement discussion 
    opened by czosel 27
  • Convert double quotes to single quotes

    Convert double quotes to single quotes

    ...if the string is "simple", i.e. doesn't use any features that require double quotes:

    • embedded variables
    • linebreaks
    • special characters like \n, \t, ", ', ... See http://php.net/manual/en/language.types.string.php#language.types.string.syntax.double

    Fixes #633

    opened by czosel 27
  • Strategy on adding new options

    Strategy on adding new options

    I think we should discuss the general procedure on how we handle the wish to add new options.

    I started writing this as a comment to #118, but I'd like to discuss the "big picture" in a separate issue instead.

    To me, #118 is a nice example to prove @evilebottnawi 's point in the discussion about opening braces (#107, #108):

    I'm not against the option or not specifically this option, the only problem is that adding one option other will want more options, and each will complicate the maintenance of the project and deliver only problems

    In this case, I'd advise against introducing a new option, because the number of options we'd have to support if we allow configuration of "this type of" styling decision. Thinking about it from this standpoint, I'd even support your wish to revert the option we introduced about curly braces and add it back in when we've released a first stable version and the tool has been in use for a while - because then we have an actual community of user that will keep asking for specific options. I'd also like to cite two comments by @vjeux which might offer guidance:

    For prettier, I used a combination of my experience writing JavaScript for 10+ years, grepping through the millions of lines of the Facebook codebase to see which style was more popular, reading through various coding styles (eg Airbnb) and what are all the related eslint configs and finally feedback from people complaining that some pattern looked bad. My guiding principle was for the code generated by prettier to pass code review as if it was written by a human. I also tried to make all the decisions be as less controversial as possible.

    Also, one thing that really helped is to have someone to make the final decision. This way all the discussions could happen and were useful input but at the end of the day, only the things I wanted would go through. I found that there are a handful of useful tactics to manage those discussions:

    • Ask for specific snippets of code and try to find solutions for those. So many times people argue about very general things but in practice there are concrete fixes you can do for their use case.
    • Explicitly say that you're not going to make a decision right now on certain issues. One thing that people pick up quickly is to engage in places where the people involve the project are responding. Then once in a while you can sort issues by upvote/comments and figure out what are the most painful things and do a deep dive.
    • Avoid style trashing. Ideally, you should think deeply about each important style decision you are making and once you do it, actually commit to it. This way you can "close" the issue and whenever this subject comes up in the future say that you have reached a decision and are not looking to spend time thinking about it for now. This way you can focus on the things that still need to be fixed rather than going through the same discussions over an over again wasting everyone's time. This is hard to do in practice but if you can pull it off, it'll help a lot.

    (See https://github.com/prettier/plugin-php/issues/59#issuecomment-366744779)

    I'm gonna make a suggestion on how i could imagine we handle things, just to keep this issue actionable:

    • Until our first release, we don't add any custom options and remain PSR-2 compatible.

    After that:

    • We only consider a new option if there is a considerable amount of requests to add it
    • If necessary, we put the decision up to a vote after a short "cool-down" period

    That would also mean that we don't open anything that involves adding options for votes just yet. Of course we can (and should) vote on difficult stylistic decisions that go into the first version.

    What do you think?

    /cc @mgrip

    opened by czosel 26
  • Behavior change: Add trailing commas to array items

    Behavior change: Add trailing commas to array items

    I propose a behavior change to array formatting: Prettier should add a trailing comma to the last item in a multi-line array.

    Trailing commas are beneficial in that they make editing easier and make diffs smaller. But more importantly, the coding standards for several significant PHP projects (e.g. Drupal, Symfony and WordPress) require/recommend trailing commas.

    PSR-2 doesn’t address this topic, so I think changing this behavior to match common practice is consistent with Prettier’s goals.

    Current behavior:

    $array = [
        'item-in-array-example-1',
        'item-in-array-example-2',
        'item-in-array-example-3'
    ];
    

    Desired behavior:

    $array = [
        'item-in-array-example-1',
        'item-in-array-example-2',
        'item-in-array-example-3',
    ];
    

    I hope this is easy to implement since the main Prettier project already has a config option for trailing comma.

    For reference, these project coding standards all recommend trailing commas:

    enhancement discussion 
    opened by gouch 25
  • If plain html code is provided, empty lines are added

    If plain html code is provided, empty lines are added

    I have alot of php files that contain pure html code.

    Prettier PHP takes those files and adds plain empty html lines between every line.

    Before:

    <section class="[ c-social-foot ]  [ has-text-centered ]">
      <div class="[ container  is-fluid ]">
        <div class="[ columns  is-centered ]">
          <div class="[ column ]">
    

    After

    <section class="[ c-social-foot ]  [ has-text-centered ]">
    
      <div class="[ container  is-fluid ]">
    
        <div class="[ columns  is-centered ]">
    
          <div class="[ column ]">
    

    This is very odd, it should remain as it was.

    ugly 
    opened by vielhuber 24
  • Force array/list shorthand notation

    Force array/list shorthand notation

    Force the use of shorthand array's, (available since php 5.4)

    Reasoning:

    The old syntax looks like a method call, not like an array. The new syntax is shorter and improves readability as it looks like an array.

    Other issues regarding array's use the shorthand notation in their example code, indicating a preference towards shorthand.

    Input:

    $my_array = array(1, 2, 3);
    

    Desired output:

    $my_array = [1, 2, 3];
    
    enhancement discussion 
    opened by bfanger 22
  • Implement Syntax Errors Matching Prettier Conventions, fixes #956

    Implement Syntax Errors Matching Prettier Conventions, fixes #956

    This PR changes the structure of SyntaxErrors thrown from the PHP plugin towards Prettier in such a way that Prettier knows how to handle them, as explained in #956.

    The small refactoring in the tests_config folder is a necessity for the added test that covers the new behavior, as this test is not matching the structure of the other run_spec() tests.

    opened by loilo 21
  • build(deps-dev): bump eslint-plugin-jest from 27.1.3 to 27.2.0

    build(deps-dev): bump eslint-plugin-jest from 27.1.3 to 27.2.0

    Bumps eslint-plugin-jest from 27.1.3 to 27.2.0.

    Release notes

    Sourced from eslint-plugin-jest's releases.

    v27.2.0

    27.2.0 (2022-12-31)

    Features

    v27.1.7

    27.1.7 (2022-12-15)

    Bug Fixes

    v27.1.6

    27.1.6 (2022-11-24)

    Bug Fixes

    • ensure rule fixes produce valid code when function params and args have trailing commas (#1282) (8eca0b7)

    v27.1.5

    27.1.5 (2022-11-10)

    Performance Improvements

    • use Set instead of iterating, and deduplicate a function (#1278) (0e048f1)

    v27.1.4

    27.1.4 (2022-11-04)

    Performance Improvements

    • don't collect more info than needed when resolving jest functions (#1275) (e4a5674)
    Changelog

    Sourced from eslint-plugin-jest's changelog.

    27.2.0 (2022-12-31)

    Features

    27.1.7 (2022-12-15)

    Bug Fixes

    27.1.6 (2022-11-24)

    Bug Fixes

    • ensure rule fixes produce valid code when function params and args have trailing commas (#1282) (8eca0b7)

    27.1.5 (2022-11-10)

    Performance Improvements

    • use Set instead of iterating, and deduplicate a function (#1278) (0e048f1)

    27.1.4 (2022-11-04)

    Performance Improvements

    • don't collect more info than needed when resolving jest functions (#1275) (e4a5674)
    Commits
    • b00b9b6 chore(release): 27.2.0 [skip ci]
    • ee43c3f feat: create require-typed-module-mocks rule (#1314)
    • 891fe1e chore(deps): update yarn to v3.3.1 (#1311)
    • fae0d2e chore: fix link in readme
    • 0958af4 chore(deps): lock file maintenance
    • 7fcf48f chore(deps): lock file maintenance
    • 42ce29f test(to-have-length): add optional chaining case (#1295)
    • 90f2d18 chore(release): 27.1.7 [skip ci]
    • 5d1b7a7 fix(prefer-spy-on): improve autofix (#1308)
    • f33b19e chore(deps): lock file maintenance
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 0
  • build(deps-dev): bump eslint-config-prettier from 8.5.0 to 8.6.0

    build(deps-dev): bump eslint-config-prettier from 8.5.0 to 8.6.0

    Bumps eslint-config-prettier from 8.5.0 to 8.6.0.

    Changelog

    Sourced from eslint-config-prettier's changelog.

    Version 8.6.0 (2023-01-02)

    • Added: [vue/multiline-ternary]. Thanks to @​xcatliu!
    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 0
  • build(deps-dev): bump eslint from 8.26.0 to 8.31.0

    build(deps-dev): bump eslint from 8.26.0 to 8.31.0

    Bumps eslint from 8.26.0 to 8.31.0.

    Release notes

    Sourced from eslint's releases.

    v8.31.0

    Features

    • 52c7c73 feat: check assignment patterns in no-underscore-dangle (#16693) (Milos Djermanovic)
    • b401cde feat: add options to check destructuring in no-underscore-dangle (#16006) (Morten Kaltoft)
    • 30d0daf feat: group properties with values in parentheses in key-spacing (#16677) (Francesco Trotta)

    Bug Fixes

    • 35439f1 fix: correct syntax error in prefer-arrow-callback autofix (#16722) (Francesco Trotta)
    • 87b2470 fix: new instance of FlatESLint should load latest config file version (#16608) (Milos Djermanovic)

    Documentation

    • 4339dc4 docs: Update README (GitHub Actions Bot)
    • 4e4049c docs: optimize code block structure (#16669) (Sam Chen)
    • 54a7ade docs: do not escape code blocks of formatters examples (#16719) (Sam Chen)
    • e5ecfef docs: Add function call example for no-undefined (#16712) (Elliot Huffman)
    • a3262f0 docs: Add mastodon link (#16638) (Amaresh S M)
    • a14ccf9 docs: clarify files property (#16709) (Sam Chen)
    • 3b29eb1 docs: fix npm link (#16710) (Abdullah Osama)
    • a638673 docs: fix search bar focus on Esc (#16700) (Shanmughapriyan S)
    • f62b722 docs: country flag missing in windows (#16698) (Shanmughapriyan S)
    • 4d27ec6 docs: display zh-hans in the docs language switcher (#16686) (Percy Ma)
    • 8bda20e docs: remove manually maintained anchors (#16685) (Percy Ma)
    • b68440f docs: User Guide Getting Started expansion (#16596) (Ben Perlmutter)

    Chores

    • 65d4e24 chore: Upgrade @​eslint/eslintrc@​1.4.1 (#16729) (Brandon Mills)
    • 8d93081 chore: fix CI failure (#16721) (Sam Chen)
    • 8f17247 chore: Set up automatic updating of README (#16717) (Nicholas C. Zakas)
    • 4cd87cb ci: bump actions/stale from 6 to 7 (#16713) (dependabot[bot])
    • fd20c75 chore: sort package.json scripts in alphabetical order (#16705) (Darius Dzien)
    • 10a5c78 chore: update ignore patterns in eslint.config.js (#16678) (Milos Djermanovic)

    v8.30.0

    Features

    • 075ef2c feat: add suggestion for no-return-await (#16637) (Daniel Bartholomae)
    • 7190d98 feat: update globals (#16654) (Sébastien Règne)

    Bug Fixes

    • 1a327aa fix: Ensure flat config unignores work consistently like eslintrc (#16579) (Nicholas C. Zakas)
    • 9b8bb72 fix: autofix recursive functions in no-var (#16611) (Milos Djermanovic)

    Documentation

    • 6a8cd94 docs: Clarify Discord info in issue template config (#16663) (Nicholas C. Zakas)
    • ad44344 docs: CLI documentation standardization (#16563) (Ben Perlmutter)
    • 293573e docs: fix broken line numbers (#16606) (Sam Chen)
    • fa2c64b docs: use relative links for internal links (#16631) (Percy Ma)
    • 75276c9 docs: reorder options in no-unused-vars (#16625) (Milos Djermanovic)
    • 7276fe5 docs: Fix anchor in URL (#16628) (Karl Horky)
    • 6bef135 docs: don't apply layouts to html formatter example (#16591) (Tanuj Kanti)
    • dfc7ec1 docs: Formatters page updates (#16566) (Ben Perlmutter)

    ... (truncated)

    Changelog

    Sourced from eslint's changelog.

    v8.31.0 - December 31, 2022

    • 65d4e24 chore: Upgrade @​eslint/eslintrc@​1.4.1 (#16729) (Brandon Mills)
    • 35439f1 fix: correct syntax error in prefer-arrow-callback autofix (#16722) (Francesco Trotta)
    • 87b2470 fix: new instance of FlatESLint should load latest config file version (#16608) (Milos Djermanovic)
    • 8d93081 chore: fix CI failure (#16721) (Sam Chen)
    • 4339dc4 docs: Update README (GitHub Actions Bot)
    • 8f17247 chore: Set up automatic updating of README (#16717) (Nicholas C. Zakas)
    • 4e4049c docs: optimize code block structure (#16669) (Sam Chen)
    • 54a7ade docs: do not escape code blocks of formatters examples (#16719) (Sam Chen)
    • 52c7c73 feat: check assignment patterns in no-underscore-dangle (#16693) (Milos Djermanovic)
    • e5ecfef docs: Add function call example for no-undefined (#16712) (Elliot Huffman)
    • a3262f0 docs: Add mastodon link (#16638) (Amaresh S M)
    • 4cd87cb ci: bump actions/stale from 6 to 7 (#16713) (dependabot[bot])
    • a14ccf9 docs: clarify files property (#16709) (Sam Chen)
    • 3b29eb1 docs: fix npm link (#16710) (Abdullah Osama)
    • fd20c75 chore: sort package.json scripts in alphabetical order (#16705) (Darius Dzien)
    • a638673 docs: fix search bar focus on Esc (#16700) (Shanmughapriyan S)
    • f62b722 docs: country flag missing in windows (#16698) (Shanmughapriyan S)
    • 4d27ec6 docs: display zh-hans in the docs language switcher (#16686) (Percy Ma)
    • 8bda20e docs: remove manually maintained anchors (#16685) (Percy Ma)
    • b401cde feat: add options to check destructuring in no-underscore-dangle (#16006) (Morten Kaltoft)
    • b68440f docs: User Guide Getting Started expansion (#16596) (Ben Perlmutter)
    • 30d0daf feat: group properties with values in parentheses in key-spacing (#16677) (Francesco Trotta)
    • 10a5c78 chore: update ignore patterns in eslint.config.js (#16678) (Milos Djermanovic)

    v8.30.0 - December 16, 2022

    • f2c4737 chore: upgrade @​eslint/eslintrc@​1.4.0 (#16675) (Milos Djermanovic)
    • 1a327aa fix: Ensure flat config unignores work consistently like eslintrc (#16579) (Nicholas C. Zakas)
    • 075ef2c feat: add suggestion for no-return-await (#16637) (Daniel Bartholomae)
    • ba74253 chore: standardize npm script names per #14827 (#16315) (Patrick McElhaney)
    • 6a8cd94 docs: Clarify Discord info in issue template config (#16663) (Nicholas C. Zakas)
    • 0d9af4c ci: fix npm v9 problem with file: (#16664) (Milos Djermanovic)
    • 7190d98 feat: update globals (#16654) (Sébastien Règne)
    • ad44344 docs: CLI documentation standardization (#16563) (Ben Perlmutter)
    • 90c9219 refactor: migrate off deprecated function-style rules in all tests (#16618) (Bryan Mishkin)
    • 9b8bb72 fix: autofix recursive functions in no-var (#16611) (Milos Djermanovic)
    • 293573e docs: fix broken line numbers (#16606) (Sam Chen)
    • fa2c64b docs: use relative links for internal links (#16631) (Percy Ma)
    • 75276c9 docs: reorder options in no-unused-vars (#16625) (Milos Djermanovic)
    • 7276fe5 docs: Fix anchor in URL (#16628) (Karl Horky)
    • 6bef135 docs: don't apply layouts to html formatter example (#16591) (Tanuj Kanti)
    • dfc7ec1 docs: Formatters page updates (#16566) (Ben Perlmutter)
    • 8ba124c docs: update the prefer-const example (#16607) (Pavel)
    • e6cb05a docs: fix css leaking (#16603) (Sam Chen)

    v8.29.0 - December 2, 2022

    • 0311d81 docs: Configuring Plugins page intro, page tweaks, and rename (#16534) (Ben Perlmutter)

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 0
  • Forcing short hand arrays in PHP

    Forcing short hand arrays in PHP

    It appears the PHP array short hand is being forced for version 5.4 and above?

    const useShortForm = (node.kind === "array" && isMinVersion(options.phpVersion, "5.4")) || (node.kind === "list" && node.shortForm

    Can this be updated to have the option to override this?

    opened by vincentmcgreevy 1
  • build(deps-dev): bump prettier from 2.1.2 to 2.8.1

    build(deps-dev): bump prettier from 2.1.2 to 2.8.1

    Bumps prettier from 2.1.2 to 2.8.1.

    Release notes

    Sourced from prettier's releases.

    2.8.1

    🔗 Changelog

    2.8.0

    diff

    🔗 Release note

    2.7.1

    🔗 Changelog

    2.7.0

    diff

    🔗 Release note

    2.6.2

    🔗 Changelog

    2.6.1

    🔗 Changelog

    2.6.0

    🔗 Release note

    2.5.1

    🔗 Changelog

    2.5.0

    diff

    🔗 Release note

    2.4.1

    🔗 Changelog

    2.4.0

    diff

    Release note

    2.3.2

    changelog

    v2.3.1

    Changelog

    2.3.0

    diff

    ... (truncated)

    Changelog

    Sourced from prettier's changelog.

    2.8.1

    diff

    Fix SCSS map in arguments (#9184 by @​agamkrbit)

    // Input
    $display-breakpoints: map-deep-merge(
      (
        "print-only": "only print",
        "screen-only": "only screen",
        "xs-only": "only screen and (max-width: #{map-get($grid-breakpoints, "sm")-1})",
      ),
      $display-breakpoints
    );
    

    // Prettier 2.8.0 $display-breakpoints: map-deep-merge( ( "print-only": "only print", "screen-only": "only screen", "xs-only": "only screen and (max-width: #{map-get($grid-breakpoints, " sm ")-1})", ), $display-breakpoints );

    // Prettier 2.8.1 $display-breakpoints: map-deep-merge( ( "print-only": "only print", "screen-only": "only screen", "xs-only": "only screen and (max-width: #{map-get($grid-breakpoints, "sm")-1})", ), $display-breakpoints );

    Support auto accessors syntax (#13919 by @​sosukesuzuki)

    Support for Auto Accessors Syntax landed in TypeScript 4.9.

    (Doesn't work well with babel-ts parser)

    class Foo {
      accessor foo: number = 3;
    </tr></table> 
    

    ... (truncated)

    Commits
    Maintainer changes

    This version was pushed to npm by prettier-bot, a new releaser for prettier since your current version.


    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 0
  • [error] No files matching the pattern were found:

    [error] No files matching the pattern were found: "path/to/file.php".

    so I installed this plugin globally with:

    npm install --global prettier @prettier/plugin-php

    but when I run prettier path/to/file.php --write

    i get this error: [error] No files matching the pattern were found: "path/to/file.php".

    opened by Shamo84 2
Releases(v0.19.2)
  • v0.19.2(Nov 2, 2022)

    Deprecations

    The psr2 setting for the braceStyle option has been renamed to per-cs to be more in line with future PER releases (see https://github.com/prettier/plugin-php/issues/2060 for details). psr2 will continue to work for now, but will be removed in a future release.

    Bugfixes

    • Support expressions in new statement (#2086, thanks @cseufert!)
    • Fix for function curly brace with attrs (#2089, thanks @cseufert!)
    • Deprecated PSR-2 braceStyle and use PER-CS instead (#2070, thanks @cseufert!)
    Source code(tar.gz)
    Source code(zip)
  • v0.19.1(Sep 13, 2022)

  • v0.19.0(Sep 7, 2022)

    • fix: formatting of long cases in match statement (#2054)
    • chore: upgrade dependencies (#2059)

    Breaking Change:

    • Dropped support for Node v12.
    Source code(tar.gz)
    Source code(zip)
  • v0.18.9(Jul 2, 2022)

  • v0.18.8(Jun 10, 2022)

  • v0.18.7(May 30, 2022)

  • v0.18.6(May 25, 2022)

  • v0.18.5(May 23, 2022)

  • v0.18.4(Mar 25, 2022)

  • v0.18.3(Mar 8, 2022)

    • feat: [8.1] add support for Intersection types (#1933, thanks @genintho!)
    • chore: add test for covering 'never' return type (#1934, thanks @genintho!)
    Source code(tar.gz)
    Source code(zip)
  • v0.18.2(Feb 20, 2022)

  • v0.18.1(Feb 12, 2022)

  • v0.18.0(Feb 3, 2022)

    • fix(attributes): remove extra line break (#1890)
    • !fix: bump php-parser and other dependencies (#1914)
    • fix member chain when nullsafe operator is used (#1912, thanks @Epskampie!)
    • added dangling commas on multiline attributes (#1886, thanks @cseufert!)
    • fix: remove jest config from package.json (#1857)

    Breaking Changes

    • dropped support for node v10
    Source code(tar.gz)
    Source code(zip)
  • v0.17.6(Oct 30, 2021)

  • v0.17.5(Sep 10, 2021)

    • fix: workaround for extra end tag appearing when first line line has comment (#1764, thanks @cseufert!)
    • fix: don't duplicate php8 attributes (#1821, thanks @cseufert!)
    Source code(tar.gz)
    Source code(zip)
  • v0.17.4(Aug 31, 2021)

    • feat(php8-attribute): PHP 8 Attribute output (#1761, thanks @cseufert!)
    • fix class const ignore formatting bug (#1799, thanks @wdoug!)
    • dependency updates
    Source code(tar.gz)
    Source code(zip)
  • v0.17.3(Jul 27, 2021)

    • Update PHP parser to allow for dangling comma in use block (#1796, thanks @justim!)
    • Added PhpStorm/Jetbrains config guide (#1787, thanks @cseufert!)
    • Updated NodeJS versions to current stable releases (#1775, thanks @cseufert!)
    • chore: update prettier to 2.1.2 (#1774)
    • dependency updates
    Source code(tar.gz)
    Source code(zip)
  • v0.17.2(Jun 26, 2021)

    • feat(php8 hanging comma) Add support for haning comma for functions, closures, arrow functions and methods (#1769)
    • fix(php8): non-capturing exception catches (#1763)
    Source code(tar.gz)
    Source code(zip)
  • v0.17.1(Jun 15, 2021)

  • v0.17.0(Jun 14, 2021)

    This release adds partial support for PHP8 :tada:

    • feat: PHP8 Promoted Props / Match Statement / Throw Statement / Union Types (#1753, thanks @cseufert!)
    • feat: add support for named arguments and nullsafepropertylookup (php8) (#1656)
    • dependency updates
    Source code(tar.gz)
    Source code(zip)
  • v0.16.3(May 13, 2021)

  • v0.16.2(Mar 19, 2021)

  • v0.16.1(Dec 12, 2020)

  • v0.16.0(Nov 12, 2020)

    • feat: Convert single quotes to double quotes (#1254 / #1582, thanks @utkarshgupta137!)
    • fix: comment position in anonymous class (#1580)
    • fix: space after anonymous class keyword (#1579)
    Source code(tar.gz)
    Source code(zip)
  • v0.15.2(Oct 26, 2020)

  • v0.15.1(Oct 17, 2020)

  • v0.15.0(Oct 4, 2020)

  • v0.14.3(Jul 25, 2020)

  • v0.14.2(May 28, 2020)

  • v0.14.1(May 20, 2020)

Owner
Prettier
Prettier is an opinionated code formatter
Prettier
A plugin manager for PocketMine-MP downloads plugin from PocketMine-MP official plugin repository

oh-my-pmmp A plugin manager for PocketMine-MP Getting Started Prerequisites Your server MUST RUN the latest version of PocketMine. Installation From P

thebigcrafter 6 Jan 4, 2023
Integrates the ClassicPress Plugin Directory and any plugin stored in GitHub (tagged with classicpress-plugin) in the ClassicPress Admin

ClassicPress Plugin Directory Adds a new screen in a ClassicPress Install where you can browse, install, activate, deactivate, update, delete and pagi

TukuToi 3 Dec 27, 2022
This Pocketmine-MP plugin is a plugin including a complete faction system.

SimpleFaction Simple faction plugin replacing FactionsPro which is no longer updated. Commands Command Name Command Description Available for /f help

Ayzrix 33 Dec 19, 2022
SpawnInLobby Pocketmine-MP plugin. With this plugin the player will always join the game at the default world spawn point

SpawnInLobby Pocketmine-MP plugin. With this plugin the player will always join the game at the default world spawn point

null 1 Jan 7, 2022
Ratio plugin is a luck plugin. The more lucky you are, the more you win!

Ratio Ratio plugin is a luck plugin. The more lucky you are, the more you win Features When you break a block (Cobblestone), it gives/puts you somethi

Ali Tura Çetin 2 Apr 25, 2022
actionMaster is a new faction plugin that aims at flexibility and customization of the plugin by the user and the developers.

FactionMaster is a new faction plugin that aims at flexibility and customization of the plugin by the user and the developers. It includes all the basic functionality of a faction plugin and data storage in MySQL or SQLITE. This is done by adding an extension system and a translation system. FactionMaster has a will of accessibility to the players and especially not to have to remember a lot of commands to play, all is done via interface.

FactionMaster 21 Dec 26, 2022
Api.video-wordpress-plugin - The official api.video plugin for WordPress

api.video WordPress Plugin api.video is the video infrastructure for product builders. Lightning fast video APIs for integrating, scaling, and managin

api.video 5 Oct 19, 2022
Ied plugin composer - Inspired Plugin Composer: Create, publish and edit plugins from within Textpattern CMS.

ied_plugin_composer Create, publish and edit plugins from within Textpattern CMS. Creates a new page under the Extensions tab where you can edit and e

Stef Dawson 8 Oct 3, 2020
BetterMobs - a plugin Remixed, by MadoxMC, the original plugin is maked by tgwaste

BetterMobsOverworld BetterMobs is a plugin Remixed, by MadoxMC, the original plugin is maked by tgwaste. MadoxMC Just Edited This plugin to Make 3 Compatible Plugins to add Mobs on your Overworld Worlds, NetherWorlds & EndWorlds, MadoxMC Idea.

MadoxMC 4 Dec 15, 2022
BetterMobs is a plugin Remixed, by MadoxMC, the original plugin is maked by tgwaste.

BetterMobs is a plugin Remixed, by MadoxMC, the original plugin is maked by tgwaste. MadoxMC Just Edited This plugin to Make 3 Compatible Plugins to add Mobs on your Overworld Worlds, NetherWorlds & EndWorlds, MadoxMC Idea.

MadoxMC 10 Dec 15, 2022
Opinionated version of Wikimedia composer-merge-plugin to work in pair with Bamarni composer-bin-plugin.

Composer Inheritance Plugin Opinionated version of Wikimedia composer-merge-plugin to work in pair with bamarni/composer-bin-plugin. Usage If you are

Théo FIDRY 25 Dec 2, 2022
SublimeLinter 3 plugin for PHP, using php -l.

SublimeLinter-php This linter plugin for SublimeLinter provides an interface to php -l. It will be used with files that have the "PHP", "HTML", or "HT

null 205 Jan 4, 2023
This is a plugin written in PHP programming language and running on the PocketMine platform that works stably on the API 3.25.0 platform

This is a plugin written in PHP programming language and running on the PocketMine platform that works stably on the API 3.25.0 platform. It allows you to hear the sound

Thành Nhân 10 Sep 27, 2022
This repository contains the codebase PHP bridge using RoadRunner Jobs plugin.

RoadRunner Jobs Plugin This repository contains the codebase PHP bridge using RoadRunner Jobs plugin. Installation To install application server and J

Spiral Scout 15 Nov 9, 2022
Composer plugin for Repman - PHP Repository Manager

Repman Composer Plugin Composer plugin for Repman - PHP Repository Manager. Adds a mirror url for all your dependencies without need to update compose

Repman 9 Mar 14, 2022
Composer Plugin for automatically including files for easing function usage in php.

Php Inc Php inc is a composer plugin for automatically including certain files into composer's autoload and autoload-dev files config. Given a set of

Krak 5 Jan 11, 2022
This plugin can be embedded in PHP application to give the web application specific routes/href

Routes Plugin PHP This plugin can be embedded in PHP application to give the web application specific routes/href location and for entering specific/l

Ifechukwudeni Oweh 7 Jul 17, 2022
Comprehensive Plugin for composer to execute PHP Quality assurance Tools

NOT MAINTANED ANYMORE The development of composer-plugin-qa was dropped in favor of phpqa which is actively maintained. The project use docker and can

Webysther Nunes 25 Apr 30, 2021