New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

php-imports

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

php-imports

JavaScript library for formatting PHP imports

  • 0.6.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

js-php-imports

Travis CI Build Status npm version

JavaScript library for formatting PHP imports.

Installation

$ npm i --save php-imports

or

$ yarn add php-imports

CLI

This package provides basic cli:

PHP imports formatter

USAGE
  $ php-imports [FILE]

OPTIONS
  -V, --verbose          Print more info
  -c, --config=config    JSON configuration
  -f, --flag=flag        Specify configuration key-value pair
  -h, --help             show CLI help
  -p, --project=project  [default: .] Project directory or .phpimportsrc file
  -v, --version          show CLI version
  --dry                  Don't write any changes to files
  --init                 Create .phpimportsrc file

By default, it uses .phpimportsrc file located at current working directory.

phpimportsrc

It is a json file that contains configuration for this package. You can create this file with $ php-imports --init.

Also, you can specify these flags with -f argument: $ php-imports -f unused.enable=true

It can contain the following options (dot means object nesting):

  • root: Base location of sources. Default is . (current working directory).

  • include: List of files to include (glob patterns) relatively to root (default is src/**/*.php).

  • exclude: List of files to exclude (relatively to root, default is node_modules and vendor).

  • order: Order of import sets and empty lines between them. An array of enums with possible values:

    • emptyLine
    • all.all
    • all.class
    • all.function
    • all.const
    • singleUses.all
    • singleUses.class
    • singleUses.function
    • singleUses.const
    • groupedUses.all
    • groupedUses.class
    • groupedUses.function
    • groupedUses.const
  • sort.order: Order of first-level imports. Possible values: default (alphabetical) or natural (first longest, alphabetical).

  • sort.nestedOrder: Order of second-level imports. Possible values: default (alphabetical) or natural (first longest, alphabetical).

  • print.emptyLinesAfterImports: Count of empty lines between last import and the declaration after it.

  • print.wrap: If false, then nested groups are never wrapped, if true (which is default), then they are always in separate lines.

    You can also set it to number to start wrapping only when line length exceeds that limit.

    Alternatively it can be set to object {"all":false,"limit":120} in order to put as much as possible imports in single line with wrapping still enabled.

  • psr12.enable: Enable PSR-12 imports formatting.

  • psr12.isolateModifiers: Whether to put different modifiers (without modifier, const and function) to different groups.

  • psr12.minNestedGroupNestedUsesCount: Minimum count of nested uses to make a nested group with them.

  • psr12.minNestedGroupUsesCount: Mimimum count of uses to make a nested group with them.

  • psr12.minGroupUsesCount: Mimimum count of uses of same namespace to make a group with them.

  • custom.enable: Enable custom imports formatting.

  • custom.isolateModifiers: Whether to put different modifiers (without modifier, const and function) to different groups.

  • custom.include: A list of namespaces that should always be grouped. Can be used with wildcards (*) and double wildcards (**).

  • custom.exclude: A list of namespaces that should never be grouped.

  • unused.enable: Clean up unused imports.

License

The project is released under the MIT license. Read the license for more information.

FAQs

Package last updated on 06 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc