Code Monkey home page Code Monkey logo

phploc's Introduction

PHPLOC

phploc is a tool for quickly measuring the size of a PHP project.

Installation

This tool is distributed as a PHP Archive (PHAR):

$ wget https://phar.phpunit.de/phploc.phar

$ php phploc.phar --version

Using Phive is the recommended way for managing the tool dependencies of your project:

$ phive install phploc

$ ./tools/phploc --version

It is not recommended to use Composer to download and install this tool.

Usage Example

$ php phploc.phar src
phploc 8.0-dev by Sebastian Bergmann.

Directories:                                        104
Files:                                              856

Lines of Code (LOC):                             67,955
Comment Lines of Code (CLOC):                    19,533 (28.74%)
Non-Comment Lines of Code (NCLOC):               48,422 (71.26%)
Logical Lines of Code (LLOC):                    18,478 (27.19%)

Classes or Traits                                   662
  Methods                                         3,389
    Cyclomatic Complexity
      Lowest                                       1.00
      Average                                      2.00
      Highest                                    156.00

Functions                                           185
  Cyclomatic Complexity
    Lowest                                         1.00
    Average                                        1.00
    Highest                                        1.00

phploc's People

Contributors

christeredvartsen avatar dennisdegreef avatar derrabus avatar edorian avatar grahamcampbell avatar henriquemoody avatar hver avatar ihabunek avatar ircmaxell avatar jakzal avatar jochenvdv avatar krzysiekpiasecki avatar kubawerlos avatar kukulich avatar matthiasnoback avatar michaelbrooks avatar philipphoffmann avatar ramonornela avatar ravage84 avatar reenexe avatar reinholdfuereder avatar remicollet avatar ronvanderheijden avatar scribam avatar sebastianbergmann avatar sgoettschkes avatar stelian avatar thomaslandauer avatar tommygnr avatar villfa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

phploc's Issues

pear install failed (Ubuntu 12.04)

pear config-set auto_discover 1
config-set succeeded

pear install pear.phpunit.de/phploc
Attempting to discover channel "pear.phpunit.de"...
downloading channel.xml ...
Starting to download channel.xml (804 bytes)
....done: 804 bytes
Auto-discovered channel "pear.phpunit.de", alias "pear.phpunit.de", adding to registry
unknown channel "pear.phpunit.de" in "pear.phpunit.de/phploc"
invalid package name/package file "pear.phpunit.de/phploc"
install failed

Add support for counting PHPUnit tests

In addition to just counting the various LOC metrics and the number of classes, methods, and functions, the number of unit tests for a project is also an interesting metric.

Undefined offset in src/Analyser.php on line 414

While running phploc the following error occurs.
See also: https://scrutinizer-ci.com/g/Mayflower/PHP_CodeBrowser/inspections/e92d48c0-6dca-42f9-9a3d-1a5d596ac876/log

phploc --progress --log-xml '/tmp/phploc-outputcmW6fM' --names '*.php' --exclude 'vendor/'
phploc 2.0.4 by Sebastian Bergmann.

