Warning: file_get_contents(https://raw.githubusercontent.com/Den1xxx/Filemanager/master/languages/ru.json): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 88
Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 215
Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 216
Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 217
Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 218
Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 219
Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 220
PK ! 4 6 type/phpunit.xmlnu 刐迭
tests/unit
src
PK ! M顺 type/README.mdnu 刐迭 [](https://packagist.org/packages/sebastian/type)
[](https://github.com/sebastianbergmann/type/actions)
[](https://shepherd.dev/github/sebastianbergmann/type)
[](https://codecov.io/gh/sebastianbergmann/type)
# sebastian/type
Collection of value objects that represent the types of the PHP type system.
## Installation
You can add this library as a local, per-project dependency to your project using [Composer](https://getcomposer.org/):
```
composer require sebastian/type
```
If you only need this library during development, for instance to run your project's test suite, then you should add it as a development-time dependency:
```
composer require --dev sebastian/type
```
PK ! 蓾 type/phive.xmlnu 刐迭
PK ! 稆鼷 type/LICENSEnu 刐迭 BSD 3-Clause License
Copyright (c) 2019-2023, Sebastian Bergmann
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
PK ! 衟镻 $ type/tests/unit/IterableTypeTest.phpnu 刐迭
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Type;
use PHPUnit\Framework\TestCase;
use SebastianBergmann\Type\TestFixture\Iterator;
/**
* @covers \SebastianBergmann\Type\IterableType
*
* @uses \SebastianBergmann\Type\Type
* @uses \SebastianBergmann\Type\TypeName
* @uses \SebastianBergmann\Type\ObjectType
* @uses \SebastianBergmann\Type\SimpleType
*/
final class IterableTypeTest extends TestCase
{
/**
* @var IterableType
*/
private $type;
protected function setUp(): void
{
$this->type = new IterableType(false);
}
public function testMayDisallowNull(): void
{
$this->assertFalse($this->type->allowsNull());
}
public function testCanGenerateReturnTypeDeclaration(): void
{
$this->assertEquals(': iterable', $this->type->getReturnTypeDeclaration());
}
public function testMayAllowNull(): void
{
$type = new IterableType(true);
$this->assertTrue($type->allowsNull());
}
public function testCanGenerateNullableReturnTypeDeclaration(): void
{
$type = new IterableType(true);
$this->assertEquals(': ?iterable', $type->getReturnTypeDeclaration());
}
public function testNullCanBeAssignedToNullableIterable(): void
{
$type = new IterableType(true);
$this->assertTrue($type->isAssignable(new NullType));
}
public function testIterableCanBeAssignedToIterable(): void
{
$this->assertTrue($this->type->isAssignable(new IterableType(false)));
}
public function testArrayCanBeAssignedToIterable(): void
{
$this->assertTrue(
$this->type->isAssignable(
Type::fromValue([], false)
)
);
}
public function testIteratorCanBeAssignedToIterable(): void
{
$this->assertTrue(
$this->type->isAssignable(
Type::fromValue(new Iterator, false)
)
);
}
public function testSomethingThatIsNotIterableCannotBeAssignedToIterable(): void
{
$this->assertFalse(
$this->type->isAssignable(
Type::fromValue(null, false)
)
);
}
}
PK ! 3e " type/tests/unit/SimpleTypeTest.phpnu 刐迭
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Type;
use PHPUnit\Framework\TestCase;
/**
* @covers \SebastianBergmann\Type\SimpleType
*
* @uses \SebastianBergmann\Type\Type
*/
final class SimpleTypeTest extends TestCase
{
public function testCanBeBool(): void
{
$type = new SimpleType('bool', false);
$this->assertSame(': bool', $type->getReturnTypeDeclaration());
}
public function testCanBeBoolean(): void
{
$type = new SimpleType('boolean', false);
$this->assertSame(': bool', $type->getReturnTypeDeclaration());
}
public function testCanBeDouble(): void
{
$type = new SimpleType('double', false);
$this->assertSame(': float', $type->getReturnTypeDeclaration());
}
public function testCanBeFloat(): void
{
$type = new SimpleType('float', false);
$this->assertSame(': float', $type->getReturnTypeDeclaration());
}
public function testCanBeReal(): void
{
$type = new SimpleType('real', false);
$this->assertSame(': float', $type->getReturnTypeDeclaration());
}
public function testCanBeInt(): void
{
$type = new SimpleType('int', false);
$this->assertSame(': int', $type->getReturnTypeDeclaration());
}
public function testCanBeInteger(): void
{
$type = new SimpleType('integer', false);
$this->assertSame(': int', $type->getReturnTypeDeclaration());
}
public function testCanBeArray(): void
{
$type = new SimpleType('array', false);
$this->assertSame(': array', $type->getReturnTypeDeclaration());
}
public function testCanBeArray2(): void
{
$type = new SimpleType('[]', false);
$this->assertSame(': array', $type->getReturnTypeDeclaration());
}
public function testMayAllowNull(): void
{
$type = new SimpleType('bool', true);
$this->assertTrue($type->allowsNull());
$this->assertSame(': ?bool', $type->getReturnTypeDeclaration());
}
public function testMayNotAllowNull(): void
{
$type = new SimpleType('bool', false);
$this->assertFalse($type->allowsNull());
}
/**
* @dataProvider assignablePairs
*/
public function testIsAssignable(Type $assignTo, Type $assignedType): void
{
$this->assertTrue($assignTo->isAssignable($assignedType));
}
public function assignablePairs(): array
{
return [
'nullable to not nullable' => [new SimpleType('int', false), new SimpleType('int', true)],
'not nullable to nullable' => [new SimpleType('int', true), new SimpleType('int', false)],
'nullable to nullable' => [new SimpleType('int', true), new SimpleType('int', true)],
'not nullable to not nullable' => [new SimpleType('int', false), new SimpleType('int', false)],
'null to not nullable' => [new SimpleType('int', true), new NullType],
];
}
/**
* @dataProvider notAssignablePairs
*/
public function testIsNotAssignable(Type $assignTo, Type $assignedType): void
{
$this->assertFalse($assignTo->isAssignable($assignedType));
}
public function notAssignablePairs(): array
{
return [
'null to not nullable' => [new SimpleType('int', false), new NullType],
'int to boolean' => [new SimpleType('boolean', false), new SimpleType('int', false)],
'object' => [new SimpleType('boolean', false), new ObjectType(TypeName::fromQualifiedName(\stdClass::class), true)],
'unknown type' => [new SimpleType('boolean', false), new UnknownType],
'void' => [new SimpleType('boolean', false), new VoidType],
];
}
/**
* @dataProvider returnTypes
*/
public function testReturnTypeDeclaration(Type $type, string $returnType): void
{
$this->assertEquals($type->getReturnTypeDeclaration(), $returnType);
}
public function returnTypes(): array
{
return [
'[]' => [new SimpleType('[]', false), ': array'],
'array' => [new SimpleType('array', false), ': array'],
'?array' => [new SimpleType('array', true), ': ?array'],
'boolean' => [new SimpleType('boolean', false), ': bool'],
'real' => [new SimpleType('real', false), ': float'],
'double' => [new SimpleType('double', false), ': float'],
'integer' => [new SimpleType('integer', false), ': int'],
];
}
public function testCanHaveValue(): void
{
$this->assertSame('string', Type::fromValue('string', false)->value());
}
}
PK ! Z[vAa a ) type/tests/unit/GenericObjectTypeTest.phpnu 刐迭
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Type;
use PHPUnit\Framework\TestCase;
/**
* @covers \SebastianBergmann\Type\GenericObjectType
*
* @uses \SebastianBergmann\Type\Type
* @uses \SebastianBergmann\Type\ObjectType
* @uses \SebastianBergmann\Type\SimpleType
* @uses \SebastianBergmann\Type\TypeName
*/
final class GenericObjectTypeTest extends TestCase
{
/**
* @var GenericObjectType
*/
private $type;
protected function setUp(): void
{
$this->type = new GenericObjectType(false);
}
public function testMayDisallowNull(): void
{
$this->assertFalse($this->type->allowsNull());
}
public function testCanGenerateReturnTypeDeclaration(): void
{
$this->assertEquals(': object', $this->type->getReturnTypeDeclaration());
}
public function testMayAllowNull(): void
{
$type = new GenericObjectType(true);
$this->assertTrue($type->allowsNull());
}
public function testCanGenerateNullableReturnTypeDeclaration(): void
{
$type = new GenericObjectType(true);
$this->assertEquals(': ?object', $type->getReturnTypeDeclaration());
}
public function testObjectCanBeAssignedToGenericObject(): void
{
$this->assertTrue(
$this->type->isAssignable(
new ObjectType(TypeName::fromQualifiedName(\stdClass::class), false)
)
);
}
public function testNullCanBeAssignedToNullableGenericObject(): void
{
$type = new GenericObjectType(true);
$this->assertTrue(
$type->isAssignable(
new NullType
)
);
}
public function testNonObjectCannotBeAssignedToGenericObject(): void
{
$this->assertFalse(
$this->type->isAssignable(
new SimpleType('bool', false)
)
);
}
}
PK ! 皴 type/tests/unit/NullTypeTest.phpnu 刐迭
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Type;
use PHPUnit\Framework\TestCase;
/**
* @covers \SebastianBergmann\Type\NullType
*/
final class NullTypeTest extends TestCase
{
/**
* @var NullType
*/
private $type;
protected function setUp(): void
{
$this->type = new NullType;
}
/**
* @dataProvider assignableTypes
*/
public function testIsAssignable(Type $assignableType): void
{
$this->assertTrue($this->type->isAssignable($assignableType));
}
public function assignableTypes(): array
{
return [
[new SimpleType('int', false)],
[new SimpleType('int', true)],
[new ObjectType(TypeName::fromQualifiedName(self::class), false)],
[new ObjectType(TypeName::fromQualifiedName(self::class), true)],
[new UnknownType],
];
}
/**
* @dataProvider notAssignable
*/
public function testIsNotAssignable(Type $assignedType): void
{
$this->assertFalse($this->type->isAssignable($assignedType));
}
public function notAssignable(): array
{
return [
'void' => [new VoidType],
];
}
public function testAllowsNull(): void
{
$this->assertTrue($this->type->allowsNull());
}
public function testCanGenerateReturnTypeDeclaration(): void
{
$this->assertEquals('', $this->type->getReturnTypeDeclaration());
}
}
PK ! '紳d d type/tests/unit/TypeNameTest.phpnu 刐迭
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Type;
use PHPUnit\Framework\TestCase;
/**
* @covers \SebastianBergmann\Type\TypeName
*/
final class TypeNameTest extends TestCase
{
public function testFromReflection(): void
{
$class = new \ReflectionClass(TypeName::class);
$typeName = TypeName::fromReflection($class);
$this->assertTrue($typeName->isNamespaced());
$this->assertEquals('SebastianBergmann\\Type', $typeName->getNamespaceName());
$this->assertEquals(TypeName::class, $typeName->getQualifiedName());
$this->assertEquals('TypeName', $typeName->getSimpleName());
}
public function testFromQualifiedName(): void
{
$typeName = TypeName::fromQualifiedName('PHPUnit\\Framework\\MockObject\\TypeName');
$this->assertTrue($typeName->isNamespaced());
$this->assertEquals('PHPUnit\\Framework\\MockObject', $typeName->getNamespaceName());
$this->assertEquals('PHPUnit\\Framework\\MockObject\\TypeName', $typeName->getQualifiedName());
$this->assertEquals('TypeName', $typeName->getSimpleName());
}
public function testFromQualifiedNameWithLeadingSeparator(): void
{
$typeName = TypeName::fromQualifiedName('\\Foo\\Bar');
$this->assertTrue($typeName->isNamespaced());
$this->assertEquals('Foo', $typeName->getNamespaceName());
$this->assertEquals('Foo\\Bar', $typeName->getQualifiedName());
$this->assertEquals('Bar', $typeName->getSimpleName());
}
public function testFromQualifiedNameWithoutNamespace(): void
{
$typeName = TypeName::fromQualifiedName('Bar');
$this->assertFalse($typeName->isNamespaced());
$this->assertNull($typeName->getNamespaceName());
$this->assertEquals('Bar', $typeName->getQualifiedName());
$this->assertEquals('Bar', $typeName->getSimpleName());
}
}
PK ! 籽 type/tests/unit/TypeTest.phpnu 刐迭
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Type;
use PHPUnit\Framework\TestCase;
/**
* @covers \SebastianBergmann\Type\Type
*
* @uses \SebastianBergmann\Type\SimpleType
* @uses \SebastianBergmann\Type\GenericObjectType
* @uses \SebastianBergmann\Type\ObjectType
* @uses \SebastianBergmann\Type\TypeName
* @uses \SebastianBergmann\Type\CallableType
* @uses \SebastianBergmann\Type\IterableType
*/
final class TypeTest extends TestCase
{
/**
* @dataProvider valuesToNullableType
*/
public function testTypeMappingFromValue($value, bool $allowsNull, Type $expectedType): void
{
$this->assertEquals($expectedType, Type::fromValue($value, $allowsNull));
}
public function valuesToNullableType(): array
{
return [
'?null' => [null, true, new NullType],
'null' => [null, false, new NullType],
'?integer' => [1, true, new SimpleType('int', true, 1)],
'integer' => [1, false, new SimpleType('int', false, 1)],
'?boolean' => [true, true, new SimpleType('bool', true, true)],
'boolean' => [true, false, new SimpleType('bool', false, true)],
'?object' => [new \stdClass, true, new ObjectType(TypeName::fromQualifiedName(\stdClass::class), true)],
'object' => [new \stdClass, false, new ObjectType(TypeName::fromQualifiedName(\stdClass::class), false)],
];
}
/**
* @dataProvider namesToTypes
*/
public function testTypeMappingFromName(string $typeName, bool $allowsNull, $expectedType): void
{
$this->assertEquals($expectedType, Type::fromName($typeName, $allowsNull));
}
public function namesToTypes(): array
{
return [
'?void' => ['void', true, new VoidType],
'void' => ['void', false, new VoidType],
'?null' => ['null', true, new NullType],
'null' => ['null', true, new NullType],
'?int' => ['int', true, new SimpleType('int', true)],
'?integer' => ['integer', true, new SimpleType('int', true)],
'int' => ['int', false, new SimpleType('int', false)],
'bool' => ['bool', false, new SimpleType('bool', false)],
'boolean' => ['boolean', false, new SimpleType('bool', false)],
'object' => ['object', false, new GenericObjectType(false)],
'real' => ['real', false, new SimpleType('float', false)],
'double' => ['double', false, new SimpleType('float', false)],
'float' => ['float', false, new SimpleType('float', false)],
'string' => ['string', false, new SimpleType('string', false)],
'array' => ['array', false, new SimpleType('array', false)],
'resource' => ['resource', false, new SimpleType('resource', false)],
'resource (closed)' => ['resource (closed)', false, new SimpleType('resource (closed)', false)],
'unknown type' => ['unknown type', false, new UnknownType],
'?classname' => [\stdClass::class, true, new ObjectType(TypeName::fromQualifiedName(\stdClass::class), true)],
'classname' => [\stdClass::class, false, new ObjectType(TypeName::fromQualifiedName(\stdClass::class), false)],
'callable' => ['callable', false, new CallableType(false)],
'?callable' => ['callable', true, new CallableType(true)],
'iterable' => ['iterable', false, new IterableType(false)],
'?iterable' => ['iterable', true, new IterableType(true)],
];
}
}
PK !
)2' ' $ type/tests/unit/CallableTypeTest.phpnu 刐迭
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Type;
use PHPUnit\Framework\TestCase;
use SebastianBergmann\Type\TestFixture\ClassWithCallbackMethods;
use SebastianBergmann\Type\TestFixture\ClassWithInvokeMethod;
/**
* @covers \SebastianBergmann\Type\CallableType
*
* @uses \SebastianBergmann\Type\Type
* @uses \SebastianBergmann\Type\ObjectType
* @uses \SebastianBergmann\Type\SimpleType
* @uses \SebastianBergmann\Type\TypeName
*/
final class CallableTypeTest extends TestCase
{
/**
* @var CallableType
*/
private $type;
protected function setUp(): void
{
$this->type = new CallableType(false);
}
public function testMayDisallowNull(): void
{
$this->assertFalse($this->type->allowsNull());
}
public function testCanGenerateReturnTypeDeclaration(): void
{
$this->assertEquals(': callable', $this->type->getReturnTypeDeclaration());
}
public function testMayAllowNull(): void
{
$type = new CallableType(true);
$this->assertTrue($type->allowsNull());
}
public function testCanGenerateNullableReturnTypeDeclaration(): void
{
$type = new CallableType(true);
$this->assertEquals(': ?callable', $type->getReturnTypeDeclaration());
}
public function testNullCanBeAssignedToNullableCallable(): void
{
$type = new CallableType(true);
$this->assertTrue($type->isAssignable(new NullType));
}
public function testCallableCanBeAssignedToCallable(): void
{
$this->assertTrue($this->type->isAssignable(new CallableType(false)));
}
public function testClosureCanBeAssignedToCallable(): void
{
$this->assertTrue(
$this->type->isAssignable(
new ObjectType(
TypeName::fromQualifiedName(\Closure::class),
false
)
)
);
}
public function testInvokableCanBeAssignedToCallable(): void
{
$this->assertTrue(
$this->type->isAssignable(
new ObjectType(
TypeName::fromQualifiedName(ClassWithInvokeMethod::class),
false
)
)
);
}
public function testStringWithFunctionNameCanBeAssignedToCallable(): void
{
$this->assertTrue(
$this->type->isAssignable(
Type::fromValue('SebastianBergmann\Type\TestFixture\callback_function', false)
)
);
}
public function testStringWithClassNameAndStaticMethodNameCanBeAssignedToCallable(): void
{
$this->assertTrue(
$this->type->isAssignable(
Type::fromValue(ClassWithCallbackMethods::class . '::staticCallback', false)
)
);
}
public function testArrayWithClassNameAndStaticMethodNameCanBeAssignedToCallable(): void
{
$this->assertTrue(
$this->type->isAssignable(
Type::fromValue([ClassWithCallbackMethods::class, 'staticCallback'], false)
)
);
}
public function testArrayWithClassNameAndInstanceMethodNameCanBeAssignedToCallable(): void
{
$this->assertTrue(
$this->type->isAssignable(
Type::fromValue([new ClassWithCallbackMethods, 'nonStaticCallback'], false)
)
);
}
public function testSomethingThatIsNotCallableCannotBeAssignedToCallable(): void
{
$this->assertFalse(
$this->type->isAssignable(
Type::fromValue(null, false)
)
);
}
public function testObjectWithoutInvokeMethodCannotBeAssignedToCallable(): void
{
$this->assertFalse(
$this->type->isAssignable(
Type::fromValue(new class {
}, false)
)
);
}
}
PK ! 浚, # type/tests/unit/UnknownTypeTest.phpnu 刐迭
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Type;
use PHPUnit\Framework\TestCase;
/**
* @covers \SebastianBergmann\Type\UnknownType
*/
final class UnknownTypeTest extends TestCase
{
/**
* @var UnknownType
*/
private $type;
protected function setUp(): void
{
$this->type = new UnknownType;
}
/**
* @dataProvider assignableTypes
*/
public function testIsAssignable(Type $assignableType): void
{
$this->assertTrue($this->type->isAssignable($assignableType));
}
public function assignableTypes(): array
{
return [
[new SimpleType('int', false)],
[new SimpleType('int', true)],
[new VoidType],
[new ObjectType(TypeName::fromQualifiedName(self::class), false)],
[new ObjectType(TypeName::fromQualifiedName(self::class), true)],
[new UnknownType],
];
}
public function testAllowsNull(): void
{
$this->assertTrue($this->type->allowsNull());
}
public function testReturnTypeDeclaration(): void
{
$this->assertEquals('', $this->type->getReturnTypeDeclaration());
}
}
PK ! u挒綍 type/tests/unit/VoidTypeTest.phpnu 刐迭
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Type;
use PHPUnit\Framework\TestCase;
/**
* @covers \SebastianBergmann\Type\VoidType
*/
final class VoidTypeTest extends TestCase
{
/**
* @dataProvider assignableTypes
*/
public function testIsAssignable(Type $assignableType): void
{
$type = new VoidType;
$this->assertTrue($type->isAssignable($assignableType));
}
public function assignableTypes(): array
{
return [
[new VoidType],
];
}
/**
* @dataProvider notAssignableTypes
*/
public function testIsNotAssignable(Type $assignableType): void
{
$type = new VoidType;
$this->assertFalse($type->isAssignable($assignableType));
}
public function notAssignableTypes(): array
{
return [
[new SimpleType('int', false)],
[new SimpleType('int', true)],
[new ObjectType(TypeName::fromQualifiedName(self::class), false)],
[new ObjectType(TypeName::fromQualifiedName(self::class), true)],
[new UnknownType],
];
}
public function testNotAllowNull(): void
{
$type = new VoidType;
$this->assertFalse($type->allowsNull());
}
public function testCanGenerateReturnTypeDeclaration(): void
{
$type = new VoidType;
$this->assertEquals(': void', $type->getReturnTypeDeclaration());
}
}
PK ! *琛摳 " type/tests/unit/ObjectTypeTest.phpnu 刐迭
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Type;
use PHPUnit\Framework\TestCase;
use SebastianBergmann\Type\TestFixture\ChildClass;
use SebastianBergmann\Type\TestFixture\ParentClass;
/**
* @covers \SebastianBergmann\Type\ObjectType
*
* @uses \SebastianBergmann\Type\TypeName
* @uses \SebastianBergmann\Type\Type
* @uses \SebastianBergmann\Type\SimpleType
*/
final class ObjectTypeTest extends TestCase
{
/**
* @var ObjectType
*/
private $childClass;
/**
* @var ObjectType
*/
private $parentClass;
protected function setUp(): void
{
$this->childClass = new ObjectType(
TypeName::fromQualifiedName(ChildClass::class),
false
);
$this->parentClass = new ObjectType(
TypeName::fromQualifiedName(ParentClass::class),
false
);
}
public function testParentIsNotAssignableToChild(): void
{
$this->assertFalse($this->childClass->isAssignable($this->parentClass));
}
public function testChildIsAssignableToParent(): void
{
$this->assertTrue($this->parentClass->isAssignable($this->childClass));
}
public function testClassIsAssignableToSelf(): void
{
$this->assertTrue($this->parentClass->isAssignable($this->parentClass));
}
public function testSimpleTypeIsNotAssignableToClass(): void
{
$this->assertFalse($this->parentClass->isAssignable(new SimpleType('int', false)));
}
public function testClassFromOneNamespaceIsNotAssignableToClassInOtherNamespace(): void
{
$classFromNamespaceA = new ObjectType(
TypeName::fromQualifiedName(\someNamespaceA\NamespacedClass::class),
false
);
$classFromNamespaceB = new ObjectType(
TypeName::fromQualifiedName(\someNamespaceB\NamespacedClass::class),
false
);
$this->assertFalse($classFromNamespaceA->isAssignable($classFromNamespaceB));
}
public function testClassIsAssignableToSelfCaseInsensitively(): void
{
$classLowercased = new ObjectType(
TypeName::fromQualifiedName(\strtolower(ParentClass::class)),
false
);
$this->assertTrue($this->parentClass->isAssignable($classLowercased));
}
public function testNullIsAssignableToNullableType(): void
{
$someClass = new ObjectType(
TypeName::fromQualifiedName(ParentClass::class),
true
);
$this->assertTrue($someClass->isAssignable(Type::fromValue(null, true)));
}
public function testNullIsNotAssignableToNotNullableType(): void
{
$someClass = new ObjectType(
TypeName::fromQualifiedName(ParentClass::class),
false
);
$this->assertFalse($someClass->isAssignable(Type::fromValue(null, true)));
}
public function testPreservesNullNotAllowed(): void
{
$someClass = new ObjectType(
TypeName::fromQualifiedName(ParentClass::class),
false
);
$this->assertFalse($someClass->allowsNull());
}
public function testPreservesNullAllowed(): void
{
$someClass = new ObjectType(
TypeName::fromQualifiedName(ParentClass::class),
true
);
$this->assertTrue($someClass->allowsNull());
}
public function testCanGenerateReturnTypeDeclaration(): void
{
$this->assertEquals(': SebastianBergmann\Type\TestFixture\ParentClass', $this->parentClass->getReturnTypeDeclaration());
}
public function testHasClassName(): void
{
$this->assertEquals('SebastianBergmann\Type\TestFixture\ParentClass', $this->parentClass->className()->getQualifiedName());
}
}
PK ! 瓌Lu u # type/tests/_fixture/ParentClass.phpnu 刐迭
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Type\TestFixture;
class ParentClass
{
public function foo(): void
{
}
}
PK ! 櫬N藠 - type/tests/_fixture/ClassWithInvokeMethod.phpnu 刐迭
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Type\TestFixture;
final class ClassWithInvokeMethod
{
public function __invoke(): void
{
}
}
PK ! 8\ \ " type/tests/_fixture/ChildClass.phpnu 刐迭
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Type\TestFixture;
class ChildClass extends ParentClass
{
}
PK ! 誥!Z Z ) type/tests/_fixture/callback_function.phpnu 刐迭
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Type\TestFixture;
function callback_function(): void
{
}
PK ! 0 type/tests/_fixture/ClassWithCallbackMethods.phpnu 刐迭
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Type\TestFixture;
final class ClassWithCallbackMethods
{
public static function staticCallback(): void
{
}
public function nonStaticCallback(): void
{
}
}
PK ! 瓅饔K K type/tests/_fixture/Iterator.phpnu 刐迭
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Type\TestFixture;
final class Iterator implements \Iterator
{
public function current(): void
{
}
public function next(): void
{
}
public function key(): void
{
}
public function valid(): void
{
}
public function rewind(): void
{
}
}
PK ! 謣d type/.travis.ymlnu 刐迭 language: php
php:
- 7.2
- 7.3
- 7.4snapshot
- nightly
matrix:
allow_failures:
- php: master
fast_finish: true
env:
matrix:
- DEPENDENCIES="high"
- DEPENDENCIES="low"
global:
- DEFAULT_COMPOSER_FLAGS="--no-interaction --no-ansi --no-progress --no-suggest"
before_install:
- ./tools/composer clear-cache
install:
- if [[ "$DEPENDENCIES" = 'high' ]]; then travis_retry ./tools/composer update $DEFAULT_COMPOSER_FLAGS; fi
- if [[ "$DEPENDENCIES" = 'low' ]]; then travis_retry ./tools/composer update $DEFAULT_COMPOSER_FLAGS --prefer-lowest; fi
script:
- ./vendor/bin/phpunit --coverage-clover=coverage.xml
after_success:
- bash <(curl -s https://codecov.io/bash)
notifications:
email: false
jobs:
include:
- stage: "Static Code Analysis"
php: 7.3
env: php-cs-fixer
install:
- phpenv config-rm xdebug.ini
script:
- ./tools/php-cs-fixer fix --dry-run -v --show-progress=dots --diff-format=udiff
- stage: "Static Code Analysis"
php: 7.3
env: psalm
install:
- phpenv config-rm xdebug.ini
script:
- travis_retry ./tools/composer update $DEFAULT_COMPOSER_FLAGS
- ./tools/psalm --shepherd --stats
PK ! o匵B type/.php_cs.distnu 刐迭
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
EOF;
return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules(
[
'align_multiline_comment' => true,
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => [
'operators' => [
'=' => 'align',
'=>' => 'align',
],
],
'blank_line_after_namespace' => true,
'blank_line_before_statement' => [
'statements' => [
'break',
'continue',
'declare',
'do',
'for',
'foreach',
'if',
'include',
'include_once',
'require',
'require_once',
'return',
'switch',
'throw',
'try',
'while',
'yield',
],
],
'braces' => true,
'cast_spaces' => true,
'class_attributes_separation' => ['elements' => ['const', 'method', 'property']],
'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true,
'compact_nullable_typehint' => true,
'concat_space' => ['spacing' => 'one'],
'declare_equal_normalize' => ['space' => 'none'],
'declare_strict_types' => true,
'dir_constant' => true,
'elseif' => true,
'encoding' => true,
'full_opening_tag' => true,
'function_declaration' => true,
'header_comment' => ['header' => $header, 'separate' => 'none'],
'indentation_type' => true,
'is_null' => true,
'line_ending' => true,
'list_syntax' => ['syntax' => 'short'],
'logical_operators' => true,
'lowercase_cast' => true,
'lowercase_constants' => true,
'lowercase_keywords' => true,
'lowercase_static_reference' => true,
'magic_constant_casing' => true,
'method_argument_space' => ['ensure_fully_multiline' => true],
'modernize_types_casting' => true,
'multiline_comment_opening_closing' => true,
'multiline_whitespace_before_semicolons' => true,
'native_constant_invocation' => true,
'native_function_casing' => true,
'native_function_invocation' => true,
'new_with_braces' => false,
'no_alias_functions' => true,
'no_alternative_syntax' => true,
'no_blank_lines_after_class_opening' => true,
'no_blank_lines_after_phpdoc' => true,
'no_blank_lines_before_namespace' => true,
'no_closing_tag' => true,
'no_empty_comment' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_extra_blank_lines' => true,
'no_homoglyph_names' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_mixed_echo_print' => ['use' => 'print'],
'no_multiline_whitespace_around_double_arrow' => true,
'no_null_property_initialization' => true,
'no_php4_constructor' => true,
'no_short_bool_cast' => true,
'no_short_echo_tag' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_spaces_after_function_name' => true,
'no_spaces_inside_parenthesis' => true,
'no_superfluous_elseif' => true,
'no_superfluous_phpdoc_tags' => true,
'no_trailing_comma_in_list_call' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_trailing_whitespace' => true,
'no_trailing_whitespace_in_comment' => true,
'no_unneeded_control_parentheses' => true,
'no_unneeded_curly_braces' => true,
'no_unneeded_final_method' => true,
'no_unreachable_default_argument_value' => true,
'no_unset_on_property' => true,
'no_unused_imports' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
'non_printable_character' => true,
'normalize_index_brace' => true,
'object_operator_without_whitespace' => true,
'ordered_class_elements' => [
'order' => [
'use_trait',
'constant_public',
'constant_protected',
'constant_private',
'property_public_static',
'property_protected_static',
'property_private_static',
'property_public',
'property_protected',
'property_private',
'method_public_static',
'construct',
'destruct',
'magic',
'phpunit',
'method_public',
'method_protected',
'method_private',
'method_protected_static',
'method_private_static',
],
],
'ordered_imports' => true,
'ordered_interfaces' => [
'direction' => 'ascend',
'order' => 'alpha',
],
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_align' => true,
'phpdoc_annotation_without_dot' => true,
'phpdoc_indent' => true,
'phpdoc_no_access' => true,
'phpdoc_no_empty_return' => true,
'phpdoc_no_package' => true,
'phpdoc_order' => true,
'phpdoc_return_self_reference' => true,
'phpdoc_scalar' => true,
'phpdoc_separation' => true,
'phpdoc_single_line_var_spacing' => true,
'phpdoc_to_comment' => true,
'phpdoc_trim' => true,
'phpdoc_trim_consecutive_blank_line_separation' => true,
'phpdoc_types' => ['groups' => ['simple', 'meta']],
'phpdoc_types_order' => true,
'phpdoc_var_without_name' => true,
'pow_to_exponentiation' => true,
'protected_to_private' => true,
'return_assignment' => true,
'return_type_declaration' => ['space_before' => 'none'],
'semicolon_after_instruction' => true,
'set_type_to_cast' => true,
'short_scalar_cast' => true,
'simplified_null_return' => true,
'single_blank_line_at_eof' => true,
'single_import_per_statement' => true,
'single_line_after_imports' => true,
'single_quote' => true,
'standardize_not_equals' => true,
'ternary_to_null_coalescing' => true,
'trailing_comma_in_multiline_array' => true,
'trim_array_spaces' => true,
'unary_operator_spaces' => true,
'visibility_required' => [
'elements' => [
'const',
'method',
'property',
],
],
'void_return' => true,
'whitespace_after_comma_in_array' => true,
]
)
->setFinder(
PhpCsFixer\Finder::create()
->files()
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests')
);
PK ! 鱉媕 type/composer.jsonnu 刐迭 {
"name": "sebastian/type",
"description": "Collection of value objects that represent the types of the PHP type system",
"type": "library",
"homepage": "https://github.com/sebastianbergmann/type",
"license": "BSD-3-Clause",
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de",
"role": "lead"
}
],
"support": {
"issues": "https://github.com/sebastianbergmann/type/issues"
},
"prefer-stable": true,
"require": {
"php": ">=8.1"
},
"require-dev": {
"phpunit/phpunit": "^10.0"
},
"config": {
"platform": {
"php": "8.1.0"
},
"optimize-autoloader": true,
"sort-packages": true
},
"autoload": {
"classmap": [
"src/"
]
},
"autoload-dev": {
"classmap": [
"tests/_fixture"
],
"files": [
"tests/_fixture/callback_function.php",
"tests/_fixture/functions_that_declare_return_types.php"
]
},
"extra": {
"branch-alias": {
"dev-main": "4.0-dev"
}
}
}
PK ! 1酳) type/.github/FUNDING.ymlnu 刐迭 patreon: s_bergmann
PK ! 鰕 type/ChangeLog.mdnu 刐迭 # ChangeLog
All notable changes are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
## [4.0.0] - 2023-02-03
### Removed
* This component is no longer supported on PHP 7.3, PHP 7.4 and PHP 8.0
## [3.2.1] - 2023-02-03
### Fixed
* [#28](https://github.com/sebastianbergmann/type/pull/28): Potential undefined offset warning/notice
## [3.2.0] - 2022-09-12
### Added
* [#25](https://github.com/sebastianbergmann/type/issues/25): Support Disjunctive Normal Form types
* Added `ReflectionMapper::fromParameterTypes()`
* Added `IntersectionType::types()` and `UnionType::types()`
* Added `UnionType::containsIntersectionTypes()`
## [3.1.0] - 2022-08-29
### Added
* [#21](https://github.com/sebastianbergmann/type/issues/21): Support `true` as stand-alone type
## [3.0.0] - 2022-03-15
### Added
* Support for intersection types introduced in PHP 8.1
* Support for the `never` return type introduced in PHP 8.1
* Added `Type::isCallable()`, `Type::isGenericObject()`, `Type::isIterable()`, `Type::isMixed()`, `Type::isNever()`, `Type::isNull()`, `Type::isObject()`, `Type::isSimple()`, `Type::isStatic()`, `Type::isUnion()`, `Type::isUnknown()`, and `Type::isVoid()`
### Changed
* Renamed `ReflectionMapper::fromMethodReturnType(ReflectionMethod $method)` to `ReflectionMapper::fromReturnType(ReflectionFunctionAbstract $functionOrMethod)`
### Removed
* Removed `Type::getReturnTypeDeclaration()` (use `Type::asString()` instead and prefix its result with `': '`)
* Removed `TypeName::getNamespaceName()` (use `TypeName::namespaceName()` instead)
* Removed `TypeName::getSimpleName()` (use `TypeName::simpleName()` instead)
* Removed `TypeName::getQualifiedName()` (use `TypeName::qualifiedName()` instead)
## [2.3.4] - 2021-06-15
### Fixed
* Fixed regression introduced in 2.3.3
## [2.3.3] - 2021-06-15 [YANKED]
### Fixed
* [#15](https://github.com/sebastianbergmann/type/issues/15): "false" pseudo type is not handled properly
## [2.3.2] - 2021-06-04
### Fixed
* Fixed handling of tentatively declared return types
## [2.3.1] - 2020-10-26
### Fixed
* `SebastianBergmann\Type\Exception` now correctly extends `\Throwable`
## [2.3.0] - 2020-10-06
### Added
* [#14](https://github.com/sebastianbergmann/type/issues/14): Support for `static` return type that is introduced in PHP 8
## [2.2.2] - 2020-09-28
### Changed
* Changed PHP version constraint in `composer.json` from `^7.3 || ^8.0` to `>=7.3`
## [2.2.1] - 2020-07-05
### Fixed
* Fixed handling of `mixed` type in `ReflectionMapper::fromMethodReturnType()`
## [2.2.0] - 2020-07-05
### Added
* Added `MixedType` object for representing PHP 8's `mixed` type
## [2.1.1] - 2020-06-26
### Added
* This component is now supported on PHP 8
## [2.1.0] - 2020-06-01
### Added
* Added `UnionType` object for representing PHP 8's Union Types
* Added `ReflectionMapper::fromMethodReturnType()` for mapping `\ReflectionMethod::getReturnType()` to a `Type` object
* Added `Type::name()` for retrieving the name of a type
* Added `Type::asString()` for retrieving a textual representation of a type
### Changed
* Deprecated `Type::getReturnTypeDeclaration()` (use `Type::asString()` instead and prefix its result with `': '`)
* Deprecated `TypeName::getNamespaceName()` (use `TypeName::namespaceName()` instead)
* Deprecated `TypeName::getSimpleName()` (use `TypeName::simpleName()` instead)
* Deprecated `TypeName::getQualifiedName()` (use `TypeName::qualifiedName()` instead)
## [2.0.0] - 2020-02-07
### Removed
* This component is no longer supported on PHP 7.2
## [1.1.3] - 2019-07-02
### Fixed
* Fixed class name comparison in `ObjectType` to be case-insensitive
## [1.1.2] - 2019-06-19
### Fixed
* Fixed handling of `object` type
## [1.1.1] - 2019-06-08
### Fixed
* Fixed autoloading of `callback_function.php` fixture file
## [1.1.0] - 2019-06-07
### Added
* Added support for `callable` type
* Added support for `iterable` type
## [1.0.0] - 2019-06-06
* Initial release based on [code contributed by Michel Hartmann to PHPUnit](https://github.com/sebastianbergmann/phpunit/pull/3673)
[4.0.0]: https://github.com/sebastianbergmann/type/compare/3.2.1...4.0.0
[3.2.1]: https://github.com/sebastianbergmann/type/compare/3.2.0...3.2.1
[3.2.0]: https://github.com/sebastianbergmann/type/compare/3.1.0...3.2.0
[3.1.0]: https://github.com/sebastianbergmann/type/compare/3.0.0...3.1.0
[3.0.0]: https://github.com/sebastianbergmann/type/compare/2.3.4...3.0.0
[2.3.4]: https://github.com/sebastianbergmann/type/compare/ca39369c41313ed12c071ed38ecda8fcdb248859...2.3.4
[2.3.3]: https://github.com/sebastianbergmann/type/compare/2.3.2...ca39369c41313ed12c071ed38ecda8fcdb248859
[2.3.2]: https://github.com/sebastianbergmann/type/compare/2.3.1...2.3.2
[2.3.1]: https://github.com/sebastianbergmann/type/compare/2.3.0...2.3.1
[2.3.0]: https://github.com/sebastianbergmann/type/compare/2.2.2...2.3.0
[2.2.2]: https://github.com/sebastianbergmann/type/compare/2.2.1...2.2.2
[2.2.1]: https://github.com/sebastianbergmann/type/compare/2.2.0...2.2.1
[2.2.0]: https://github.com/sebastianbergmann/type/compare/2.1.1...2.2.0
[2.1.1]: https://github.com/sebastianbergmann/type/compare/2.1.0...2.1.1
[2.1.0]: https://github.com/sebastianbergmann/type/compare/2.0.0...2.1.0
[2.0.0]: https://github.com/sebastianbergmann/type/compare/1.1.3...2.0.0
[1.1.3]: https://github.com/sebastianbergmann/type/compare/1.1.2...1.1.3
[1.1.2]: https://github.com/sebastianbergmann/type/compare/1.1.1...1.1.2
[1.1.1]: https://github.com/sebastianbergmann/type/compare/1.1.0...1.1.1
[1.1.0]: https://github.com/sebastianbergmann/type/compare/1.0.0...1.1.0
[1.0.0]: https://github.com/sebastianbergmann/type/compare/ff74aa41746bd8d10e931843ebf37d42da513ede...1.0.0
PK ! X铋扏 @ type/src/TypeName.phpnu 刐迭
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Type;
use function array_pop;
use function explode;
use function implode;
use function substr;
use ReflectionClass;
final class TypeName
{
private ?string $namespaceName;
private string $simpleName;
public static function fromQualifiedName(string $fullClassName): self
{
if ($fullClassName[0] === '\\') {
$fullClassName = substr($fullClassName, 1);
}
$classNameParts = explode('\\', $fullClassName);
$simpleName = array_pop($classNameParts);
$namespaceName = implode('\\', $classNameParts);
return new self($namespaceName, $simpleName);
}
public static function fromReflection(ReflectionClass $type): self
{
return new self(
$type->getNamespaceName(),
$type->getShortName()
);
}
public function __construct(?string $namespaceName, string $simpleName)
{
if ($namespaceName === '') {
$namespaceName = null;
}
$this->namespaceName = $namespaceName;
$this->simpleName = $simpleName;
}
public function namespaceName(): ?string
{
return $this->namespaceName;
}
public function simpleName(): string
{
return $this->simpleName;
}
public function qualifiedName(): string
{
return $this->namespaceName === null
? $this->simpleName
: $this->namespaceName . '\\' . $this->simpleName;
}
public function isNamespaced(): bool
{
return $this->namespaceName !== null;
}
}
PK ! )T[ [ type/src/VoidType.phpnu 刐迭
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Type;
final class VoidType extends Type
{
public function isAssignable(Type $other): bool
{
return $other instanceof self;
}
public function getReturnTypeDeclaration(): string
{
return ': void';
}
public function allowsNull(): bool
{
return false;
}
}
PK ! 彻璹Q Q type/src/IterableType.phpnu 刐迭
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Type;
final class IterableType extends Type
{
/**
* @var bool
*/
private $allowsNull;
public function __construct(bool $nullable)
{
$this->allowsNull = $nullable;
}
/**
* @throws RuntimeException
*/
public function isAssignable(Type $other): bool
{
if ($this->allowsNull && $other instanceof NullType) {
return true;
}
if ($other instanceof self) {
return true;
}
if ($other instanceof SimpleType) {
return \is_iterable($other->value());
}
if ($other instanceof ObjectType) {
try {
return (new \ReflectionClass($other->className()->getQualifiedName()))->isIterable();
// @codeCoverageIgnoreStart
} catch (\ReflectionException $e) {
throw new RuntimeException(
$e->getMessage(),
(int) $e->getCode(),
$e
);
// @codeCoverageIgnoreEnd
}
}
return false;
}
public function getReturnTypeDeclaration(): string
{
return ': ' . ($this->allowsNull ? '?' : '') . 'iterable';
}
public function allowsNull(): bool
{
return $this->allowsNull;
}
}
PK ! 9誳闧 [ type/src/NullType.phpnu 刐迭
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Type;
final class NullType extends Type
{
public function isAssignable(Type $other): bool
{
return !($other instanceof VoidType);
}
public function getReturnTypeDeclaration(): string
{
return '';
}
public function allowsNull(): bool
{
return true;
}
}
PK ! 艠1咤 type/src/ObjectType.phpnu 刐迭
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Type;
final class ObjectType extends Type
{
/**
* @var TypeName
*/
private $className;
/**
* @var bool
*/
private $allowsNull;
public function __construct(TypeName $className, bool $allowsNull)
{
$this->className = $className;
$this->allowsNull = $allowsNull;
}
public function isAssignable(Type $other): bool
{
if ($this->allowsNull && $other instanceof NullType) {
return true;
}
if ($other instanceof self) {
if (0 === \strcasecmp($this->className->getQualifiedName(), $other->className->getQualifiedName())) {
return true;
}
if (\is_subclass_of($other->className->getQualifiedName(), $this->className->getQualifiedName(), true)) {
return true;
}
}
return false;
}
public function getReturnTypeDeclaration(): string
{
return ': ' . ($this->allowsNull ? '?' : '') . $this->className->getQualifiedName();
}
public function allowsNull(): bool
{
return $this->allowsNull;
}
public function className(): TypeName
{
return $this->className;
}
}
PK ! 螉]練 type/src/CallableType.phpnu 刐迭
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Type;
final class CallableType extends Type
{
/**
* @var bool
*/
private $allowsNull;
public function __construct(bool $nullable)
{
$this->allowsNull = $nullable;
}
/**
* @throws RuntimeException
*/
public function isAssignable(Type $other): bool
{
if ($this->allowsNull && $other instanceof NullType) {
return true;
}
if ($other instanceof self) {
return true;
}
if ($other instanceof ObjectType) {
if ($this->isClosure($other)) {
return true;
}
if ($this->hasInvokeMethod($other)) {
return true;
}
}
if ($other instanceof SimpleType) {
if ($this->isFunction($other)) {
return true;
}
if ($this->isClassCallback($other)) {
return true;
}
if ($this->isObjectCallback($other)) {
return true;
}
}
return false;
}
public function getReturnTypeDeclaration(): string
{
return ': ' . ($this->allowsNull ? '?' : '') . 'callable';
}
public function allowsNull(): bool
{
return $this->allowsNull;
}
private function isClosure(ObjectType $type): bool
{
return !$type->className()->isNamespaced() && $type->className()->getSimpleName() === \Closure::class;
}
/**
* @throws RuntimeException
*/
private function hasInvokeMethod(ObjectType $type): bool
{
try {
$class = new \ReflectionClass($type->className()->getQualifiedName());
// @codeCoverageIgnoreStart
} catch (\ReflectionException $e) {
throw new RuntimeException(
$e->getMessage(),
(int) $e->getCode(),
$e
);
// @codeCoverageIgnoreEnd
}
if ($class->hasMethod('__invoke')) {
return true;
}
return false;
}
private function isFunction(SimpleType $type): bool
{
if (!\is_string($type->value())) {
return false;
}
return \function_exists($type->value());
}
private function isObjectCallback(SimpleType $type): bool
{
if (!\is_array($type->value())) {
return false;
}
if (\count($type->value()) !== 2) {
return false;
}
if (!\is_object($type->value()[0]) || !\is_string($type->value()[1])) {
return false;
}
[$object, $methodName] = $type->value();
$reflector = new \ReflectionObject($object);
return $reflector->hasMethod($methodName);
}
private function isClassCallback(SimpleType $type): bool
{
if (!\is_string($type->value()) && !\is_array($type->value())) {
return false;
}
if (\is_string($type->value())) {
if (\strpos($type->value(), '::') === false) {
return false;
}
[$className, $methodName] = \explode('::', $type->value());
}
if (\is_array($type->value())) {
if (\count($type->value()) !== 2) {
return false;
}
if (!\is_string($type->value()[0]) || !\is_string($type->value()[1])) {
return false;
}
[$className, $methodName] = $type->value();
}
\assert(isset($className) && \is_string($className));
\assert(isset($methodName) && \is_string($methodName));
try {
$class = new \ReflectionClass($className);
if ($class->hasMethod($methodName)) {
$method = $class->getMethod($methodName);
return $method->isPublic() && $method->isStatic();
}
// @codeCoverageIgnoreStart
} catch (\ReflectionException $e) {
throw new RuntimeException(
$e->getMessage(),
(int) $e->getCode(),
$e
);
// @codeCoverageIgnoreEnd
}
return false;
}
}
PK ! k5 type/src/Type.phpnu 刐迭
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Type;
abstract class Type
{
public static function fromValue($value, bool $allowsNull): self
{
$typeName = \gettype($value);
if ($typeName === 'object') {
return new ObjectType(TypeName::fromQualifiedName(\get_class($value)), $allowsNull);
}
$type = self::fromName($typeName, $allowsNull);
if ($type instanceof SimpleType) {
$type = new SimpleType($typeName, $allowsNull, $value);
}
return $type;
}
public static function fromName(string $typeName, bool $allowsNull): self
{
switch (\strtolower($typeName)) {
case 'callable':
return new CallableType($allowsNull);
case 'iterable':
return new IterableType($allowsNull);
case 'null':
return new NullType;
case 'object':
return new GenericObjectType($allowsNull);
case 'unknown type':
return new UnknownType;
case 'void':
return new VoidType;
case 'array':
case 'bool':
case 'boolean':
case 'double':
case 'float':
case 'int':
case 'integer':
case 'real':
case 'resource':
case 'resource (closed)':
case 'string':
return new SimpleType($typeName, $allowsNull);
default:
return new ObjectType(TypeName::fromQualifiedName($typeName), $allowsNull);
}
}
abstract public function isAssignable(Type $other): bool;
abstract public function getReturnTypeDeclaration(): string;
abstract public function allowsNull(): bool;
}
PK ! 56媴w w ' type/src/exception/RuntimeException.phpnu 刐迭
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Type;
final class RuntimeException extends \RuntimeException implements Exception
{
}
PK ! g@杉a a type/src/exception/Exception.phpnu 刐迭
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Type;
use Throwable;
interface Exception extends Throwable
{
}
PK ! type/src/GenericObjectType.phpnu 刐迭
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Type;
final class GenericObjectType extends Type
{
/**
* @var bool
*/
private $allowsNull;
public function __construct(bool $nullable)
{
$this->allowsNull = $nullable;
}
public function isAssignable(Type $other): bool
{
if ($this->allowsNull && $other instanceof NullType) {
return true;
}
if (!$other instanceof ObjectType) {
return false;
}
return true;
}
public function getReturnTypeDeclaration(): string
{
return ': ' . ($this->allowsNull ? '?' : '') . 'object';
}
public function allowsNull(): bool
{
return $this->allowsNull;
}
}
PK ! 猾E E type/src/UnknownType.phpnu 刐迭
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Type;
final class UnknownType extends Type
{
public function isAssignable(Type $other): bool
{
return true;
}
public function getReturnTypeDeclaration(): string
{
return '';
}
public function allowsNull(): bool
{
return true;
}
}
PK ! g type/src/SimpleType.phpnu 刐迭
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Type;
final class SimpleType extends Type
{
/**
* @var string
*/
private $name;
/**
* @var bool
*/
private $allowsNull;
/**
* @var mixed
*/
private $value;
public function __construct(string $name, bool $nullable, $value = null)
{
$this->name = $this->normalize($name);
$this->allowsNull = $nullable;
$this->value = $value;
}
public function isAssignable(Type $other): bool
{
if ($this->allowsNull && $other instanceof NullType) {
return true;
}
if ($other instanceof self) {
return $this->name === $other->name;
}
return false;
}
public function getReturnTypeDeclaration(): string
{
return ': ' . ($this->allowsNull ? '?' : '') . $this->name;
}
public function allowsNull(): bool
{
return $this->allowsNull;
}
public function value()
{
return $this->value;
}
private function normalize(string $name): string
{
$name = \strtolower($name);
switch ($name) {
case 'boolean':
return 'bool';
case 'real':
case 'double':
return 'float';
case 'integer':
return 'int';
case '[]':
return 'array';
default:
return $name;
}
}
}
PK ! 罨 type/psalm.xmlnu 刐迭
PK ! 鳘霉 type/build.xmlnu 刐迭
PK ! 拿e9 type/.gitattributesnu 刐迭 /tools export-ignore
PK ! 婰馅 type/.gitignorenu 刐迭 /.php_cs
/.php_cs.cache
/.phpunit.result.cache
/composer.lock
/vendor
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
PK ! : diff/phpunit.xmlnu 誌w洞
tests
src
PK ! 坌f diff/README.mdnu 誌w洞 # sebastian/diff
Diff implementation for PHP, factored out of PHPUnit into a stand-alone component.
## Installation
You can add this library as a local, per-project dependency to your project using [Composer](https://getcomposer.org/):
composer require sebastian/diff
If you only need this library during development, for instance to run your project's test suite, then you should add it as a development-time dependency:
composer require --dev sebastian/diff
### Usage
The `Differ` class can be used to generate a textual representation of the difference between two strings:
```php
use SebastianBergmann\Diff\Differ;
$differ = new Differ;
print $differ->diff('foo', 'bar');
```
The code above yields the output below:
--- Original
+++ New
@@ @@
-foo
+bar
The `Parser` class can be used to parse a unified diff into an object graph:
```php
use SebastianBergmann\Diff\Parser;
use SebastianBergmann\Git;
$git = new Git('/usr/local/src/money');
$diff = $git->getDiff(
'948a1a07768d8edd10dcefa8315c1cbeffb31833',
'c07a373d2399f3e686234c4f7f088d635eb9641b'
);
$parser = new Parser;
print_r($parser->parse($diff));
```
The code above yields the output below:
Array
(
[0] => SebastianBergmann\Diff\Diff Object
(
[from:SebastianBergmann\Diff\Diff:private] => a/tests/MoneyTest.php
[to:SebastianBergmann\Diff\Diff:private] => b/tests/MoneyTest.php
[chunks:SebastianBergmann\Diff\Diff:private] => Array
(
[0] => SebastianBergmann\Diff\Chunk Object
(
[start:SebastianBergmann\Diff\Chunk:private] => 87
[startRange:SebastianBergmann\Diff\Chunk:private] => 7
[end:SebastianBergmann\Diff\Chunk:private] => 87
[endRange:SebastianBergmann\Diff\Chunk:private] => 7
[lines:SebastianBergmann\Diff\Chunk:private] => Array
(
[0] => SebastianBergmann\Diff\Line Object
(
[type:SebastianBergmann\Diff\Line:private] => 3
[content:SebastianBergmann\Diff\Line:private] => * @covers SebastianBergmann\Money\Money::add
)
[1] => SebastianBergmann\Diff\Line Object
(
[type:SebastianBergmann\Diff\Line:private] => 3
[content:SebastianBergmann\Diff\Line:private] => * @covers SebastianBergmann\Money\Money::newMoney
)
[2] => SebastianBergmann\Diff\Line Object
(
[type:SebastianBergmann\Diff\Line:private] => 3
[content:SebastianBergmann\Diff\Line:private] => */
)
[3] => SebastianBergmann\Diff\Line Object
(
[type:SebastianBergmann\Diff\Line:private] => 2
[content:SebastianBergmann\Diff\Line:private] => public function testAnotherMoneyWithSameCurrencyObjectCanBeAdded()
)
[4] => SebastianBergmann\Diff\Line Object
(
[type:SebastianBergmann\Diff\Line:private] => 1
[content:SebastianBergmann\Diff\Line:private] => public function testAnotherMoneyObjectWithSameCurrencyCanBeAdded()
)
[5] => SebastianBergmann\Diff\Line Object
(
[type:SebastianBergmann\Diff\Line:private] => 3
[content:SebastianBergmann\Diff\Line:private] => {
)
[6] => SebastianBergmann\Diff\Line Object
(
[type:SebastianBergmann\Diff\Line:private] => 3
[content:SebastianBergmann\Diff\Line:private] => $a = new Money(1, new Currency('EUR'));
)
[7] => SebastianBergmann\Diff\Line Object
(
[type:SebastianBergmann\Diff\Line:private] => 3
[content:SebastianBergmann\Diff\Line:private] => $b = new Money(2, new Currency('EUR'));
)
)
)
)
)
)
PK !
diff/LICENSEnu 誌w洞 sebastian/diff
Copyright (c) 2002-2017, Sebastian Bergmann .
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the name of Sebastian Bergmann nor the names of his
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
PK ! ?承* diff/tests/LineTest.phpnu 誌w洞
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Diff;
use PHPUnit\Framework\TestCase;
/**
* @covers SebastianBergmann\Diff\Line
*/
class LineTest extends TestCase
{
/**
* @var Line
*/
private $line;
protected function setUp()
{
$this->line = new Line;
}
public function testCanBeCreatedWithoutArguments()
{
$this->assertInstanceOf('SebastianBergmann\Diff\Line', $this->line);
}
public function testTypeCanBeRetrieved()
{
$this->assertEquals(Line::UNCHANGED, $this->line->getType());
}
public function testContentCanBeRetrieved()
{
$this->assertEquals('', $this->line->getContent());
}
}
PK ! s'D ! diff/tests/fixtures/.editorconfignu 刐迭 root = true
PK ! 腢$ diff/tests/fixtures/patch.txtnu 誌w洞 diff --git a/Foo.php b/Foo.php
index abcdefg..abcdefh 100644
--- a/Foo.php
+++ b/Foo.php
@@ -20,4 +20,5 @@ class Foo
const ONE = 1;
const TWO = 2;
+ const THREE = 3;
const FOUR = 4;
PK ! s'D % diff/tests/fixtures/out/.editorconfignu 刐迭 root = true
PK ! 鞴D D " diff/tests/fixtures/out/.gitignorenu 刐迭 # reset all ignore rules to create sandbox for integration test
!/**PK ! Z$>/ / ' diff/tests/fixtures/serialized_diff.binnu 刐迭 a:1:{i:0;O:27:"SebastianBergmann\Diff\Diff":3:{s:33:" SebastianBergmann\Diff\Diff from";s:7:"old.txt";s:31:" SebastianBergmann\Diff\Diff to";s:7:"new.txt";s:35:" SebastianBergmann\Diff\Diff chunks";a:3:{i:0;O:28:"SebastianBergmann\Diff\Chunk":5:{s:35:" SebastianBergmann\Diff\Chunk start";i:1;s:40:" SebastianBergmann\Diff\Chunk startRange";i:3;s:33:" SebastianBergmann\Diff\Chunk end";i:1;s:38:" SebastianBergmann\Diff\Chunk endRange";i:4;s:35:" SebastianBergmann\Diff\Chunk lines";a:4:{i:0;O:27:"SebastianBergmann\Diff\Line":2:{s:33:" SebastianBergmann\Diff\Line type";i:1;s:36:" SebastianBergmann\Diff\Line content";s:7:"2222111";}i:1;O:27:"SebastianBergmann\Diff\Line":2:{s:33:" SebastianBergmann\Diff\Line type";i:3;s:36:" SebastianBergmann\Diff\Line content";s:7:"1111111";}i:2;O:27:"SebastianBergmann\Diff\Line":2:{s:33:" SebastianBergmann\Diff\Line type";i:3;s:36:" SebastianBergmann\Diff\Line content";s:7:"1111111";}i:3;O:27:"SebastianBergmann\Diff\Line":2:{s:33:" SebastianBergmann\Diff\Line type";i:3;s:36:" SebastianBergmann\Diff\Line content";s:7:"1111111";}}}i:1;O:28:"SebastianBergmann\Diff\Chunk":5:{s:35:" SebastianBergmann\Diff\Chunk start";i:5;s:40:" SebastianBergmann\Diff\Chunk startRange";i:10;s:33:" SebastianBergmann\Diff\Chunk end";i:6;s:38:" SebastianBergmann\Diff\Chunk endRange";i:8;s:35:" SebastianBergmann\Diff\Chunk lines";a:11:{i:0;O:27:"SebastianBergmann\Diff\Line":2:{s:33:" SebastianBergmann\Diff\Line type";i:3;s:36:" SebastianBergmann\Diff\Line content";s:7:"1111111";}i:1;O:27:"SebastianBergmann\Diff\Line":2:{s:33:" SebastianBergmann\Diff\Line type";i:3;s:36:" SebastianBergmann\Diff\Line content";s:7:"1111111";}i:2;O:27:"SebastianBergmann\Diff\Line":2:{s:33:" SebastianBergmann\Diff\Line type";i:3;s:36:" SebastianBergmann\Diff\Line content";s:7:"1111111";}i:3;O:27:"SebastianBergmann\Diff\Line":2:{s:33:" SebastianBergmann\Diff\Line type";i:3;s:36:" SebastianBergmann\Diff\Line content";s:8:"+1121211";}i:4;O:27:"SebastianBergmann\Diff\Line":2:{s:33:" SebastianBergmann\Diff\Line type";i:3;s:36:" SebastianBergmann\Diff\Line content";s:7:"1111111";}i:5;O:27:"SebastianBergmann\Diff\Line":2:{s:33:" SebastianBergmann\Diff\Line type";i:3;s:36:" SebastianBergmann\Diff\Line content";s:8:"-1111111";}i:6;O:27:"SebastianBergmann\Diff\Line":2:{s:33:" SebastianBergmann\Diff\Line type";i:3;s:36:" SebastianBergmann\Diff\Line content";s:8:"-1111111";}i:7;O:27:"SebastianBergmann\Diff\Line":2:{s:33:" SebastianBergmann\Diff\Line type";i:3;s:36:" SebastianBergmann\Diff\Line content";s:8:"-2222222";}i:8;O:27:"SebastianBergmann\Diff\Line":2:{s:33:" SebastianBergmann\Diff\Line type";i:3;s:36:" SebastianBergmann\Diff\Line content";s:7:"2222222";}i:9;O:27:"SebastianBergmann\Diff\Line":2:{s:33:" SebastianBergmann\Diff\Line type";i:3;s:36:" SebastianBergmann\Diff\Line content";s:7:"2222222";}i:10;O:27:"SebastianBergmann\Diff\Line":2:{s:33:" SebastianBergmann\Diff\Line type";i:3;s:36:" SebastianBergmann\Diff\Line content";s:7:"2222222";}}}i:2;O:28:"SebastianBergmann\Diff\Chunk":5:{s:35:" SebastianBergmann\Diff\Chunk start";i:17;s:40:" SebastianBergmann\Diff\Chunk startRange";i:5;s:33:" SebastianBergmann\Diff\Chunk end";i:16;s:38:" SebastianBergmann\Diff\Chunk endRange";i:6;s:35:" SebastianBergmann\Diff\Chunk lines";a:6:{i:0;O:27:"SebastianBergmann\Diff\Line":2:{s:33:" SebastianBergmann\Diff\Line type";i:3;s:36:" SebastianBergmann\Diff\Line content";s:7:"2222222";}i:1;O:27:"SebastianBergmann\Diff\Line":2:{s:33:" SebastianBergmann\Diff\Line type";i:3;s:36:" SebastianBergmann\Diff\Line content";s:7:"2222222";}i:2;O:27:"SebastianBergmann\Diff\Line":2:{s:33:" SebastianBergmann\Diff\Line type";i:3;s:36:" SebastianBergmann\Diff\Line content";s:7:"2222222";}i:3;O:27:"SebastianBergmann\Diff\Line":2:{s:33:" SebastianBergmann\Diff\Line type";i:3;s:36:" SebastianBergmann\Diff\Line content";s:8:"+2122212";}i:4;O:27:"SebastianBergmann\Diff\Line":2:{s:33:" SebastianBergmann\Diff\Line type";i:3;s:36:" SebastianBergmann\Diff\Line content";s:7:"2222222";}i:5;O:27:"SebastianBergmann\Diff\Line":2:{s:33:" SebastianBergmann\Diff\Line type";i:3;s:36:" SebastianBergmann\Diff\Line content";s:7:"2222222";}}}}}}PK ! C痉 A diff/tests/fixtures/UnifiedDiffAssertTraitIntegrationTest/1_a.txtnu 刐迭 aPK ! 2# # A diff/tests/fixtures/UnifiedDiffAssertTraitIntegrationTest/2_b.txtnu 刐迭 a
a
a
a
a
a
a
a
a
a
b
a
a
a
a
a
a
cPK ! &/鬍 E A diff/tests/fixtures/UnifiedDiffAssertTraitIntegrationTest/2_a.txtnu 刐迭 a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
aPK ! A diff/tests/fixtures/UnifiedDiffAssertTraitIntegrationTest/1_b.txtnu 刐迭 PK ! @k閻 diff/tests/fixtures/patch2.txtnu 誌w洞 diff --git a/Foo.php b/Foo.php
index abcdefg..abcdefh 100644
--- a/Foo.php
+++ b/Foo.php
@@ -20,4 +20,5 @@ class Foo
const ONE = 1;
const TWO = 2;
+ const THREE = 3;
const FOUR = 4;
@@ -320,4 +320,5 @@ class Foo
const A = 'A';
const B = 'B';
+ const C = 'C';
const D = 'D';
@@ -600,4 +600,5 @@ class Foo
public function doSomething() {
+ return 'foo';
}
PK ! 嘜鼺
diff/tests/ChunkTest.phpnu 誌w洞
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Diff;
use PHPUnit\Framework\TestCase;
/**
* @covers SebastianBergmann\Diff\Chunk
*/
class ChunkTest extends TestCase
{
/**
* @var Chunk
*/
private $chunk;
protected function setUp()
{
$this->chunk = new Chunk;
}
public function testCanBeCreatedWithoutArguments()
{
$this->assertInstanceOf('SebastianBergmann\Diff\Chunk', $this->chunk);
}
public function testStartCanBeRetrieved()
{
$this->assertEquals(0, $this->chunk->getStart());
}
public function testStartRangeCanBeRetrieved()
{
$this->assertEquals(1, $this->chunk->getStartRange());
}
public function testEndCanBeRetrieved()
{
$this->assertEquals(0, $this->chunk->getEnd());
}
public function testEndRangeCanBeRetrieved()
{
$this->assertEquals(1, $this->chunk->getEndRange());
}
public function testLinesCanBeRetrieved()
{
$this->assertEquals(array(), $this->chunk->getLines());
}
public function testLinesCanBeSet()
{
$this->assertEquals(array(), $this->chunk->getLines());
$testValue = array('line0', 'line1');
$this->chunk->setLines($testValue);
$this->assertEquals($testValue, $this->chunk->getLines());
}
}
PK ! 犡锨><