Skip to content

Commit

Permalink
Merge branch 'release/0.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
bobthecow committed Dec 16, 2014
2 parents 6be7c75 + 0b72360 commit bbd62e4
Show file tree
Hide file tree
Showing 46 changed files with 468 additions and 88 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ vendor/
composer.lock
manual/
__pycache__
.php_cs.cache
18 changes: 9 additions & 9 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?php

use Symfony\CS\Config\Config;
use Symfony\CS\Fixer;
use Symfony\CS\FixerInterface;

$config = new Config();
$config = Config::create()
// use default level and extra fixers:
->fixers(array('-concat_without_spaces', 'concat_with_spaces', 'strict'))
->setUsingCache(true)
->setUsingLinter(false);

$config->fixers(array('-concat_without_spaces', 'concat_with_spaces'));
$finder = $config->getFinder()
->in('src')
->in('test');

$config->getFinder()
->in(__DIR__)
->exclude('bin')
->exclude('vendor');

return $config;
return $config;
23 changes: 15 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
language: php

php:
- 5.3
- 5.4
- 5.5
- 5.6
- hhvm
- 5.3
- 5.4
- 5.5
- 5.6
- hhvm

install:
- travis_retry composer install --no-interaction --prefer-source

before_script:
- composer install
script:
- vendor/bin/phpunit
- vendor/bin/phpcs -n --standard=phpcs.xml ./
- vendor/bin/php-cs-fixer --diff --dry-run -vv fix

matrix:
allow_failures:
- php: hhvm
- php: hhvm
fast_finish: true
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## Code style

