Phpstan: Jean85\PrettyVersions not found

Created on 28 Sep 2017  ·  38Comments  ·  Source: phpstan/phpstan

Both composer global install and phar fail with:

phpstan.phar    
PHP Fatal error:  Uncaught Error: Class 'PHPStanVendor\Jean85\PrettyVersions' not found in phar:///usr/local/bin/phpstan.phar/bin/phpstan:23
Stack trace:
#0 /usr/local/bin/phpstan.phar(4): require()
#1 {main}
  thrown in phar:///usr/local/bin/phpstan.phar/bin/phpstan on line 23

In addition, https://github.com/phpstan/phpstan/releases/tag/0.8.5 is missing phar.

bug

All 38 comments

Hi,
how exactly are you installing it?

On Thu, 28 Sep 2017 at 23:33, Saša Stamenković notifications@github.com
wrote:

Both composer global install and phar fail with:

PHP Fatal error: Uncaught Error: Class 'PHPStanVendor\Jean85\PrettyVersions' not found in phar:///usr/local/bin/phpstan.phar/bin/phpstan:23
Stack trace:

0 /usr/local/bin/phpstan.phar(4): require()

1 {main}

thrown in phar:///usr/local/bin/phpstan.phar/bin/phpstan on line 23

In addition, https://github.com/phpstan/phpstan/releases/tag/0.8.5 is
missing phar.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/phpstan/phpstan/issues/525, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAGZuNTfOiZNRl0U3KZacejqhwmbPN-Sks5snBCTgaJpZM4Pn6w6
.

>

Ondřej Mirtes

Composer

composer global require phpstan/phpstan

Phar

wget https://github.com/phpstan/phpstan/releases/download/0.8.4/phpstan.phar
mv phpstan.phar /usr/local/bin

Could not reproduce your problem:

Composer

~ $ composer global require phpstan/phpstan
Changed current directory to /Users/ondrej/.composer
Using version ^0.8.5 for phpstan/phpstan
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
Writing lock file
Generating autoload files
ocramius/package-versions:  Generating version class...
ocramius/package-versions: ...done generating version class
~ $ /Users/ondrej/.composer/vendor/bin/phpstan --version
PHPStan - PHP Static Analysis Tool dev-master@651dd78

Phar

~ $ wget https://github.com/phpstan/phpstan/releases/download/0.8.4/phpstan.phar
--2017-09-29 16:30:13--  https://github.com/phpstan/phpstan/releases/download/0.8.4/phpstan.phar
Resolving github.com... 192.30.253.113, 192.30.253.112
Connecting to github.com|192.30.253.113|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://github-production-release-asset-2e65be.s3.amazonaws.com/49014795/ff480f42-8980-11e7-8f76-eb9f4ad07bb3?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20170929%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20170929T143014Z&X-Amz-Expires=300&X-Amz-Signature=9b1bb64ca89bb1eaa7433205ba55051b0b578ca1256330010b0793abf4857503&X-Amz-SignedHeaders=host&actor_id=0&response-content-disposition=attachment%3B%20filename%3Dphpstan.phar&response-content-type=application%2Foctet-stream [following]
--2017-09-29 16:30:14--  https://github-production-release-asset-2e65be.s3.amazonaws.com/49014795/ff480f42-8980-11e7-8f76-eb9f4ad07bb3?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20170929%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20170929T143014Z&X-Amz-Expires=300&X-Amz-Signature=9b1bb64ca89bb1eaa7433205ba55051b0b578ca1256330010b0793abf4857503&X-Amz-SignedHeaders=host&actor_id=0&response-content-disposition=attachment%3B%20filename%3Dphpstan.phar&response-content-type=application%2Foctet-stream
Resolving github-production-release-asset-2e65be.s3.amazonaws.com... 54.231.98.152
Connecting to github-production-release-asset-2e65be.s3.amazonaws.com|54.231.98.152|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2434713 (2.3M) [application/octet-stream]
Saving to: ‘phpstan.phar’

phpstan.phar               100%[=======================================>]   2.32M  1.70MB/s    in 1.4s

2017-09-29 16:30:16 (1.70 MB/s) - ‘phpstan.phar’ saved [2434713/2434713]

~ $ chmod +x phpstan.phar
~ $ ./phpstan.phar --version
PHPStan - PHP Static Analysis Tool 0.8.4.0

And the missing phar issue for 0.8.5 is a duplicate of #496.

Not sure why this happens, file is there:

cat ~/.composer/vendor/jean85/pretty-package-versions/src/PrettyVersions.php
<?php

namespace Jean85;

use PackageVersions\Versions;

class PrettyVersions
{
    const SHORT_COMMIT_LENGTH = 7;

    public static function getVersion(string $packageName): Version
    {
        return new Version($packageName, Versions::getVersion($packageName));
    }
}

Looks like autoload issue.

Feel free to debug it, I have no idea what can it be caused by 😊 cc @Jean85

My packages:

composer global show
Changed current directory to /home/umpirsky/.composer
doctrine/annotations           v1.5.0  Docblock Annotations Parser
doctrine/lexer                 v1.0.1  Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.
herrera-io/annotations         1.0.1   A tokenizer for Doctrine annotations.
herrera-io/box                 1.6.1   A library for simplifying the PHAR build process.
herrera-io/json                1.0.3   A library for simplifying JSON linting and validation.
herrera-io/phar-update         2.0.0   A library for self-updating Phars.
herrera-io/version             1.1.1   A library for creating, editing, and comparing semantic versioning numbers.
hirak/prestissimo              0.3.5   composer parallel install plugin
jean85/pretty-package-versions 1.0.2   A wrapper for ocramius/pretty-package-versions to get pretty versions strings
justinrainbow/json-schema      1.6.1   A library to validate a json schema.
kherge/amend                   3.0.5   Integrates Phar Update to Symfony Console.
kherge/box                     2.7.5   A tool to simplify building PHARs.
nette/bootstrap                v2.4.5  🅱 Nette Bootstrap: the simple way to configure and bootstrap your Nette application.
nette/di                       v2.4.10 💎 Nette Dependency Injection Container: Flexible, compiled and full-featured DIC with perfect...
nette/finder                   v2.4.1  Nette Finder: Files Searching
nette/neon                     v2.4.2  Nette NEON: parser & generator for Nette Object Notation
nette/php-generator            v3.0.1  🐘 Nette PHP Generator: generates neat PHP code for you. Supports new PHP 7.1 features.
nette/robot-loader             v3.0.2  🍀 Nette RobotLoader: high performance and comfortable autoloader that will search and autoloa...
nette/utils                    v2.4.8  🛠 Nette Utils: lightweight utilities for string & array manipulation, image handling, safe JS...
nikic/php-parser               v3.1.1  A PHP parser written in PHP
ocramius/package-versions      1.1.3   Composer plugin that provides efficient querying for installed package versions (no runtime IO)
phine/exception                1.0.0   A PHP library for improving the use of exceptions.
phine/path                     1.1.0   A PHP library for improving the use of file system paths.
phpseclib/phpseclib            2.0.6   PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.
phpstan/phpstan                0.8.5   PHPStan - PHP Static Analysis Tool
psr/log                        1.0.2   Common interface for logging libraries
pyrech/composer-changelogs     v1.5.1  Display changelogs after each composer update
seld/jsonlint                  1.6.1   JSON Linter
symfony/console                v3.3.6  Symfony Console Component
symfony/debug                  v3.3.6  Symfony Debug Component
symfony/finder                 v3.3.6  Symfony Finder Component
symfony/polyfill-mbstring      v1.5.0  Symfony polyfill for the Mbstring extension
symfony/process                v3.3.6  Symfony Process Component
tedivm/jshrink                 v1.2.0  Javascript Minifier built in PHP

The only strange stuff that I can see is Class 'PHPStanVendor\Jean85\PrettyVersions'.. Who's prepending PHPStanVendor in the namespace? PHPStan's PHAR has some autoloader additions?

@Jean85 That happens only for phar, with composer global it's just Jean85\PrettyVersions. I guess phar is prepending PHPStanVendor namespace to prevent collision with root.

Ok, understood. Since yours seems to be a config problem, can you post your environment spec?

@Jean85 What do you need?

php -v
PHP 7.1.9-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Sep  2 2017 05:56:43) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.1.9-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2017, by Zend Technologies

cat /etc/issue
Ubuntu 16.04.3 LTS \n \l

Ok, you're using Linux like me. Are you using any other tech? Docker? VM? I cannot reproduce this too. Maybe you have some basic PHP extension disabled?

@Jean85 I use both vagrant and docker, but this (phpstan) is run on bare metal.

[PHP Modules]
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
intl
json
libxml
mbstring
openssl
pcntl
pcre
PDO
pdo_sqlite
Phar
posix
readline
Reflection
session
shmop
SimpleXML
sockets
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zlib

[Zend Modules]
Zend OPcache
phpinfo()
PHP Version => 7.1.10-1+ubuntu16.04.1+deb.sury.org+1

System => Linux zenbook 4.4.0-87-generic #110-Ubuntu SMP Tue Jul 18 12:55:35 UTC 2017 x86_64
Build Date => Sep 29 2017 17:04:25
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /etc/php/7.1/cli
Loaded Configuration File => /etc/php/7.1/cli/php.ini
Scan this dir for additional .ini files => /etc/php/7.1/cli/conf.d
Additional .ini files parsed => /etc/php/7.1/cli/conf.d/10-opcache.ini,
/etc/php/7.1/cli/conf.d/10-pdo.ini,
/etc/php/7.1/cli/conf.d/15-xml.ini,
/etc/php/7.1/cli/conf.d/20-calendar.ini,
/etc/php/7.1/cli/conf.d/20-ctype.ini,
/etc/php/7.1/cli/conf.d/20-curl.ini,
/etc/php/7.1/cli/conf.d/20-dom.ini,
/etc/php/7.1/cli/conf.d/20-exif.ini,
/etc/php/7.1/cli/conf.d/20-fileinfo.ini,
/etc/php/7.1/cli/conf.d/20-ftp.ini,
/etc/php/7.1/cli/conf.d/20-gd.ini,
/etc/php/7.1/cli/conf.d/20-gettext.ini,
/etc/php/7.1/cli/conf.d/20-iconv.ini,
/etc/php/7.1/cli/conf.d/20-intl.ini,
/etc/php/7.1/cli/conf.d/20-json.ini,
/etc/php/7.1/cli/conf.d/20-mbstring.ini,
/etc/php/7.1/cli/conf.d/20-pdo_sqlite.ini,
/etc/php/7.1/cli/conf.d/20-phar.ini,
/etc/php/7.1/cli/conf.d/20-posix.ini,
/etc/php/7.1/cli/conf.d/20-readline.ini,
/etc/php/7.1/cli/conf.d/20-shmop.ini,
/etc/php/7.1/cli/conf.d/20-simplexml.ini,
/etc/php/7.1/cli/conf.d/20-sockets.ini,
/etc/php/7.1/cli/conf.d/20-sqlite3.ini,
/etc/php/7.1/cli/conf.d/20-sysvmsg.ini,
/etc/php/7.1/cli/conf.d/20-sysvsem.ini,
/etc/php/7.1/cli/conf.d/20-sysvshm.ini,
/etc/php/7.1/cli/conf.d/20-tokenizer.ini,
/etc/php/7.1/cli/conf.d/20-wddx.ini,
/etc/php/7.1/cli/conf.d/20-xmlreader.ini,
/etc/php/7.1/cli/conf.d/20-xmlwriter.ini,
/etc/php/7.1/cli/conf.d/20-xsl.ini

PHP API => 20160303
PHP Extension => 20160303
Zend Extension => 320160303
Zend Extension Build => API320160303,NTS
PHP Extension Build => API20160303,NTS
Debug Build => no
Thread Safety => disabled
Zend Signal Handling => enabled
Zend Memory Manager => enabled
Zend Multibyte Support => provided by mbstring
IPv6 Support => enabled
DTrace Support => available, disabled

Registered PHP Streams => https, ftps, compress.zlib, php, file, glob, data, http, ftp, phar
Registered Stream Socket Transports => tcp, udp, unix, udg, ssl, tls, tlsv1.0, tlsv1.1, tlsv1.2
Registered Stream Filters => zlib.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk, convert.iconv.*

This program makes use of the Zend Scripting Language Engine:
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.1.10-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2017, by Zend Technologies


 _______________________________________________________________________


Configuration

calendar

Calendar support => enabled

Core

PHP Version => 7.1.10-1+ubuntu16.04.1+deb.sury.org+1

Directive => Local Value => Master Value
allow_url_fopen => On => On
allow_url_include => Off => Off
arg_separator.input => & => &
arg_separator.output => & => &
auto_append_file => no value => no value
auto_globals_jit => On => On
auto_prepend_file => no value => no value
browscap => no value => no value
default_charset => UTF-8 => UTF-8
default_mimetype => text/html => text/html
disable_classes => no value => no value
disable_functions => no value => no value
display_errors => Off => Off
display_startup_errors => Off => Off
doc_root => no value => no value
docref_ext => no value => no value
docref_root => no value => no value
enable_dl => Off => Off
enable_post_data_reading => On => On
error_append_string => no value => no value
error_log => no value => no value
error_prepend_string => no value => no value
error_reporting => 22527 => 22527
expose_php => On => On
extension_dir => /usr/lib/php/20160303 => /usr/lib/php/20160303
file_uploads => On => On
hard_timeout => 2 => 2
highlight.comment => <font style="color: #FF8000">#FF8000</font> => <font style="color: #FF8000">#FF8000</font>
highlight.default => <font style="color: #0000BB">#0000BB</font> => <font style="color: #0000BB">#0000BB</font>
highlight.html => <font style="color: #000000">#000000</font> => <font style="color: #000000">#000000</font>
highlight.keyword => <font style="color: #007700">#007700</font> => <font style="color: #007700">#007700</font>
highlight.string => <font style="color: #DD0000">#DD0000</font> => <font style="color: #DD0000">#DD0000</font>
html_errors => Off => Off
ignore_repeated_errors => Off => Off
ignore_repeated_source => Off => Off
ignore_user_abort => Off => Off
implicit_flush => On => On
include_path => .:/usr/share/php => .:/usr/share/php
input_encoding => no value => no value
internal_encoding => no value => no value
log_errors => On => On
log_errors_max_len => 1024 => 1024
mail.add_x_header => On => On
mail.force_extra_parameters => no value => no value
mail.log => no value => no value
max_execution_time => 0 => 0
max_file_uploads => 20 => 20
max_input_nesting_level => 64 => 64
max_input_time => -1 => -1
max_input_vars => 1000 => 1000
memory_limit => -1 => -1
open_basedir => no value => no value
output_buffering => 0 => 0
output_encoding => no value => no value
output_handler => no value => no value
post_max_size => 8M => 8M
precision => 14 => 14
realpath_cache_size => 4096K => 4096K
realpath_cache_ttl => 120 => 120
register_argc_argv => On => On
report_memleaks => On => On
report_zend_debug => Off => Off
request_order => GP => GP
sendmail_from => no value => no value
sendmail_path => /usr/sbin/sendmail -t -i  => /usr/sbin/sendmail -t -i 
serialize_precision => -1 => -1
short_open_tag => Off => Off
SMTP => localhost => localhost
smtp_port => 25 => 25
sql.safe_mode => Off => Off
sys_temp_dir => no value => no value
track_errors => Off => Off
unserialize_callback_func => no value => no value
upload_max_filesize => 2M => 2M
upload_tmp_dir => no value => no value
user_dir => no value => no value
user_ini.cache_ttl => 300 => 300
user_ini.filename => .user.ini => .user.ini
variables_order => GPCS => GPCS
xmlrpc_error_number => 0 => 0
xmlrpc_errors => Off => Off
zend.assertions => -1 => -1
zend.detect_unicode => On => On
zend.enable_gc => On => On
zend.multibyte => Off => Off
zend.script_encoding => no value => no value
zend.signal_check => Off => Off

ctype

ctype functions => enabled

curl

cURL support => enabled
cURL Information => 7.47.0
Age => 3
Features
AsynchDNS => Yes
CharConv => No
Debug => No
GSS-Negotiate => No
IDN => Yes
IPv6 => Yes
krb4 => No
Largefile => Yes
libz => Yes
NTLM => Yes
NTLMWB => Yes
SPNEGO => Yes
SSL => Yes
SSPI => No
TLS-SRP => Yes
HTTP2 => No
GSSAPI => Yes
KERBEROS5 => Yes
UNIX_SOCKETS => Yes
PSL => No
Protocols => dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, ldaps, pop3, pop3s, rtmp, rtsp, smb, smbs, smtp, smtps, telnet, tftp
Host => x86_64-pc-linux-gnu
SSL Version => OpenSSL/1.0.2g
ZLib Version => 1.2.8

date

date/time support => enabled
timelib version => 2016.05
"Olson" Timezone Database Version => 0.system
Timezone Database => internal
Default timezone => Europe/Berlin

Directive => Local Value => Master Value
date.default_latitude => 31.7667 => 31.7667
date.default_longitude => 35.2333 => 35.2333
date.sunrise_zenith => 90.583333 => 90.583333
date.sunset_zenith => 90.583333 => 90.583333
date.timezone => no value => no value

dom

DOM/XML => enabled
DOM/XML API Version => 20031129
libxml Version => 2.9.4
HTML Support => enabled
XPath Support => enabled
XPointer Support => enabled
Schema Support => enabled
RelaxNG Support => enabled

exif

EXIF Support => enabled
EXIF Version => 1.4 $Id: 8bdc0c8f27c2c9dd1f7551f1f9fe3ab57a06a4b1 $
Supported EXIF Version => 0220
Supported filetypes => JPEG,TIFF

Directive => Local Value => Master Value
exif.decode_jis_intel => JIS => JIS
exif.decode_jis_motorola => JIS => JIS
exif.decode_unicode_intel => UCS-2LE => UCS-2LE
exif.decode_unicode_motorola => UCS-2BE => UCS-2BE
exif.encode_jis => no value => no value
exif.encode_unicode => ISO-8859-15 => ISO-8859-15

fileinfo

fileinfo support => enabled
version => 1.0.5
libmagic => 522

filter

Input Validation and Filtering => enabled
Revision => $Id: cdc5e15bb616f10210b94ecd8789e66c927a375f $

Directive => Local Value => Master Value
filter.default => unsafe_raw => unsafe_raw
filter.default_flags => no value => no value

ftp

FTP support => enabled
FTPS support => enabled

gd

GD Support => enabled
GD headers Version => 2.2.5
GD library Version => 2.2.5
FreeType Support => enabled
FreeType Linkage => with freetype
FreeType Version => 2.6.1
GIF Read Support => enabled
GIF Create Support => enabled
JPEG Support => enabled
libJPEG Version => 8
PNG Support => enabled
libPNG Version => 1.2.54
WBMP Support => enabled
XPM Support => enabled
libXpm Version => 30411
XBM Support => enabled
WebP Support => enabled

Directive => Local Value => Master Value
gd.jpeg_ignore_warning => 1 => 1

gettext

GetText Support => enabled

hash

hash support => enabled
Hashing Engines => md2 md4 md5 sha1 sha224 sha256 sha384 sha512/224 sha512/256 sha512 sha3-224 sha3-256 sha3-384 sha3-512 ripemd128 ripemd160 ripemd256 ripemd320 whirlpool tiger128,3 tiger160,3 tiger192,3 tiger128,4 tiger160,4 tiger192,4 snefru snefru256 gost gost-crypto adler32 crc32 crc32b fnv132 fnv1a32 fnv164 fnv1a64 joaat haval128,3 haval160,3 haval192,3 haval224,3 haval256,3 haval128,4 haval160,4 haval192,4 haval224,4 haval256,4 haval128,5 haval160,5 haval192,5 haval224,5 haval256,5 

MHASH support => Enabled
MHASH API Version => Emulated Support

iconv

iconv support => enabled
iconv implementation => glibc
iconv library version => 2.23

Directive => Local Value => Master Value
iconv.input_encoding => no value => no value
iconv.internal_encoding => no value => no value
iconv.output_encoding => no value => no value

intl

Internationalization support => enabled
version => 1.1.0
ICU version => 55.1
ICU Data version => 55.1

Directive => Local Value => Master Value
intl.default_locale => no value => no value
intl.error_level => 0 => 0
intl.use_exceptions => 0 => 0

json

json support => enabled
json version => 1.5.0

libxml

libXML support => active
libXML Compiled Version => 2.9.4
libXML Loaded Version => 20904
libXML streams => enabled

mbstring

Multibyte Support => enabled
Multibyte string engine => libmbfl
HTTP input encoding translation => disabled
libmbfl version => 1.3.2
oniguruma version => 5.9.6

mbstring extension makes use of "streamable kanji code filter and converter", which is distributed under the GNU Lesser General Public License version 2.1.

Multibyte (japanese) regex support => enabled
Multibyte regex (oniguruma) backtrack check => On
Multibyte regex (oniguruma) version => 5.9.6

Directive => Local Value => Master Value
mbstring.detect_order => no value => no value
mbstring.encoding_translation => Off => Off
mbstring.func_overload => 0 => 0
mbstring.http_input => no value => no value
mbstring.http_output => no value => no value
mbstring.http_output_conv_mimetypes => ^(text/|application/xhtml\+xml) => ^(text/|application/xhtml\+xml)
mbstring.internal_encoding => no value => no value
mbstring.language => neutral => neutral
mbstring.strict_detection => Off => Off
mbstring.substitute_character => no value => no value

openssl

OpenSSL support => enabled
OpenSSL Library Version => OpenSSL 1.1.0f  25 May 2017
OpenSSL Header Version => OpenSSL 1.1.0f  25 May 2017
Openssl default config => /usr/lib/ssl/openssl.cnf

Directive => Local Value => Master Value
openssl.cafile => no value => no value
openssl.capath => no value => no value

pcntl

pcntl support => enabled

pcre

PCRE (Perl Compatible Regular Expressions) Support => enabled
PCRE Library Version => 8.41 2017-07-05
PCRE JIT Support => enabled

Directive => Local Value => Master Value
pcre.backtrack_limit => 1000000 => 1000000
pcre.jit => 1 => 1
pcre.recursion_limit => 100000 => 100000

PDO

PDO support => enabled
PDO drivers => sqlite

pdo_sqlite

PDO Driver for SQLite 3.x => enabled
SQLite Library => 3.11.0

Phar

Phar: PHP Archive support => enabled
Phar EXT version => 2.0.2
Phar API version => 1.1.1
SVN revision => $Id: 59c11f4e29768bfbbf6f41cb469abd81d8655850 $
Phar-based phar archives => enabled
Tar-based phar archives => enabled
ZIP-based phar archives => enabled
gzip compression => enabled
bzip2 compression => disabled (install pecl/bz2)
Native OpenSSL support => enabled


Phar based on pear/PHP_Archive, original concept by Davey Shafik.
Phar fully realized by Gregory Beaver and Marcus Boerger.
Portions of tar implementation Copyright (c) 2003-2009 Tim Kientzle.
Directive => Local Value => Master Value
phar.cache_list => no value => no value
phar.readonly => Off => Off
phar.require_hash => On => On

posix

Revision => $Id: b691ca925e7a085e6929579c4eba8fed0732e0ef $

readline

Readline Support => enabled
Readline library => EditLine wrapper

Directive => Local Value => Master Value
cli.pager => no value => no value
cli.prompt => \b \>  => \b \> 

Reflection

Reflection => enabled
Version => $Id: fa936d2e1587e7b6b6c0f7235f4d9df7564a77ad $

session

Session Support => enabled
Registered save handlers => files user 
Registered serializer handlers => php_serialize php php_binary wddx 

Directive => Local Value => Master Value
session.auto_start => Off => Off
session.cache_expire => 180 => 180
session.cache_limiter => nocache => nocache
session.cookie_domain => no value => no value
session.cookie_httponly => Off => Off
session.cookie_lifetime => 0 => 0
session.cookie_path => / => /
session.cookie_secure => Off => Off
session.gc_divisor => 1000 => 1000
session.gc_maxlifetime => 1440 => 1440
session.gc_probability => 0 => 0
session.lazy_write => On => On
session.name => PHPSESSID => PHPSESSID
session.referer_check => no value => no value
session.save_handler => files => files
session.save_path => /var/lib/php/sessions => /var/lib/php/sessions
session.serialize_handler => php => php
session.sid_bits_per_character => 5 => 5
session.sid_length => 26 => 26
session.upload_progress.cleanup => On => On
session.upload_progress.enabled => On => On
session.upload_progress.freq => 1% => 1%
session.upload_progress.min_freq => 1 => 1
session.upload_progress.name => PHP_SESSION_UPLOAD_PROGRESS => PHP_SESSION_UPLOAD_PROGRESS
session.upload_progress.prefix => upload_progress_ => upload_progress_
session.use_cookies => On => On
session.use_only_cookies => On => On
session.use_strict_mode => Off => Off
session.use_trans_sid => 0 => 0

shmop

shmop support => enabled

SimpleXML

Simplexml support => enabled
Revision => $Id: 50413b12ac745b94b27ffbdd5454e6e0d7809909 $
Schema support => enabled

sockets

Sockets Support => enabled

SPL

SPL support => enabled
Interfaces => Countable, OuterIterator, RecursiveIterator, SeekableIterator, SplObserver, SplSubject
Classes => AppendIterator, ArrayIterator, ArrayObject, BadFunctionCallException, BadMethodCallException, CachingIterator, CallbackFilterIterator, DirectoryIterator, DomainException, EmptyIterator, FilesystemIterator, FilterIterator, GlobIterator, InfiniteIterator, InvalidArgumentException, IteratorIterator, LengthException, LimitIterator, LogicException, MultipleIterator, NoRewindIterator, OutOfBoundsException, OutOfRangeException, OverflowException, ParentIterator, RangeException, RecursiveArrayIterator, RecursiveCachingIterator, RecursiveCallbackFilterIterator, RecursiveDirectoryIterator, RecursiveFilterIterator, RecursiveIteratorIterator, RecursiveRegexIterator, RecursiveTreeIterator, RegexIterator, RuntimeException, SplDoublyLinkedList, SplFileInfo, SplFileObject, SplFixedArray, SplHeap, SplMinHeap, SplMaxHeap, SplObjectStorage, SplPriorityQueue, SplQueue, SplStack, SplTempFileObject, UnderflowException, UnexpectedValueException

sqlite3

SQLite3 support => enabled
SQLite3 module version => 7.1.10-1+ubuntu16.04.1+deb.sury.org+1
SQLite Library => 3.11.0

Directive => Local Value => Master Value
sqlite3.extension_dir => no value => no value

standard

Dynamic Library Support => enabled
Path to sendmail => /usr/sbin/sendmail -t -i 

Directive => Local Value => Master Value
assert.active => 1 => 1
assert.bail => 0 => 0
assert.callback => no value => no value
assert.exception => 0 => 0
assert.quiet_eval => 0 => 0
assert.warning => 1 => 1
auto_detect_line_endings => 0 => 0
default_socket_timeout => 60 => 60
from => no value => no value
session.trans_sid_hosts => no value => no value
session.trans_sid_tags => a=href,area=href,frame=src,form= => a=href,area=href,frame=src,form=
url_rewriter.hosts => no value => no value
url_rewriter.tags => form= => form=
user_agent => no value => no value

sysvmsg

sysvmsg support => enabled
Revision => $Id: 37aa0d90288b1385356784f17694f4c700575736 $

sysvsem

Version => 7.1.10-1+ubuntu16.04.1+deb.sury.org+1

sysvshm

Version => 7.1.10-1+ubuntu16.04.1+deb.sury.org+1

tokenizer

Tokenizer Support => enabled

wddx

WDDX Support => enabled
WDDX Session Serializer => enabled

xml

XML Support => active
XML Namespace Support => active
libxml2 Version => 2.9.4

xmlreader

XMLReader => enabled

xmlwriter

XMLWriter => enabled

xsl

XSL => enabled
libxslt Version => 1.1.28
libxslt compiled against libxml Version => 2.9.3
EXSLT => enabled
libexslt Version => 1.1.28

Zend OPcache

Opcode Caching => Disabled
Optimization => Disabled
SHM Cache => Enabled
File Cache => Disabled
Startup Failed => Opcode Caching is disabled for CLI

Directive => Local Value => Master Value
opcache.blacklist_filename => no value => no value
opcache.consistency_checks => 0 => 0
opcache.dups_fix => Off => Off
opcache.enable => On => On
opcache.enable_cli => Off => Off
opcache.enable_file_override => Off => Off
opcache.error_log => no value => no value
opcache.fast_shutdown => 0 => 0
opcache.file_cache => no value => no value
opcache.file_cache_consistency_checks => 1 => 1
opcache.file_cache_only => 0 => 0
opcache.file_update_protection => 2 => 2
opcache.force_restart_timeout => 180 => 180
opcache.huge_code_pages => Off => Off
opcache.inherited_hack => On => On
opcache.interned_strings_buffer => 8 => 8
opcache.lockfile_path => /tmp => /tmp
opcache.log_verbosity_level => 1 => 1
opcache.max_accelerated_files => 10000 => 10000
opcache.max_file_size => 0 => 0
opcache.max_wasted_percentage => 5 => 5
opcache.memory_consumption => 128 => 128
opcache.opt_debug_level => 0 => 0
opcache.optimization_level => 0x7FFFBFFF => 0x7FFFBFFF
opcache.preferred_memory_model => no value => no value
opcache.protect_memory => 0 => 0
opcache.restrict_api => no value => no value
opcache.revalidate_freq => 2 => 2
opcache.revalidate_path => Off => Off
opcache.save_comments => 1 => 1
opcache.use_cwd => On => On
opcache.validate_permission => Off => Off
opcache.validate_root => Off => Off
opcache.validate_timestamps => On => On

zlib

ZLib Support => enabled
Stream Wrapper => compress.zlib://
Stream Filter => zlib.inflate, zlib.deflate
Compiled Version => 1.2.8
Linked Version => 1.2.8

Directive => Local Value => Master Value
zlib.output_compression => Off => Off
zlib.output_compression_level => -1 => -1
zlib.output_handler => no value => no value

Additional Modules

Module Name

Environment

Variable => Value
XDG_CONFIG_DIRS => /etc/xdg/xdg-gnome:/etc/xdg
LC_TELEPHONE => en_GB.UTF-8
LANG => en_US.UTF-8
DISPLAY => :1
SHLVL => 1
LOGNAME => umpirsky
XDG_VTNR => 2
MANDATORY_PATH => /usr/share/gconf/gnome.mandatory.path
LC_NAME => en_GB.UTF-8
PWD => /home/umpirsky
USER => umpirsky
XAUTHORITY => /run/user/1000/gdm/Xauthority
QT_LINUX_ACCESSIBILITY_ALWAYS_ON => 1
GTK_IM_MODULE => ibus
XDG_SESSION_ID => 112
COGL_ATLAS_DEFAULT_BLIT_MODE => framebuffer
GTK3_MODULES => /home/umpirsky/Projects/plotinus/build/libplotinus.so
DESKTOP_SESSION => gnome
XDG_SESSION_DESKTOP => gnome
GDMSESSION => gnome
GNOME_DESKTOP_SESSION_ID => this-is-deprecated
DEFAULTS_PATH => /usr/share/gconf/gnome.default.path
WINDOWPATH => 2
LC_MEASUREMENT => en_GB.UTF-8
PAPERSIZE => a4
LC_PAPER => en_GB.UTF-8
LC_MONETARY => en_GB.UTF-8
DBUS_SESSION_BUS_ADDRESS => unix:abstract=/tmp/dbus-O2DeEIdsBr,guid=f7c53b9b8d1384e1ecf9f75b599e83d9
VTE_VERSION => 4205
DESKTOP_AUTOSTART_ID => 105b67f257a19b6d88150356066551810400000058490001
CLUTTER_IM_MODULE => xim
LC_IDENTIFICATION => en_GB.UTF-8
QT4_IM_MODULE => ibus
XDG_DATA_DIRS => /usr/share/gnome:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop
USERNAME => umpirsky
XDG_MENU_PREFIX => gnome-
QT_ACCESSIBILITY => 1
SHELL => /usr/bin/zsh
QT_IM_MODULE => ibus
XDG_SESSION_TYPE => x11
LC_TIME => en_GB.UTF-8
WINDOWID => 37748742
TERM => xterm-256color
SSH_AGENT_PID => 5918
GTK_MODULES => gail:atk-bridge
XDG_CURRENT_DESKTOP => GNOME
SESSION_MANAGER => local/zenbook:@/tmp/.ICE-unix/5849,unix/zenbook:/tmp/.ICE-unix/5849
PATH => /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
HOME => /home/umpirsky
SSH_AUTH_SOCK => /run/user/1000/keyring/ssh
XMODIFIERS => @im=ibus
XDG_SEAT => seat0
XDG_RUNTIME_DIR => /run/user/1000
LC_ADDRESS => en_GB.UTF-8
LC_NUMERIC => en_GB.UTF-8
OLDPWD => /home/umpirsky/Projects/chess.com
ZSH => /home/umpirsky/.oh-my-zsh
PAGER => less
LESS => -R
LSCOLORS => Gxfxcxdxbxegedabagacad
LS_COLORS => rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
LC_CTYPE => en_US.UTF-8
_ => /usr/bin/php

PHP Variables

Variable => Value
$_SERVER['XDG_CONFIG_DIRS'] => /etc/xdg/xdg-gnome:/etc/xdg
$_SERVER['LC_TELEPHONE'] => en_GB.UTF-8
$_SERVER['LANG'] => en_US.UTF-8
$_SERVER['DISPLAY'] => :1
$_SERVER['SHLVL'] => 1
$_SERVER['LOGNAME'] => umpirsky
$_SERVER['XDG_VTNR'] => 2
$_SERVER['MANDATORY_PATH'] => /usr/share/gconf/gnome.mandatory.path
$_SERVER['LC_NAME'] => en_GB.UTF-8
$_SERVER['PWD'] => /home/umpirsky
$_SERVER['USER'] => umpirsky
$_SERVER['XAUTHORITY'] => /run/user/1000/gdm/Xauthority
$_SERVER['QT_LINUX_ACCESSIBILITY_ALWAYS_ON'] => 1
$_SERVER['GTK_IM_MODULE'] => ibus
$_SERVER['XDG_SESSION_ID'] => 112
$_SERVER['COGL_ATLAS_DEFAULT_BLIT_MODE'] => framebuffer
$_SERVER['GTK3_MODULES'] => /home/umpirsky/Projects/plotinus/build/libplotinus.so
$_SERVER['DESKTOP_SESSION'] => gnome
$_SERVER['XDG_SESSION_DESKTOP'] => gnome
$_SERVER['GDMSESSION'] => gnome
$_SERVER['GNOME_DESKTOP_SESSION_ID'] => this-is-deprecated
$_SERVER['DEFAULTS_PATH'] => /usr/share/gconf/gnome.default.path
$_SERVER['WINDOWPATH'] => 2
$_SERVER['LC_MEASUREMENT'] => en_GB.UTF-8
$_SERVER['PAPERSIZE'] => a4
$_SERVER['LC_PAPER'] => en_GB.UTF-8
$_SERVER['LC_MONETARY'] => en_GB.UTF-8
$_SERVER['DBUS_SESSION_BUS_ADDRESS'] => unix:abstract=/tmp/dbus-O2DeEIdsBr,guid=f7c53b9b8d1384e1ecf9f75b599e83d9
$_SERVER['VTE_VERSION'] => 4205
$_SERVER['DESKTOP_AUTOSTART_ID'] => 105b67f257a19b6d88150356066551810400000058490001
$_SERVER['CLUTTER_IM_MODULE'] => xim
$_SERVER['LC_IDENTIFICATION'] => en_GB.UTF-8
$_SERVER['QT4_IM_MODULE'] => ibus
$_SERVER['XDG_DATA_DIRS'] => /usr/share/gnome:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop
$_SERVER['USERNAME'] => umpirsky
$_SERVER['XDG_MENU_PREFIX'] => gnome-
$_SERVER['QT_ACCESSIBILITY'] => 1
$_SERVER['SHELL'] => /usr/bin/zsh
$_SERVER['QT_IM_MODULE'] => ibus
$_SERVER['XDG_SESSION_TYPE'] => x11
$_SERVER['LC_TIME'] => en_GB.UTF-8
$_SERVER['WINDOWID'] => 37748742
$_SERVER['TERM'] => xterm-256color
$_SERVER['SSH_AGENT_PID'] => 5918
$_SERVER['GTK_MODULES'] => gail:atk-bridge
$_SERVER['XDG_CURRENT_DESKTOP'] => GNOME
$_SERVER['SESSION_MANAGER'] => local/zenbook:@/tmp/.ICE-unix/5849,unix/zenbook:/tmp/.ICE-unix/5849
$_SERVER['PATH'] => /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
$_SERVER['HOME'] => /home/umpirsky
$_SERVER['SSH_AUTH_SOCK'] => /run/user/1000/keyring/ssh
$_SERVER['XMODIFIERS'] => @im=ibus
$_SERVER['XDG_SEAT'] => seat0
$_SERVER['XDG_RUNTIME_DIR'] => /run/user/1000
$_SERVER['LC_ADDRESS'] => en_GB.UTF-8
$_SERVER['LC_NUMERIC'] => en_GB.UTF-8
$_SERVER['OLDPWD'] => /home/umpirsky/Projects/chess.com
$_SERVER['ZSH'] => /home/umpirsky/.oh-my-zsh
$_SERVER['PAGER'] => less
$_SERVER['LESS'] => -R
$_SERVER['LSCOLORS'] => Gxfxcxdxbxegedabagacad
$_SERVER['LS_COLORS'] => rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
$_SERVER['LC_CTYPE'] => en_US.UTF-8
$_SERVER['_'] => /usr/bin/php
$_SERVER['PHP_SELF'] => 
$_SERVER['SCRIPT_NAME'] => 
$_SERVER['SCRIPT_FILENAME'] => 
$_SERVER['PATH_TRANSLATED'] => 
$_SERVER['DOCUMENT_ROOT'] => 
$_SERVER['REQUEST_TIME_FLOAT'] => 1506950927.0156
$_SERVER['REQUEST_TIME'] => 1506950927
$_SERVER['argv'] => Array
(
)

$_SERVER['argc'] => 0

PHP License
This program is free software; you can redistribute it and/or modify
it under the terms of the PHP License as published by the PHP Group
and included in the distribution in the file:  LICENSE

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

If you did not receive a copy of the PHP license, or have any
questions about PHP licensing, please contact [email protected].

Composer version in use?

BTW I'm not able to reproduce it with an isolated Docker env, using this command:

docker run --rm php:7.1.10-cli \
    curl -sS https://github.com/phpstan/phpstan/releases/download/0.8.4/phpstan.phar \
    && php ./phpstan.phar

Composer version 1.5.1 2017-08-09 16:07:22

Tried your docker command:

docker run --rm php:7.1.10-cli \
    curl -sS https://github.com/phpstan/phpstan/releases/download/0.8.4/phpstan.phar \
    && php ./phpstan.phar
Unable to find image 'php:7.1.10-cli' locally
7.1.10-cli: Pulling from library/php
aa18ad1a0d33: Pull complete 
29d5f85af454: Pull complete 
eca642e7826b: Pull complete 
dff3328cc427: Pull complete 
71edc0a65fa6: Pull complete 
7216d01164dd: Pull complete 
436741cba8f1: Pull complete 
Digest: sha256:8f2d107951a9295e4174b717ff46977ab053178ca602f9695c37e71a0922dba7
Status: Downloaded newer image for php:7.1.10-cli
<html><body>You are being <a href="https://github-production-release-asset-2e65be.s3.amazonaws.com/49014795/ff480f42-8980-11e7-8f76-eb9f4ad07bb3?X-Amz-Algorithm=AWS4-HMAC-SHA256&amp;X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20171002%2Fus-east-1%2Fs3%2Faws4_request&amp;X-Amz-Date=20171002T162239Z&amp;X-Amz-Expires=300&amp;X-Amz-Signature=38196c18ac0f584f11af175e47425e34b29d395d88cb877ed627cb909ff0df19&amp;X-Amz-SignedHeaders=host&amp;actor_id=0&amp;response-content-disposition=attachment%3B%20filename%3Dphpstan.phar&amp;response-content-type=application%2Foctet-stream">redirected</a>.</body></html>Could not open input file: ./phpstan.phar

Not sure why? Thanks.

Woha, it doesn't work for you even in an isolated Docker container? That's really strange!

@Jean85 My Docker skills are not very high but the commands is likely wrong, because the php ./phpstan.phar will be executed outside of the image because the && is processed by top-level bash, not by bash inside the image.

Thanks @JanTvrdik, you're absolutely right! My bash-fu is not so strong :smile:

The revised command is:

docker run --rm php:7.1.10-cli sh -c "curl -OJL https://github.com/phpstan/phpstan/releases/download/0.8.4/phpstan.phar && php ./phpstan.phar"

...and it works correctly for me:

$ docker run --rm php:7.1.10-cli sh -c "curl -OJL https://github.com/phpstan/phpstan/releases/download/0.8.4/phpstan.phar && php ./phpstan.phar"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   602    0   602    0     0   1248      0 --:--:-- --:--:-- --:--:--  1248
100 2377k  100 2377k    0     0  1009k      0  0:00:02  0:00:02 --:--:-- 1571k
curl: Saved to filename 'phpstan.phar'
PHPStan - PHP Static Analysis Tool 0.8.4.0

Usage:
  command [options] [arguments]

Options:
  -h, --help            Display this help message
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi            Force ANSI output
      --no-ansi         Disable ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
  analyse  [analyze] Analyses source code
  help     Displays help for a command
  list     Lists commands

Worked for me too, and now, I don't know how, but phpstan is magically working for me natively.

Mystery!

Maybe the project that you were using PHPStan on did something dodgy that broke everything?
BTW, happy to see your issue is resolved!

No idea. Thanks for your help!

I'm getting exactly the same error, it's somehow related to the working dir my own vendor/ folder.

[dado@fredo rollerworks-search]$ docker run -it --rm -v `pwd`:/project  jakzal/phpqa:alpine phpstan --version
PHPStan - PHP Static Analysis Tool 0.8.4.0
[dado@fredo rollerworks-search]$ docker run -it --rm -v `pwd`:/project -w /project jakzal/phpqa:alpine phpstan --version

Fatal error: Uncaught Error: Class 'PHPStanVendor\Jean85\PrettyVersions' not found in phar:///usr/local/bin/phpstan/bin/phpstan:23
Stack trace:
#0 /usr/local/bin/phpstan(4): require()
#1 {main}
  thrown in phar:///usr/local/bin/phpstan/bin/phpstan on line 23

Edit: I'm guessing PHAR is picking up my own vendor/ folder for some reason? If I delete it, it runs fine.

Steps to reproduce:

  1. phpstan.neon contains:
parameters:
    autoload_files:
        - vendor/autoload.php
    excludes_analyse:
        - vendor/
  1. in root of your project, containing your own vendor/, run
docker run -it --rm -v `pwd`:/project -w /project jakzal/phpqa:alpine phpstan analyse --configuration phpstan.neon --level max .

Should get the same error.

Oh, I had phpstan installed in my vendor/ too (migrating to a Docker-based solution). Once removed, it works as expected.

In any way, phar shouldn't really care about any of that, it should work regardless.

It seems that, for some strange reason, the PHAR cares about the local/global autoloader: https://github.com/Ocramius/PackageVersions/issues/48#issuecomment-338867092

@Jean85 Do you have a suggestion how to prevent this error in case both are installed?

Maybe generating a random namespace prefix in the PHAR? It's a hack, but since it's hard to pin down why this clash occurs...

I must admit that I do not understand the nature of the problem. The problem is Fatal error: Uncaught Error: Class 'PHPStanVendor\Jean85\PrettyVersions' not found. And the class exists in two versions when this occurs:

  • PHPStanVendorJean85\PrettyVersions from the PHAR
  • Jean85\PrettyVersions installed via composer locally/globally

So I don't get why does it result in this error.

Question is, why is PHAR allowing its autoloader to get overriden? Shouldn't it all be baked in by default?

PHPStan needs to autoload classes from the analyzed project.

So, is this error coming from the autoloader loading PHPStan itself or PHPStan's autoloader? It seems like the former, still feels like that autoloader should be untouched by the project's autoloader.

Basically, PHPStan should use own autoloader for itself always, they shouldn't come into contact.

Umh.... maybe the autoloaders are not chained correctly and the local one overrides the one inside the PHAR?

That's exactly what I'm thinking. So, autoloader loading PHPStan (ALPS) should be classmap-based, and the class map is built when the PHAR is built. After that, PHPStan's autoloader (PSA) which is probably just loading the project's autoload.php would kick in.

This way, the autoload process would go

  1. ALPS
  2. PSA
  3. project's autoloader

If PHAR is trying to load itself, it would always succeed in 1) and it should never reach beyond that. Everything else is loaded from 2) forward (ALPS always misses). It probably works like this already, but something is off by one somewhere. I'm guessing so because PSA is error-managed by PHPStan already, ALPS isn't.

ping

@dinamic Why are you pinging? This is not a solved issue, if you have a solution, I'm open for it.

The problem is that globally and locally installed PHPStan instances clash. So if you see this error it means that you're either:

1) Running a locally installed PHPStan (meaning in a project) while there's one installed globally (using composer require -g.
2) Running a globally installed PHPStan (using composer require -g) while there's one installed localy in a project.

Steps to reproduce in my instance:

  • use docker to run phpstan
  • composer require phpstan/phpstan-phpunit --dev into the project
  • try to invoke it

Requiring phpstan/phpstan-phpunit would require also phpstan/phpstan, which seems to be causing the problem here.

Maybe phpstan/phpstan-phpunit can suggest phpstan/phpstan, but not require it?

@ondrejmirtes, just suggested a solution. Maybe we were typing at the same time.

@dinamic You have a completely different problem and this error is just a side effect. When using PHPStan with its extensions, they have to see each other. So when using the docker image, you have to install PHPStan extensions alongside PHPStan. See "Install PHPStan extensions" at https://github.com/phpstan/docker-image/blob/master/README.md

I'm using jakzal's phpqa docker image, so I will request the extension to be installed there.

Thanks for the solution, @ondrejmirtes! Much appreciated!

Was this page helpful?
0 / 5 - 0 ratings