Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
129
vendor/psy/psysh/test/Formatter/CodeFormatterTest.php
vendored
Normal file
129
vendor/psy/psysh/test/Formatter/CodeFormatterTest.php
vendored
Normal file
|
@ -0,0 +1,129 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2018 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Psy\Test\Formatter;
|
||||
|
||||
use Psy\Formatter\CodeFormatter;
|
||||
use Psy\Test\Formatter\Fixtures\SomeClass;
|
||||
|
||||
class CodeFormatterTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider reflectors
|
||||
*/
|
||||
public function testFormat($reflector, $expected)
|
||||
{
|
||||
$formatted = CodeFormatter::format($reflector);
|
||||
$formattedWithoutColors = \preg_replace('#' . \chr(27) . '\[\d\d?m#', '', $formatted);
|
||||
|
||||
$this->assertEquals($expected, self::trimLines($formattedWithoutColors));
|
||||
$this->assertNotEquals($expected, self::trimLines($formatted));
|
||||
}
|
||||
|
||||
public function reflectors()
|
||||
{
|
||||
$expectClass = <<<'EOS'
|
||||
> 14| class SomeClass
|
||||
15| {
|
||||
16| const SOME_CONST = 'some const';
|
||||
17| private $someProp = 'some prop';
|
||||
18|
|
||||
19| public function someMethod($someParam)
|
||||
20| {
|
||||
21| return 'some method';
|
||||
22| }
|
||||
23|
|
||||
24| public static function someClosure()
|
||||
25| {
|
||||
26| return function () {
|
||||
27| return 'some closure';
|
||||
28| };
|
||||
29| }
|
||||
30| }
|
||||
EOS;
|
||||
|
||||
$expectMethod = <<<'EOS'
|
||||
> 19| public function someMethod($someParam)
|
||||
20| {
|
||||
21| return 'some method';
|
||||
22| }
|
||||
EOS;
|
||||
|
||||
$expectClosure = <<<'EOS'
|
||||
> 26| return function () {
|
||||
27| return 'some closure';
|
||||
28| };
|
||||
EOS;
|
||||
|
||||
return [
|
||||
[new \ReflectionClass('Psy\Test\Formatter\Fixtures\SomeClass'), $expectClass],
|
||||
[new \ReflectionObject(new SomeClass()), $expectClass],
|
||||
[new \ReflectionMethod('Psy\Test\Formatter\Fixtures\SomeClass', 'someMethod'), $expectMethod],
|
||||
[new \ReflectionFunction(SomeClass::someClosure()), $expectClosure],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider invalidReflectors
|
||||
* @expectedException \Psy\Exception\RuntimeException
|
||||
*/
|
||||
public function testCodeFormatterThrowsExceptionForReflectorsItDoesntUnderstand($reflector)
|
||||
{
|
||||
CodeFormatter::format($reflector);
|
||||
}
|
||||
|
||||
public function invalidReflectors()
|
||||
{
|
||||
$reflectors = [
|
||||
[new \ReflectionExtension('json')],
|
||||
[new \ReflectionParameter(['Psy\Test\Formatter\Fixtures\SomeClass', 'someMethod'], 'someParam')],
|
||||
[new \ReflectionProperty('Psy\Test\Formatter\Fixtures\SomeClass', 'someProp')],
|
||||
];
|
||||
|
||||
if (\version_compare(PHP_VERSION, '7.1.0', '>=')) {
|
||||
$reflectors[] = [new \ReflectionClassConstant('Psy\Test\Formatter\Fixtures\SomeClass', 'SOME_CONST')];
|
||||
}
|
||||
|
||||
return $reflectors;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider filenames
|
||||
* @expectedException \Psy\Exception\RuntimeException
|
||||
*/
|
||||
public function testCodeFormatterThrowsExceptionForMissingFile($filename)
|
||||
{
|
||||
$reflector = $this->getMockBuilder('ReflectionClass')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$reflector
|
||||
->expects($this->once())
|
||||
->method('getFileName')
|
||||
->will($this->returnValue($filename));
|
||||
|
||||
CodeFormatter::format($reflector);
|
||||
}
|
||||
|
||||
public function filenames()
|
||||
{
|
||||
if (\defined('HHVM_VERSION')) {
|
||||
$this->markTestSkipped('We have issues with PHPUnit mocks on HHVM.');
|
||||
}
|
||||
|
||||
return [[null], ['not a file']];
|
||||
}
|
||||
|
||||
private static function trimLines($code)
|
||||
{
|
||||
return \rtrim(\implode("\n", \array_map('rtrim', \explode("\n", $code))));
|
||||
}
|
||||
}
|
63
vendor/psy/psysh/test/Formatter/DocblockFormatterTest.php
vendored
Normal file
63
vendor/psy/psysh/test/Formatter/DocblockFormatterTest.php
vendored
Normal file
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2018 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Psy\Test\Formatter;
|
||||
|
||||
use Psy\Formatter\DocblockFormatter;
|
||||
|
||||
class DocblockFormatterTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* This is a docblock!
|
||||
*
|
||||
* @author Justin Hileman <justin@justinhileman.info>
|
||||
*
|
||||
* @throws InvalidArgumentException if $foo is empty
|
||||
*
|
||||
* @param mixed $foo It's a foo thing
|
||||
* @param int $bar This is definitely bar
|
||||
*
|
||||
* @return string A string of no consequence
|
||||
*/
|
||||
private function methodWithDocblock($foo, $bar = 1)
|
||||
{
|
||||
if (empty($foo)) {
|
||||
throw new \InvalidArgumentException();
|
||||
}
|
||||
|
||||
return 'method called';
|
||||
}
|
||||
|
||||
public function testFormat()
|
||||
{
|
||||
$expected = <<<EOS
|
||||
<comment>Description:</comment>
|
||||
This is a docblock!
|
||||
|
||||
<comment>Throws:</comment>
|
||||
<info>InvalidArgumentException </info> if \$foo is empty
|
||||
|
||||
<comment>Param:</comment>
|
||||
<info>mixed </info> <strong>\$foo </strong> It's a foo thing
|
||||
<info>int </info> <strong>\$bar </strong> This is definitely bar
|
||||
|
||||
<comment>Return:</comment>
|
||||
<info>string </info> A string of no consequence
|
||||
|
||||
<comment>Author:</comment> Justin Hileman \<justin@justinhileman.info>
|
||||
EOS;
|
||||
|
||||
$this->assertSame(
|
||||
$expected,
|
||||
DocblockFormatter::format(new \ReflectionMethod($this, 'methodWithDocblock'))
|
||||
);
|
||||
}
|
||||
}
|
20
vendor/psy/psysh/test/Formatter/Fixtures/BoringTrait.php
vendored
Normal file
20
vendor/psy/psysh/test/Formatter/Fixtures/BoringTrait.php
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2018 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Psy\Test\Formatter\Fixtures;
|
||||
|
||||
trait BoringTrait
|
||||
{
|
||||
public function boringMethod($one = 1)
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
}
|
30
vendor/psy/psysh/test/Formatter/Fixtures/SomeClass.php
vendored
Normal file
30
vendor/psy/psysh/test/Formatter/Fixtures/SomeClass.php
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2018 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Psy\Test\Formatter\Fixtures;
|
||||
|
||||
class SomeClass
|
||||
{
|
||||
const SOME_CONST = 'some const';
|
||||
private $someProp = 'some prop';
|
||||
|
||||
public function someMethod($someParam)
|
||||
{
|
||||
return 'some method';
|
||||
}
|
||||
|
||||
public static function someClosure()
|
||||
{
|
||||
return function () {
|
||||
return 'some closure';
|
||||
};
|
||||
}
|
||||
}
|
95
vendor/psy/psysh/test/Formatter/SignatureFormatterTest.php
vendored
Normal file
95
vendor/psy/psysh/test/Formatter/SignatureFormatterTest.php
vendored
Normal file
|
@ -0,0 +1,95 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2018 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Psy\Test\Formatter;
|
||||
|
||||
use Psy\Formatter\SignatureFormatter;
|
||||
use Psy\Reflection\ReflectionClassConstant;
|
||||
use Psy\Reflection\ReflectionConstant_;
|
||||
|
||||
class SignatureFormatterTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
const FOO = 'foo value';
|
||||
private static $bar = 'bar value';
|
||||
|
||||
private function someFakeMethod(array $one, $two = 'TWO', \Reflector $three = null)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider signatureReflectors
|
||||
*/
|
||||
public function testFormat($reflector, $expected)
|
||||
{
|
||||
$this->assertSame($expected, \strip_tags(SignatureFormatter::format($reflector)));
|
||||
}
|
||||
|
||||
public function signatureReflectors()
|
||||
{
|
||||
return [
|
||||
[
|
||||
new \ReflectionFunction('implode'),
|
||||
\defined('HHVM_VERSION') ? 'function implode($arg1, $arg2 = null)' : 'function implode($glue, $pieces)',
|
||||
],
|
||||
[
|
||||
ReflectionClassConstant::create($this, 'FOO'),
|
||||
'const FOO = "foo value"',
|
||||
],
|
||||
[
|
||||
new \ReflectionMethod($this, 'someFakeMethod'),
|
||||
'private function someFakeMethod(array $one, $two = \'TWO\', Reflector $three = null)',
|
||||
],
|
||||
[
|
||||
new \ReflectionProperty($this, 'bar'),
|
||||
'private static $bar',
|
||||
],
|
||||
[
|
||||
new \ReflectionClass('Psy\CodeCleaner\CodeCleanerPass'),
|
||||
'abstract class Psy\CodeCleaner\CodeCleanerPass '
|
||||
. 'extends PhpParser\NodeVisitorAbstract '
|
||||
. 'implements PhpParser\NodeVisitor',
|
||||
],
|
||||
[
|
||||
new \ReflectionFunction('array_chunk'),
|
||||
'function array_chunk($arg, $size, $preserve_keys = unknown)',
|
||||
],
|
||||
[
|
||||
new \ReflectionClass('Psy\Test\Formatter\Fixtures\BoringTrait'),
|
||||
'trait Psy\Test\Formatter\Fixtures\BoringTrait',
|
||||
],
|
||||
[
|
||||
new \ReflectionMethod('Psy\Test\Formatter\Fixtures\BoringTrait', 'boringMethod'),
|
||||
'public function boringMethod($one = 1)',
|
||||
],
|
||||
[
|
||||
new ReflectionConstant_('E_ERROR'),
|
||||
'define("E_ERROR", 1)',
|
||||
],
|
||||
[
|
||||
new ReflectionConstant_('PHP_VERSION'),
|
||||
'define("PHP_VERSION", "' . PHP_VERSION . '")',
|
||||
],
|
||||
[
|
||||
new ReflectionConstant_('__LINE__'),
|
||||
'define("__LINE__", null)', // @todo show this as `unknown` in red or something?
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testSignatureFormatterThrowsUnknownReflectorExpeption()
|
||||
{
|
||||
$refl = $this->getMockBuilder('Reflector')->getMock();
|
||||
SignatureFormatter::format($refl);
|
||||
}
|
||||
}
|
Reference in a new issue