PHP Notice:  Undefined offset: 11 in phar:///usr/bin/phploc/src/Analyser.php on line 414
PHP Stack trace:
PHP   1. {main}() /usr/bin/phploc:0
PHP   2. Symfony\Component\Console\Application->run() /usr/bin/phploc:129
PHP   3. SebastianBergmann\PHPLOC\CLI\Application->doRun() phar:///usr/bin/phploc/symfony/console/Symfony/Component/Console/Application.php:121
PHP   4. Symfony\Component\Console\Application->doRun() phar:///usr/bin/phploc/src/CLI/Application.php:135
PHP   5. Symfony\Component\Console\Application->doRunCommand() phar:///usr/bin/phploc/symfony/console/Symfony/Component/Console/Application.php:191
PHP   6. Symfony\Component\Console\Command\Command->run() phar:///usr/bin/phploc/symfony/console/Symfony/Component/Console/Application.php:881
PHP   7. SebastianBergmann\PHPLOC\CLI\Command->execute() phar:///usr/bin/phploc/symfony/console/Symfony/Component/Console/Command/Command.php:241
PHP   8. SebastianBergmann\PHPLOC\CLI\Command->executeSingle() phar:///usr/bin/phploc/src/CLI/Command.php:145
PHP   9. SebastianBergmann\PHPLOC\CLI\Command->count() phar:///usr/bin/phploc/src/CLI/Command.php:165
PHP  10. SebastianBergmann\PHPLOC\Analyser->countFiles() phar:///usr/bin/phploc/src/CLI/Command.php:262
PHP  11. SebastianBergmann\PHPLOC\Analyser->countFile() phar:///usr/bin/phploc/src/Analyser.php:175
PHP Notice:  Undefined offset: 11 in phar:///usr/bin/phploc/src/Analyser.php on line 419
PHP Stack trace:
PHP   1. {main}() /usr/bin/phploc:0
PHP   2. Symfony\Component\Console\Application->run() /usr/bin/phploc:129
PHP   3. SebastianBergmann\PHPLOC\CLI\Application->doRun() phar:///usr/bin/phploc/symfony/console/Symfony/Component/Console/Application.php:121
PHP   4. Symfony\Component\Console\Application->doRun() phar:///usr/bin/phploc/src/CLI/Application.php:135
PHP   5. Symfony\Component\Console\Application->doRunCommand() phar:///usr/bin/phploc/symfony/console/Symfony/Component/Console/Application.php:191
PHP   6. Symfony\Component\Console\Command\Command->run() phar:///usr/bin/phploc/symfony/console/Symfony/Component/Console/Application.php:881
PHP   7. SebastianBergmann\PHPLOC\CLI\Command->execute() phar:///usr/bin/phploc/symfony/console/Symfony/Component/Console/Command/Command.php:241
PHP   8. SebastianBergmann\PHPLOC\CLI\Command->executeSingle() phar:///usr/bin/phploc/src/CLI/Command.php:145
PHP   9. SebastianBergmann\PHPLOC\CLI\Command->count() phar:///usr/bin/phploc/src/CLI/Command.php:165
PHP  10. SebastianBergmann\PHPLOC\Analyser->countFiles() phar:///usr/bin/phploc/src/CLI/Command.php:262
PHP  11. SebastianBergmann\PHPLOC\Analyser->countFile() phar:///usr/bin/phploc/src/Analyser.php:175

CLOC are counted twice

Running PHPLoc 2.0.0 on the following code:

<?php
function fn()
{
    // CLOC
}

will give

Lines of Code (LOC)                                4
Comment Lines of Code (CLOC)                       2 (50.00%)
Non-Comment Lines of Code (NCLOC)                  2 (50.00%)

when it should be

Lines of Code (LOC)                                4
Comment Lines of Code (CLOC)                       1 (25.00%)
Non-Comment Lines of Code (NCLOC)                  3 (75.00%)

Removing the comment (but keeping the line) will give

Lines of Code (LOC)                                4
Comment Lines of Code (CLOC)                       0 (0.00%)
Non-Comment Lines of Code (NCLOC)                  4 (100.00%)

Adding a CLOC for a total of 2 CLOCs will give

Lines of Code (LOC)                                5
Comment Lines of Code (CLOC)                       4 (80.00%)
Non-Comment Lines of Code (NCLOC)                  1 (20.00%)

Since you calculate NCLOC by substracing CLOC from LOC you get funny results for 4 CLOC

Lines of Code (LOC)                                7
Comment Lines of Code (CLOC)                       8 (114.29%)
Non-Comment Lines of Code (NCLOC)                 -1 (-14.29%)

Tried with PHP 5.5.0 on Windows 7

phploc generates notice when bytekit extension is not present

Analyzer.php generates a notice "Notice: Undefined index: eloc in /home/steve/projects/phploc/PHPLOC/Analyser.php on line 132" when no bytekit extension is used (you unset the value line 120 of that file in that case).

Suggested fix:

git diff Analyser.php
diff --git a/PHPLOC/Analyser.php b/PHPLOC/Analyser.php
index f0b326a..78007cc 100644
--- a/PHPLOC/Analyser.php
+++ b/PHPLOC/Analyser.php
@@ -129,7 +129,7 @@ class PHPLOC_Analyser
$count['constants'] = $count['classConstants'] +
$count['globalConstants'];

  •    if ($count['eloc'] > 0) {
    
  •    if (isset($count['eloc']) && $count['eloc'] > 0) {
         $count['ccnByLoc'] = $count['ccn'] / $count['eloc'];
     }
    

phploc lin 48 not finding autoload

The test in phploc.php found @php_bin@, which was set, but the PEAR share path was not in the include_path, resulting in the following error:

Fatal error: require(): Failed opening required 'SebastianBergmann/PHPLOC/autoload.php' (include_path='.:') in /usr/local/pear/bin/phploc on line 48

Yeah, it technically means an invalid PEAR install, but this can happen when PEAR is installed before PHP. (Due to, say, OS X upgrades, which have an annoying tendency to re-write php.ini.)

/// From phploc.php

if (strpos('@php_bin@', '@php_bin') === 0) {
    require __DIR__ . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'autoload.php';
} else {
    require 'SebastianBergmann/PHPLOC/autoload.php';
}

If @php_bin@ is defined, can't either a) include_path be redefined to include it (for good measure), or b) it simply be concat-ed in the else branch so as not to rely on the include_path?

Add commit number in exported CSV

Hello,

I would love to have the commit number in the exported csv for the --git-repository switch. I have a pretty clear use case for it, in terms of graphing the data over time and adding references to commits.

If this would be something you consider nice to have, I could submit a PR for it.

Thanks,
Stelian

Error when attempting to run on a windows box...

C:\php5\PEAR>phploc "C:\Source\WebApps1\web"

Warning: require(SebastianBergmann/PHPLOC/autoload.php): failed to open stream: No such file or directory in C:\php5\PEAR\phploc on line 48

Call Stack:
0.0003 326744 1. {main}() C:\php5\PEAR\phploc:0

Fatal error: require(): Failed opening required 'SebastianBergmann/PHPLOC/autoload.php' include_path='C:\PHP5\pear;C:\Source\WebApps1\web\W1;C:\Source\WebApps1\web\hps\php-inc') in C:\php5\PEAR\phploc on line 48

Call Stack:
0.0003 326744 1. {main}() C:\php5\PEAR\phploc:0

C:\php5\PEAR>_

Any ideas on how to correct this? Thanks.

Uninitialized string offset: 1 in PHPLOC/Analyser.php on line 602

When I run phploc against the vendor/ folder of symfony2 ( in wich I do have bundle that are not part of the standard edition ), I get about 10 PHP notice:

Uninitialized string offset: 1 in PHPLOC/Analyser.php on line 602

I've edited the PHPLOC/Analyser.php file to help debug the issue:

protected function getClassName($namespace, array $tokens, $i)
{
    $i         += 2;
    $namespaced = FALSE;
    if(!isset($tokens[$i][1])){
            var_dump($namespace, $i, $tokens[$i]);
    }
    $className  = $tokens[$i][1];

And the output is:
bool(false)
int(51)
string(1) "{"

I've also done a debug_print_backtrace:
#0 PHPLOC_Analyser->getClassName()
#1 PHPLOC_Analyser->countFile() called at [/usr/local/Cellar/php/5.3.8/lib/php/PHPLOC/Analyser.php:170]
#2 PHPLOC_Analyser->countFiles() called at [/usr/local/Cellar/php/5.3.8/lib/php/PHPLOC/TextUI/Command.php:220]
#3 PHPLOC_TextUI_Command::main() called at [/usr/local/Cellar/php/5.3.8/bin/phploc:51]

phploc script uses wrong autoloader?

I could be wrong, but I'm seeing the phploc file loading the PHPCPD autoloader instead of the PHPLOC autoloader here. Is that supposed to be that way?

Resulting in this error when I run phploc:
PHP Fatal error: Class 'SebastianBergmann\PHPLOC\TextUI\Command' not found in phploc on line 52

PHPLOC

Hi Sebastian,

It was a pleasure to have the opportunity to chat with yourself in IRC yesterday.
As requested, here's the issue.

We have a custom ruleset.xml for PHPCS where we eliminate from the PEAR standard the requirement for the file PHPDocumentor DocBlock.

The following warning fires by PHPLOC at build time:

"WARNING in foo.php on line 15: DocBlock would be page-level, but precedes class "Foo", use another DocBlock to document the file"

Its only a warning and i can't confirm (today) that this would be the reason why the plots in Jenkins show only the LOC in the 1st graph. Will get back to you on this.

I would be cool if we could/can do something about configuring the requirement for it

Thank you
Andre R. Ferreira

Fatal Error TextUI\Command

PHP Fatal error:  Class 'SebastianBergmann\PHPLOC\TextUI\Command' not found in .../vendor/phploc/phploc/composer/bin/phploc on line 70
PHP Stack trace:
PHP   1. {main}() .../vendor/phploc/phploc/composer/bin/phploc:0

I'm getting this error using the dev-symfony-console from composer.

filter LOC count

Hi there,

Thanks for providing such a great tool :). I have a suggestion to make the lines of code (LOC) count and the Cyclomatic Complexity / LOC measures more comparable between projects. I suggest filtering out empty lines and lines containing only { or }. The code formatting currently confounds these measures quite a lot. These snippets should give the same Complexity / LOC measure.

if ($condition) {
   echo "Hello";
   echo "There";
}


if ($condition)
{
    // Boy, I like to comment everything
    echo "Hello";


    // even if it doesn't make sense
    echo "There";
}

Non-Static method is counted as static when declared after declaration of static attribute

➜  ~  cat /tmp/test.php 
<?php
class A
{
    private static $a = array();

    public function __construct()
    {
    }
}


➜  ~  phploc /tmp/test.php
phploc 2.0.3 by Sebastian Bergmann.

Size
  Lines of Code (LOC)                                9
  Comment Lines of Code (CLOC)                       0 (0.00%)
  Non-Comment Lines of Code (NCLOC)                  9 (100.00%)
  Logical Lines of Code (LLOC)                       1 (11.11%)
    Classes                                          1 (100.00%)
      Average Class Length                           1
      Average Method Length                          1
    Functions                                        0 (0.00%)
      Average Function Length                        0
    Not in classes or functions                      0 (0.00%)

Complexity
  Cyclomatic Complexity / LLOC                    0.00
  Cyclomatic Complexity / Number of Methods       1.00

Dependencies
  Global Accesses                                    0
    Global Constants                                 0 (0.00%)
    Global Variables                                 0 (0.00%)
    Super-Global Variables                           0 (0.00%)
  Attribute Accesses                                 0
    Non-Static                                       0 (0.00%)
    Static                                           0 (0.00%)
  Method Calls                                       0
    Non-Static                                       0 (0.00%)
    Static                                           0 (0.00%)

Structure
  Namespaces                                         0
  Interfaces                                         0
  Traits                                             0
  Classes                                            1
    Abstract Classes                                 0 (0.00%)
    Concrete Classes                                 1 (100.00%)
  Methods                                            1
    Scope
      Non-Static Methods                             0 (0.00%)
      Static Methods                                 1 (100.00%)
    Visibility
      Public Method                                  0 (0.00%)
      Non-Public Methods                             1 (100.00%)
  Functions                                          0
    Named Functions                                  0 (0.00%)
    Anonymous Functions                              0 (0.00%)
  Constants                                          0
    Global Constants                                 0 (0.00%)
    Class Constants                                  0 (0.00%)

composer.json - error can't install 2.0

Hi There

I'm getting an error with my composer.json when I use your example. Is 2.0.* available yet?

cheers

damien

The requested package phploc/phploc 2.0.* could not be found.

--exclude does not work

As far as I can tell, the --exclude flag doesn't work. If I run:

./phploc.phar --exclude /path/to/files/subdir /path/to/files

the files in subdir are still scanned and counted.

$ ./phploc.phar --version phploc 1.7.4 by Sebastian Bergmann.

Global install with Composer failed

I am running on a Windows 7 machine, that may be the issue? I do use composer all the time for other projects without an issue though.

I ran

composer global require 'phploc/phploc=*'

but unfortunately I got this nasty error message in the console...

[UnexpectedValueException]
  Could not parse version constraint *': Invalid version string "*'"

PHP Warning: require_once(Symfony/Component/Finder/autoloader.php): failed to open stream: No such file or directory in /usr/share/php/SebastianBergmann/FinderFacade/autoload.php on line 44

an normal install following http://jenkins-php.org/ instruction

me@mysever:~$ pear install -a -f pear.phpunit.de/phploc
phpunit/phploc can optionally use PHP extension "bytekit"
downloading phploc-1.7.4.tgz ...
Starting to download phploc-1.7.4.tgz (10,134 bytes)
.....done: 10,134 bytes
install ok: channel://pear.phpunit.de/phploc-1.7.4
me@mysever:~$ phploc
PHP Warning:  require_once(Symfony/Component/Finder/autoloader.php): failed to open stream: No such file or directory in /usr/share/php/SebastianBergmann/FinderFacade/autoload.php on line 44
PHP Fatal error:  require_once(): Failed opening required 'Symfony/Component/Finder/autoloader.php' (include_path='.:/usr/share/php:/usr/share/pear') in /usr/share/php/SebastianBergmann/FinderFacade/autoload.php on line 44
me@mysever:~$ pear remote-list -c phpunit
Channel phpunit Available packages:
===================================
Package                           Version
DbUnit                            1.2.3
File_Iterator                     1.3.3
FinderFacade                      1.1.0
Git                               1.0.0
Object_Freezer                    1.0.0
PHPUnit                           3.7.21
PHPUnit_MockObject                1.2.3
PHPUnit_Selenium                  1.3.1
PHPUnit_SkeletonGenerator         1.2.1
PHPUnit_Story                     1.0.2
PHPUnit_TestListener_DBUS         1.0.0
PHPUnit_TestListener_XHProf       1.0.0
PHPUnit_TicketListener_Fogbugz    1.0.0
PHPUnit_TicketListener_GitHub     1.0.0
PHPUnit_TicketListener_GoogleCode 1.0.0
PHPUnit_TicketListener_Trac       1.0.0
PHP_CodeBrowser                   1.0.2
PHP_CodeCoverage                  1.2.11
PHP_Invoker                       1.1.2
PHP_Timer                         1.0.4
PHP_TokenStream                   1.1.5
Text_Template                     1.1.4
Version                           1.0.1
bytekit                           1.1.3
hphpa                             1.3.0
phpcov                            1.1.0
phpcpd                            1.4.1
phpdcd                            0.9.3
phploc                            1.7.4
ppw                               1.0.4
test_helpers                      1.1.0

Ignoring .svn directories

Hello,

I just see that PHPLoc haven't ignore my .svn directories and all my previous locs are wrong :(

I also see there is an 'exclude' option but it works only with path, not with basename. So, I think a 'excludeName' (or s.o. like that) could be a good option for people still using SVN ;-)

Regards,
Erwan

Overriding bin-dir in composer.json

Hi!

I was wondering why you override the default setting for bin-dir in composer.json? It is common to use the default setting of vendor/bin. Changing it to just bin makes phploc behave inconsistent with most other tools.

Regards,
Ivan

.DS_Store files disturbs phploc

Macs generates .DS_Store files and this makes phploc results wrongs if this file is present in the directory you target.

So, if I have a .DS_Store in Symfony2 src/ directory and if I run phploc src/, it reports 246 interfaces, whereas the right number is 123. If I remove the .DS_Store file, everything works as expected.

Integrate as a library?

I'd like to leverage PHPLOC in my project without having to call out to the cli with exec() and requiring the csv/xml output is written to disk.

Is there a way this tool can be called directly?

Composer installation

It seems that the composer installation does not work. It would be preferrable to simply set the dependency:

    "require-dev": {
        "phpunit/phpunit": "3.7.9",
        "phake/phake": "v1.0.3",
        "phploc/phploc": "1.7.4"

    },

However this always fails with the following message when running vendor/bin/phploc:

    - phploc/phploc 1.7.4 requires symfony/finder 2.1.x-dev -> no matching package found.

I add those transitive dependencies manually:

    "require-dev": {
        "phpunit/phpunit": "3.7.9",
        "phake/phake": "v1.0.3",
        "phploc/phploc": "1.7.4",
        "symfony/finder":"2.1.3 as 2.1.x-dev",
        "zetacomponents/console-tools": "1.6 as dev-master"

    },

Now I get this:

$ vendor/bin/phploc                                                  [15:14:23]
PHP Fatal error:  Class 'PHPLOC_TextUI_Command' not found in /home/user/Projects/sample-project/vendor/phploc/phploc/composer/bin/phploc on line 70

Any ideas?

No output when calling phploc

Hi

I've installed phploc throug PEAR and the installation was successful. When I know call it in the Terminal (Mac OS X Lion) I don't get any output. It doesn't matter if I give a location for the file ort not.
The only thing what happens, is a new line in the Terminal.

Is there a solution for this problem?

Thanks

foreach and while are not counted as LLOC

When running PHPLoc 2.0.0 on the following code

function fn()
{
    foreach([1,2,3] as $i) {
        echo $i;
    }
}

I get the following metrics

Lines of Code (LOC)                                6
Non-Comment Lines of Code (NCLOC)                  6 (100.00%)
Logical Lines of Code (LLOC)                       1 (16.67%)
  Functions                                        1 (100.00%)
    Average Function Length                        1
  Not in classes or functions                      0 (0.00%)

I get the same when using while instead of foreach.

The problem seems to be in line https://github.com/sebastianbergmann/phploc/blob/master/src/Analyser.php#L306:

if ($token == ';') {
    if ($className !== NULL && !$testClass) {
        $this->count['llocClasses']++;
    }

    else if ($functionName !== NULL) {
        $this->count['llocFunctions']++;
    }

    $this->count['lloc']++;
}

So apparently you are only counting the statements when terminate with a semicolon. But since while and foreach are both executable statements, they should be counted, shouldn't they?

Is Average Method Length (LLOC) calculated correctly

I have a question about Average Method Length (LLOC).
In the File phploc/src/Analyser.php at 217-223:

if ($count['classes'] > 0) {
    $count['llocByNoc'] = $count['llocClasses'] / $count['classes'];
}

if ($count['methods'] > 0) {
    $count['llocByNom'] = $count['llocClasses'] / $count['methods'];
}

The number of average lines in method (llocByNom) is calculated by dividing number of lines in classes by number of methods.
More correct would be to use the
number of lines in methods devided by number of methods
, because in the classes you also have traits, variable, constants, etc. lines.

BETA leads to uninstallable phploc

After upgraded Pear to be able to install phpploc on Win8-64bits, it throws:
'''' CLI
phpunit/phploc can optionally use PHP extension "bytekit"
phpunit/FinderFacade requires package "symfony2/Finder" (version >= 2.1.0, versi
on <= 2.1.99), installed version is 2.2.0BETA1
phpunit/phploc requires package "phpunit/FinderFacade" (version >= 1.0.4)
No valid packages found
install failed

I guess a cursor should be moved to allow more recent package not to block install.
Let me know when it's fixed to continue install.
Thanks

--exclude does not work

Since upgrade to (File_Iterator 1.2.2 stable) the --exclude parameter does not work anymore. Its is completely ignored. (I dont know what was the previous version).

I use phploc 1.5.1

I tried:

phploc --exclude subdir .
phploc --exclude subdir/ .

where subdir is the dir which should be ignored. I also tried absolute paths to exclude. Nothing worked for me.

Dev requirements in "require" section of composer.json

Hi,

could you change the minimum stability of the requirements to a non-dev one in the require section? This is not working nicely with composer install.

"require": {
...
        "zetacomponents/console-tools": "dev-master",
...
}
´´´

halts very long on two notices

when I run phploc (with jenkins) it halts on two notices for over 10 minutes with a cpu load of 100%:

 [exec] PHP Notice:  Undefined offset: 23524 in /usr/share/php/PHP/CodeSniffer/Tokenizers/JS.php on line 884
 [exec] PHP Stack trace:
 [exec] PHP   1. {main}() /usr/bin/phpcs:0
 [exec] PHP   2. PHP_CodeSniffer_CLI->process() /usr/bin/phpcs:30
 [exec] PHP   3. PHP_CodeSniffer->process() /usr/share/php/PHP/CodeSniffer/CLI.php:423
 [exec] PHP   4. PHP_CodeSniffer->processFiles() /usr/share/php/PHP/CodeSniffer.php:374
 [exec] PHP   5. PHP_CodeSniffer->processFile() /usr/share/php/PHP/CodeSniffer.php:734
 [exec] PHP   6. PHP_CodeSniffer->_processFile() /usr/share/php/PHP/CodeSniffer.php:815
 [exec] PHP   7. PHP_CodeSniffer_File->start() /usr/share/php/PHP/CodeSniffer.php:900
 [exec] PHP   8. PHP_CodeSniffer_File->_parse() /usr/share/php/PHP/CodeSniffer/File.php:362
 [exec] PHP   9. PHP_CodeSniffer_File::tokenizeString() /usr/share/php/PHP/CodeSniffer/File.php:522
 [exec] PHP  10. PHP_CodeSniffer_Tokenizers_JS->tokenizeString() /usr/share/php/PHP/CodeSniffer/File.php:779
 [exec] PHP  11. PHP_CodeSniffer_Tokenizers_JS->getRegexToken() /usr/share/php/PHP/CodeSniffer/Tokenizers/JS.php:417
 [exec] PHP Notice:  Undefined offset: 7726 in /usr/share/php/PHP/CodeSniffer/Tokenizers/JS.php on line 884
 [exec] PHP Stack trace:
 [exec] PHP   1. {main}() /usr/bin/phpcs:0
 [exec] PHP   2. PHP_CodeSniffer_CLI->process() /usr/bin/phpcs:30
 [exec] PHP   3. PHP_CodeSniffer->process() /usr/share/php/PHP/CodeSniffer/CLI.php:423
 [exec] PHP   4. PHP_CodeSniffer->processFiles() /usr/share/php/PHP/CodeSniffer.php:374
 [exec] PHP   5. PHP_CodeSniffer->processFile() /usr/share/php/PHP/CodeSniffer.php:734
 [exec] PHP   6. PHP_CodeSniffer->_processFile() /usr/share/php/PHP/CodeSniffer.php:815
 [exec] PHP   7. PHP_CodeSniffer_File->start() /usr/share/php/PHP/CodeSniffer.php:900
 [exec] PHP   8. PHP_CodeSniffer_File->_parse() /usr/share/php/PHP/CodeSniffer/File.php:362
 [exec] PHP   9. PHP_CodeSniffer_File::tokenizeString() /usr/share/php/PHP/CodeSniffer/File.php:522
 [exec] PHP  10. PHP_CodeSniffer_Tokenizers_JS->tokenizeString() /usr/share/php/PHP/CodeSniffer/File.php:779
 [exec] PHP  11. PHP_CodeSniffer_Tokenizers_JS->getRegexToken() /usr/share/php/PHP/CodeSniffer/Tokenizers/JS.php:417

Output of "phploc" and "phploc --help" is wrong

phploc and phploc --help print the following:

➜  phploc git:(master) phploc
phploc 2.0-g5db25c3 by Sebastian Bergmann.

Usage:
 help [--xml] [command_name]

Arguments:
 command_name          The command name (default: "help")

Options:
 --xml                 To output help as XML
 --help (-h)           Display this help message.
 --quiet (-q)          Do not output any message.
 --verbose (-v)        Increase verbosity of messages.
 --version (-V)        Display this application version.
 --ansi                Force ANSI output.
 --no-ansi             Disable ANSI output.
 --no-interaction (-n) Do not ask any interactive question.

Help:
 The help command displays help for a given command:

   php /usr/local/src/phploc/phploc.php help list

 You can also output the help as XML by using the --xml option:

   php /usr/local/src/phploc/phploc.php help --xml list

 To display the list of available commands, please use the list command.

With this patch

diff --git a/src/CLI/Application.php b/src/CLI/Application.php
index 57cf6de..f22c261 100644
--- a/src/CLI/Application.php
+++ b/src/CLI/Application.php
@@ -76,10 +76,6 @@ public function __construct()
          */
         protected function getCommandName(InputInterface $input)
         {
-            if (!$input->getFirstArgument()) {
-                return 'help';
-            }
-
             return 'phploc';
         }

the output of phploc --help is correct:

➜  phploc git:(master) ✗ phploc --help
phploc 2.0-g5db25c3 by Sebastian Bergmann.

Usage:
 phploc [--names="..."] [--names-exclude="..."] [--count-tests] [--git-repository] [--exclude="..."] [--log-csv="..."] [--log-xml="..."] [--progress] [values1] ... [valuesN]

Arguments:
 values                

Options:
 --names               A comma-separated list of file names to check (default: ["*.php"])
 --names-exclude       A comma-separated list of file names to exclude
 --count-tests         Count PHPUnit test case classes and test methods
 --git-repository      Collect metrics over the history of a Git repository
 --exclude             Exclude a directory from code analysis (multiple values allowed)
 --log-csv             Write result in CSV format to file
 --log-xml             Write result in XML format to file
 --progress            Print progress bar
 --help (-h)           Display this help message.
 --quiet (-q)          Do not output any message.
 --verbose (-v)        Increase verbosity of messages.
 --version (-V)        Display this application version.
 --ansi                Force ANSI output.
 --no-ansi             Disable ANSI output.
 --no-interaction (-n) Do not ask any interactive question.

However, with this patch the output of phploc becomes:

➜  phploc git:(master) ✗ phploc
phploc 2.0-g5db25c3 by Sebastian Bergmann.

No files found to scan

Move from PHPLOC to src breaks PSR-0

Since the refactor in bfebe77 PSR-0 compliance has been broken.

This basically means that phploc can not be used as is via composer.

Was there a particular reason for the directory structure to be changed? The namspace used throughout is also out of line with the current directory structure.

Namespace issue...

$ phploc --progress /usr/share/php/htmLawed
phploc 1.7.1 by Sebastian Bergmann.


Catchable fatal error: Argument 1 passed to SebastianBergmann\PHPLOC\Analyser::__construct()
must be an instance of SebastianBergmann\PHPLOC\ezcConsoleOutput, 
instance of ezcConsoleOutput given, called in 
/usr/share/pear/SebastianBergmann/PHPLOC/TextUI/Command.php on line 208 
and defined in /usr/share/pear/SebastianBergmann/PHPLOC/Analyser.php on line 124

Undefined offset: 8 in ...

Hi,

I have a trouble with the composer version. Could you help me? My Composer requirements:

"require-dev": {
    "phpunit/phpunit": "3.7.*",
    "squizlabs/php_codesniffer": "1.4.*",
    "phploc/phploc": "*",
    "phpmd/phpmd" : "1.4.*"
}

Tried to run on my project:

./vendor/bin/phploc --count-tests --log-xml build/logs/phploc.xml .

My PHP version:

php --version
PHP 5.4.12--pl0-gentoo (cli) (built: Jun  6 2013 09:33:08) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
    with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans

Here is a stack trace:

phploc 2.0-g93a43e3 by Sebastian Bergmann.

PHP Notice: Undefined offset: 8 in /home/dev/src/zfcore/vendor/phploc/phploc/src/Analyser.php on line 699
PHP Stack trace:
PHP 1. {main}() /home/dev/src/zfcore/vendor/phploc/phploc/composer/bin/phploc:0
PHP 2. SebastianBergmann\PHPLOC\TextUI\Command->main() /home/dev/src/zfcore/vendor/phploc/phploc/composer/bin/phploc:71
PHP 3. SebastianBergmann\PHPLOC\TextUI\Command->run() /home/dev/src/zfcore/vendor/phploc/phploc/src/TextUI/Command.php:247
PHP 4. SebastianBergmann\PHPLOC\Analyser->countFiles() /home/dev/src/zfcore/vendor/phploc/phploc/src/TextUI/Command.php:318
PHP 5. SebastianBergmann\PHPLOC\Analyser->preProcessFile() /home/dev/src/zfcore/vendor/phploc/phploc/src/Analyser.php:183
PHP 6. SebastianBergmann\PHPLOC\Analyser->getClassName() /home/dev/src/zfcore/vendor/phploc/phploc/src/Analyser.php:315

Notice: Undefined offset: 8 in /home/dev/src/zfcore/vendor/phploc/phploc/src/Analyser.php on line 699

Call Stack:
0.0004 231208 1. {main}() /home/dev/src/zfcore/vendor/phploc/phploc/composer/bin/phploc:0
0.0206 637608 2. SebastianBergmann\PHPLOC\TextUI\Command->main() /home/dev/src/zfcore/vendor/phploc/phploc/composer/bin/phploc:71
0.0303 1245400 3. SebastianBergmann\PHPLOC\TextUI\Command->run() /home/dev/src/zfcore/vendor/phploc/phploc/src/TextUI/Command.php:247
1.3149 3343480 4. SebastianBergmann\PHPLOC\Analyser->countFiles() /home/dev/src/zfcore/vendor/phploc/phploc/src/TextUI/Command.php:318
3.6788 3934512 5. SebastianBergmann\PHPLOC\Analyser->preProcessFile() /home/dev/src/zfcore/vendor/phploc/phploc/src/Analyser.php:183
3.6789 3940872 6. SebastianBergmann\PHPLOC\Analyser->getClassName() /home/dev/src/zfcore/vendor/phploc/phploc/src/Analyser.php:315

--exclude

Add a switch to exclude certain directories underneath the supplied path?

E.g.

My project is:

app/
app/library/
app/library/Zend

I'd like to exclude it, using something like:

phploc --exclude=Zend /path/to/app/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.