Skip to content

Commit

Permalink
Merge branch 'release/0.8.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
bobthecow committed Mar 1, 2017
2 parents 701e8a1 + 9460a7e commit 97113db
Show file tree
Hide file tree
Showing 177 changed files with 950 additions and 295 deletions.
46 changes: 46 additions & 0 deletions .phan/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

/**
* This configuration will be read and overlaid on top of the
* default configuration. Command line arguments will be applied
* after this file is read.
*/
return [

// A list of directories that should be parsed for class and
// method information. After excluding the directories
// defined in exclude_analysis_directory_list, the remaining
// files will be statically analyzed for errors.
//
// Thus, both first-party and third-party code being used by
// your application should be included in this list.
'directory_list' => [
'src/',
'vendor/dnoegel/php-xdg-base-dir/src/',
'vendor/doctrine/instantiator/src/',
'vendor/hoa/console/',
'vendor/jakub-onderka/php-console-color/src/',
'vendor/jakub-onderka/php-console-highlighter/src/',
'vendor/nikic/php-parser/lib/',
'vendor/phpdocumentor/reflection-docblock/',
'vendor/symfony/console/',
'vendor/symfony/filesystem/',
'vendor/symfony/finder/',
'vendor/symfony/var-dumper/',
],

// A directory list that defines files that will be excluded
// from static analysis, but whose class and method
// information should be included.
//
// Generally, you'll want to include the directories for
// third-party code (such as "vendor/") in this list.
//
// n.b.: If you'd like to parse but not analyze 3rd
// party code, directories containing that code
// should be added to both the `directory_list`
// and `exclude_analysis_directory_list` arrays.
"exclude_analysis_directory_list" => [
'vendor/'
],
];
3 changes: 2 additions & 1 deletion .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use Symfony\CS\Fixer\Contrib\HeaderCommentFixer;
$header = <<<EOF
This file is part of Psy Shell.
(c) 2012-2015 Justin Hileman
(c) 2012-2017 Justin Hileman
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
Expand All @@ -30,6 +30,7 @@ $config = Config::create()
'-pre_increment',
'-unalign_double_arrow',
'-unalign_equals',
'-no_empty_comment', // stop removing slashes in the middle of multi-line comments
))
->setUsingLinter(false);

Expand Down
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ install:

script:
- vendor/bin/phpunit
# - '[[ "$TRAVIS_PHP_VERSION" != 7.1* ]] || bin/build'

before_deploy:
- bin/package -v $TRAVIS_TAG
Expand All @@ -53,4 +54,4 @@ deploy:
on:
tags: true
repo: bobthecow/psysh
condition: ($TRAVIS_PHP_VERSION = 5.3* || $TRAVIS_PHP_VERSION = 7.0*) && -z "$COMPOSER_FLAGS"
condition: ($TRAVIS_PHP_VERSION = 5.3* || $TRAVIS_PHP_VERSION = 7.1*) && -z "$COMPOSER_FLAGS"
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2012-2015 Justin Hileman
Copyright (c) 2012-2017 Justin Hileman

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ return array(
//
// To disable update checks entirely, set to 'never'.
'updateCheck' => 'daily',

// Display an additional startup message. Default is ''.
// You can color and style the message thanks to the Symfony Console tags.
// See https://symfony.com/doc/current/console/coloring.html for more details.
'startupMessage' => sprintf('<info>%s</info>', shell_exec('uptime')),
);
```

Expand Down Expand Up @@ -178,7 +183,7 @@ The PsySH `doc` command is great for documenting source code, but you'll need a
* Drupal: [`drush php`](http://drushcommands.com/drush-8x/core/core-cli/), [drush-psysh](https://github.com/grota/drush-psysh)
* eZ Publish: [`ezsh`](https://github.com/lolautruche/ezsh)
* Jupyter: [Jupyter-PHP](https://github.com/Litipk/Jupyter-PHP)
* Laravel: [`artisan tinker`](https://github.com/laravel/framework/blob/5.0/src/Illuminate/Foundation/Console/TinkerCommand.php)
* Laravel: [`artisan tinker`](https://github.com/laravel/tinker)
* Lumen: [`artisan tinker`](https://github.com/vluzrmos/lumen-tinker)
* Magento: [`magerun console`](https://github.com/netz98/n98-magerun/blob/develop/src/N98/Magento/Command/Developer/ConsoleCommand.php)
* Pantheon CLI: [`terminus cli console`](https://github.com/pantheon-systems/terminus)
Expand Down
8 changes: 5 additions & 3 deletions bin/build
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#!/usr/bin/env bash

set -ev

cd "${BASH_SOURCE%/*}/.."

echo "Building phar"
./bin/build-vendor || exit 1
./bin/build-phar || exit 1
./bin/build-vendor
./bin/build-phar

echo "Building compat phar"
./bin/build-vendor-compat || exit 1
./bin/build-vendor-compat
./bin/build-phar --compat
2 changes: 1 addition & 1 deletion bin/build-manual
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/*
* This file is part of Psy Shell.
*
* (c) 2012-2015 Justin Hileman
* (c) 2012-2017 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
2 changes: 1 addition & 1 deletion bin/build-phar
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/*
* This file is part of Psy Shell.
*
* (c) 2012-2015 Justin Hileman
* (c) 2012-2017 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
4 changes: 3 additions & 1 deletion bin/build-vendor
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/usr/bin/env bash

set -ev

cd "${BASH_SOURCE%/*}/.."

rm -rf build-vendor

COMPOSER_VENDOR_DIR=build-vendor composer update --prefer-stable --no-dev --no-progress --classmap-authoritative
COMPOSER_VENDOR_DIR=build-vendor composer update --prefer-stable --no-dev --no-progress --classmap-authoritative --no-interaction --verbose
6 changes: 4 additions & 2 deletions bin/build-vendor-compat
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bash

set -ev

cd "${BASH_SOURCE%/*}/.."

rm -rf build-vendor
Expand All @@ -12,8 +14,8 @@ if [[ $(php --version) = PHP\ 5.3* ]]; then
fi

COMPOSER=composer-compat.json COMPOSER_VENDOR_DIR=build-vendor \
composer require symfony/intl hoa/console $HOA_VERSION --no-progress --no-update
composer require symfony/intl hoa/console $HOA_VERSION --no-progress --no-update --no-interaction --verbose

COMPOSER=composer-compat.json COMPOSER_VENDOR_DIR=build-vendor \
composer update --prefer-stable --no-dev --no-progress --classmap-authoritative
composer update --prefer-stable --no-dev --no-progress --classmap-authoritative --no-interaction --verbose

6 changes: 4 additions & 2 deletions bin/package
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bash

set -ev

cd "${BASH_SOURCE%/*}/.."

USAGE="usage: bin/package [-v PACKAGE_VERSION]"
Expand Down Expand Up @@ -34,7 +36,7 @@ echo "Creating tarballs"
mkdir -p dist || exit 1

if [ -z "$PKG_VERSION" ]; then
PKG_VERSION=$(git describe --tag --exact-match) || exit 1
PKG_VERSION=$(git describe --tag --exact-match)
if [[ $(php --version) = PHP\ 5.3* ]]; then
PKG_VERSION=${PKG_VERSION}-php53
fi
Expand All @@ -46,5 +48,5 @@ if [[ $(tar --version) = bsdtar* ]]; then
TAR_FLAGS='-s /.*/psysh/'
fi

tar $TAR_FLAGS -czf dist/psysh-${PKG_VERSION}.tar.gz psysh.phar || exit 1
tar $TAR_FLAGS -czf dist/psysh-${PKG_VERSION}.tar.gz psysh.phar
tar $TAR_FLAGS -czf dist/psysh-${PKG_VERSION}-compat.tar.gz psysh-compat.phar
2 changes: 1 addition & 1 deletion bin/psysh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/*
* This file is part of Psy Shell.
*
* (c) 2012-2015 Justin Hileman
* (c) 2012-2017 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
2 changes: 1 addition & 1 deletion src/Psy/Autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of Psy Shell.
*
* (c) 2012-2015 Justin Hileman
* (c) 2012-2017 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
4 changes: 3 additions & 1 deletion src/Psy/CodeCleaner.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of Psy Shell.
*
* (c) 2012-2015 Justin Hileman
* (c) 2012-2017 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -19,6 +19,7 @@
use Psy\CodeCleaner\CalledClassPass;
use Psy\CodeCleaner\CallTimePassByReferencePass;
use Psy\CodeCleaner\ExitPass;
use Psy\CodeCleaner\FinalClassPass;
use Psy\CodeCleaner\FunctionReturnInWriteContextPass;
use Psy\CodeCleaner\ImplicitReturnPass;
use Psy\CodeCleaner\InstanceOfPass;
Expand Down Expand Up @@ -83,6 +84,7 @@ private function getDefaultPasses()
new CallTimePassByReferencePass(),
new PassableByReferencePass(),
new CalledClassPass(),
new FinalClassPass(),
new InstanceOfPass(),
new LeavePsyshAlonePass(),
new LegacyEmptyPass(),
Expand Down
2 changes: 1 addition & 1 deletion src/Psy/CodeCleaner/AbstractClassPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of Psy Shell.
*
* (c) 2012-2015 Justin Hileman
* (c) 2012-2017 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
2 changes: 1 addition & 1 deletion src/Psy/CodeCleaner/AssignThisVariablePass.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of Psy Shell.
*
* (c) 2012-2015 Justin Hileman
* (c) 2012-2017 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
2 changes: 1 addition & 1 deletion src/Psy/CodeCleaner/CallTimePassByReferencePass.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of Psy Shell.
*
* (c) 2012-2015 Justin Hileman
* (c) 2012-2017 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
2 changes: 1 addition & 1 deletion src/Psy/CodeCleaner/CalledClassPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of Psy Shell.
*
* (c) 2012-2015 Justin Hileman
* (c) 2012-2017 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
2 changes: 1 addition & 1 deletion src/Psy/CodeCleaner/CodeCleanerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of Psy Shell.
*
* (c) 2012-2015 Justin Hileman
* (c) 2012-2017 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
2 changes: 1 addition & 1 deletion src/Psy/CodeCleaner/ExitPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of Psy Shell.
*
* (c) 2012-2015 Justin Hileman
* (c) 2012-2017 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
70 changes: 70 additions & 0 deletions src/Psy/CodeCleaner/FinalClassPass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

/*
* This file is part of Psy Shell.
*
* (c) 2012-2017 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Psy\CodeCleaner;

use PhpParser\Node;
use PhpParser\Node\Stmt\Class_ as ClassStmt;
use Psy\Exception\FatalErrorException;

/**
* The final class pass handles final classes.
*/
class FinalClassPass extends CodeCleanerPass
{
private $finalClasses;

/**
* @param array $nodes
*/
public function beforeTraverse(array $nodes)
{
$this->finalClasses = array();
}

/**
* @throws RuntimeException if the node is a class that extends a final class
*
* @param Node $node
*/
public function enterNode(Node $node)
{
if ($node instanceof ClassStmt) {
if ($node->extends) {
$extends = (string) $node->extends;
if ($this->isFinalClass($extends)) {
$msg = sprintf('Class %s may not inherit from final class (%s)', $node->name, $extends);
throw new FatalErrorException($msg);
}
}

if ($node->isFinal()) {
$this->finalClasses[strtolower($node->name)] = true;
}
}
}

/**
* @param string $name Class name
*
* @return bool
*/
private function isFinalClass($name)
{
if (!class_exists($name)) {
return isset($this->finalClasses[strtolower($name)]);
}

$refl = new \ReflectionClass($name);

return $refl->isFinal();
}
}
2 changes: 1 addition & 1 deletion src/Psy/CodeCleaner/FunctionReturnInWriteContextPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of Psy Shell.
*
* (c) 2012-2015 Justin Hileman
* (c) 2012-2017 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
2 changes: 1 addition & 1 deletion src/Psy/CodeCleaner/ImplicitReturnPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of Psy Shell.
*
* (c) 2012-2015 Justin Hileman
* (c) 2012-2017 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
2 changes: 1 addition & 1 deletion src/Psy/CodeCleaner/InstanceOfPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of Psy Shell.
*
* (c) 2012-2015 Justin Hileman
* (c) 2012-2017 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
2 changes: 1 addition & 1 deletion src/Psy/CodeCleaner/LeavePsyshAlonePass.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of Psy Shell.
*
* (c) 2012-2015 Justin Hileman
* (c) 2012-2017 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
Loading

0 comments on commit 97113db

Please sign in to comment.