Download the PHP package povils/phpmnd without Composer

On this page you can find all versions of the php package povils/phpmnd. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package phpmnd

PHP Magic Number Detector (PHPMND)

Minimum PHP version: 7.4.0 Scrutinizer Code Quality License CI

phpmnd is a tool that aims to help you to detect magic numbers in your PHP code. By default 0 and 1 are not considered to be magic numbers.

What is a magic number?

A magic number is a numeric literal that is not defined as a constant, but which may change at a later stage, and therefore can be hard to update. It's considered a bad programming practice to use numbers directly in any source code without an explanation. In most cases this makes programs harder to read, understand, and maintain.

Consider the following hypothetical code:

which should be refactored to:

This clearly improves the code readability and also reduces its maintenance cost.

Of course not every literal number is a magic number.

Surely in this case the number 2 is not a magic number.

My rule of thumb:

Installation

Locally

You can add this tool as a local, per-project, development dependency to your project by using Composer:

Afterwards you can then invoke it using the vendor/bin/phpmnd executable.

Globally

To install it globally simply run:

Afterwards make sure you have the global Composer binaries directory in your PATH. Example for some Unix systems:

Usage Example

Demo

Basic usage

The --allow-array-mapping option allow keys as strings when using "array" extension.

The --exclude-file option will exclude a file from the code analysis. Multiple values are allowed.

The --exclude-path option will exclude a path, which must be relative to the source, from the code analysis. Multiple values are allowed.

The --exclude option will exclude a directory, which must be relative to the source, from the code analysis. Multiple values are allowed (e.g. --exclude=tests --exclude=examples).

The --extensions option lets you extend the code analysis. The provided extensions must be comma separated.

The --hint option will suggest replacements for magic numbers based on your codebase constants.

The --ignore-funcs option will exclude a list of comma separated functions from the code analysis, when using the "argument" extension. Defaults to intval, floatval, strval.

The --ignore-numbers option will exclude a list of comma separated numbers from the code analysis.

The --ignore-strings option will exclude strings from the code analysis, when using the "strings" option.

The --include-numeric-string option forces numeric strings such as "1234" to also be treated as a number.

The --progress option will display a progress bar.

The --strings option will include strings literal search in code analysis.

The --suffixes option will configure a comma separated list of valid source code filename extensions.

The --whitelist option will only process the files listed in the file specified. This is useful for incremental analysis.

The --xml-output option will generate an report in an Xml format to the path specified by the option. By default it analyses conditions, return statements, and switch cases.

Extensions

If extensions start with a minus, it means that these will be removed from the code analysis. I would recommend to clean up your code by using the default extension before using any of these extensions.

Ignoring a number from analysis

Sometimes magic numbers are required. For example implementing a known mathematical formula, by default intval, floatval and strval mark a number as not magic.

eg

would show 100 as a magic number

would mark 100 as not magic.

Contributing

Please see CONTRIBUTING.md for more information.

License

The MIT License (MIT). Please see LICENSE for more information.


All versions of phpmnd with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4 || ^8.0
symfony/console Version ^4.4 || ^5.0 || ^6.0 || ^7.0
symfony/finder Version ^4.4 || ^5.0 || ^6.0 || ^7.0
nikic/php-parser Version ^4.18 || ^5.0
php-parallel-lint/php-console-highlighter Version ^1.0
phpunit/php-timer Version ^2.0||^3.0||^4.0||^5.0||^6.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package povils/phpmnd contains the following files

Loading the files please wait ....