updated-packages

This commit is contained in:
RafficMohammed
2023-01-08 00:13:22 +05:30
parent 3ff7df7487
commit da241bacb6
12659 changed files with 563377 additions and 510538 deletions

View File

@@ -0,0 +1 @@
patreon: s_bergmann

View File

@@ -1,40 +0,0 @@
# Configuration for probot-stale - https://github.com/probot/stale
# Number of days of inactivity before an Issue or Pull Request becomes stale
daysUntilStale: 60
# Number of days of inactivity before a stale Issue or Pull Request is closed.
# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
daysUntilClose: 7
# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable
exemptLabels:
- enhancement
# Set to true to ignore issues in a project (defaults to false)
exemptProjects: false
# Set to true to ignore issues in a milestone (defaults to false)
exemptMilestones: false
# Label to use when marking as stale
staleLabel: stale
# Comment to post when marking as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had activity within the last 60 days. It will be closed after 7 days if no further activity occurs. Thank you for your contributions.
# Comment to post when removing the stale label.
# unmarkComment: >
# Your comment here.
# Comment to post when closing a stale Issue or Pull Request.
closeComment: >
This issue has been automatically closed because it has not had activity since it was marked as stale. Thank you for your contributions.
# Limit the number of actions per hour, from 1-30. Default is 30
limitPerRun: 30
# Limit to only `issues` or `pulls`
only: issues

View File

@@ -4,7 +4,7 @@ php:
- 7.1
- 7.2
- 7.3
- master
- 7.4snapshot
sudo: false

View File

@@ -2,6 +2,36 @@
All notable changes to `sebastianbergmann/php-token-stream` are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
## [3.1.3] - 2021-07-26
### Changed
* The declarations of methods in `PHP_Token_Stream` that implement the `ArrayAccess`, `Countable`, and `SeekableIterator` interfaces are now compatible with PHP 8.1
## [3.1.2] - 2020-11-30
### Changed
* Changed PHP version constraint in `composer.json` from `^7.1` to `>=7.1` to allow installation of this version of this library on PHP 8. However, this version of this library does not work on PHP 8. PHPUnit 8.5, which uses this version of this library (through phpunit/php-code-coverage), does not call into this library and instead shows a message that code coverage functionality is not available for PHPUnit 8.5 on PHP 8.
## [3.1.1] - 2019-09-17
### Fixed
* Fixed [#84](https://github.com/sebastianbergmann/php-token-stream/issues/84): Methods named `class` are not handled correctly
## [3.1.0] - 2019-07-25
### Added
* Added support for `FN` and `COALESCE_EQUAL` tokens introduced in PHP 7.4
## [3.0.2] - 2019-07-08
### Changed
* Implemented [#82](https://github.com/sebastianbergmann/php-token-stream/issues/82): Make sure this component works when its classes are prefixed using php-scoper
## [3.0.1] - 2018-10-30
### Fixed
@@ -29,6 +59,11 @@ All notable changes to `sebastianbergmann/php-token-stream` are documented in th
## [2.0.0] - 2017-08-03
[3.1.3]: https://github.com/sebastianbergmann/php-token-stream/compare/3.1.2...3.1.3
[3.1.2]: https://github.com/sebastianbergmann/php-token-stream/compare/3.1.1...3.1.2
[3.1.1]: https://github.com/sebastianbergmann/php-token-stream/compare/3.1.0...3.1.1
[3.1.0]: https://github.com/sebastianbergmann/php-token-stream/compare/3.0.2...3.1.0
[3.0.2]: https://github.com/sebastianbergmann/php-token-stream/compare/3.0.1...3.0.2
[3.0.1]: https://github.com/sebastianbergmann/php-token-stream/compare/3.0.0...3.0.1
[3.0.0]: https://github.com/sebastianbergmann/php-token-stream/compare/2.0...3.0.0
[2.0.2]: https://github.com/sebastianbergmann/php-token-stream/compare/2.0.1...2.0.2

View File

@@ -1,6 +1,6 @@
php-token-stream
Copyright (c) 2009-2018, Sebastian Bergmann <sebastian@phpunit.de>.
Copyright (c) 2009-2019, Sebastian Bergmann <sebastian@phpunit.de>.
All rights reserved.
Redistribution and use in source and binary forms, with or without

View File

@@ -16,7 +16,7 @@
},
"prefer-stable": true,
"require": {
"php": "^7.1",
"php": ">=7.1",
"ext-tokenizer": "*"
},
"require-dev": {
@@ -33,7 +33,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
"dev-master": "3.1-dev"
}
}
}

View File

@@ -1,13 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.0/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.4/phpunit.xsd"
bootstrap="tests/bootstrap.php"
forceCoversAnnotation="false"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
verbose="true">
<testsuite>
<directory suffix="Test.php">tests</directory>
</testsuite>
<testsuites>
<testsuite name="default">
<directory suffix="Test.php">tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">

View File

@@ -186,7 +186,7 @@ abstract class PHP_TokenWithScopeAndVisibility extends PHP_TokenWithScope
$tokens[$i] instanceof PHP_Token_PROTECTED ||
$tokens[$i] instanceof PHP_Token_PUBLIC)) {
return strtolower(
str_replace('PHP_Token_', '', get_class($tokens[$i]))
str_replace('PHP_Token_', '', PHP_Token_Util::getClass($tokens[$i]))
);
}
if (isset($tokens[$i]) &&
@@ -220,7 +220,7 @@ abstract class PHP_TokenWithScopeAndVisibility extends PHP_TokenWithScope
$tokens[$i] instanceof PHP_Token_FINAL ||
$tokens[$i] instanceof PHP_Token_ABSTRACT)) {
$keywords[] = strtolower(
str_replace('PHP_Token_', '', get_class($tokens[$i]))
str_replace('PHP_Token_', '', PHP_Token_Util::getClass($tokens[$i]))
);
}
}
@@ -272,7 +272,7 @@ abstract class PHP_Token_Includes extends PHP_Token
if ($tokens[$this->id + 2] instanceof PHP_Token_CONSTANT_ENCAPSED_STRING) {
$this->name = trim($tokens[$this->id + 2], "'\"");
$this->type = strtolower(
str_replace('PHP_Token_', '', get_class($tokens[$this->id]))
str_replace('PHP_Token_', '', PHP_Token_Util::getClass($tokens[$this->id]))
);
}
}
@@ -405,7 +405,7 @@ class PHP_Token_FUNCTION extends PHP_TokenWithScopeAndVisibility
$tokens = $this->tokenStream->tokens();
for ($i = $this->id; $i <= $end; $i++) {
switch (get_class($tokens[$i])) {
switch (PHP_Token_Util::getClass($tokens[$i])) {
case 'PHP_Token_IF':
case 'PHP_Token_ELSEIF':
case 'PHP_Token_FOR':
@@ -1350,3 +1350,12 @@ class PHP_Token_SPACESHIP extends PHP_Token
class PHP_Token_YIELD_FROM extends PHP_Token
{
}
// Tokens introduced in PHP 7.4
class PHP_Token_COALESCE_EQUAL extends PHP_Token
{
}
class PHP_Token_FN extends PHP_Token
{
}

View File

@@ -204,10 +204,7 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator
$this->linesOfCode['cloc'];
}
/**
* @return int
*/
public function count()
public function count(): int
{
return count($this->tokens);
}
@@ -303,7 +300,7 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator
];
foreach ($this->tokens as $token) {
switch (get_class($token)) {
switch (PHP_Token_Util::getClass($token)) {
case 'PHP_Token_REQUIRE_ONCE':
case 'PHP_Token_REQUIRE':
case 'PHP_Token_INCLUDE_ONCE':
@@ -358,7 +355,7 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator
$interfaceEndLine = false;
foreach ($this->tokens as $token) {
switch (get_class($token)) {
switch (PHP_Token_Util::getClass($token)) {
case 'PHP_Token_HALT_COMPILER':
return;
@@ -392,15 +389,17 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator
'file' => $this->filename
];
if ($token instanceof PHP_Token_CLASS) {
$class[] = $token->getName();
$classEndLine[] = $token->getEndLine();
if ($token->getName() !== null) {
if ($token instanceof PHP_Token_CLASS) {
$class[] = $token->getName();
$classEndLine[] = $token->getEndLine();
$this->classes[$class[count($class) - 1]] = $tmp;
} else {
$trait = $token->getName();
$traitEndLine = $token->getEndLine();
$this->traits[$trait] = $tmp;
$this->classes[$class[count($class) - 1]] = $tmp;
} else {
$trait = $token->getName();
$traitEndLine = $token->getEndLine();
$this->traits[$trait] = $tmp;
}
}
break;
@@ -475,61 +474,42 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator
return $this->linesOfCode;
}
/**
*/
public function rewind()
public function rewind(): void
{
$this->position = 0;
}
/**
* @return bool
*/
public function valid()
public function valid(): bool
{
return isset($this->tokens[$this->position]);
}
/**
* @return int
*/
#[\ReturnTypeWillChange]
public function key()
{
return $this->position;
}
/**
* @return PHP_Token
*/
#[\ReturnTypeWillChange]
public function current()
{
return $this->tokens[$this->position];
}
/**
*/
public function next()
public function next(): void
{
$this->position++;
}
/**
* @param int $offset
*
* @return bool
*/
public function offsetExists($offset)
public function offsetExists($offset): bool
{
return isset($this->tokens[$offset]);
}
/**
* @param int $offset
*
* @return mixed
*
* @throws OutOfBoundsException
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
if (!$this->offsetExists($offset)) {
@@ -548,7 +528,7 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator
* @param int $offset
* @param mixed $value
*/
public function offsetSet($offset, $value)
public function offsetSet($offset, $value): void
{
$this->tokens[$offset] = $value;
}
@@ -558,7 +538,7 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator
*
* @throws OutOfBoundsException
*/
public function offsetUnset($offset)
public function offsetUnset($offset): void
{
if (!$this->offsetExists($offset)) {
throw new OutOfBoundsException(
@@ -579,7 +559,7 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator
*
* @throws OutOfBoundsException
*/
public function seek($position)
public function seek($position): void
{
$this->position = $position;

View File

@@ -0,0 +1,19 @@
<?php declare(strict_types=1);
/*
* This file is part of php-token-stream.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
final class PHP_Token_Util
{
public static function getClass($object): string
{
$parts = explode('\\', get_class($object));
return array_pop($parts);
}
}

View File

@@ -24,9 +24,7 @@ class PHP_Token_ClassTest extends TestCase
protected function setUp()
{
$ts = new PHP_Token_Stream(TEST_FILES_PATH . 'source2.php');
foreach ($ts as $token) {
foreach (new PHP_Token_Stream(TEST_FILES_PATH . 'source2.php') as $token) {
if ($token instanceof PHP_Token_CLASS) {
$this->class = $token;
}
@@ -38,25 +36,16 @@ class PHP_Token_ClassTest extends TestCase
}
}
/**
* @covers PHP_Token_CLASS::getKeywords
*/
public function testGetClassKeywords()
{
$this->assertEquals('abstract', $this->class->getKeywords());
}
/**
* @covers PHP_Token_FUNCTION::getKeywords
*/
public function testGetFunctionKeywords()
{
$this->assertEquals('abstract,static', $this->function->getKeywords());
}
/**
* @covers PHP_Token_FUNCTION::getVisibility
*/
public function testGetFunctionVisibility()
{
$this->assertEquals('public', $this->function->getVisibility());
@@ -64,9 +53,7 @@ class PHP_Token_ClassTest extends TestCase
public function testIssue19()
{
$ts = new PHP_Token_Stream(TEST_FILES_PATH . 'issue19.php');
foreach ($ts as $token) {
foreach (new PHP_Token_Stream(TEST_FILES_PATH . 'issue19.php') as $token) {
if ($token instanceof PHP_Token_CLASS) {
$this->assertFalse($token->hasInterfaces());
}
@@ -143,9 +130,7 @@ class PHP_Token_ClassTest extends TestCase
*/
public function testClassWithMethodNamedEmptyIsHandledCorrectly()
{
$ts = new PHP_Token_Stream(TEST_FILES_PATH . 'class_with_method_named_empty.php');
$classes = $ts->getClasses();
$classes = (new PHP_Token_Stream(TEST_FILES_PATH . 'class_with_method_named_empty.php'))->getClasses();
$this->assertArrayHasKey('class_with_method_named_empty', $classes);
$this->assertArrayHasKey('empty', $classes['class_with_method_named_empty']['methods']);
@@ -156,9 +141,7 @@ class PHP_Token_ClassTest extends TestCase
*/
public function testAnonymousFunctionDoesNotAffectStartAndEndLineOfMethod()
{
$ts = new PHP_Token_Stream(TEST_FILES_PATH . 'php-code-coverage-issue-424.php');
$classes = $ts->getClasses();
$classes = (new PHP_Token_Stream(TEST_FILES_PATH . 'php-code-coverage-issue-424.php'))->getClasses();
$this->assertSame(5, $classes['Example']['methods']['even']['startLine']);
$this->assertSame(12, $classes['Example']['methods']['even']['endLine']);

View File

@@ -19,18 +19,13 @@ class PHP_Token_ClosureTest extends TestCase
protected function setUp()
{
$ts = new PHP_Token_Stream(TEST_FILES_PATH . 'closure.php');
foreach ($ts as $token) {
foreach (new PHP_Token_Stream(TEST_FILES_PATH . 'closure.php') as $token) {
if ($token instanceof PHP_Token_FUNCTION) {
$this->functions[] = $token;
}
}
}
/**
* @covers PHP_Token_FUNCTION::getArguments
*/
public function testGetArguments()
{
$this->assertEquals(['$foo' => null, '$bar' => null], $this->functions[0]->getArguments());
@@ -41,9 +36,6 @@ class PHP_Token_ClosureTest extends TestCase
$this->assertEquals([], $this->functions[5]->getArguments());
}
/**
* @covers PHP_Token_FUNCTION::getName
*/
public function testGetName()
{
$this->assertEquals('anonymousFunction:2#5', $this->functions[0]->getName());
@@ -54,9 +46,6 @@ class PHP_Token_ClosureTest extends TestCase
$this->assertEquals('anonymousFunction:7#106', $this->functions[5]->getName());
}
/**
* @covers PHP_Token::getLine
*/
public function testGetLine()
{
$this->assertEquals(2, $this->functions[0]->getLine());
@@ -65,9 +54,6 @@ class PHP_Token_ClosureTest extends TestCase
$this->assertEquals(5, $this->functions[3]->getLine());
}
/**
* @covers PHP_TokenWithScope::getEndLine
*/
public function testGetEndLine()
{
$this->assertEquals(2, $this->functions[0]->getLine());

View File

@@ -19,32 +19,27 @@ class PHP_Token_FunctionTest extends TestCase
protected function setUp()
{
$ts = new PHP_Token_Stream(TEST_FILES_PATH . 'source.php');
foreach ($ts as $token) {
foreach (new PHP_Token_Stream(TEST_FILES_PATH . 'source.php') as $token) {
if ($token instanceof PHP_Token_FUNCTION) {
$this->functions[] = $token;
}
}
}
/**
* @covers PHP_Token_FUNCTION::getArguments
*/
public function testGetArguments()
{
$this->assertEquals([], $this->functions[0]->getArguments());
$this->assertEquals(
['$baz' => 'Baz'], $this->functions[1]->getArguments()
['$baz' => 'Baz'], $this->functions[1]->getArguments()
);
$this->assertEquals(
['$foobar' => 'Foobar'], $this->functions[2]->getArguments()
['$foobar' => 'Foobar'], $this->functions[2]->getArguments()
);
$this->assertEquals(
['$barfoo' => 'Barfoo'], $this->functions[3]->getArguments()
['$barfoo' => 'Barfoo'], $this->functions[3]->getArguments()
);
$this->assertEquals([], $this->functions[4]->getArguments());
@@ -52,9 +47,6 @@ class PHP_Token_FunctionTest extends TestCase
$this->assertEquals(['$x' => null, '$y' => null], $this->functions[5]->getArguments());
}
/**
* @covers PHP_Token_FUNCTION::getName
*/
public function testGetName()
{
$this->assertEquals('foo', $this->functions[0]->getName());
@@ -64,9 +56,6 @@ class PHP_Token_FunctionTest extends TestCase
$this->assertEquals('baz', $this->functions[4]->getName());
}
/**
* @covers PHP_Token::getLine
*/
public function testGetLine()
{
$this->assertEquals(5, $this->functions[0]->getLine());
@@ -77,9 +66,6 @@ class PHP_Token_FunctionTest extends TestCase
$this->assertEquals(37, $this->functions[6]->getLine());
}
/**
* @covers PHP_TokenWithScope::getEndLine
*/
public function testGetEndLine()
{
$this->assertEquals(5, $this->functions[0]->getEndLine());
@@ -90,21 +76,18 @@ class PHP_Token_FunctionTest extends TestCase
$this->assertEquals(41, $this->functions[6]->getEndLine());
}
/**
* @covers PHP_Token_FUNCTION::getDocblock
*/
public function testGetDocblock()
{
$this->assertNull($this->functions[0]->getDocblock());
$this->assertEquals(
"/**\n * @param Baz \$baz\n */",
$this->functions[1]->getDocblock()
"/**\n * @param Baz \$baz\n */",
$this->functions[1]->getDocblock()
);
$this->assertEquals(
"/**\n * @param Foobar \$foobar\n */",
$this->functions[2]->getDocblock()
"/**\n * @param Foobar \$foobar\n */",
$this->functions[2]->getDocblock()
);
$this->assertNull($this->functions[3]->getDocblock());
@@ -113,29 +96,29 @@ class PHP_Token_FunctionTest extends TestCase
public function testSignature()
{
$ts = new PHP_Token_Stream(TEST_FILES_PATH . 'source5.php');
$f = $ts->getFunctions();
$c = $ts->getClasses();
$i = $ts->getInterfaces();
$tokens = new PHP_Token_Stream(TEST_FILES_PATH . 'source5.php');
$functions = $tokens->getFunctions();
$classes = $tokens->getClasses();
$interfaces = $tokens->getInterfaces();
$this->assertEquals(
'foo($a, array $b, array $c = array())',
$f['foo']['signature']
'foo($a, array $b, array $c = array())',
$functions['foo']['signature']
);
$this->assertEquals(
'm($a, array $b, array $c = array())',
$c['c']['methods']['m']['signature']
'm($a, array $b, array $c = array())',
$classes['c']['methods']['m']['signature']
);
$this->assertEquals(
'm($a, array $b, array $c = array())',
$c['a']['methods']['m']['signature']
'm($a, array $b, array $c = array())',
$classes['a']['methods']['m']['signature']
);
$this->assertEquals(
'm($a, array $b, array $c = array())',
$i['i']['methods']['m']['signature']
'm($a, array $b, array $c = array())',
$interfaces['i']['methods']['m']['signature']
);
}
}

View File

@@ -22,44 +22,32 @@ class PHP_Token_IncludeTest extends TestCase
$this->ts = new PHP_Token_Stream(TEST_FILES_PATH . 'source3.php');
}
/**
* @covers PHP_Token_Includes::getName
* @covers PHP_Token_Includes::getType
*/
public function testGetIncludes()
{
$this->assertSame(
['test4.php', 'test3.php', 'test2.php', 'test1.php'],
$this->ts->getIncludes()
['test4.php', 'test3.php', 'test2.php', 'test1.php'],
$this->ts->getIncludes()
);
}
/**
* @covers PHP_Token_Includes::getName
* @covers PHP_Token_Includes::getType
*/
public function testGetIncludesCategorized()
{
$this->assertSame(
[
'require_once' => ['test4.php'],
'require' => ['test3.php'],
'include_once' => ['test2.php'],
'include' => ['test1.php']
],
$this->ts->getIncludes(true)
[
'require_once' => ['test4.php'],
'require' => ['test3.php'],
'include_once' => ['test2.php'],
'include' => ['test1.php']
],
$this->ts->getIncludes(true)
);
}
/**
* @covers PHP_Token_Includes::getName
* @covers PHP_Token_Includes::getType
*/
public function testGetIncludesCategory()
{
$this->assertSame(
['test4.php'],
$this->ts->getIncludes(true, 'require_once')
['test4.php'],
$this->ts->getIncludes(true, 'require_once')
);
}
}

View File

@@ -37,9 +37,6 @@ class PHP_Token_InterfaceTest extends TestCase
}
}
/**
* @covers PHP_Token_INTERFACE::getName
*/
public function testGetName()
{
$this->assertEquals(
@@ -47,9 +44,6 @@ class PHP_Token_InterfaceTest extends TestCase
);
}
/**
* @covers PHP_Token_INTERFACE::getParent
*/
public function testGetParentNotExists()
{
$this->assertFalse(
@@ -57,9 +51,6 @@ class PHP_Token_InterfaceTest extends TestCase
);
}
/**
* @covers PHP_Token_INTERFACE::hasParent
*/
public function testHasParentNotExists()
{
$this->assertFalse(
@@ -67,9 +58,6 @@ class PHP_Token_InterfaceTest extends TestCase
);
}
/**
* @covers PHP_Token_INTERFACE::getParent
*/
public function testGetParentExists()
{
$this->assertEquals(
@@ -77,9 +65,6 @@ class PHP_Token_InterfaceTest extends TestCase
);
}
/**
* @covers PHP_Token_INTERFACE::hasParent
*/
public function testHasParentExists()
{
$this->assertTrue(
@@ -87,9 +72,6 @@ class PHP_Token_InterfaceTest extends TestCase
);
}
/**
* @covers PHP_Token_INTERFACE::getInterfaces
*/
public function testGetInterfacesExists()
{
$this->assertEquals(
@@ -98,9 +80,6 @@ class PHP_Token_InterfaceTest extends TestCase
);
}
/**
* @covers PHP_Token_INTERFACE::hasInterfaces
*/
public function testHasInterfacesExists()
{
$this->assertTrue(
@@ -108,13 +87,9 @@ class PHP_Token_InterfaceTest extends TestCase
);
}
/**
* @covers PHP_Token_INTERFACE::getPackage
*/
public function testGetPackageNamespace()
{
$tokenStream = new PHP_Token_Stream(TEST_FILES_PATH . 'classInNamespace.php');
foreach ($tokenStream as $token) {
foreach (new PHP_Token_Stream(TEST_FILES_PATH . 'classInNamespace.php') as $token) {
if ($token instanceof PHP_Token_INTERFACE) {
$package = $token->getPackage();
$this->assertSame('Foo\\Bar', $package['namespace']);
@@ -122,7 +97,6 @@ class PHP_Token_InterfaceTest extends TestCase
}
}
public function provideFilesWithClassesWithinMultipleNamespaces()
{
return [
@@ -133,12 +107,12 @@ class PHP_Token_InterfaceTest extends TestCase
/**
* @dataProvider provideFilesWithClassesWithinMultipleNamespaces
* @covers PHP_Token_INTERFACE::getPackage
*/
public function testGetPackageNamespaceForFileWithMultipleNamespaces($filepath)
{
$tokenStream = new PHP_Token_Stream($filepath);
$firstClassFound = false;
foreach ($tokenStream as $token) {
if ($firstClassFound === false && $token instanceof PHP_Token_INTERFACE) {
$package = $token->getPackage();
@@ -167,13 +141,11 @@ class PHP_Token_InterfaceTest extends TestCase
}
}
/**
* @covers PHP_Token_INTERFACE::getPackage
*/
public function testGetPackageNamespaceWhenExtentingFromNamespaceClass()
{
$tokenStream = new PHP_Token_Stream(TEST_FILES_PATH . 'classExtendsNamespacedClass.php');
$firstClassFound = false;
foreach ($tokenStream as $token) {
if ($firstClassFound === false && $token instanceof PHP_Token_INTERFACE) {
$package = $token->getPackage();
@@ -182,6 +154,7 @@ class PHP_Token_InterfaceTest extends TestCase
$firstClassFound = true;
continue;
}
if ($token instanceof PHP_Token_INTERFACE) {
$package = $token->getPackage();
$this->assertSame('Extender', $token->getName());
@@ -190,6 +163,7 @@ class PHP_Token_InterfaceTest extends TestCase
return;
}
}
$this->fail('Searching for 2 classes failed');
}
}

View File

@@ -12,9 +12,6 @@ use PHPUnit\Framework\TestCase;
class PHP_Token_NamespaceTest extends TestCase
{
/**
* @covers PHP_Token_NAMESPACE::getName
*/
public function testGetName()
{
$tokenStream = new PHP_Token_Stream(
@@ -30,8 +27,7 @@ class PHP_Token_NamespaceTest extends TestCase
public function testGetStartLineWithUnscopedNamespace()
{
$tokenStream = new PHP_Token_Stream(TEST_FILES_PATH . 'classInNamespace.php');
foreach ($tokenStream as $token) {
foreach (new PHP_Token_Stream(TEST_FILES_PATH . 'classInNamespace.php') as $token) {
if ($token instanceof PHP_Token_NAMESPACE) {
$this->assertSame(2, $token->getLine());
}
@@ -40,8 +36,7 @@ class PHP_Token_NamespaceTest extends TestCase
public function testGetEndLineWithUnscopedNamespace()
{
$tokenStream = new PHP_Token_Stream(TEST_FILES_PATH . 'classInNamespace.php');
foreach ($tokenStream as $token) {
foreach (new PHP_Token_Stream(TEST_FILES_PATH . 'classInNamespace.php') as $token) {
if ($token instanceof PHP_Token_NAMESPACE) {
$this->assertSame(2, $token->getEndLine());
}
@@ -49,8 +44,7 @@ class PHP_Token_NamespaceTest extends TestCase
}
public function testGetStartLineWithScopedNamespace()
{
$tokenStream = new PHP_Token_Stream(TEST_FILES_PATH . 'classInScopedNamespace.php');
foreach ($tokenStream as $token) {
foreach (new PHP_Token_Stream(TEST_FILES_PATH . 'classInScopedNamespace.php') as $token) {
if ($token instanceof PHP_Token_NAMESPACE) {
$this->assertSame(2, $token->getLine());
}
@@ -59,8 +53,7 @@ class PHP_Token_NamespaceTest extends TestCase
public function testGetEndLineWithScopedNamespace()
{
$tokenStream = new PHP_Token_Stream(TEST_FILES_PATH . 'classInScopedNamespace.php');
foreach ($tokenStream as $token) {
foreach (new PHP_Token_Stream(TEST_FILES_PATH . 'classInScopedNamespace.php') as $token) {
if ($token instanceof PHP_Token_NAMESPACE) {
$this->assertSame(8, $token->getEndLine());
}