Download the PHP package joeymckenzie/nasastan without Composer

On this page you can find all versions of the php package joeymckenzie/nasastan. 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 nasastan

packgist downloads ci packgist downloads packgist downloads

🚀 NASAStan

PHPStan extension that enforces NASA's Power of Ten rules in your PHP code.

Table of Contents

Why should I use this extension?

Great question. I'm still trying to figure out an answer to that myself.

Getting started

To get started, install the package with composer:

Usage

If you're using phpstan/extension-installer, you're all set!

If not, however, include the extension in your PHPStan configuration:

Not all rules may be applicable to PHP. Yes, I'm aware these rules are primarily targeted at C/C++ and some may not be nonsensical for PHP's use case. The rules are opt-in, allowing for a "choose your own" adventure with rules you may prefer while disabling ones that you may want in your project.

Configuring NASAStan

To use NASAStan with its default configuration, add the extension to your phpstan.neon file:

Customizing rules

You can customize NASAStan's behavior by overriding configuration parameters in your phpstan.neon file.

Enabling or disabling rules

By default, all NASAStan rules are enabled. To select only specific rules:

To exclude specific rules while keeping others enabled:

Rule-specific configuration

Each rule has its own customizable parameters. Here are examples for each rule:

Rule 2: Fixed upper bounds on loops

Rule 3: No heap allocation after initialization

Rule 4: Restrict function length

Rule 5: Minimum assertions per function

Rule 6: Restrict data scope

Rule 7: Check return values

Rule 9: Limit dereferences

Rule 10: Compile with all warnings active

Complete configuration example

Here's an example of a complete configuration with customized values:

Default Values

If you don't override a configuration parameter, NASAStan will use the following default values:

Parameter Default Value
enabledRules All rules (1-7, 9-10)
exceptRules [] (empty array)
maxAllowedIterations 1000
maxLinesPerFunction 60
includeComments true
includeBlankLines true
minimumAssertionsRequired 2
maxClassProperties 10
maxAllowedDereferences 1

For complete details on all available configuration options, refer to the NASAStanConfiguration.php class or the default extension.neon file.

Original NASA Power of Ten Rules

  1. Avoid complex flow constructs, such as goto and recursion.
  2. All loops must have fixed bounds. This prevents runaway code.
  3. Avoid heap memory allocation after initialization.
  4. Restrict functions to a single printed page.
  5. Use a minimum of two runtime assertions per function.
  6. Restrict the scope of data to the smallest possible.
  7. Check the return value of all non-void functions, or cast to void to indicate the return value is useless.
  8. Use the preprocessor only for header files and simple macros.
  9. Limit pointer use to a single dereference, and do not use function pointers.
  10. Compile with all possible warnings active; all warnings should then be addressed before release of the software.

Rules

Rule #1

Avoid complex flow constructs, such as goto and recursion

Disallows the use of goto statements and recursive functions. The following code would be in direct violation of this rule and reported on by NASAStan:

Rule #2

All loops must have fixed bounds. This prevents runaway code

Enforces all loops within PHP code to have a fixed upper bound. Things like while(true), do-while(true), Generator types, and array types greater than the configurable upper-bound will cause NASAStan to flag for errors.

Unbound while loops

With Generator types

Rule #3

Avoid heap memory allocation after initialization

Constricts resource allocation to only be allowed within approved initialization methods. Things like newing up objects outside of constructors, array allocations, etc. will cause NASAStan to report on this rule.

Rule #4

Restrict functions to a single printed page

Enforces a strict method length rule within a function or method. Can be adjusted through configuration with a default set to 60 lines.

Rule #5

Use a minimum of two runtime assertions per function

Requires at least two runtime assertions either in the form of assert() methods, exceptions, or test-based assertions like PHPUnit's Assert.

Rule #6

Restrict the scope of data to the smallest possible

This rule limits the number of properties on classes and their visibility. Properties may be whitelisted within configuration telling NASAStan to ignore reporting on these instances.

Rule #7

Check the return value of all non-void functions, or cast to void to indicate the return value is useless

This rule enforces all method and function values to be used. Any unused values will be reported by NASAStan.

Rule #8

Use the preprocessor only for header files and simple macros

This rule does not apply to PHP and has been deliberately ignored. PHP does not use preprocessors for header files nor allows for the use of traditional macros.

Rule #9

Limit pointer use to a single dereference, and do not use function pointers

This rule limits the number of times functions or properties may be derefenced (or called) within code. The amount of dereferences is configurable.

Rule #10

Compile with all possible warnings active; all warnings should then be addressed before release of the software

This rules bans the use of @ error suppression symbols and enforces the use of strict type declarations.

References


All versions of nasastan with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
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 joeymckenzie/nasastan contains the following files

Loading the files please wait ...