Please make your code look like the other code in the project. PsySH follows [PSR-1](http://php-fig.org/psr/psr-1/) and [PSR-2](http://php-fig.org/psr/psr-2/). The easiest way to do make sure you're following the coding standard is to run `vendor/bin/php-cs-fixer fix` before committing.


## Building the manual

```sh
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# PsySH

[![Package version](http://img.shields.io/packagist/v/psy/psysh.svg)](https://packagist.org/packages/psy/psysh)
[![Build status](http://img.shields.io/travis/bobthecow/psysh/master.svg)](http://travis-ci.org/bobthecow/psysh)
[![Made out of awesome](http://img.shields.io/badge/made_out_of_awesome-✓-brightgreen.svg)](http://psysh.org)
[![Package version](http://img.shields.io/packagist/v/psy/psysh.svg?style=flat-square)](https://packagist.org/packages/psy/psysh)
[![Build status](http://img.shields.io/travis/bobthecow/psysh/master.svg?style=flat-square)](http://travis-ci.org/bobthecow/psysh)
[![Made out of awesome](http://img.shields.io/badge/made_out_of_awesome-✓-brightgreen.svg?style=flat-square)](http://psysh.org)

Check out the [Interactive Debugging in PHP talk from OSCON](https://presentate.com/bobthecow/talks/php-for-pirates) on Presentate.

Expand Down
10 changes: 7 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,24 @@
],
"require": {
"php": ">=5.3.0",
"symfony/console": ">=2.3.10, <2.6.0",
"symfony/console": "~2.3.10|~2.4.2|~2.5",
"nikic/php-parser": "~1.0",
"dnoegel/php-xdg-base-dir": "0.1"
"dnoegel/php-xdg-base-dir": "0.1",
"jakub-onderka/php-console-highlighter": "dev-master"
},
"require-dev": {
"phpunit/phpunit": ">=3.7, <4.3",
"symfony/finder": "~2.1"
"symfony/finder": "~2.1",
"squizlabs/php_codesniffer": "~2.0",
"fabpot/php-cs-fixer": "2.0.*@dev"
},
"suggest": {
"ext-pcntl": "Enabling the PCNTL extension makes PsySH a lot happier :)",
"ext-posix": "If you have PCNTL, you'll want the POSIX extension as well.",
"ext-readline": "Enables support for arrow-key history navigation, and showing and manipulating command history."
},
"autoload": {
"files": ["src/Psy/functions.php"],
"psr-0": {
"Psy\\": "src/"
}
Expand Down
11 changes: 11 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0"?>
<ruleset name="PsySH Coding Standard">
<description>The coding standard for PsySH</description>

<exclude-pattern>*/bin/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>

<rule ref="PSR2">
<exclude name="Generic.Functions.FunctionCallArgumentSpacing.TooMuchSpaceAfterComma"/>
</rule>
</ruleset>
2 changes: 2 additions & 0 deletions src/Psy/CodeCleaner.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Psy\CodeCleaner\ImplicitReturnPass;
use Psy\CodeCleaner\InstanceOfPass;
use Psy\CodeCleaner\LeavePsyshAlonePass;
use Psy\CodeCleaner\LegacyEmptyPass;
use Psy\CodeCleaner\MagicConstantsPass;
use Psy\CodeCleaner\NamespacePass;
use Psy\CodeCleaner\StaticConstructorPass;
Expand Down Expand Up @@ -76,6 +77,7 @@ private function getDefaultPasses()
new CalledClassPass(),
new InstanceOfPass(),
new LeavePsyshAlonePass(),
new LegacyEmptyPass(),
new ImplicitReturnPass(),
new UseStatementPass(), // must run before namespace and validation passes
new NamespacePass($this), // must run after the implicit return pass
Expand Down
64 changes: 64 additions & 0 deletions src/Psy/CodeCleaner/LegacyEmptyPass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

/*
* This file is part of Psy Shell
*
* (c) 2012-2014 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\Expr\Empty_ as ExprEmpty;
use PhpParser\Node\Expr\Variable;
use Psy\Exception\ParseErrorException;

/**
* Validate that the user did not call the language construct `empty()` on a
* statement in PHP < 5.5.
*/
class LegacyEmptyPass extends CodeCleanerPass
{
/**
* Validate use of empty in PHP < 5.5.
*
* @throws ParseErrorException if the user used empty with anything but a variable.
*
* @param Node $node
*/
public function enterNode(Node $node)
{
if (version_compare(PHP_VERSION, '5.5', '>=')) {
return;
}

if (!$node instanceof ExprEmpty) {
return;
}

if (!$node->expr instanceof Variable) {
$msg = sprintf('syntax error, unexpected %s', $this->getUnexpectedThing($node->expr));

throw new ParseErrorException($msg, $node->expr->getLine());
}
}

private function getUnexpectedThing(Node $node)
{
switch ($node->getType()) {
case 'Scalar_String':
case 'Scalar_LNumber':
case 'Scalar_DNumber':
return json_encode($node->value);

case 'Expr_ConstFetch':
return (string) $node->name;

default:
return $node->getType();
}
}
}
2 changes: 1 addition & 1 deletion src/Psy/CodeCleaner/UseStatementPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function enterNode(Node $node)
if ($node instanceof NamespaceStmt) {
// If this is the same namespace as last namespace, let's do ourselves
// a favor and reload all the aliases...
if (strtolower($node->name) == strtolower($this->lastNamespace)) {
if (strtolower($node->name) === strtolower($this->lastNamespace)) {
$this->aliases = $this->lastAliases;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Psy/CodeCleaner/ValidClassNamePass.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ protected function getScopeType(Stmt $stmt)
*/
protected function classExists($name)
{
return class_exists($name) || $this->findInScope($name) == self::CLASS_TYPE;
return class_exists($name) || $this->findInScope($name) === self::CLASS_TYPE;
}

/**
Expand All @@ -207,7 +207,7 @@ protected function classExists($name)
*/
protected function interfaceExists($name)
{
return interface_exists($name) || $this->findInScope($name) == self::INTERFACE_TYPE;
return interface_exists($name) || $this->findInScope($name) === self::INTERFACE_TYPE;
}

/**
Expand All @@ -219,7 +219,7 @@ protected function interfaceExists($name)
*/
protected function traitExists($name)
{
return $this->checkTraits && (trait_exists($name) || $this->findInScope($name) == self::TRAIT_TYPE);
return $this->checkTraits && (trait_exists($name) || $this->findInScope($name) === self::TRAIT_TYPE);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Psy/Command/BufferCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ protected function configure()
new InputOption('clear', '', InputOption::VALUE_NONE, 'Clear the current buffer.'),
))
->setDescription('Show (or clear) the contents of the code input buffer.')
->setHelp(<<<HELP
->setHelp(
<<<HELP
Show the contents of the code buffer for the current multi-line expression.
Optionally, clear the buffer by passing the <info>--clear</info> option.
Expand Down
3 changes: 2 additions & 1 deletion src/Psy/Command/ClearCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ protected function configure()
->setName('clear')
->setDefinition(array())
->setDescription('Clear the Psy Shell screen.')
->setHelp(<<<HELP
->setHelp(
<<<HELP
Clear the Psy Shell screen.
Pro Tip: If your PHP has readline support, you should be able to use ctrl+l too!
Expand Down
3 changes: 2 additions & 1 deletion src/Psy/Command/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ private function optionsAsText()
$description = str_replace("\n", "\n" . str_pad('', $max + 2, ' '), $option->getDescription());

$optionMax = $max - strlen($option->getName()) - 2;
$messages[] = sprintf(" <info>%s</info> %-${optionMax}s%s%s%s",
$messages[] = sprintf(
" <info>%s</info> %-${optionMax}s%s%s%s",
'--' . $option->getName(),
$option->getShortcut() ? sprintf('(-%s) ', $option->getShortcut()) : '',
$description,
Expand Down
3 changes: 2 additions & 1 deletion src/Psy/Command/DocCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ protected function configure()
new InputArgument('value', InputArgument::REQUIRED, 'Function, class, instance, constant, method or property to document.'),
))
->setDescription('Read the documentation for an object, class, constant, method or property.')
->setHelp(<<<HELP
->setHelp(
<<<HELP
Read the documentation for an object, class, constant, method or property.
It's awesome for well-documented code, not quite as awesome for poorly documented code.
Expand Down
3 changes: 2 additions & 1 deletion src/Psy/Command/DumpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ protected function configure()
new InputOption('all', 'a', InputOption::VALUE_NONE, 'Include private and protected methods and properties.'),
))
->setDescription('Dump an object or primitive.')
->setHelp(<<<HELP
->setHelp(
<<<HELP
Dump an object or primitive.
This is like var_dump but <strong>way</strong> awesomer.
Expand Down
3 changes: 2 additions & 1 deletion src/Psy/Command/ExitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ protected function configure()
->setAliases(array('quit', 'q'))
->setDefinition(array())
->setDescription('End the current session and return to caller.')
->setHelp(<<<HELP
->setHelp(
<<<HELP
End the current session and return to caller.
e.g.
Expand Down
5 changes: 3 additions & 2 deletions src/Psy/Command/HistoryCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ protected function configure()
new InputOption('clear', '', InputOption::VALUE_NONE, 'Clear the history.'),
))
->setDescription('Show the Psy Shell history.')
->setHelp(<<<HELP
->setHelp(
<<<HELP
Show, search, save or replay the Psy Shell history.
e.g.
Expand Down Expand Up @@ -130,7 +131,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

$count = count($history);
$output->writeln(sprintf('Replaying %d line%s of history', $count, ($count != 1) ? 's' : ''));
$output->writeln(sprintf('Replaying %d line%s of history', $count, ($count !== 1) ? 's' : ''));
$this->getApplication()->addInput($history);
} elseif ($input->getOption('clear')) {
$this->clearHistory();
Expand Down
3 changes: 2 additions & 1 deletion src/Psy/Command/ListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ protected function configure()
new InputOption('long', 'l', InputOption::VALUE_NONE, 'List in long format: includes class names and method signatures.'),
))
->setDescription('List local, instance or class variables, methods and constants.')
->setHelp(<<<HELP
->setHelp(
<<<HELP
List variables, constants, classes, interfaces, traits, functions, methods,
and properties.
Expand Down
8 changes: 4 additions & 4 deletions src/Psy/Command/ListCommand/VariableEnumerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ protected function getVariables($showAll)
{
$scopeVars = $this->context->getAll();
uksort($scopeVars, function ($a, $b) {
if ($a == '_e') {
if ($a === '_e') {
return 1;
} elseif ($b == '_e') {
} elseif ($b === '_e') {
return -1;
} elseif ($a == '_') {
} elseif ($a === '_') {
return 1;
} elseif ($b == '_') {
} elseif ($b === '_') {
return -1;
} else {
// TODO: this should be natcasesort
Expand Down
3 changes: 2 additions & 1 deletion src/Psy/Command/ParseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ protected function configure()
new InputOption('depth', '', InputOption::VALUE_REQUIRED, 'Depth to parse', 10),
))
->setDescription('Parse PHP code and show the abstract syntax tree.')
->setHelp(<<<HELP
->setHelp(
<<<HELP
Parse PHP code and show the abstract syntax tree.
This command is used in the development of PsySH. Given a string of PHP code,
Expand Down
4 changes: 2 additions & 2 deletions src/Psy/Command/ReflectingCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ protected function getTarget($valueName, $classOnly = false)
return array($this->resolveName($matches[1]), $matches[2], Mirror::STATIC_PROPERTY | Mirror::PROPERTY);

case (!$classOnly && preg_match(self::INSTANCE_MEMBER, $valueName, $matches)):
if ($matches[2] == '->') {
if ($matches[2] === '->') {
$kind = Mirror::METHOD | Mirror::PROPERTY;
} else {
$kind = Mirror::CONSTANT | Mirror::METHOD;
Expand Down Expand Up @@ -124,7 +124,7 @@ protected function resolveName($name, $includeFunctions = false)
*/
protected function getTargetAndReflector($valueName, $classOnly = false)
{
list ($value, $member, $kind) = $this->getTarget($valueName, $classOnly);
list($value, $member, $kind) = $this->getTarget($valueName, $classOnly);

return array($value, Mirror::get($value, $member, $kind));
}
Expand Down
3 changes: 2 additions & 1 deletion src/Psy/Command/ShowCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ protected function configure()
new InputArgument('value', InputArgument::REQUIRED, 'Function, class, instance, constant, method or property to show.'),
))
->setDescription('Show the code for an object, class, constant, method or property.')
->setHelp(<<<HELP
->setHelp(
<<<HELP
Show the code for an object, class, constant, method or property.
e.g.
Expand Down
Loading

0 comments on commit bbd62e4

Please sign in to comment.