Commit ffd8c287 authored by hujun's avatar hujun

composer file

parent fa63fdb9
......@@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderIniteae526504930a78fdf1cf0a82c228fa7::getLoader();
return ComposerAutoloaderInit563e23492907a0ecb0dae7ce3a76ccdc::getLoader();
#!/usr/bin/env sh
dir=$(d=${0%[/\\]*}; cd "$d" > /dev/null; cd "../phpunit/phpunit" && pwd)
# See if we are running in Cygwin by checking for cygpath program
if command -v 'cygpath' >/dev/null 2>&1; then
# Cygwin paths start with /cygdrive/ which will break windows PHP,
# so we need to translate the dir path to windows format. However
# we could be using cygwin PHP which does not require this, so we
# test if the path to PHP starts with /cygdrive/ rather than /usr/bin
if [[ $(which php) == /cygdrive/* ]]; then
dir=$(cygpath -m "$dir");
fi
fi
dir=$(echo $dir | sed 's/ /\ /g')
"${dir}/phpunit" "$@"
#!/usr/bin/env php
<?php
/*
* This file is part of PHPUnit.
*
* (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.
*/
if (version_compare('5.3.3', PHP_VERSION, '>')) {
fwrite(
STDERR,
sprintf(
'This version of PHPUnit is supported on PHP 5.3, PHP 5.4, PHP 5.5, and PHP 5.6.' . PHP_EOL .
'You are using PHP %s%s.' . PHP_EOL,
PHP_VERSION,
defined('PHP_BINARY') ? ' (' . PHP_BINARY . ')' : ''
)
);
die(1);
}
if (!ini_get('date.timezone')) {
ini_set('date.timezone', 'UTC');
}
foreach (array(__DIR__ . '/../../autoload.php', __DIR__ . '/../vendor/autoload.php', __DIR__ . '/vendor/autoload.php') as $file) {
if (file_exists($file)) {
define('PHPUNIT_COMPOSER_INSTALL', $file);
break;
}
}
unset($file);
if (!defined('PHPUNIT_COMPOSER_INSTALL')) {
fwrite(STDERR,
'You need to set up the project dependencies using Composer:' . PHP_EOL . PHP_EOL .
' composer install' . PHP_EOL . PHP_EOL .
'You can learn all about Composer on https://getcomposer.org/.' . PHP_EOL
);
die(1);
}
require PHPUNIT_COMPOSER_INSTALL;
PHPUnit_TextUI_Command::main();
......@@ -6,6 +6,10 @@ $vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'ArithmeticError' => $vendorDir . '/symfony/polyfill-php70/Resources/stubs/ArithmeticError.php',
'AssertionError' => $vendorDir . '/symfony/polyfill-php70/Resources/stubs/AssertionError.php',
'DivisionByZeroError' => $vendorDir . '/symfony/polyfill-php70/Resources/stubs/DivisionByZeroError.php',
'Error' => $vendorDir . '/symfony/polyfill-php70/Resources/stubs/Error.php',
'File_Iterator' => $vendorDir . '/phpunit/php-file-iterator/src/Iterator.php',
'File_Iterator_Facade' => $vendorDir . '/phpunit/php-file-iterator/src/Facade.php',
'File_Iterator_Factory' => $vendorDir . '/phpunit/php-file-iterator/src/Factory.php',
......@@ -414,6 +418,8 @@ return array(
'PHP_Token_XOR_EQUAL' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_YIELD' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_YIELD_FROM' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'ParseError' => $vendorDir . '/symfony/polyfill-php70/Resources/stubs/ParseError.php',
'QrReader' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/QrReader.php',
'SebastianBergmann\\Comparator\\ArrayComparator' => $vendorDir . '/sebastian/comparator/src/ArrayComparator.php',
'SebastianBergmann\\Comparator\\Comparator' => $vendorDir . '/sebastian/comparator/src/Comparator.php',
'SebastianBergmann\\Comparator\\ComparisonFailure' => $vendorDir . '/sebastian/comparator/src/ComparisonFailure.php',
......@@ -450,5 +456,65 @@ return array(
'SebastianBergmann\\RecursionContext\\Exception' => $vendorDir . '/sebastian/recursion-context/src/Exception.php',
'SebastianBergmann\\RecursionContext\\InvalidArgumentException' => $vendorDir . '/sebastian/recursion-context/src/InvalidArgumentException.php',
'SebastianBergmann\\Version' => $vendorDir . '/sebastian/version/src/Version.php',
'SessionUpdateTimestampHandlerInterface' => $vendorDir . '/symfony/polyfill-php70/Resources/stubs/SessionUpdateTimestampHandlerInterface.php',
'Text_Template' => $vendorDir . '/phpunit/php-text-template/src/Template.php',
'TypeError' => $vendorDir . '/symfony/polyfill-php70/Resources/stubs/TypeError.php',
'Zxing\\Binarizer' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/Binarizer.php',
'Zxing\\BinaryBitmap' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/BinaryBitmap.php',
'Zxing\\ChecksumException' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/ChecksumException.php',
'Zxing\\Common\\BitArray' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/common/BitArray.php',
'Zxing\\Common\\BitMatrix' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/common/BitMatrix.php',
'Zxing\\Common\\BitSource' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/common/BitSource.php',
'Zxing\\Common\\CharacterSetECI' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/common/CharacterSetEci.php',
'Zxing\\Common\\CharacterSetEci\\AbstractEnum\\AbstractEnum' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/common/AbstractEnum.php',
'Zxing\\Common\\DecoderResult' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/common/DecoderResult.php',
'Zxing\\Common\\DefaultGridSampler' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/common/DefaultGridSampler.php',
'Zxing\\Common\\DetectorResult' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/common/DetectorResult.php',
'Zxing\\Common\\Detector\\MathUtils' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/common/detector/MathUtils.php',
'Zxing\\Common\\Detector\\MonochromeRectangleDetector' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/common/detector/MonochromeRectangleDetector.php',
'Zxing\\Common\\GlobalHistogramBinarizer' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/common/GlobalHistogramBinarizer.php',
'Zxing\\Common\\GridSampler' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/common/GridSampler.php',
'Zxing\\Common\\HybridBinarizer' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/common/HybridBinarizer.php',
'Zxing\\Common\\PerspectiveTransform' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/common/PerspectiveTransform.php',
'Zxing\\Common\\Reedsolomon\\GenericGF' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/common/reedsolomon/GenericGF.php',
'Zxing\\Common\\Reedsolomon\\GenericGFPoly' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/common/reedsolomon/GenericGFPoly.php',
'Zxing\\Common\\Reedsolomon\\ReedSolomonDecoder' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/common/reedsolomon/ReedSolomonDecoder.php',
'Zxing\\Common\\Reedsolomon\\ReedSolomonException' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/common/reedsolomon/ReedSolomonException.php',
'Zxing\\FormatException' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/FormatException.php',
'Zxing\\GDLuminanceSource' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/GDLuminanceSource.php',
'Zxing\\IMagickLuminanceSource' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/IMagickLuminanceSource.php',
'Zxing\\LuminanceSource' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/LuminanceSource.php',
'Zxing\\NotFoundException' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/NotFoundException.php',
'Zxing\\PlanarYUVLuminanceSource' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/PlanarYUVLuminanceSource.php',
'Zxing\\Qrcode\\Decoder\\BitMatrixParser' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/qrcode/decoder/BitMatrixParser.php',
'Zxing\\Qrcode\\Decoder\\DataBlock' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/qrcode/decoder/DataBlock.php',
'Zxing\\Qrcode\\Decoder\\DataMask' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/qrcode/decoder/DataMask.php',
'Zxing\\Qrcode\\Decoder\\DataMask000' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/qrcode/decoder/DataMask.php',
'Zxing\\Qrcode\\Decoder\\DataMask001' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/qrcode/decoder/DataMask.php',
'Zxing\\Qrcode\\Decoder\\DataMask010' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/qrcode/decoder/DataMask.php',
'Zxing\\Qrcode\\Decoder\\DataMask011' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/qrcode/decoder/DataMask.php',
'Zxing\\Qrcode\\Decoder\\DataMask100' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/qrcode/decoder/DataMask.php',
'Zxing\\Qrcode\\Decoder\\DataMask101' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/qrcode/decoder/DataMask.php',
'Zxing\\Qrcode\\Decoder\\DataMask110' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/qrcode/decoder/DataMask.php',
'Zxing\\Qrcode\\Decoder\\DataMask111' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/qrcode/decoder/DataMask.php',
'Zxing\\Qrcode\\Decoder\\DecodedBitStreamParser' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/qrcode/decoder/DecodedBitStreamParser.php',
'Zxing\\Qrcode\\Decoder\\Decoder' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/qrcode/decoder/Decoder.php',
'Zxing\\Qrcode\\Decoder\\ECB' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/qrcode/decoder/Version.php',
'Zxing\\Qrcode\\Decoder\\ECBlocks' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/qrcode/decoder/Version.php',
'Zxing\\Qrcode\\Decoder\\ErrorCorrectionLevel' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/qrcode/decoder/ErrorCorrectionLevel.php',
'Zxing\\Qrcode\\Decoder\\FormatInformation' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/qrcode/decoder/FormatInformation.php',
'Zxing\\Qrcode\\Decoder\\Mode' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/qrcode/decoder/Mode.php',
'Zxing\\Qrcode\\Decoder\\Version' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/qrcode/decoder/Version.php',
'Zxing\\Qrcode\\Detector\\AlignmentPattern' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/qrcode/detector/AlignmentPattern.php',
'Zxing\\Qrcode\\Detector\\AlignmentPatternFinder' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/qrcode/detector/AlignmentPatternFinder.php',
'Zxing\\Qrcode\\Detector\\Detector' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/qrcode/detector/Detector.php',
'Zxing\\Qrcode\\Detector\\FinderPattern' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/qrcode/detector/FinderPattern.php',
'Zxing\\Qrcode\\Detector\\FinderPatternFinder' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/qrcode/detector/FinderPatternFinder.php',
'Zxing\\Qrcode\\Detector\\FinderPatternInfo' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/qrcode/detector/FinderPatternInfo.php',
'Zxing\\Qrcode\\QRCodeReader' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/qrcode/QRCodeReader.php',
'Zxing\\RGBLuminanceSource' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/RGBLuminanceSource.php',
'Zxing\\Reader' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/Reader.php',
'Zxing\\ReaderException' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/ReaderException.php',
'Zxing\\Result' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/Result.php',
'Zxing\\ResultPoint' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/ResultPoint.php',
);
......@@ -6,8 +6,11 @@ $vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'5255c38a0faeba867671b61dfda6d864' => $vendorDir . '/paragonie/random_compat/lib/random.php',
'023d27dca8066ef29e6739335ea73bad' => $vendorDir . '/symfony/polyfill-php70/bootstrap.php',
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
'9b552a3cc426e3287cc811caefa3cf53' => $vendorDir . '/topthink/think-helper/src/helper.php',
'626dcc41390ebdaa619faa02d99943b0' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/common/customFunctions.php',
'1cfd2761b63b0a29ed23657ea394cb2d' => $vendorDir . '/topthink/think-captcha/src/helper.php',
'ddc3cd2a04224f9638c5d0de6a69c7e3' => $vendorDir . '/topthink/think-migration/src/config.php',
'72c97b53391125cae04082a81029f42d' => $vendorDir . '/topthink/think-testing/src/config.php',
......
......@@ -7,4 +7,5 @@ $baseDir = dirname($vendorDir);
return array(
'Prophecy\\' => array($vendorDir . '/phpspec/prophecy/src'),
'BaconQrCode' => array($vendorDir . '/bacon/bacon-qr-code/src'),
);
......@@ -16,10 +16,16 @@ return array(
'phpDocumentor\\Reflection\\' => array($vendorDir . '/phpdocumentor/reflection-common/src', $vendorDir . '/phpdocumentor/type-resolver/src', $vendorDir . '/phpdocumentor/reflection-docblock/src'),
'app\\' => array($baseDir . '/application'),
'Webmozart\\Assert\\' => array($vendorDir . '/webmozart/assert/src'),
'Symfony\\Polyfill\\Php70\\' => array($vendorDir . '/symfony/polyfill-php70'),
'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
'Symfony\\Component\\Yaml\\' => array($vendorDir . '/symfony/yaml'),
'Symfony\\Component\\PropertyAccess\\' => array($vendorDir . '/symfony/property-access'),
'Symfony\\Component\\OptionsResolver\\' => array($vendorDir . '/symfony/options-resolver'),
'Symfony\\Component\\Inflector\\' => array($vendorDir . '/symfony/inflector'),
'Symfony\\Component\\DomCrawler\\' => array($vendorDir . '/symfony/dom-crawler'),
'Phinx\\' => array($vendorDir . '/topthink/think-migration/phinx/src/Phinx'),
'MyCLabs\\Enum\\' => array($vendorDir . '/myclabs/php-enum/src'),
'Firebase\\JWT\\' => array($vendorDir . '/firebase/php-jwt/src'),
'Endroid\\QrCode\\' => array($vendorDir . '/endroid/qrcode/src'),
'Doctrine\\Instantiator\\' => array($vendorDir . '/doctrine/instantiator/src/Doctrine/Instantiator'),
);
......@@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderIniteae526504930a78fdf1cf0a82c228fa7
class ComposerAutoloaderInit563e23492907a0ecb0dae7ce3a76ccdc
{
private static $loader;
......@@ -19,15 +19,15 @@ class ComposerAutoloaderIniteae526504930a78fdf1cf0a82c228fa7
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderIniteae526504930a78fdf1cf0a82c228fa7', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit563e23492907a0ecb0dae7ce3a76ccdc', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderIniteae526504930a78fdf1cf0a82c228fa7', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit563e23492907a0ecb0dae7ce3a76ccdc', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticIniteae526504930a78fdf1cf0a82c228fa7::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit563e23492907a0ecb0dae7ce3a76ccdc::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
......@@ -48,19 +48,19 @@ class ComposerAutoloaderIniteae526504930a78fdf1cf0a82c228fa7
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticIniteae526504930a78fdf1cf0a82c228fa7::$files;
$includeFiles = Composer\Autoload\ComposerStaticInit563e23492907a0ecb0dae7ce3a76ccdc::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequireeae526504930a78fdf1cf0a82c228fa7($fileIdentifier, $file);
composerRequire563e23492907a0ecb0dae7ce3a76ccdc($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequireeae526504930a78fdf1cf0a82c228fa7($fileIdentifier, $file)
function composerRequire563e23492907a0ecb0dae7ce3a76ccdc($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;
......
This diff is collapsed.
This diff is collapsed.
......@@ -10,16 +10,12 @@ that is 100% compatible with the [PHPDoc standard](http://phpdoc.org/docs/latest
With this component, a library can provide support for annotations via DocBlocks
or otherwise retrieve information that is embedded in a DocBlock.
> **Note**: *this is a core component of phpDocumentor and is constantly being
> optimized for performance.*
Installation
------------
You can install the component in the following ways:
* Use the official Github repository (https://github.com/phpDocumentor/ReflectionDocBlock)
* Via Composer (http://packagist.org/packages/phpdocumentor/reflection-docblock)
```bash
composer require phpdocumentor/reflection-docblock
```
Usage
-----
......@@ -52,18 +48,20 @@ $docblock = $factory->create($docComment);
```
The `create` method will yield an object of type `\phpDocumentor\Reflection\DocBlock`
whose methods can be queried as shown in the following example.
whose methods can be queried:
```php
// Should contain the summary for this DocBlock
// Contains the summary for this DocBlock
$summary = $docblock->getSummary();
// Contains an object of type \phpDocumentor\Reflection\DocBlock\Description;
// you can either cast it to string or use the render method to get a string
// representation of the Description.
// Contains \phpDocumentor\Reflection\DocBlock\Description object
$description = $docblock->getDescription();
```
> For more examples it would be best to review the scripts in the `/examples`
> folder.
// You can either cast it to string
$description = (string) $docblock->getDescription();
// Or use the render method to get a string representation of the Description.
$description = $docblock->getDescription()->render();
```
> For more examples it would be best to review the scripts in the [`/examples` folder](/examples).
......@@ -10,7 +10,7 @@
}
],
"require": {
"php": "^5.6 || ^7.0",
"php": "^7.0",
"phpdocumentor/reflection-common": "^1.0.0",
"phpdocumentor/type-resolver": "^0.4.0",
"webmozart/assert": "^1.0"
......@@ -22,7 +22,13 @@
"psr-4": {"phpDocumentor\\Reflection\\": ["tests/unit"]}
},
"require-dev": {
"mockery/mockery": "^0.9.4",
"phpunit/phpunit": "^4.4"
"mockery/mockery": "^1.0",
"phpunit/phpunit": "^6.4",
"doctrine/instantiator": "~1.0.5"
},
"extra": {
"branch-alias": {
"dev-master": "4.x-dev"
}
}
}
......@@ -24,7 +24,7 @@ final class DocBlock
private $description = null;
/** @var Tag[] An array containing all the tags in this docblock; except inline. */
private $tags = array();
private $tags = [];
/** @var Types\Context Information about the context of this DocBlock. */
private $context = null;
......@@ -55,8 +55,7 @@ final class DocBlock
Location $location = null,
$isTemplateStart = false,
$isTemplateEnd = false
)
{
) {
Assert::string($summary);
Assert::boolean($isTemplateStart);
Assert::boolean($isTemplateEnd);
......@@ -171,11 +170,11 @@ final class DocBlock
{
Assert::string($name);
$result = array();
$result = [];
/** @var Tag $tag */
foreach ($this->getTags() as $tag) {
if ($tag->getName() != $name) {
if ($tag->getName() !== $name) {
continue;
}
......@@ -198,7 +197,7 @@ final class DocBlock
/** @var Tag $tag */
foreach ($this->getTags() as $tag) {
if ($tag->getName() == $name) {
if ($tag->getName() === $name) {
return true;
}
}
......@@ -206,6 +205,23 @@ final class DocBlock
return false;
}
/**
* Remove a tag from this DocBlock.
*
* @param Tag $tag The tag to remove.
*
* @return void
*/
public function removeTag(Tag $tagToRemove)
{
foreach ($this->tags as $key => $tag) {
if ($tag === $tagToRemove) {
unset($this->tags[$key]);
break;
}
}
}
/**
* Adds a tag to this DocBlock.
*
......
......@@ -69,7 +69,7 @@ class Description
$this->bodyTemplate = $bodyTemplate;
$this->tags = $tags;
}
/**
* Returns the tags for this DocBlock.
*
......@@ -98,6 +98,7 @@ class Description
foreach ($this->tags as $tag) {
$tags[] = '{' . $formatter->format($tag) . '}';
}
return vsprintf($this->bodyTemplate, $tags);
}
......
......@@ -188,5 +188,4 @@ class DescriptionFactory
return implode("\n", $lines);
}
}
......@@ -23,7 +23,7 @@ class ExampleFinder
private $sourceDirectory = '';
/** @var string[] */
private $exampleDirectories = array();
private $exampleDirectories = [];
/**
* Attempts to find the example contents for the given descriptor.
......
......@@ -121,6 +121,7 @@ class Serializer
$text = wordwrap($text, $wrapLength);
return $text;
}
return $text;
}
......@@ -138,6 +139,7 @@ class Serializer
if ($wrapLength !== null) {
$tagText = wordwrap($tagText, $wrapLength);
}
$tagText = str_replace("\n", "\n{$indent} * ", $tagText);
$comment .= "{$indent} * {$tagText}\n";
......
......@@ -166,7 +166,7 @@ final class StandardTagFactory implements TagFactory
*/
private function extractTagParts($tagLine)
{
$matches = array();
$matches = [];
if (! preg_match('/^@(' . self::REGEX_TAGNAME . ')(?:\s*([^\s].*)|$)/us', $tagLine, $matches)) {
throw new \InvalidArgumentException(
'The tag "' . $tagLine . '" does not seem to be wellformed, please check it for errors'
......@@ -196,8 +196,7 @@ final class StandardTagFactory implements TagFactory
$arguments = $this->getArgumentsForParametersFromWiring(
$this->fetchParametersForHandlerFactoryMethod($handlerClassName),
$this->getServiceLocatorWithDynamicParameters($context, $name, $body)
)
;
);
return call_user_func_array([$handlerClassName, 'create'], $arguments);
}
......
......@@ -12,11 +12,11 @@
namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\Fqsen;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use phpDocumentor\Reflection\FqsenResolver;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use Webmozart\Assert\Assert;
/**
......@@ -49,8 +49,7 @@ final class Covers extends BaseTag implements Factory\StaticMethod
DescriptionFactory $descriptionFactory = null,
FqsenResolver $resolver = null,
TypeContext $context = null
)
{
) {
Assert::string($body);
Assert::notEmpty($body);
......
......@@ -12,9 +12,9 @@
namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use Webmozart\Assert\Assert;
/**
......
......@@ -33,12 +33,12 @@ final class Example extends BaseTag
private $isURI = false;
/**
* @var
* @var int
*/
private $startingLine;
/**
* @var
* @var int
*/
private $lineCount;
......
......@@ -135,7 +135,7 @@ final class Method extends BaseTag implements Factory\StaticMethod
if (is_string($arguments) && strlen($arguments) > 0) {
$arguments = explode(',', $arguments);
foreach($arguments as &$argument) {
foreach ($arguments as &$argument) {
$argument = explode(' ', self::stripRestArg(trim($argument)), 2);
if ($argument[0][0] === '$') {
$argumentName = substr($argument[0], 1);
......@@ -214,10 +214,13 @@ final class Method extends BaseTag implements Factory\StaticMethod
if (is_string($argument)) {
$argument = [ 'name' => $argument ];
}
if (! isset($argument['type'])) {
$argument['type'] = new Void_();
}
$keys = array_keys($argument);
sort($keys);
if ($keys !== [ 'name', 'type' ]) {
throw new \InvalidArgumentException(
'Arguments can only have the "name" and "type" fields, found: ' . var_export($keys, true)
......
......@@ -77,7 +77,7 @@ final class Param extends BaseTag implements Factory\StaticMethod
}
// if the next item starts with a $ or ...$ it must be the variable name
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] == '$' || substr($parts[0], 0, 4) === '...$')) {
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] === '$' || substr($parts[0], 0, 4) === '...$')) {
$variableName = array_shift($parts);
array_shift($parts);
......
......@@ -70,7 +70,7 @@ class Property extends BaseTag implements Factory\StaticMethod
}
// if the next item starts with a $ or ...$ it must be the variable name
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] == '$')) {
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] === '$')) {
$variableName = array_shift($parts);
array_shift($parts);
......
......@@ -70,7 +70,7 @@ class PropertyRead extends BaseTag implements Factory\StaticMethod
}
// if the next item starts with a $ or ...$ it must be the variable name
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] == '$')) {
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] === '$')) {
$variableName = array_shift($parts);
array_shift($parts);
......
......@@ -70,7 +70,7 @@ class PropertyWrite extends BaseTag implements Factory\StaticMethod
}
// if the next item starts with a $ or ...$ it must be the variable name
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] == '$')) {
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] === '$')) {
$variableName = array_shift($parts);
array_shift($parts);
......
......@@ -17,5 +17,5 @@ namespace phpDocumentor\Reflection\DocBlock\Tags\Reference;
*/
interface Reference
{
public function __toString();
public function __toString();
}
......@@ -43,8 +43,7 @@ final class Return_ extends BaseTag implements Factory\StaticMethod
TypeResolver $typeResolver = null,
DescriptionFactory $descriptionFactory = null,
TypeContext $context = null
)
{
) {
Assert::string($body);
Assert::allNotNull([$typeResolver, $descriptionFactory]);
......
......@@ -12,14 +12,13 @@
namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\DocBlock\Tags\Reference\Fqsen as FqsenRef;
use phpDocumentor\Reflection\DocBlock\Tags\Reference\Reference;
use phpDocumentor\Reflection\DocBlock\Tags\Reference\Url;
use phpDocumentor\Reflection\Fqsen;
use phpDocumentor\Reflection\FqsenResolver;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use phpDocumentor\Reflection\DocBlock\Description;
use Webmozart\Assert\Assert;
/**
......
......@@ -12,9 +12,9 @@
namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use Webmozart\Assert\Assert;
/**
......
......@@ -59,6 +59,7 @@ final class Source extends BaseTag implements Factory\StaticMethod
if (isset($matches[2]) && $matches[2] !== '') {
$lineCount = (int)$matches[2];
}
$description = $matches[3];
}
......
......@@ -70,7 +70,7 @@ class Var_ extends BaseTag implements Factory\StaticMethod
}
// if the next item starts with a $ or ...$ it must be the variable name
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] == '$')) {
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] === '$')) {
$variableName = array_shift($parts);
array_shift($parts);
......@@ -111,8 +111,8 @@ class Var_ extends BaseTag implements Factory\StaticMethod
*/
public function __toString()
{
return ($this->type ? $this->type.' ' : '')
.(empty($this->variableName) ? null : ('$'.$this->variableName))
.($this->description ? ' '.$this->description : '');
return ($this->type ? $this->type . ' ' : '')
. (empty($this->variableName) ? null : ('$' . $this->variableName))
. ($this->description ? ' ' . $this->description : '');
}
}
......@@ -12,9 +12,9 @@
namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use Webmozart\Assert\Assert;
/**
......
......@@ -93,7 +93,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
return new DocBlock(
$summary,
$description ? $this->descriptionFactory->create($description, $context) : null,
array_filter($this->parseTagBlock($tags, $context), function($tag) {
array_filter($this->parseTagBlock($tags, $context), function ($tag) {
return $tag instanceof Tag;
}),
$context,
......@@ -120,11 +120,11 @@ final class DocBlockFactory implements DocBlockFactoryInterface
$comment = trim(preg_replace('#[ \t]*(?:\/\*\*|\*\/|\*)?[ \t]{0,1}(.*)?#u', '$1', $comment));
// reg ex above is not able to remove */ from a single line docblock
if (substr($comment, -2) == '*/') {
if (substr($comment, -2) === '*/') {
$comment = trim(substr($comment, 0, -2));
}
return str_replace(array("\r\n", "\r"), "\n", $comment);
return str_replace(["\r\n", "\r"], "\n", $comment);
}
/**
......@@ -143,7 +143,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
// method does not split tags so we return this verbatim as the fourth result (tags). This saves us the
// performance impact of running a regular expression
if (strpos($comment, '@') === 0) {
return array('', '', '', $comment);
return ['', '', '', $comment];
}
// clears all extra horizontal whitespace from the line endings to prevent parsing issues
......@@ -241,7 +241,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
*/
private function splitTagBlockIntoTagLines($tags)
{
$result = array();
$result = [];
foreach (explode("\n", $tags) as $tag_line) {
if (isset($tag_line[0]) && ($tag_line[0] === '@')) {
$result[] = $tag_line;
......
......@@ -707,7 +707,8 @@ class Inline
return;
case 0 === strpos($scalar, '!php/const'):
if (self::$constantSupport) {
if (defined($const = self::parseScalar(substr($scalar, 11)))) {
$i = 0;
if (defined($const = self::parseScalar(substr($scalar, 11), 0, null, $i, false))) {
return constant($const);
}
......
......@@ -362,8 +362,6 @@ class Parser
@trigger_error($this->getDeprecationMessage(sprintf('Duplicate key "%s" detected whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated since version 3.2 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.', $key)), E_USER_DEPRECATED);
}
} else {
// remember the parsed line number here in case we need it to provide some contexts in error messages below
$realCurrentLineNbKey = $this->getRealCurrentLineNb();
$value = $this->parseBlock($this->getRealCurrentLineNb() + 1, $this->getNextEmbedBlock(), $flags);
if ('<<' === $key) {
$this->refs[$refMatches['ref']] = $value;
......@@ -573,7 +571,27 @@ class Parser
}
if (null === $indentation) {
$newIndent = $this->getCurrentLineIndentation();
$newIndent = null;
$movements = 0;
do {
$EOF = false;
// empty and comment-like lines do not influence the indentation depth
if ($this->isCurrentLineEmpty() || $this->isCurrentLineComment()) {
$EOF = !$this->moveToNextLine();
if (!$EOF) {
++$movements;
}
} else {
$newIndent = $this->getCurrentLineIndentation();
}
} while (!$EOF && null === $newIndent);
for ($i = 0; $i < $movements; ++$i) {
$this->moveToPreviousLine();
}
$unindentedEmbedBlock = $this->isStringUnIndentedCollectionItem();
......@@ -587,6 +605,8 @@ class Parser
$data = array();
if ($this->getCurrentLineIndentation() >= $newIndent) {
$data[] = substr($this->currentLine, $newIndent);
} elseif ($this->isCurrentLineEmpty() || $this->isCurrentLineComment()) {
$data[] = $this->currentLine;
} else {
$this->moveToPreviousLine();
......@@ -905,11 +925,15 @@ class Parser
private function isNextLineIndented()
{
$currentIndentation = $this->getCurrentLineIndentation();
$EOF = !$this->moveToNextLine();
$movements = 0;
while (!$EOF && $this->isCurrentLineEmpty()) {
do {
$EOF = !$this->moveToNextLine();
}
if (!$EOF) {
++$movements;
}
} while (!$EOF && ($this->isCurrentLineEmpty() || $this->isCurrentLineComment()));
if ($EOF) {
return false;
......@@ -917,7 +941,9 @@ class Parser
$ret = $this->getCurrentLineIndentation() > $currentIndentation;
$this->moveToPreviousLine();
for ($i = 0; $i < $movements; ++$i) {
$this->moveToPreviousLine();
}
return $ret;
}
......@@ -1006,19 +1032,25 @@ class Parser
private function isNextLineUnIndentedCollection()
{
$currentIndentation = $this->getCurrentLineIndentation();
$notEOF = $this->moveToNextLine();
$movements = 0;
while ($notEOF && $this->isCurrentLineEmpty()) {
$notEOF = $this->moveToNextLine();
}
do {
$EOF = !$this->moveToNextLine();
if (!$EOF) {
++$movements;
}
} while (!$EOF && ($this->isCurrentLineEmpty() || $this->isCurrentLineComment()));
if (false === $notEOF) {
if ($EOF) {
return false;
}
$ret = $this->getCurrentLineIndentation() === $currentIndentation && $this->isStringUnIndentedCollectionItem();
$this->moveToPreviousLine();
for ($i = 0; $i < $movements; ++$i) {
$this->moveToPreviousLine();
}
return $ret;
}
......
......@@ -58,6 +58,7 @@ class InlineTest extends TestCase
array('!php/const PHP_INT_MAX', PHP_INT_MAX),
array('[!php/const PHP_INT_MAX]', array(PHP_INT_MAX)),
array('{ foo: !php/const PHP_INT_MAX }', array('foo' => PHP_INT_MAX)),
array('!php/const NULL', null),
);
}
......@@ -82,10 +83,22 @@ class InlineTest extends TestCase
/**
* @group legacy
* @expectedDeprecation The !php/const: tag to indicate dumped PHP constants is deprecated since version 3.4 and will be removed in 4.0. Use the !php/const (without the colon) tag instead on line 1.
* @dataProvider getTestsForParseLegacyPhpConstants
*/
public function testDeprecatedConstantTag()
public function testDeprecatedConstantTag($yaml, $expectedValue)
{
Inline::parse('!php/const:PHP_INT_MAX', Yaml::PARSE_CONSTANT);
$this->assertSame($expectedValue, Inline::parse($yaml, Yaml::PARSE_CONSTANT));
}
public function getTestsForParseLegacyPhpConstants()
{
return array(
array('!php/const:Symfony\Component\Yaml\Yaml::PARSE_CONSTANT', Yaml::PARSE_CONSTANT),
array('!php/const:PHP_INT_MAX', PHP_INT_MAX),
array('[!php/const:PHP_INT_MAX]', array(PHP_INT_MAX)),
array('{ foo: !php/const:PHP_INT_MAX }', array('foo' => PHP_INT_MAX)),
array('!php/const:NULL', null),
);
}
/**
......
......@@ -2090,6 +2090,80 @@ foo: { &foo { a: Steve, <<: *foo} }
EOE;
$this->parser->parse($yaml);
}
/**
* @dataProvider indentedMappingData
*/
public function testParseIndentedMappings($yaml, $expected)
{
$this->assertSame($expected, $this->parser->parse($yaml));
}
public function indentedMappingData()
{
$tests = array();
$yaml = <<<YAML
foo:
- bar: "foobar"
# A comment
baz: "foobaz"
YAML;
$expected = array(
'foo' => array(
array(
'bar' => 'foobar',
'baz' => 'foobaz',
),
),
);
$tests['comment line is first line in indented block'] = array($yaml, $expected);
$yaml = <<<YAML
foo:
- bar:
# comment
baz: [1, 2, 3]
YAML;
$expected = array(
'foo' => array(
array(
'bar' => array(
'baz' => array(1, 2, 3),
),
),
),
);
$tests['mapping value on new line starting with a comment line'] = array($yaml, $expected);
$yaml = <<<YAML
foo:
-
bar: foobar
YAML;
$expected = array(
'foo' => array(
array(
'bar' => 'foobar',
),
),
);
$tests['mapping in sequence starting on a new line'] = array($yaml, $expected);
$yaml = <<<YAML
foo:
bar: baz
YAML;
$expected = array(
'foo' => array(
'bar' => 'baz',
),
);
$tests['blank line at the beginning of an indented mapping value'] = array($yaml, $expected);
return $tests;
}
}
class B
......
......@@ -21,3 +21,6 @@ Db::name('demo')
->order('id','desc')
->select();
~~~
1.*版本支持ThinkPHP 5.0
2.*版本支持ThinkPHP 5.1
......@@ -14,6 +14,7 @@ use MongoDB\BSON\ObjectID;
use MongoDB\BSON\Regex;
use MongoDB\Driver\BulkWrite;
use MongoDB\Driver\Command;
use MongoDB\Driver\Exception\InvalidArgumentException;
use MongoDB\Driver\Query as MongoQuery;
use think\Exception;
......@@ -69,7 +70,11 @@ class Builder
protected function parseValue($value, $field = '')
{
if ('_id' == $field && 'ObjectID' == $this->connection->getConfig('pk_type') && is_string($value)) {
return new ObjectID($value);
try {
return new ObjectID($value);
} catch (InvalidArgumentException $e) {
return new ObjectID();
}
}
return $value;
}
......@@ -119,7 +124,7 @@ class Builder
$result = [];
foreach ($data as $key => $val) {
$item = $this->parseKey($key);
if (is_array($val) && isset($val[0]) && in_array($val[0], ['$inc', '$set', '$unset', '$push', '$pushall', '$addtoset', '$pop', '$pull', '$pullall'])) {
if (is_array($val) && isset($val[0]) && 0 === strpos($val[0], '$')) {
$result[$val[0]][$item] = $this->parseValue($val[1], $key);
} else {
$result['$set'][$item] = $this->parseValue($val, $key);
......@@ -134,7 +139,7 @@ class Builder
* @param mixed $where
* @return array
*/
public function parseWhere($where)
public function parseWhere($where, $options = [])
{
if (empty($where)) {
$where = [];
......@@ -147,7 +152,7 @@ class Builder
// 使用闭包查询
$query = new Query($this->connection);
call_user_func_array($value, [ & $query]);
$filter[$logic][] = $this->parseWhere($query->getOptions('where'));
$filter[$logic][] = $this->parseWhere($query->getOptions('where'), $options);
} else {
if (strpos($field, '|')) {
// 不同字段使用相同查询条件(OR)
......@@ -169,6 +174,14 @@ class Builder
}
}
}
if (!empty($options['soft_delete'])) {
// 附加软删除条件
list($field, $condition) = $options['soft_delete'];
$filter['$and'][] = $this->parseWhereItem($field, $condition);
}
return $filter;
}
......@@ -362,7 +375,7 @@ class Builder
public function update($data, $options = [])
{
$data = $this->parseSet($data, $options);
$where = $this->parseWhere($options['where']);
$where = $this->parseWhere($options['where'], $options);
if (1 == $options['limit']) {
$updateOptions = ['multi' => false];
......@@ -383,7 +396,7 @@ class Builder
*/
public function delete($options)
{
$where = $this->parseWhere($options['where']);
$where = $this->parseWhere($options['where'], $options);
$bulk = new BulkWrite;
if (1 == $options['limit']) {
$deleteOptions = ['limit' => 1];
......@@ -403,7 +416,7 @@ class Builder
*/
public function select($options)
{
$where = $this->parseWhere($options['where']);
$where = $this->parseWhere($options['where'], $options);
$query = new MongoQuery($where, $options);
$this->log('find', $where, $options);
return $query;
......@@ -418,7 +431,7 @@ class Builder
public function count($options)
{
$cmd['count'] = $options['table'];
$cmd['query'] = $this->parseWhere($options['where']);
$cmd['query'] = $this->parseWhere($options['where'], $options);
foreach (['hint', 'limit', 'maxTimeMS', 'skip'] as $option) {
if (isset($options[$option])) {
$cmd[$option] = $options[$option];
......@@ -440,7 +453,7 @@ class Builder
{
list($fun, $field) = $extra;
$pipeline = [
['$match' => (object) $this->parseWhere($options['where'])],
['$match' => (object) $this->parseWhere($options['where'], $options)],
['$group' => ['_id' => null, 'aggregate' => ['$' . $fun => '$' . $field]]],
];
$cmd = [
......@@ -459,6 +472,44 @@ class Builder
return $command;
}
/**
* 多聚合查询命令, 可以对多个字段进行 group by 操作
*
* @param array $options 参数
* @param array $extra 指令和字段
* @return Command
*/
public function multiAggregate($options, $extra)
{
list($aggregate, $groupBy) = $extra;
$groups = ['_id' => []];
foreach ($groupBy as $field) {
$groups['_id'][$field] = '$' . $field;
}
foreach ($aggregate as $fun => $field) {
$groups[$field . '_' . $fun] = ['$' . $fun => '$' . $field];
}
$pipeline = [
['$match' => (object) $this->parseWhere($options['where'], $options)],
['$group' => $groups],
];
$cmd = [
'aggregate' => $options['table'],
'allowDiskUse' => true,
'pipeline' => $pipeline,
];
foreach (['explain', 'collation', 'bypassDocumentValidation', 'readConcern'] as $option) {
if (isset($options[$option])) {
$cmd[$option] = $options[$option];
}
}
$command = new Command($cmd);
$this->log('group', $cmd);
return $command;
}
/**
* 生成distinct命令
* @access public
......@@ -474,7 +525,7 @@ class Builder
];
if (!empty($options['where'])) {
$cmd['query'] = $this->parseWhere($options['where']);
$cmd['query'] = $this->parseWhere($options['where'], $options);
}
if (isset($options['maxTimeMS'])) {
......
......@@ -491,6 +491,28 @@ class Query
return $result[0]['n'];
}
/**
* 多聚合操作
*
* @param array $aggregate 聚合指令, 可以聚合多个参数, 如 ['sum' => 'field1', 'avg' => 'field2']
* @param array $groupBy 类似mysql里面的group字段, 可以传入多个字段, 如 ['field_a', 'field_b', 'field_c']
* @return array 查询结果
*/
public function multiAggregate($aggregate, $groupBy)
{
$result = $this->cmd('multiAggregate', [$aggregate, $groupBy]);
$result = isset($result[0]['result']) ? $result[0]['result'] : [];
foreach ($result as &$row) {
if (isset($row['_id']) && !empty($row['_id'])) {
foreach ($row['_id'] as $k => $v) {
$row[$k] = $v;
}
unset($row['_id']);
}
}
return $result;
}
/**
* 聚合查询
* @access public
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment