Provides functionality that helps writing PHP code that has runtime-specific (PHP / HHVM) execution paths

Overview

sebastian/environment

Latest Stable Version CI Status Type Coverage

This component provides functionality that helps writing PHP code that has runtime-specific (PHP / HHVM) execution paths.

Installation

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

composer require sebastian/environment

If you only need this library during development, for instance to run your project's test suite, then you should add it as a development-time dependency:

composer require --dev sebastian/environment
Comments
  • Implement equivalent of PHP_OS_FAMILY (for PHP < 7.2)

    Implement equivalent of PHP_OS_FAMILY (for PHP < 7.2)

    Below is the code used in PHP >= 7.2 to define the PHP_OS_FAMILY constant:

    #ifdef PHP_WIN32
    # define PHP_OS_FAMILY			"Windows"
    #elif defined(BSD) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
    # define PHP_OS_FAMILY			"BSD"
    #elif defined(__APPLE__) || defined(__MACH__)
    # define PHP_OS_FAMILY			"Mac"
    #elif defined(__sun__)
    # define PHP_OS_FAMILY			"Solaris"
    #elif defined(__linux__)
    # define PHP_OS_FAMILY			"Linux"
    #else
    # define PHP_OS_FAMILY			"Unknown"
    #endif
    

    It would be great if this component had a method that returns the string that would be in PHP_OS_FAMILY on >= PHP 7.2 for versions of PHP < 7.2.

    In order to implement this based on PHP_OS, I need to know the output of

    $ php -r 'var_dump(PHP_OS);'
    

    run on the following operating systems:

    • [X] Windows (various (currently supported) versions)
    • [X] DragonFly BSD
    • [X] FreeBSD
    • [X] NetBSD
    • [X] OpenBSD
    • [X] macOS X
    • [X] Solaris
    • [X] Linux
    enhancement 
    opened by sebastianbergmann 21
  • Test failures with PHPUnit's own test suite and ^4.0 of this component

    Test failures with PHPUnit's own test suite and ^4.0 of this component

    $ ./phpunit 
    PHPUnit 7.4.2 by Sebastian Bergmann and contributors.
    
    Runtime:       PHP 7.2.11 with Xdebug 2.6.1
    Configuration: /usr/local/src/phpunit/phpunit.xml
    
    .............................................................   61 / 1989 (  3%)
    .............................................................  122 / 1989 (  6%)
    .............................................................  183 / 1989 (  9%)
    .............................................................  244 / 1989 ( 12%)
    .............................................................  305 / 1989 ( 15%)
    .............................................................  366 / 1989 ( 18%)
    .............................................................  427 / 1989 ( 21%)
    .............................................................  488 / 1989 ( 24%)
    .............................................................  549 / 1989 ( 27%)
    .............................................................  610 / 1989 ( 30%)
    .............................................................  671 / 1989 ( 33%)
    .............................................................  732 / 1989 ( 36%)
    .............................................................  793 / 1989 ( 39%)
    .............................................................  854 / 1989 ( 42%)
    .............................................................  915 / 1989 ( 46%)
    .............................................................  976 / 1989 ( 49%)
    ............................................................. 1037 / 1989 ( 52%)
    ............................................................. 1098 / 1989 ( 55%)
    ............................................................. 1159 / 1989 ( 58%)
    ............................................................. 1220 / 1989 ( 61%)
    ............................................................. 1281 / 1989 ( 64%)
    ............................................................. 1342 / 1989 ( 67%)
    ............................................................. 1403 / 1989 ( 70%)
    ............................................................. 1464 / 1989 ( 73%)
    ............................................................. 1525 / 1989 ( 76%)
    ............................................................. 1586 / 1989 ( 79%)
    ............................................................. 1647 / 1989 ( 82%)
    ............................................................. 1708 / 1989 ( 85%)
    ........................FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 1769 / 1989 ( 88%)
    FFFFFFFFFFFFFFFFFFFFFFFFFFFFF...F....FF...................... 1830 / 1989 ( 92%)
    ..........................................................FF. 1891 / 1989 ( 95%)
    F.F.....FFFFFFFFFFFFFFFSSFFFFFFFFFFF.FFSFSFFFFFFFF.FFFFFFFFFF 1952 / 1989 ( 98%)
    FF.FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF                         1989 / 1989 (100%)
    
    Time: 8.07 seconds, Memory: 26.00MB
    
    There were 156 failures:
    
    1) /usr/local/src/phpunit/tests/end-to-end/abstract-test-class.phpt
    Failed asserting that string matches format description.
    --- Expected
    +++ Actual
    @@ @@
    -PHPUnit %s by Sebastian Bergmann and contributors.
    -
    -W                                                                   1 / 1 (100%)
    -
    -Time: %s, Memory: %s
    -
    -There was 1 warning:
    -
    -1) Warning
    -Cannot instantiate class "AbstractTest".
    -
    -WARNINGS!
    -Tests: 1, Assertions: 0, Warnings: 1.
    +Fatal error: Uncaught Error: Undefined constant 'STDIN' in /usr/local/src/phpunit/vendor/sebastian/environment/src/Console.php:55
    +Stack trace:
    +#0 /usr/local/src/phpunit/src/TextUI/ResultPrinter.php(163): SebastianBergmann\Environment\Console->getNumberOfColumns()
    +#1 /usr/local/src/phpunit/src/TextUI/TestRunner.php(310): PHPUnit\TextUI\ResultPrinter->__construct(NULL, false, 'never', false, 80, false)
    +#2 /usr/local/src/phpunit/src/TextUI/Command.php(206): PHPUnit\TextUI\TestRunner->doRun(Object(PHPUnit\Framework\TestSuite), Array, true)
    +#3 /usr/local/src/phpunit/src/TextUI/Command.php(162): PHPUnit\TextUI\Command->run(Array, true)
    +#4 Standard input code(7): PHPUnit\TextUI\Command::main()
    +#5 {main}
    +  thrown in /usr/local/src/phpunit/vendor/sebastian/environment/src/Console.php on line 55
    
    /usr/local/src/phpunit/src/Framework/Constraint/Constraint.php:112
    /usr/local/src/phpunit/src/Framework/Constraint/Constraint.php:60
    /usr/local/src/phpunit/src/Framework/Assert.php:1855
    /usr/local/src/phpunit/src/Framework/Assert.php:1555
    /usr/local/src/phpunit/src/Runner/PhptTestCase.php:277
    /usr/local/src/phpunit/src/Runner/PhptTestCase.php:166
    /usr/local/src/phpunit/src/Framework/TestSuite.php:750
    /usr/local/src/phpunit/src/Framework/TestSuite.php:750
    /usr/local/src/phpunit/src/TextUI/TestRunner.php:622
    /usr/local/src/phpunit/src/TextUI/Command.php:206
    /usr/local/src/phpunit/src/TextUI/Command.php:162
    
    2) /usr/local/src/phpunit/tests/end-to-end/assertion.phpt
    Failed asserting that string matches format description.
    --- Expected
    +++ Actual
    @@ @@
    -PHPUnit %s by Sebastian Bergmann and contributors.
    -
    -F                                                                   1 / 1 (100%)
    -
    -Time: %s, Memory: %s
    -
    -There was 1 failure:
    -
    -1) AssertionExampleTest::testOne
    -assert(false) in %sAssertionExample.php:%d
    -
    -FAILURES!
    -Tests: 1, Assertions: 1, Failures: 1.
    +Fatal error: Uncaught Error: Undefined constant 'STDIN' in /usr/local/src/phpunit/vendor/sebastian/environment/src/Console.php:55
    +Stack trace:
    +#0 /usr/local/src/phpunit/src/TextUI/ResultPrinter.php(163): SebastianBergmann\Environment\Console->getNumberOfColumns()
    +#1 /usr/local/src/phpunit/src/TextUI/TestRunner.php(310): PHPUnit\TextUI\ResultPrinter->__construct(NULL, false, 'never', false, 80, false)
    +#2 /usr/local/src/phpunit/src/TextUI/Command.php(206): PHPUnit\TextUI\TestRunner->doRun(Object(PHPUnit\Framework\TestSuite), Array, true)
    +#3 /usr/local/src/phpunit/src/TextUI/Command.php(162): PHPUnit\TextUI\Command->run(Array, true)
    +#4 Standard input code(7): PHPUnit\TextUI\Command::main()
    +#5 {main}
    +  thrown in /usr/local/src/phpunit/vendor/sebastian/environment/src/Console.php on line 55
    
    /usr/local/src/phpunit/src/Framework/Constraint/Constraint.php:112
    /usr/local/src/phpunit/src/Framework/Constraint/Constraint.php:60
    /usr/local/src/phpunit/src/Framework/Assert.php:1855
    /usr/local/src/phpunit/src/Framework/Assert.php:1555
    /usr/local/src/phpunit/src/Runner/PhptTestCase.php:277
    /usr/local/src/phpunit/src/Runner/PhptTestCase.php:166
    /usr/local/src/phpunit/src/Framework/TestSuite.php:750
    /usr/local/src/phpunit/src/Framework/TestSuite.php:750
    /usr/local/src/phpunit/src/TextUI/TestRunner.php:622
    /usr/local/src/phpunit/src/TextUI/Command.php:206
    /usr/local/src/phpunit/src/TextUI/Command.php:162
    
    .
    .
    .
    
    156) /usr/local/src/phpunit/tests/end-to-end/testdox.phpt
    Failed asserting that string matches format description.
    --- Expected
    +++ Actual
    @@ @@
    -PHPUnit %s by Sebastian Bergmann and contributors.
    -
    -BankAccount
    - ✔ Balance is initially zero
    - ✔ Balance cannot become negative
    - ✔ Balance cannot become negative
    -
    -Time: %s, Memory: %s
    -
    -OK (3 tests, 3 assertions)
    +Fatal error: Uncaught Error: Undefined constant 'STDIN' in /usr/local/src/phpunit/vendor/sebastian/environment/src/Console.php:55
    +Stack trace:
    +#0 /usr/local/src/phpunit/src/TextUI/ResultPrinter.php(163): SebastianBergmann\Environment\Console->getNumberOfColumns()
    +#1 /usr/local/src/phpunit/src/Util/TestDox/CliTestDoxPrinter.php(51): PHPUnit\TextUI\ResultPrinter->__construct(NULL, false, 'never', false, 80, false)
    +#2 /usr/local/src/phpunit/src/TextUI/TestRunner.php(310): PHPUnit\Util\TestDox\CliTestDoxPrinter->__construct(NULL, false, 'never', false, 80, false)
    +#3 /usr/local/src/phpunit/src/TextUI/Command.php(206): PHPUnit\TextUI\TestRunner->doRun(Object(PHPUnit\Framework\TestSuite), Array, true)
    +#4 /usr/local/src/phpunit/src/TextUI/Command.php(162): PHPUnit\TextUI\Command->run(Array, true)
    +#5 Standard input code(8): PHPUnit\TextUI\Command::main()
    +#6 {main}
    +  thrown in /usr/local/src/phpunit/vendor/sebastian/environment/src/Console.php on line 55
    
    /usr/local/src/phpunit/src/Framework/Constraint/Constraint.php:112
    /usr/local/src/phpunit/src/Framework/Constraint/Constraint.php:60
    /usr/local/src/phpunit/src/Framework/Assert.php:1855
    /usr/local/src/phpunit/src/Framework/Assert.php:1555
    /usr/local/src/phpunit/src/Runner/PhptTestCase.php:277
    /usr/local/src/phpunit/src/Runner/PhptTestCase.php:166
    /usr/local/src/phpunit/src/Framework/TestSuite.php:750
    /usr/local/src/phpunit/src/Framework/TestSuite.php:750
    /usr/local/src/phpunit/src/TextUI/TestRunner.php:622
    /usr/local/src/phpunit/src/TextUI/Command.php:206
    /usr/local/src/phpunit/src/TextUI/Command.php:162
    
    --
    
    There were 4 skipped tests:
    
    1) /usr/local/src/phpunit/tests/end-to-end/regression/GitHub/2085-enforce-time-limit-options-via-config-without-invoker.phpt
    package phpunit/php-invoker is installed
    
    /usr/local/src/phpunit/src/Runner/PhptTestCase.php:305
    /usr/local/src/phpunit/src/Runner/PhptTestCase.php:134
    /usr/local/src/phpunit/src/Framework/TestSuite.php:750
    /usr/local/src/phpunit/src/Framework/TestSuite.php:750
    /usr/local/src/phpunit/src/TextUI/TestRunner.php:622
    /usr/local/src/phpunit/src/TextUI/Command.php:206
    /usr/local/src/phpunit/src/TextUI/Command.php:162
    
    2) /usr/local/src/phpunit/tests/end-to-end/regression/GitHub/2085-without-invoker.phpt
    package phpunit/php-invoker is installed
    
    /usr/local/src/phpunit/src/Runner/PhptTestCase.php:305
    /usr/local/src/phpunit/src/Runner/PhptTestCase.php:134
    /usr/local/src/phpunit/src/Framework/TestSuite.php:750
    /usr/local/src/phpunit/src/Framework/TestSuite.php:750
    /usr/local/src/phpunit/src/TextUI/TestRunner.php:622
    /usr/local/src/phpunit/src/TextUI/Command.php:206
    /usr/local/src/phpunit/src/TextUI/Command.php:162
    
    3) /usr/local/src/phpunit/tests/end-to-end/regression/GitHub/2591-separate-function-no-preserve-no-bootstrap-php73.phpt
    xdebug loaded
    
    /usr/local/src/phpunit/src/Runner/PhptTestCase.php:305
    /usr/local/src/phpunit/src/Runner/PhptTestCase.php:134
    /usr/local/src/phpunit/src/Framework/TestSuite.php:750
    /usr/local/src/phpunit/src/Framework/TestSuite.php:750
    /usr/local/src/phpunit/src/TextUI/TestRunner.php:622
    /usr/local/src/phpunit/src/TextUI/Command.php:206
    /usr/local/src/phpunit/src/TextUI/Command.php:162
    
    4) /usr/local/src/phpunit/tests/end-to-end/regression/GitHub/2591-separate-function-no-preserve-no-bootstrap.phpt
    xdebug loaded
    
    /usr/local/src/phpunit/src/Runner/PhptTestCase.php:305
    /usr/local/src/phpunit/src/Runner/PhptTestCase.php:134
    /usr/local/src/phpunit/src/Framework/TestSuite.php:750
    /usr/local/src/phpunit/src/Framework/TestSuite.php:750
    /usr/local/src/phpunit/src/TextUI/TestRunner.php:622
    /usr/local/src/phpunit/src/TextUI/Command.php:206
    /usr/local/src/phpunit/src/TextUI/Command.php:162
    
    FAILURES!
    Tests: 1989, Assertions: 3454, Failures: 156, Skipped: 4.
    
    bug 
    opened by sebastianbergmann 7
  • Fix exception when DBG extension is loaded

    Fix exception when DBG extension is loaded

    The DBG extension injects its own code coverage driver for use with the PhpEd IDE. http://www.nusphere.com/products/php_debugger.htm This causes Runtime::getNameWithVersionAndCodeCoverageDriver to throw an exception because it returns null, rather than a string.

    I appreciate that this is entirely the fault of DBG but it has been hooking into PHPUnit for a very long time and the debugger itself has been around for years: http://www.php-debugger.com/dbg/

    I have reported this issue to Nusphere so guess they will fix it. However this PR makes the code here less "brittle".

    opened by johnstevenson 5
  • Windows improvements to console capabilities

    Windows improvements to console capabilities

    This reorganizes things so that Windows users can take advantage of new functions introduced in php7.2

    It will also fix a failing test on Windows here: https://github.com/sebastianbergmann/phpunit/pull/3941

    FYI: I was responsible for the color support stuff in Symfony\Console\Output\StreamOutput and Composer\XdebugHandler (https://github.com/composer/xdebug-handler/blob/cbe23383749496fe0f373345208b79568e4bc248/src/Process.php#L121)

    opened by johnstevenson 5
  • Warning are thrown for 'stty size'

    Warning are thrown for 'stty size'

    PHP Warning in Environment that forbidden stty command:

    demo-5b72bc:~$ php vendor/phpunit/phpunit/phpunit tests/Unit/ExampleTest.php
    PHP Warning:  shell_exec(): Unable to execute 'stty size' in /var/www/demo/vendor/sebastian/environment/src/Console.php on line 93
    PHP Fatal error:  Uncaught TypeError: preg_match() expects parameter 2 to be string, boolean given in /var/www/demo/vendor/sebastian/environment/src/Console.php:93
    Stack trace:
    #0 /var/www/demo/vendor/sebastian/environment/src/Console.php(93): preg_match('#\\d+ (\\d+)#', false, NULL)
    #1 /var/www/demo/vendor/sebastian/environment/src/Console.php(70): SebastianBergmann\Environment\Console->getNumberOfColumnsInteractive()
    #2 /var/www/demo/vendor/phpunit/phpunit/src/TextUI/ResultPrinter.php(173): SebastianBergmann\Environment\Console->getNumberOfColumns()
    #3 /var/www/demo/vendor/phpunit/phpunit/src/TextUI/TestRunner.php(287): PHPUnit\TextUI\ResultPrinter->__construct(NULL, false, 'auto', false, 80, false)
    #4 /var/www/demo/vendor/phpunit/phpunit/src/TextUI/Command.php(195): PHPUnit\TextUI\TestRunner->doRun(Object(PHPUnit\Framework\TestSuite), Array, true)
    #5 /var/www/demo/vendor/phpunit/phpunit/src/TextUI/Command.php(148): PHPUnit\TextUI\Command->ru in /var/www/demo/vendor/sebastian/environment/src/Console.php on line 93
    

    It is somewhat similar to #16

    stale 
    opened by yassine-ah 5
  • Console - always pass resource to detect is it interactive or not

    Console - always pass resource to detect is it interactive or not

    as we can see in https://github.com/sebastianbergmann/environment/pull/25 , passing a resource instead of file description ID of it give use more possibility to detect is it interactive or not.

    for next BC release, I would suggest to drop int from possible input types

    opened by keradus 4
  • Windows terminal width is not always 80 chars

    Windows terminal width is not always 80 chars

    The cmd shell is indeed 80 chars by default. But this does not mean it is always the case:

    • you can change the size of cmd (not user-friendly as it is not about resizing the window, but possible)
    • there is many better terminals for windows, which support arbitrary width.

    See https://github.com/symfony/symfony/blob/2.8/src/Symfony/Component/Console/Application.php#L779-L788 for a logic determining it when possible (using 79 as fallback is still a sensible default though)

    stale 
    opened by stof 4
  • Fix php ini parsing from the CLI

    Fix php ini parsing from the CLI

    This is a (possible) fix for the PHPUnit issue https://github.com/sebastianbergmann/phpunit/issues/4664

    I've added the suggestion by @krakjoe (link) and some tests to cover this part of the code.

    I've run the tests on the PHPUnit locally on the latest branch to check if anything broke, and the existing tests passed. I guess this should be tested a bit thoroughly.

    When I ran the tests on the PHPUnit repo and put the breakpoint to inspect the result of merging the settings with getCurrentSettings method in the AbstractPhpProcess.php file inside the getCommand method I could see my xdebug settings correctly parsed, so I think there should be no breaks.

    I had to add the updated code manually inside the vendor file to test this because I got a composer error when trying to use my branch instead of the v6 for the php-code-coverage package.

     Problem 1
        - phpunit/php-code-coverage dev-master requires sebastian/environment ^6.0 -> found sebastian/environment[dev-master, 6.0.x-dev (alias of dev-master)] but it conflicts with your root composer.json require (dev-fix-php-ini-parsing).
        - phpunit/php-code-coverage 10.0.x-dev is an alias of phpunit/php-code-coverage dev-master and thus requires it to be installed too.
        - Root composer.json requires phpunit/php-code-coverage ^10.0 -> satisfiable by phpunit/php-code-coverage[10.0.x-dev (alias of dev-master)].
    

    This is the image of the breakpoint and part of the $settings array:

    image

    I'd love to have somebody test it a bit more just to be sure.

    Oh and I'd love to add a co-authored commit for @krakjoe but I'm not sure what the no-reply email is 🙈 I can update the commit message to add it once I find out the correct email 🙂

    opened by dingo-d 3
  • Test against HHVM

    Test against HHVM

    On travis, currently requires docker - example: https://github.com/facebook/xhp-lib/blob/master/.travis.yml https://github.com/facebook/xhp-lib/blob/master/.travis.sh

    Should support 3.20.2+

    I understand why you've generally stopped testing most of your projects against HHVM, however given the purpose of this project, it seems likely to be worth an exception.

    stale 
    opened by fredemmott 3
  • Overridden ini values are ignored when php.ini uses section headers

    Overridden ini values are ignored when php.ini uses section headers

    As of right now, Runtime::getCurrentSettings() parses php.ini files respecting section headers using the optional $process_sections parameter of parse_ini_file(), however, these section headers are then later ignored when comparing the ini file's values to the value retrieved by ini_get(). This erroneously causes some ini values that have been overridden via the command line to be ignored and don't get passed through if they either don't exist in the ini file or are under a section header:

    ; php.ini
    [xdebug]
    xdebug.mode=debug
    

    $config = parse_ini_file($ini, true) results in

    array(1) {
      'xdebug' =>
      array(1) {
        'xdebug.mode' =>
        string(5) "debug"
      }
    }
    

    $config = parse_ini_file($ini) results in

    array(1) {
      'xdebug.mode' =>
      string(5) "debug"
    }
    

    Additionally, I believe if (isset($config[$value]) && $set != $config[$value]) should be changed to if (!isset($config[$value]) || $set != $config[$value]) as otherwise, values not set in php.ini but set through the command line would also not be passed through.

    opened by Emosewaj 2
  • Getting

    Getting "opcache.save_comments=0 set; annotations will not work"

    I get "Warning: opcache.save_comments=0 set; annotations will not work" when running phpunit with phpdbg.

    I have opcache.enabled=1, opcache.enabled_cli=0 and opcache.save_comments=0.

    Please change the \PHP_SAPI === 'cli' checks to also include \PHP_SAPI === 'phpdbg'.

    Thank you

    bug 
    opened by hcomnetworkers 2
  • Ini setting with special chars breaks parsing

    Ini setting with special chars breaks parsing

    When an ini setting is quoted, for example xdebug.file_link_format = "phpstorm://open?file=%f&line=%l", ini_get will return a simple string without the protection quotes and Runtime::getCurrentSettings will return an invalid unqoted stringxdebug.file_link_format=phpstorm://open?file=%f&line=%l" which will break any test.

    PHPUnit\Framework\Exception: PHP:  syntax error, unexpected '=' in Unknown on line 20
    

    We could ensure string settings are wrapped in quotes.

    bug 
    opened by Aerzas 1
  • Want to contribute, need pointer on mocking in tests

    Want to contribute, need pointer on mocking in tests

    Hello.

    I want to submit a PR, but am not certain how to structure the tests as they with 99% certainty require some level of mocking (php.ini reading) I think.

    Are you OK with a more elaborate test setup to allow mocking things or are you comfortable with allowing soft failures in case some INI settings are not adjustable for some test cases? I know this is a relatively small library and adding boilerplate for mocking might seem overkill.

    The thing I would like to tackle with my PR is the possibility to have Xdebug enabled, but code coverage disabled, leading to runtime errors when one could instead try PCOV for coverage in that case.

    opened by rask 0
Owner
Sebastian Bergmann
Sebastian Bergmann is the creator of PHPUnit. He co-founded thePHP.cc and helps PHP teams build better software.
Sebastian Bergmann
Deptrac is a static code analysis tool for PHP that helps you communicate, visualize and enforce architectural decisions in your projects

Deptrac is a static code analysis tool for PHP that helps you communicate, visualize and enforce architectural decisions in your projects. You can freely define your architectural layers over classes and which rules should apply to them.

QOSSMIC GmbH 2.2k Dec 30, 2022
The Stopwatch component provides a way to profile code.

Stopwatch Component The Stopwatch component provides a way to profile code.

Symfony 2.6k Dec 28, 2022
A full-scale PHP sandbox class that utilizes PHP-Parser to prevent sandboxed code from running unsafe code

A full-scale PHP 7.4+ sandbox class that utilizes PHP-Parser to prevent sandboxed code from running unsafe code. It also utilizes FunctionParser to di

Corveda 192 Dec 10, 2022
A full-scale PHP 5.3.2+ sandbox class that utilizes PHPParser to prevent sandboxed code from running unsafe code.

##DEPRECATED: The PHPSandbox project has transfered to Corveda/PHPSandbox and will be actively maintained there. This branch is no longer being active

Elijah Horton 219 Sep 2, 2022
Library for counting the lines of code in PHP source code

sebastian/lines-of-code Library for counting the lines of code in PHP source code. Installation You can add this library as a local, per-project depen

Sebastian Bergmann 715 Jan 5, 2023
PHPCheckstyle is an open-source tool that helps PHP programmers adhere to certain coding conventions.

PHPCheckstyle Overview PHPCheckstyle is an open-source tool that helps PHP programmers adhere to certain coding conventions. The tools checks the inpu

PHPCheckstyle 157 Dec 5, 2022
Slevomat Coding Standard for PHP_CodeSniffer provides many useful sniffs

Slevomat Coding Standard Slevomat Coding Standard for PHP_CodeSniffer provides sniffs that fall into three categories: Functional - improving the safe

Slevomat 1.2k Jan 5, 2023
Search PHP source code for function & method calls, variables, and more from PHP.

Searching PHP source code made easy Search PHP source code for function & method calls, variable assignments, classes and more directly from PHP. Inst

Permafrost Software 22 Nov 24, 2022
PHP Static Analysis Tool - discover bugs in your code without running it!

PHPStan - PHP Static Analysis Tool PHPStan focuses on finding errors in your code without actually running it. It catches whole classes of bugs even b

PHPStan 11.6k Dec 30, 2022
A PHP code-quality tool

GrumPHP Sick and tired of defending code quality over and over again? GrumPHP will do it for you! This composer plugin will register some git hooks in

PHPro 3.9k Jan 1, 2023
Copy/Paste Detector (CPD) for PHP code.

PHP Copy/Paste Detector (PHPCPD) phpcpd is a Copy/Paste Detector (CPD) for PHP code. Installation This tool is distributed as a PHP Archive (PHAR): $

Sebastian Bergmann 2.2k Jan 1, 2023
Analyze PHP code with one command

PHPQA Analyze PHP code with one command. Requirements PHP >= 5.4.0 xsl extension for HTML reports Why? Every analyzer has different arguments and opti

edgedesign/phpqa 542 Dec 24, 2022
Performs advanced static analysis on PHP code

PHP Analyzer Please report bugs or feature requests via our website support system ? in bottom right or by emailing [email protected]. Contri

Continuous Inspection 443 Sep 23, 2022
A static php code analysis tool using the Graph Theory

Mondrian Ok guyz, you have a master degree in Graph Theory, you follow Law of Demeter and you live on S.O.L.I.D principles ? Let's have some Fun ! (^ω

Florent Genette 391 Nov 30, 2022
Instant Upgrades and Instant Refactoring of any PHP 5.3+ code

Rector - Speedup Your PHP Development Rector helps you with 2 areas - major code changes and in daily work. Do you have a legacy code base? Do you wan

RectorPHP 6.5k Jan 8, 2023
phpcs-security-audit is a set of PHP_CodeSniffer rules that finds vulnerabilities and weaknesses related to security in PHP code

phpcs-security-audit v3 About phpcs-security-audit is a set of PHP_CodeSniffer rules that finds vulnerabilities and weaknesses related to security in

Floe design + technologies 655 Jan 3, 2023
A tool to automatically fix PHP Coding Standards issues by Dragon Code.

A tool to automatically fix PHP Coding Standards issues by Dragon Code.

The Dragon Code 24 Aug 27, 2022
PHP code scanner to use with gettext/gettext

PHP code scanner to use with gettext/gettext

Gettext 12 Nov 11, 2022
Code Climate CLI

Code Climate CLI Overview codeclimate is a command line interface for the Code Climate analysis platform. It allows you to run Code Climate engines on

Code Climate 2.4k Dec 26, 2022