Laravel version update
Laravel version update
This commit is contained in:
1
vendor/phpunit/php-token-stream/.gitignore
vendored
1
vendor/phpunit/php-token-stream/.gitignore
vendored
@@ -1,4 +1,3 @@
|
||||
/.idea
|
||||
/composer.lock
|
||||
/composer.phar
|
||||
/vendor
|
||||
|
27
vendor/phpunit/php-token-stream/.travis.yml
vendored
27
vendor/phpunit/php-token-stream/.travis.yml
vendored
@@ -1,35 +1,26 @@
|
||||
language: php
|
||||
|
||||
php:
|
||||
- 5.3.3
|
||||
- 5.3
|
||||
- 5.4
|
||||
- 5.5
|
||||
- 5.6
|
||||
- 7.0
|
||||
- hhvm
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- php: hhvm
|
||||
- 7.1
|
||||
- 7.2
|
||||
- master
|
||||
|
||||
sudo: false
|
||||
|
||||
before_install:
|
||||
- composer self-update
|
||||
- composer clear-cache
|
||||
|
||||
install:
|
||||
- travis_retry composer install --no-interaction --prefer-source
|
||||
- travis_retry composer update --no-interaction --no-ansi --no-progress --no-suggest
|
||||
|
||||
script:
|
||||
- ./vendor/bin/phpunit --configuration ./build/phpunit.xml
|
||||
- ./vendor/bin/phpunit --coverage-clover=coverage.xml
|
||||
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
webhooks:
|
||||
urls:
|
||||
- https://webhooks.gitter.im/e/6668f52f3dd4e3f81960
|
||||
on_success: always
|
||||
on_failure: always
|
||||
on_start: false
|
||||
|
||||
|
19
vendor/phpunit/php-token-stream/ChangeLog.md
vendored
Normal file
19
vendor/phpunit/php-token-stream/ChangeLog.md
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
# Change Log
|
||||
|
||||
All notable changes to `sebastianbergmann/php-token-stream` are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
|
||||
|
||||
## [2.0.2] - 2017-11-27
|
||||
|
||||
* Fixed [#69](https://github.com/sebastianbergmann/php-token-stream/issues/69): `PHP_Token_USE_FUNCTION` does not serialize correctly
|
||||
|
||||
## [2.0.1] - 2017-08-20
|
||||
|
||||
### Fixed
|
||||
|
||||
* Fixed [#68](https://github.com/sebastianbergmann/php-token-stream/issues/68): Method with name `empty` wrongly recognized as anonymous function
|
||||
|
||||
## [2.0.0] - 2017-08-03
|
||||
|
||||
[2.0.2]: https://github.com/sebastianbergmann/php-token-stream/compare/2.0.1...2.0.2
|
||||
[2.0.1]: https://github.com/sebastianbergmann/php-token-stream/compare/2.0.0...2.0.1
|
||||
[2.0.0]: https://github.com/sebastianbergmann/php-token-stream/compare/1.4.11...2.0.0
|
2
vendor/phpunit/php-token-stream/LICENSE
vendored
2
vendor/phpunit/php-token-stream/LICENSE
vendored
@@ -1,6 +1,6 @@
|
||||
PHP_TokenStream
|
||||
|
||||
Copyright (c) 2009-2015, Sebastian Bergmann <sebastian@phpunit.de>.
|
||||
Copyright (c) 2009-2017, Sebastian Bergmann <sebastian@phpunit.de>.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
15
vendor/phpunit/php-token-stream/README.md
vendored
15
vendor/phpunit/php-token-stream/README.md
vendored
@@ -1,13 +1,14 @@
|
||||
[](https://travis-ci.org/sebastianbergmann/php-token-stream)
|
||||
|
||||
# PHP_TokenStream
|
||||
# php-token-stream
|
||||
|
||||
## Installation
|
||||
|
||||
To add this package as a local, per-project dependency to your project, simply add a dependency on `phpunit/php-token-stream` to your project's `composer.json` file. Here is a minimal example of a `composer.json` file that just defines a dependency on PHP_TokenStream:
|
||||
You can add this library as a local, per-project dependency to your project using [Composer](https://getcomposer.org/):
|
||||
|
||||
composer require phpunit/php-token-stream
|
||||
|
||||
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 phpunit/php-token-stream
|
||||
|
||||
{
|
||||
"require": {
|
||||
"phpunit/php-token-stream": "~1.2"
|
||||
}
|
||||
}
|
||||
|
46
vendor/phpunit/php-token-stream/build.xml
vendored
46
vendor/phpunit/php-token-stream/build.xml
vendored
@@ -1,33 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="php-token-stream">
|
||||
<target name="clean" description="Cleanup build artifacts">
|
||||
<delete dir="${basedir}/vendor"/>
|
||||
<delete file="${basedir}/composer.lock"/>
|
||||
</target>
|
||||
<project name="php-token-stream" default="setup">
|
||||
<target name="setup" depends="clean,composer"/>
|
||||
|
||||
<target name="composer" depends="clean" description="Install dependencies with Composer">
|
||||
<tstamp>
|
||||
<format property="thirty.days.ago" pattern="MM/dd/yyyy hh:mm aa" offset="-30" unit="day"/>
|
||||
</tstamp>
|
||||
<delete>
|
||||
<fileset dir="${basedir}">
|
||||
<include name="composer.phar" />
|
||||
<date datetime="${thirty.days.ago}" when="before"/>
|
||||
</fileset>
|
||||
</delete>
|
||||
<target name="clean" description="Cleanup build artifacts">
|
||||
<delete dir="${basedir}/vendor"/>
|
||||
<delete file="${basedir}/composer.lock"/>
|
||||
</target>
|
||||
|
||||
<get src="https://getcomposer.org/composer.phar" dest="${basedir}/composer.phar" skipexisting="true"/>
|
||||
|
||||
<exec executable="php">
|
||||
<arg value="composer.phar"/>
|
||||
<arg value="install"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="phpunit" description="Run unit tests with PHPUnit">
|
||||
<exec executable="${basedir}/vendor/bin/phpunit" failonerror="true">
|
||||
<arg value="--configuration"/>
|
||||
<arg path="${basedir}/build/phpunit.xml"/>
|
||||
</exec>
|
||||
</target>
|
||||
<target name="composer" depends="clean" description="Install dependencies with Composer">
|
||||
<exec executable="composer" taskname="composer">
|
||||
<env key="COMPOSER_DISABLE_XDEBUG_WARN" value="1"/>
|
||||
<arg value="update"/>
|
||||
<arg value="--no-interaction"/>
|
||||
<arg value="--no-progress"/>
|
||||
<arg value="--no-ansi"/>
|
||||
<arg value="--no-suggest"/>
|
||||
</exec>
|
||||
</target>
|
||||
</project>
|
||||
|
||||
|
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
bootstrap="../tests/bootstrap.php"
|
||||
verbode="true">
|
||||
<testsuites>
|
||||
<testsuite name="php-token-stream">
|
||||
<directory suffix="Test.php">../tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<filter>
|
||||
<whitelist addUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">../src</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
10
vendor/phpunit/php-token-stream/composer.json
vendored
10
vendor/phpunit/php-token-stream/composer.json
vendored
@@ -15,11 +15,15 @@
|
||||
"issues": "https://github.com/sebastianbergmann/php-token-stream/issues"
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3",
|
||||
"php": "^7.0",
|
||||
"ext-tokenizer": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.2"
|
||||
"phpunit/phpunit": "^6.2.4"
|
||||
},
|
||||
"config": {
|
||||
"optimize-autoloader": true,
|
||||
"sort-packages": true
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
@@ -28,7 +32,7 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.4-dev"
|
||||
"dev-master": "2.0-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
17
vendor/phpunit/php-token-stream/phpunit.xml
vendored
Normal file
17
vendor/phpunit/php-token-stream/phpunit.xml
vendored
Normal file
@@ -0,0 +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"
|
||||
bootstrap="tests/bootstrap.php"
|
||||
beStrictAboutOutputDuringTests="true"
|
||||
beStrictAboutTodoAnnotatedTests="true"
|
||||
verbose="true">
|
||||
<testsuite>
|
||||
<directory suffix="Test.php">tests</directory>
|
||||
</testsuite>
|
||||
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">src</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
1114
vendor/phpunit/php-token-stream/src/Token.php
vendored
1114
vendor/phpunit/php-token-stream/src/Token.php
vendored
File diff suppressed because it is too large
Load Diff
125
vendor/phpunit/php-token-stream/src/Token/Stream.php
vendored
125
vendor/phpunit/php-token-stream/src/Token/Stream.php
vendored
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHP_TokenStream package.
|
||||
* This file is part of php-token-stream.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
@@ -10,19 +10,13 @@
|
||||
|
||||
/**
|
||||
* A stream of PHP tokens.
|
||||
*
|
||||
* @author Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @copyright Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
|
||||
* @link http://github.com/sebastianbergmann/php-token-stream/tree
|
||||
* @since Class available since Release 1.0.0
|
||||
*/
|
||||
class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected static $customTokens = array(
|
||||
protected static $customTokens = [
|
||||
'(' => 'PHP_Token_OPEN_BRACKET',
|
||||
')' => 'PHP_Token_CLOSE_BRACKET',
|
||||
'[' => 'PHP_Token_OPEN_SQUARE',
|
||||
@@ -51,7 +45,7 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator
|
||||
'^' => 'PHP_Token_CARET',
|
||||
'~' => 'PHP_Token_TILDE',
|
||||
'`' => 'PHP_Token_BACKTICK'
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* @var string
|
||||
@@ -61,17 +55,17 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $tokens = array();
|
||||
protected $tokens = [];
|
||||
|
||||
/**
|
||||
* @var integer
|
||||
* @var int
|
||||
*/
|
||||
protected $position = 0;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $linesOfCode = array('loc' => 0, 'cloc' => 0, 'ncloc' => 0);
|
||||
protected $linesOfCode = ['loc' => 0, 'cloc' => 0, 'ncloc' => 0];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
@@ -101,7 +95,7 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $lineToFunctionMap = array();
|
||||
protected $lineToFunctionMap = [];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -123,7 +117,7 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
$this->tokens = array();
|
||||
$this->tokens = [];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -142,7 +136,6 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @since Method available since Release 1.1.0
|
||||
*/
|
||||
public function getFilename()
|
||||
{
|
||||
@@ -157,6 +150,7 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator
|
||||
*/
|
||||
protected function scan($sourceCode)
|
||||
{
|
||||
$id = 0;
|
||||
$line = 1;
|
||||
$tokens = token_get_all($sourceCode);
|
||||
$numTokens = count($tokens);
|
||||
@@ -165,7 +159,7 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator
|
||||
|
||||
for ($i = 0; $i < $numTokens; ++$i) {
|
||||
$token = $tokens[$i];
|
||||
unset($tokens[$i]);
|
||||
$skip = 0;
|
||||
|
||||
if (is_array($token)) {
|
||||
$name = substr(token_name($token[0]), 2);
|
||||
@@ -173,6 +167,10 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator
|
||||
|
||||
if ($lastNonWhitespaceTokenWasDoubleColon && $name == 'CLASS') {
|
||||
$name = 'CLASS_NAME_CONSTANT';
|
||||
} elseif ($name == 'USE' && isset($tokens[$i + 2][0]) && $tokens[$i + 2][0] == T_FUNCTION) {
|
||||
$name = 'USE_FUNCTION';
|
||||
$text .= $tokens[$i + 1][1] . $tokens[$i + 2][1];
|
||||
$skip = 2;
|
||||
}
|
||||
|
||||
$tokenClass = 'PHP_Token_' . $name;
|
||||
@@ -181,9 +179,9 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator
|
||||
$tokenClass = self::$customTokens[$token];
|
||||
}
|
||||
|
||||
$this->tokens[] = new $tokenClass($text, $line, $this, $i);
|
||||
$this->tokens[] = new $tokenClass($text, $line, $this, $id++);
|
||||
$lines = substr_count($text, "\n");
|
||||
$line += $lines;
|
||||
$line += $lines;
|
||||
|
||||
if ($tokenClass == 'PHP_Token_HALT_COMPILER') {
|
||||
break;
|
||||
@@ -197,6 +195,8 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator
|
||||
} elseif ($name != 'WHITESPACE') {
|
||||
$lastNonWhitespaceTokenWasDoubleColon = false;
|
||||
}
|
||||
|
||||
$i += $skip;
|
||||
}
|
||||
|
||||
$this->linesOfCode['loc'] = substr_count($sourceCode, "\n");
|
||||
@@ -205,7 +205,7 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator
|
||||
}
|
||||
|
||||
/**
|
||||
* @return integer
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
@@ -264,7 +264,6 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @since Method available since Release 1.1.0
|
||||
*/
|
||||
public function getTraits()
|
||||
{
|
||||
@@ -289,19 +288,19 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator
|
||||
*
|
||||
* @param bool $categorize OPTIONAL
|
||||
* @param string $category OPTIONAL Either 'require_once', 'require',
|
||||
* 'include_once', 'include'.
|
||||
* 'include_once', 'include'.
|
||||
*
|
||||
* @return array
|
||||
* @since Method available since Release 1.1.0
|
||||
*/
|
||||
public function getIncludes($categorize = false, $category = null)
|
||||
{
|
||||
if ($this->includes === null) {
|
||||
$this->includes = array(
|
||||
'require_once' => array(),
|
||||
'require' => array(),
|
||||
'include_once' => array(),
|
||||
'include' => array()
|
||||
);
|
||||
$this->includes = [
|
||||
'require_once' => [],
|
||||
'require' => [],
|
||||
'include_once' => [],
|
||||
'include' => []
|
||||
];
|
||||
|
||||
foreach ($this->tokens as $token) {
|
||||
switch (get_class($token)) {
|
||||
@@ -335,7 +334,6 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator
|
||||
* Returns the name of the function or method a line belongs to.
|
||||
*
|
||||
* @return string or null if the line is not in a function or method
|
||||
* @since Method available since Release 1.2.0
|
||||
*/
|
||||
public function getFunctionForLine($line)
|
||||
{
|
||||
@@ -348,12 +346,12 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator
|
||||
|
||||
protected function parse()
|
||||
{
|
||||
$this->interfaces = array();
|
||||
$this->classes = array();
|
||||
$this->traits = array();
|
||||
$this->functions = array();
|
||||
$class = array();
|
||||
$classEndLine = array();
|
||||
$this->interfaces = [];
|
||||
$this->classes = [];
|
||||
$this->traits = [];
|
||||
$this->functions = [];
|
||||
$class = [];
|
||||
$classEndLine = [];
|
||||
$trait = false;
|
||||
$traitEndLine = false;
|
||||
$interface = false;
|
||||
@@ -368,8 +366,8 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator
|
||||
$interface = $token->getName();
|
||||
$interfaceEndLine = $token->getEndLine();
|
||||
|
||||
$this->interfaces[$interface] = array(
|
||||
'methods' => array(),
|
||||
$this->interfaces[$interface] = [
|
||||
'methods' => [],
|
||||
'parent' => $token->getParent(),
|
||||
'keywords' => $token->getKeywords(),
|
||||
'docblock' => $token->getDocblock(),
|
||||
@@ -377,13 +375,13 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator
|
||||
'endLine' => $interfaceEndLine,
|
||||
'package' => $token->getPackage(),
|
||||
'file' => $this->filename
|
||||
);
|
||||
];
|
||||
break;
|
||||
|
||||
case 'PHP_Token_CLASS':
|
||||
case 'PHP_Token_TRAIT':
|
||||
$tmp = array(
|
||||
'methods' => array(),
|
||||
$tmp = [
|
||||
'methods' => [],
|
||||
'parent' => $token->getParent(),
|
||||
'interfaces'=> $token->getInterfaces(),
|
||||
'keywords' => $token->getKeywords(),
|
||||
@@ -392,15 +390,13 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator
|
||||
'endLine' => $token->getEndLine(),
|
||||
'package' => $token->getPackage(),
|
||||
'file' => $this->filename
|
||||
);
|
||||
];
|
||||
|
||||
if ($token instanceof PHP_Token_CLASS) {
|
||||
$class[] = $token->getName();
|
||||
$classEndLine[] = $token->getEndLine();
|
||||
|
||||
if ($class[count($class)-1] != 'anonymous class') {
|
||||
$this->classes[$class[count($class)-1]] = $tmp;
|
||||
}
|
||||
$this->classes[$class[count($class) - 1]] = $tmp;
|
||||
} else {
|
||||
$trait = $token->getName();
|
||||
$traitEndLine = $token->getEndLine();
|
||||
@@ -410,7 +406,7 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator
|
||||
|
||||
case 'PHP_Token_FUNCTION':
|
||||
$name = $token->getName();
|
||||
$tmp = array(
|
||||
$tmp = [
|
||||
'docblock' => $token->getDocblock(),
|
||||
'keywords' => $token->getKeywords(),
|
||||
'visibility'=> $token->getVisibility(),
|
||||
@@ -419,7 +415,7 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator
|
||||
'endLine' => $token->getEndLine(),
|
||||
'ccn' => $token->getCCN(),
|
||||
'file' => $this->filename
|
||||
);
|
||||
];
|
||||
|
||||
if (empty($class) &&
|
||||
$trait === false &&
|
||||
@@ -431,11 +427,11 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator
|
||||
$tmp['startLine'],
|
||||
$tmp['endLine']
|
||||
);
|
||||
} elseif (!empty($class) && $class[count($class)-1] != 'anonymous class') {
|
||||
$this->classes[$class[count($class)-1]]['methods'][$name] = $tmp;
|
||||
} elseif (!empty($class)) {
|
||||
$this->classes[$class[count($class) - 1]]['methods'][$name] = $tmp;
|
||||
|
||||
$this->addFunctionToMap(
|
||||
$class[count($class)-1] . '::' . $name,
|
||||
$class[count($class) - 1] . '::' . $name,
|
||||
$tmp['startLine'],
|
||||
$tmp['endLine']
|
||||
);
|
||||
@@ -454,7 +450,7 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator
|
||||
|
||||
case 'PHP_Token_CLOSE_CURLY':
|
||||
if (!empty($classEndLine) &&
|
||||
$classEndLine[count($classEndLine)-1] == $token->getLine()) {
|
||||
$classEndLine[count($classEndLine) - 1] == $token->getLine()) {
|
||||
array_pop($classEndLine);
|
||||
array_pop($class);
|
||||
} elseif ($traitEndLine !== false &&
|
||||
@@ -487,7 +483,7 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
@@ -495,7 +491,7 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator
|
||||
}
|
||||
|
||||
/**
|
||||
* @return integer
|
||||
* @return int
|
||||
*/
|
||||
public function key()
|
||||
{
|
||||
@@ -518,8 +514,9 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $offset
|
||||
* @return boolean
|
||||
* @param int $offset
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
@@ -527,8 +524,10 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $offset
|
||||
* @param int $offset
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws OutOfBoundsException
|
||||
*/
|
||||
public function offsetGet($offset)
|
||||
@@ -546,8 +545,8 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $offset
|
||||
* @param mixed $value
|
||||
* @param int $offset
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
@@ -555,7 +554,8 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $offset
|
||||
* @param int $offset
|
||||
*
|
||||
* @throws OutOfBoundsException
|
||||
*/
|
||||
public function offsetUnset($offset)
|
||||
@@ -575,7 +575,8 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator
|
||||
/**
|
||||
* Seek to an absolute position.
|
||||
*
|
||||
* @param integer $position
|
||||
* @param int $position
|
||||
*
|
||||
* @throws OutOfBoundsException
|
||||
*/
|
||||
public function seek($position)
|
||||
@@ -593,9 +594,9 @@ class PHP_Token_Stream implements ArrayAccess, Countable, SeekableIterator
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param integer $startLine
|
||||
* @param integer $endLine
|
||||
* @param string $name
|
||||
* @param int $startLine
|
||||
* @param int $endLine
|
||||
*/
|
||||
private function addFunctionToMap($name, $startLine, $endLine)
|
||||
{
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHP_TokenStream package.
|
||||
* This file is part of php-token-stream.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
@@ -10,22 +10,17 @@
|
||||
|
||||
/**
|
||||
* A caching factory for token stream objects.
|
||||
*
|
||||
* @author Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @copyright Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
|
||||
* @link http://github.com/sebastianbergmann/php-token-stream/tree
|
||||
* @since Class available since Release 1.0.0
|
||||
*/
|
||||
class PHP_Token_Stream_CachingFactory
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected static $cache = array();
|
||||
protected static $cache = [];
|
||||
|
||||
/**
|
||||
* @param string $filename
|
||||
* @param string $filename
|
||||
*
|
||||
* @return PHP_Token_Stream
|
||||
*/
|
||||
public static function get($filename)
|
||||
@@ -45,7 +40,7 @@ class PHP_Token_Stream_CachingFactory
|
||||
if (is_string($filename)) {
|
||||
unset(self::$cache[$filename]);
|
||||
} else {
|
||||
self::$cache = array();
|
||||
self::$cache = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHP_TokenStream package.
|
||||
* This file is part of php-token-stream.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
@@ -8,22 +8,19 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests for the PHP_Token_CLASS class.
|
||||
*
|
||||
* @package PHP_TokenStream
|
||||
* @subpackage Tests
|
||||
* @author Laurent Laville <pear@laurent-laville.org>
|
||||
* @copyright Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
|
||||
* @version Release: @package_version@
|
||||
* @link http://github.com/sebastianbergmann/php-token-stream/
|
||||
* @since Class available since Release 1.0.2
|
||||
*/
|
||||
class PHP_Token_ClassTest extends PHPUnit_Framework_TestCase
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class PHP_Token_ClassTest extends TestCase
|
||||
{
|
||||
protected $class;
|
||||
protected $function;
|
||||
/**
|
||||
* @var PHP_Token_CLASS
|
||||
*/
|
||||
private $class;
|
||||
|
||||
/**
|
||||
* @var PHP_Token_FUNCTION
|
||||
*/
|
||||
private $function;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
@@ -82,21 +79,27 @@ class PHP_Token_ClassTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertCount(1, $ts->getClasses());
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 7
|
||||
*/
|
||||
public function testAnonymousClassesAreHandledCorrectly()
|
||||
{
|
||||
$ts = new PHP_Token_Stream(TEST_FILES_PATH . 'class_with_method_that_declares_anonymous_class.php');
|
||||
|
||||
$classes = $ts->getClasses();
|
||||
|
||||
$this->assertEquals(array('class_with_method_that_declares_anonymous_class'), array_keys($classes));
|
||||
$this->assertEquals(
|
||||
[
|
||||
'class_with_method_that_declares_anonymous_class',
|
||||
'AnonymousClass:9#31',
|
||||
'AnonymousClass:10#55',
|
||||
'AnonymousClass:11#75',
|
||||
'AnonymousClass:12#91',
|
||||
'AnonymousClass:13#107'
|
||||
],
|
||||
array_keys($classes)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 7
|
||||
* @ticket https://github.com/sebastianbergmann/php-token-stream/issues/52
|
||||
* @ticket https://github.com/sebastianbergmann/php-token-stream/issues/52
|
||||
*/
|
||||
public function testAnonymousClassesAreHandledCorrectly2()
|
||||
{
|
||||
@@ -104,9 +107,63 @@ class PHP_Token_ClassTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
$classes = $ts->getClasses();
|
||||
|
||||
$this->assertEquals(array('Test'), array_keys($classes));
|
||||
$this->assertEquals(array('methodOne', 'methodTwo'), array_keys($classes['Test']['methods']));
|
||||
$this->assertEquals(['Test', 'AnonymousClass:4#23'], array_keys($classes));
|
||||
$this->assertEquals(['methodOne', 'methodTwo'], array_keys($classes['Test']['methods']));
|
||||
|
||||
$this->assertEmpty($ts->getFunctions());
|
||||
}
|
||||
|
||||
public function testImportedFunctionsAreHandledCorrectly()
|
||||
{
|
||||
$ts = new PHP_Token_Stream(TEST_FILES_PATH . 'classUsesNamespacedFunction.php');
|
||||
|
||||
$this->assertEmpty($ts->getFunctions());
|
||||
$this->assertCount(1, $ts->getClasses());
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket https://github.com/sebastianbergmann/php-code-coverage/issues/543
|
||||
*/
|
||||
public function testClassWithMultipleAnonymousClassesAndFunctionsIsHandledCorrectly()
|
||||
{
|
||||
$ts = new PHP_Token_Stream(TEST_FILES_PATH . 'class_with_multiple_anonymous_classes_and_functions.php');
|
||||
|
||||
$classes = $ts->getClasses();
|
||||
|
||||
$this->assertArrayHasKey('class_with_multiple_anonymous_classes_and_functions', $classes);
|
||||
$this->assertArrayHasKey('AnonymousClass:6#23', $classes);
|
||||
$this->assertArrayHasKey('AnonymousClass:12#53', $classes);
|
||||
$this->assertArrayHasKey('m', $classes['class_with_multiple_anonymous_classes_and_functions']['methods']);
|
||||
$this->assertArrayHasKey('anonymousFunction:18#81', $classes['class_with_multiple_anonymous_classes_and_functions']['methods']);
|
||||
$this->assertArrayHasKey('anonymousFunction:22#108', $classes['class_with_multiple_anonymous_classes_and_functions']['methods']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket https://github.com/sebastianbergmann/php-token-stream/issues/68
|
||||
*/
|
||||
public function testClassWithMethodNamedEmptyIsHandledCorrectly()
|
||||
{
|
||||
$ts = new PHP_Token_Stream(TEST_FILES_PATH . 'class_with_method_named_empty.php');
|
||||
|
||||
$classes = $ts->getClasses();
|
||||
|
||||
$this->assertArrayHasKey('class_with_method_named_empty', $classes);
|
||||
$this->assertArrayHasKey('empty', $classes['class_with_method_named_empty']['methods']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket https://github.com/sebastianbergmann/php-code-coverage/issues/424
|
||||
*/
|
||||
public function testSomething()
|
||||
{
|
||||
$ts = new PHP_Token_Stream(TEST_FILES_PATH . 'php-code-coverage-issue-424.php');
|
||||
|
||||
$classes = $ts->getClasses();
|
||||
|
||||
$this->assertSame(5, $classes['Example']['methods']['even']['startLine']);
|
||||
$this->assertSame(12, $classes['Example']['methods']['even']['endLine']);
|
||||
|
||||
$this->assertSame(7, $classes['Example']['methods']['anonymousFunction:7#28']['startLine']);
|
||||
$this->assertSame(9, $classes['Example']['methods']['anonymousFunction:7#28']['endLine']);
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHP_TokenStream package.
|
||||
* This file is part of php-token-stream.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
@@ -8,21 +8,14 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests for the PHP_Token_FUNCTION class.
|
||||
*
|
||||
* @package PHP_TokenStream
|
||||
* @subpackage Tests
|
||||
* @author Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @copyright Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
|
||||
* @version Release: @package_version@
|
||||
* @link http://github.com/sebastianbergmann/php-token-stream/
|
||||
* @since Class available since Release 1.0.0
|
||||
*/
|
||||
class PHP_Token_ClosureTest extends PHPUnit_Framework_TestCase
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class PHP_Token_ClosureTest extends TestCase
|
||||
{
|
||||
protected $functions;
|
||||
/**
|
||||
* @var PHP_Token_FUNCTION[]
|
||||
*/
|
||||
private $functions;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
@@ -40,12 +33,12 @@ class PHP_Token_ClosureTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testGetArguments()
|
||||
{
|
||||
$this->assertEquals(array('$foo' => null, '$bar' => null), $this->functions[0]->getArguments());
|
||||
$this->assertEquals(array('$foo' => 'Foo', '$bar' => null), $this->functions[1]->getArguments());
|
||||
$this->assertEquals(array('$foo' => null, '$bar' => null, '$baz' => null), $this->functions[2]->getArguments());
|
||||
$this->assertEquals(array('$foo' => 'Foo', '$bar' => null, '$baz' => null), $this->functions[3]->getArguments());
|
||||
$this->assertEquals(array(), $this->functions[4]->getArguments());
|
||||
$this->assertEquals(array(), $this->functions[5]->getArguments());
|
||||
$this->assertEquals(['$foo' => null, '$bar' => null], $this->functions[0]->getArguments());
|
||||
$this->assertEquals(['$foo' => 'Foo', '$bar' => null], $this->functions[1]->getArguments());
|
||||
$this->assertEquals(['$foo' => null, '$bar' => null, '$baz' => null], $this->functions[2]->getArguments());
|
||||
$this->assertEquals(['$foo' => 'Foo', '$bar' => null, '$baz' => null], $this->functions[3]->getArguments());
|
||||
$this->assertEquals([], $this->functions[4]->getArguments());
|
||||
$this->assertEquals([], $this->functions[5]->getArguments());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,12 +46,12 @@ class PHP_Token_ClosureTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testGetName()
|
||||
{
|
||||
$this->assertEquals('anonymous function', $this->functions[0]->getName());
|
||||
$this->assertEquals('anonymous function', $this->functions[1]->getName());
|
||||
$this->assertEquals('anonymous function', $this->functions[2]->getName());
|
||||
$this->assertEquals('anonymous function', $this->functions[3]->getName());
|
||||
$this->assertEquals('anonymous function', $this->functions[4]->getName());
|
||||
$this->assertEquals('anonymous function', $this->functions[5]->getName());
|
||||
$this->assertEquals('anonymousFunction:2#5', $this->functions[0]->getName());
|
||||
$this->assertEquals('anonymousFunction:3#27', $this->functions[1]->getName());
|
||||
$this->assertEquals('anonymousFunction:4#51', $this->functions[2]->getName());
|
||||
$this->assertEquals('anonymousFunction:5#71', $this->functions[3]->getName());
|
||||
$this->assertEquals('anonymousFunction:6#93', $this->functions[4]->getName());
|
||||
$this->assertEquals('anonymousFunction:7#106', $this->functions[5]->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHP_TokenStream package.
|
||||
* This file is part of php-token-stream.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
@@ -8,21 +8,14 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests for the PHP_Token_FUNCTION class.
|
||||
*
|
||||
* @package PHP_TokenStream
|
||||
* @subpackage Tests
|
||||
* @author Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @copyright Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
|
||||
* @version Release: @package_version@
|
||||
* @link http://github.com/sebastianbergmann/php-token-stream/
|
||||
* @since Class available since Release 1.0.0
|
||||
*/
|
||||
class PHP_Token_FunctionTest extends PHPUnit_Framework_TestCase
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class PHP_Token_FunctionTest extends TestCase
|
||||
{
|
||||
protected $functions;
|
||||
/**
|
||||
* @var PHP_Token_FUNCTION[]
|
||||
*/
|
||||
private $functions;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
@@ -40,23 +33,23 @@ class PHP_Token_FunctionTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testGetArguments()
|
||||
{
|
||||
$this->assertEquals(array(), $this->functions[0]->getArguments());
|
||||
$this->assertEquals([], $this->functions[0]->getArguments());
|
||||
|
||||
$this->assertEquals(
|
||||
array('$baz' => 'Baz'), $this->functions[1]->getArguments()
|
||||
['$baz' => 'Baz'], $this->functions[1]->getArguments()
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
array('$foobar' => 'Foobar'), $this->functions[2]->getArguments()
|
||||
['$foobar' => 'Foobar'], $this->functions[2]->getArguments()
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
array('$barfoo' => 'Barfoo'), $this->functions[3]->getArguments()
|
||||
['$barfoo' => 'Barfoo'], $this->functions[3]->getArguments()
|
||||
);
|
||||
|
||||
$this->assertEquals(array(), $this->functions[4]->getArguments());
|
||||
$this->assertEquals([], $this->functions[4]->getArguments());
|
||||
|
||||
$this->assertEquals(array('$x' => null, '$y' => null), $this->functions[5]->getArguments());
|
||||
$this->assertEquals(['$x' => null, '$y' => null], $this->functions[5]->getArguments());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHP_TokenStream package.
|
||||
* This file is part of php-token-stream.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
@@ -8,22 +8,14 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests for the PHP_Token_REQUIRE_ONCE, PHP_Token_REQUIRE
|
||||
* PHP_Token_INCLUDE_ONCE and PHP_Token_INCLUDE_ONCE classes.
|
||||
*
|
||||
* @package PHP_TokenStream
|
||||
* @subpackage Tests
|
||||
* @author Laurent Laville <pear@laurent-laville.org>
|
||||
* @copyright Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
|
||||
* @version Release: @package_version@
|
||||
* @link http://github.com/sebastianbergmann/php-token-stream/
|
||||
* @since Class available since Release 1.0.2
|
||||
*/
|
||||
class PHP_Token_IncludeTest extends PHPUnit_Framework_TestCase
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class PHP_Token_IncludeTest extends TestCase
|
||||
{
|
||||
protected $ts;
|
||||
/**
|
||||
* @var PHP_Token_Stream
|
||||
*/
|
||||
private $ts;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
@@ -37,7 +29,7 @@ class PHP_Token_IncludeTest extends PHPUnit_Framework_TestCase
|
||||
public function testGetIncludes()
|
||||
{
|
||||
$this->assertSame(
|
||||
array('test4.php', 'test3.php', 'test2.php', 'test1.php'),
|
||||
['test4.php', 'test3.php', 'test2.php', 'test1.php'],
|
||||
$this->ts->getIncludes()
|
||||
);
|
||||
}
|
||||
@@ -49,13 +41,13 @@ class PHP_Token_IncludeTest extends PHPUnit_Framework_TestCase
|
||||
public function testGetIncludesCategorized()
|
||||
{
|
||||
$this->assertSame(
|
||||
array(
|
||||
'require_once' => array('test4.php'),
|
||||
'require' => array('test3.php'),
|
||||
'include_once' => array('test2.php'),
|
||||
'include' => array('test1.php')
|
||||
),
|
||||
$this->ts->getIncludes(TRUE)
|
||||
[
|
||||
'require_once' => ['test4.php'],
|
||||
'require' => ['test3.php'],
|
||||
'include_once' => ['test2.php'],
|
||||
'include' => ['test1.php']
|
||||
],
|
||||
$this->ts->getIncludes(true)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -66,8 +58,8 @@ class PHP_Token_IncludeTest extends PHPUnit_Framework_TestCase
|
||||
public function testGetIncludesCategory()
|
||||
{
|
||||
$this->assertSame(
|
||||
array('test4.php'),
|
||||
$this->ts->getIncludes(TRUE, 'require_once')
|
||||
['test4.php'],
|
||||
$this->ts->getIncludes(true, 'require_once')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHP_TokenStream package.
|
||||
* This file is part of php-token-stream.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
@@ -8,33 +8,29 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests for the PHP_Token_INTERFACE class.
|
||||
*
|
||||
* @package PHP_TokenStream
|
||||
* @subpackage Tests
|
||||
* @author Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @author Laurent Laville <pear@laurent-laville.org>
|
||||
* @copyright Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
|
||||
* @version Release: @package_version@
|
||||
* @link http://github.com/sebastianbergmann/php-token-stream/
|
||||
* @since Class available since Release 1.0.0
|
||||
*/
|
||||
class PHP_Token_InterfaceTest extends PHPUnit_Framework_TestCase
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class PHP_Token_InterfaceTest extends TestCase
|
||||
{
|
||||
protected $class;
|
||||
protected $interfaces;
|
||||
/**
|
||||
* @var PHP_Token_CLASS
|
||||
*/
|
||||
private $class;
|
||||
|
||||
/**
|
||||
* @var PHP_Token_INTERFACE[]
|
||||
*/
|
||||
private $interfaces;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$ts = new PHP_Token_Stream(TEST_FILES_PATH . 'source4.php');
|
||||
$i = 0;
|
||||
|
||||
foreach ($ts as $token) {
|
||||
if ($token instanceof PHP_Token_CLASS) {
|
||||
$this->class = $token;
|
||||
}
|
||||
elseif ($token instanceof PHP_Token_INTERFACE) {
|
||||
} elseif ($token instanceof PHP_Token_INTERFACE) {
|
||||
$this->interfaces[$i] = $token;
|
||||
$i++;
|
||||
}
|
||||
@@ -97,7 +93,7 @@ class PHP_Token_InterfaceTest extends PHPUnit_Framework_TestCase
|
||||
public function testGetInterfacesExists()
|
||||
{
|
||||
$this->assertEquals(
|
||||
array('b'),
|
||||
['b'],
|
||||
$this->class->getInterfaces()
|
||||
);
|
||||
}
|
||||
@@ -111,13 +107,15 @@ class PHP_Token_InterfaceTest extends PHPUnit_Framework_TestCase
|
||||
$this->class->hasInterfaces()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Token_INTERFACE::getPackage
|
||||
*/
|
||||
public function testGetPackageNamespace() {
|
||||
public function testGetPackageNamespace()
|
||||
{
|
||||
$tokenStream = new PHP_Token_Stream(TEST_FILES_PATH . 'classInNamespace.php');
|
||||
foreach($tokenStream as $token) {
|
||||
if($token instanceOf PHP_Token_INTERFACE) {
|
||||
foreach ($tokenStream as $token) {
|
||||
if ($token instanceof PHP_Token_INTERFACE) {
|
||||
$package = $token->getPackage();
|
||||
$this->assertSame('Foo\\Bar', $package['namespace']);
|
||||
}
|
||||
@@ -125,22 +123,24 @@ class PHP_Token_InterfaceTest extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
|
||||
public function provideFilesWithClassesWithinMultipleNamespaces() {
|
||||
return array(
|
||||
array(TEST_FILES_PATH . 'multipleNamespacesWithOneClassUsingBraces.php'),
|
||||
array(TEST_FILES_PATH . 'multipleNamespacesWithOneClassUsingNonBraceSyntax.php'),
|
||||
);
|
||||
public function provideFilesWithClassesWithinMultipleNamespaces()
|
||||
{
|
||||
return [
|
||||
[TEST_FILES_PATH . 'multipleNamespacesWithOneClassUsingBraces.php'],
|
||||
[TEST_FILES_PATH . 'multipleNamespacesWithOneClassUsingNonBraceSyntax.php'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFilesWithClassesWithinMultipleNamespaces
|
||||
* @covers PHP_Token_INTERFACE::getPackage
|
||||
*/
|
||||
public function testGetPackageNamespaceForFileWithMultipleNamespaces($filepath) {
|
||||
$tokenStream = new PHP_Token_Stream($filepath);
|
||||
public function testGetPackageNamespaceForFileWithMultipleNamespaces($filepath)
|
||||
{
|
||||
$tokenStream = new PHP_Token_Stream($filepath);
|
||||
$firstClassFound = false;
|
||||
foreach($tokenStream as $token) {
|
||||
if($firstClassFound === false && $token instanceOf PHP_Token_INTERFACE) {
|
||||
foreach ($tokenStream as $token) {
|
||||
if ($firstClassFound === false && $token instanceof PHP_Token_INTERFACE) {
|
||||
$package = $token->getPackage();
|
||||
$this->assertSame('TestClassInBar', $token->getName());
|
||||
$this->assertSame('Foo\\Bar', $package['namespace']);
|
||||
@@ -148,44 +148,48 @@ class PHP_Token_InterfaceTest extends PHPUnit_Framework_TestCase
|
||||
continue;
|
||||
}
|
||||
// Secound class
|
||||
if($token instanceOf PHP_Token_INTERFACE) {
|
||||
if ($token instanceof PHP_Token_INTERFACE) {
|
||||
$package = $token->getPackage();
|
||||
$this->assertSame('TestClassInBaz', $token->getName());
|
||||
$this->assertSame('Foo\\Baz', $package['namespace']);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
$this->fail("Seachring for 2 classes failed");
|
||||
$this->fail('Seachring for 2 classes failed');
|
||||
}
|
||||
|
||||
public function testGetPackageNamespaceIsEmptyForInterfacesThatAreNotWithinNamespaces() {
|
||||
foreach($this->interfaces as $token) {
|
||||
public function testGetPackageNamespaceIsEmptyForInterfacesThatAreNotWithinNamespaces()
|
||||
{
|
||||
foreach ($this->interfaces as $token) {
|
||||
$package = $token->getPackage();
|
||||
$this->assertSame("", $package['namespace']);
|
||||
$this->assertSame('', $package['namespace']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PHP_Token_INTERFACE::getPackage
|
||||
*/
|
||||
public function testGetPackageNamespaceWhenExtentingFromNamespaceClass() {
|
||||
$tokenStream = new PHP_Token_Stream(TEST_FILES_PATH . 'classExtendsNamespacedClass.php');
|
||||
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) {
|
||||
foreach ($tokenStream as $token) {
|
||||
if ($firstClassFound === false && $token instanceof PHP_Token_INTERFACE) {
|
||||
$package = $token->getPackage();
|
||||
$this->assertSame('Baz', $token->getName());
|
||||
$this->assertSame('Foo\\Bar', $package['namespace']);
|
||||
$firstClassFound = true;
|
||||
continue;
|
||||
}
|
||||
if($token instanceOf PHP_Token_INTERFACE) {
|
||||
if ($token instanceof PHP_Token_INTERFACE) {
|
||||
$package = $token->getPackage();
|
||||
$this->assertSame('Extender', $token->getName());
|
||||
$this->assertSame('Other\\Space', $package['namespace']);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
$this->fail("Searching for 2 classes failed");
|
||||
$this->fail('Searching for 2 classes failed');
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHP_TokenStream package.
|
||||
* This file is part of php-token-stream.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
@@ -8,19 +8,9 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests for the PHP_Token_NAMESPACE class.
|
||||
*
|
||||
* @package PHP_TokenStream
|
||||
* @subpackage Tests
|
||||
* @author Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @copyright Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
|
||||
* @version Release: @package_version@
|
||||
* @link http://github.com/sebastianbergmann/php-token-stream/
|
||||
* @since Class available since Release 1.0.0
|
||||
*/
|
||||
class PHP_Token_NamespaceTest extends PHPUnit_Framework_TestCase
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class PHP_Token_NamespaceTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers PHP_Token_NAMESPACE::getName
|
||||
@@ -41,8 +31,8 @@ class PHP_Token_NamespaceTest extends PHPUnit_Framework_TestCase
|
||||
public function testGetStartLineWithUnscopedNamespace()
|
||||
{
|
||||
$tokenStream = new PHP_Token_Stream(TEST_FILES_PATH . 'classInNamespace.php');
|
||||
foreach($tokenStream as $token) {
|
||||
if($token instanceOf PHP_Token_NAMESPACE) {
|
||||
foreach ($tokenStream as $token) {
|
||||
if ($token instanceof PHP_Token_NAMESPACE) {
|
||||
$this->assertSame(2, $token->getLine());
|
||||
}
|
||||
}
|
||||
@@ -51,8 +41,8 @@ class PHP_Token_NamespaceTest extends PHPUnit_Framework_TestCase
|
||||
public function testGetEndLineWithUnscopedNamespace()
|
||||
{
|
||||
$tokenStream = new PHP_Token_Stream(TEST_FILES_PATH . 'classInNamespace.php');
|
||||
foreach($tokenStream as $token) {
|
||||
if($token instanceOf PHP_Token_NAMESPACE) {
|
||||
foreach ($tokenStream as $token) {
|
||||
if ($token instanceof PHP_Token_NAMESPACE) {
|
||||
$this->assertSame(2, $token->getEndLine());
|
||||
}
|
||||
}
|
||||
@@ -60,8 +50,8 @@ class PHP_Token_NamespaceTest extends PHPUnit_Framework_TestCase
|
||||
public function testGetStartLineWithScopedNamespace()
|
||||
{
|
||||
$tokenStream = new PHP_Token_Stream(TEST_FILES_PATH . 'classInScopedNamespace.php');
|
||||
foreach($tokenStream as $token) {
|
||||
if($token instanceOf PHP_Token_NAMESPACE) {
|
||||
foreach ($tokenStream as $token) {
|
||||
if ($token instanceof PHP_Token_NAMESPACE) {
|
||||
$this->assertSame(2, $token->getLine());
|
||||
}
|
||||
}
|
||||
@@ -70,11 +60,10 @@ class PHP_Token_NamespaceTest extends PHPUnit_Framework_TestCase
|
||||
public function testGetEndLineWithScopedNamespace()
|
||||
{
|
||||
$tokenStream = new PHP_Token_Stream(TEST_FILES_PATH . 'classInScopedNamespace.php');
|
||||
foreach($tokenStream as $token) {
|
||||
if($token instanceOf PHP_Token_NAMESPACE) {
|
||||
foreach ($tokenStream as $token) {
|
||||
if ($token instanceof PHP_Token_NAMESPACE) {
|
||||
$this->assertSame(8, $token->getEndLine());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the PHP_TokenStream package.
|
||||
* This file is part of php-token-stream.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
@@ -8,19 +8,9 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests for the PHP_Token class.
|
||||
*
|
||||
* @package PHP_TokenStream
|
||||
* @subpackage Tests
|
||||
* @author Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @copyright Sebastian Bergmann <sebastian@phpunit.de>
|
||||
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
|
||||
* @version Release: @package_version@
|
||||
* @link http://github.com/sebastianbergmann/php-token-stream/
|
||||
* @since Class available since Release 1.0.0
|
||||
*/
|
||||
class PHP_TokenTest extends PHPUnit_Framework_TestCase
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class PHP_TokenTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers PHP_Token::__construct
|
||||
|
8
vendor/phpunit/php-token-stream/tests/_fixture/classUsesNamespacedFunction.php
vendored
Normal file
8
vendor/phpunit/php-token-stream/tests/_fixture/classUsesNamespacedFunction.php
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
namespace foo;
|
||||
|
||||
use function bar\baz;
|
||||
|
||||
class Foo
|
||||
{
|
||||
}
|
7
vendor/phpunit/php-token-stream/tests/_fixture/class_with_method_named_empty.php
vendored
Normal file
7
vendor/phpunit/php-token-stream/tests/_fixture/class_with_method_named_empty.php
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
class class_with_method_named_empty
|
||||
{
|
||||
public function empty(): void
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
class class_with_multiple_anonymous_classes_and_functions
|
||||
{
|
||||
public function m()
|
||||
{
|
||||
$c = new class {
|
||||
public function n() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
$d = new class {
|
||||
public function o() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
$f = function ($a, $b) {
|
||||
return $a + $b;
|
||||
};
|
||||
|
||||
$g = function ($a, $b) {
|
||||
return $a - $b;
|
||||
};
|
||||
}
|
||||
}
|
13
vendor/phpunit/php-token-stream/tests/_fixture/php-code-coverage-issue-424.php
vendored
Normal file
13
vendor/phpunit/php-token-stream/tests/_fixture/php-code-coverage-issue-424.php
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
class Example
|
||||
{
|
||||
public function even($numbers)
|
||||
{
|
||||
$numbers = array_filter($numbers, function($number) {
|
||||
return $number % 2 === 0;
|
||||
});
|
||||
|
||||
return array_merge($numbers);
|
||||
}
|
||||
}
|
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
define(
|
||||
|
Reference in New Issue
Block a user