Commit ffd8c287 authored by hujun's avatar hujun

composer file

parent fa63fdb9
...@@ -4,4 +4,4 @@ ...@@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php'; require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderIniteae526504930a78fdf1cf0a82c228fa7::getLoader(); return ComposerAutoloaderInit563e23492907a0ecb0dae7ce3a76ccdc::getLoader();
#!/usr/bin/env sh #!/usr/bin/env php
<?php
dir=$(d=${0%[/\\]*}; cd "$d" > /dev/null; cd "../phpunit/phpunit" && pwd) /*
* This file is part of PHPUnit.
# See if we are running in Cygwin by checking for cygpath program *
if command -v 'cygpath' >/dev/null 2>&1; then * (c) Sebastian Bergmann <sebastian@phpunit.de>
# Cygwin paths start with /cygdrive/ which will break windows PHP, *
# so we need to translate the dir path to windows format. However * For the full copyright and license information, please view the LICENSE
# we could be using cygwin PHP which does not require this, so we * file that was distributed with this source code.
# test if the path to PHP starts with /cygdrive/ rather than /usr/bin */
if [[ $(which php) == /cygdrive/* ]]; then
dir=$(cygpath -m "$dir"); if (version_compare('5.3.3', PHP_VERSION, '>')) {
fi fwrite(
fi STDERR,
sprintf(
dir=$(echo $dir | sed 's/ /\ /g') 'This version of PHPUnit is supported on PHP 5.3, PHP 5.4, PHP 5.5, and PHP 5.6.' . PHP_EOL .
"${dir}/phpunit" "$@" '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__)); ...@@ -6,6 +6,10 @@ $vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
return array( 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' => $vendorDir . '/phpunit/php-file-iterator/src/Iterator.php',
'File_Iterator_Facade' => $vendorDir . '/phpunit/php-file-iterator/src/Facade.php', 'File_Iterator_Facade' => $vendorDir . '/phpunit/php-file-iterator/src/Facade.php',
'File_Iterator_Factory' => $vendorDir . '/phpunit/php-file-iterator/src/Factory.php', 'File_Iterator_Factory' => $vendorDir . '/phpunit/php-file-iterator/src/Factory.php',
...@@ -414,6 +418,8 @@ return array( ...@@ -414,6 +418,8 @@ return array(
'PHP_Token_XOR_EQUAL' => $vendorDir . '/phpunit/php-token-stream/src/Token.php', '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' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_YIELD_FROM' => $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\\ArrayComparator' => $vendorDir . '/sebastian/comparator/src/ArrayComparator.php',
'SebastianBergmann\\Comparator\\Comparator' => $vendorDir . '/sebastian/comparator/src/Comparator.php', 'SebastianBergmann\\Comparator\\Comparator' => $vendorDir . '/sebastian/comparator/src/Comparator.php',
'SebastianBergmann\\Comparator\\ComparisonFailure' => $vendorDir . '/sebastian/comparator/src/ComparisonFailure.php', 'SebastianBergmann\\Comparator\\ComparisonFailure' => $vendorDir . '/sebastian/comparator/src/ComparisonFailure.php',
...@@ -450,5 +456,65 @@ return array( ...@@ -450,5 +456,65 @@ return array(
'SebastianBergmann\\RecursionContext\\Exception' => $vendorDir . '/sebastian/recursion-context/src/Exception.php', 'SebastianBergmann\\RecursionContext\\Exception' => $vendorDir . '/sebastian/recursion-context/src/Exception.php',
'SebastianBergmann\\RecursionContext\\InvalidArgumentException' => $vendorDir . '/sebastian/recursion-context/src/InvalidArgumentException.php', 'SebastianBergmann\\RecursionContext\\InvalidArgumentException' => $vendorDir . '/sebastian/recursion-context/src/InvalidArgumentException.php',
'SebastianBergmann\\Version' => $vendorDir . '/sebastian/version/src/Version.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', '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__)); ...@@ -6,8 +6,11 @@ $vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
return array( return array(
'5255c38a0faeba867671b61dfda6d864' => $vendorDir . '/paragonie/random_compat/lib/random.php',
'023d27dca8066ef29e6739335ea73bad' => $vendorDir . '/symfony/polyfill-php70/bootstrap.php',
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php', '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
'9b552a3cc426e3287cc811caefa3cf53' => $vendorDir . '/topthink/think-helper/src/helper.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', '1cfd2761b63b0a29ed23657ea394cb2d' => $vendorDir . '/topthink/think-captcha/src/helper.php',
'ddc3cd2a04224f9638c5d0de6a69c7e3' => $vendorDir . '/topthink/think-migration/src/config.php', 'ddc3cd2a04224f9638c5d0de6a69c7e3' => $vendorDir . '/topthink/think-migration/src/config.php',
'72c97b53391125cae04082a81029f42d' => $vendorDir . '/topthink/think-testing/src/config.php', '72c97b53391125cae04082a81029f42d' => $vendorDir . '/topthink/think-testing/src/config.php',
......
...@@ -7,4 +7,5 @@ $baseDir = dirname($vendorDir); ...@@ -7,4 +7,5 @@ $baseDir = dirname($vendorDir);
return array( return array(
'Prophecy\\' => array($vendorDir . '/phpspec/prophecy/src'), 'Prophecy\\' => array($vendorDir . '/phpspec/prophecy/src'),
'BaconQrCode' => array($vendorDir . '/bacon/bacon-qr-code/src'),
); );
...@@ -16,10 +16,16 @@ return array( ...@@ -16,10 +16,16 @@ return array(
'phpDocumentor\\Reflection\\' => array($vendorDir . '/phpdocumentor/reflection-common/src', $vendorDir . '/phpdocumentor/type-resolver/src', $vendorDir . '/phpdocumentor/reflection-docblock/src'), 'phpDocumentor\\Reflection\\' => array($vendorDir . '/phpdocumentor/reflection-common/src', $vendorDir . '/phpdocumentor/type-resolver/src', $vendorDir . '/phpdocumentor/reflection-docblock/src'),
'app\\' => array($baseDir . '/application'), 'app\\' => array($baseDir . '/application'),
'Webmozart\\Assert\\' => array($vendorDir . '/webmozart/assert/src'), 'Webmozart\\Assert\\' => array($vendorDir . '/webmozart/assert/src'),
'Symfony\\Polyfill\\Php70\\' => array($vendorDir . '/symfony/polyfill-php70'),
'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'), 'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
'Symfony\\Component\\Yaml\\' => array($vendorDir . '/symfony/yaml'), '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'), 'Symfony\\Component\\DomCrawler\\' => array($vendorDir . '/symfony/dom-crawler'),
'Phinx\\' => array($vendorDir . '/topthink/think-migration/phinx/src/Phinx'), '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'), 'Firebase\\JWT\\' => array($vendorDir . '/firebase/php-jwt/src'),
'Endroid\\QrCode\\' => array($vendorDir . '/endroid/qrcode/src'),
'Doctrine\\Instantiator\\' => array($vendorDir . '/doctrine/instantiator/src/Doctrine/Instantiator'), 'Doctrine\\Instantiator\\' => array($vendorDir . '/doctrine/instantiator/src/Doctrine/Instantiator'),
); );
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer // autoload_real.php @generated by Composer
class ComposerAutoloaderIniteae526504930a78fdf1cf0a82c228fa7 class ComposerAutoloaderInit563e23492907a0ecb0dae7ce3a76ccdc
{ {
private static $loader; private static $loader;
...@@ -19,15 +19,15 @@ class ComposerAutoloaderIniteae526504930a78fdf1cf0a82c228fa7 ...@@ -19,15 +19,15 @@ class ComposerAutoloaderIniteae526504930a78fdf1cf0a82c228fa7
return self::$loader; 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(); 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()); $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) { if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php'; require_once __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticIniteae526504930a78fdf1cf0a82c228fa7::getInitializer($loader)); call_user_func(\Composer\Autoload\ComposerStaticInit563e23492907a0ecb0dae7ce3a76ccdc::getInitializer($loader));
} else { } else {
$map = require __DIR__ . '/autoload_namespaces.php'; $map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) { foreach ($map as $namespace => $path) {
...@@ -48,19 +48,19 @@ class ComposerAutoloaderIniteae526504930a78fdf1cf0a82c228fa7 ...@@ -48,19 +48,19 @@ class ComposerAutoloaderIniteae526504930a78fdf1cf0a82c228fa7
$loader->register(true); $loader->register(true);
if ($useStaticLoader) { if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticIniteae526504930a78fdf1cf0a82c228fa7::$files; $includeFiles = Composer\Autoload\ComposerStaticInit563e23492907a0ecb0dae7ce3a76ccdc::$files;
} else { } else {
$includeFiles = require __DIR__ . '/autoload_files.php'; $includeFiles = require __DIR__ . '/autoload_files.php';
} }
foreach ($includeFiles as $fileIdentifier => $file) { foreach ($includeFiles as $fileIdentifier => $file) {
composerRequireeae526504930a78fdf1cf0a82c228fa7($fileIdentifier, $file); composerRequire563e23492907a0ecb0dae7ce3a76ccdc($fileIdentifier, $file);
} }
return $loader; return $loader;
} }
} }
function composerRequireeae526504930a78fdf1cf0a82c228fa7($fileIdentifier, $file) function composerRequire563e23492907a0ecb0dae7ce3a76ccdc($fileIdentifier, $file)
{ {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file; 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 ...@@ -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 With this component, a library can provide support for annotations via DocBlocks
or otherwise retrieve information that is embedded in a DocBlock. 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 Installation
------------ ------------
You can install the component in the following ways: ```bash
composer require phpdocumentor/reflection-docblock
* Use the official Github repository (https://github.com/phpDocumentor/ReflectionDocBlock) ```
* Via Composer (http://packagist.org/packages/phpdocumentor/reflection-docblock)
Usage Usage
----- -----
...@@ -52,18 +48,20 @@ $docblock = $factory->create($docComment); ...@@ -52,18 +48,20 @@ $docblock = $factory->create($docComment);
``` ```
The `create` method will yield an object of type `\phpDocumentor\Reflection\DocBlock` 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 ```php
// Should contain the summary for this DocBlock // Contains the summary for this DocBlock
$summary = $docblock->getSummary(); $summary = $docblock->getSummary();
// Contains an object of type \phpDocumentor\Reflection\DocBlock\Description; // Contains \phpDocumentor\Reflection\DocBlock\Description object
// you can either cast it to string or use the render method to get a string
// representation of the Description.
$description = $docblock->getDescription(); $description = $docblock->getDescription();
```
> For more examples it would be best to review the scripts in the `/examples` // You can either cast it to string
> folder. $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 @@ ...@@ -10,7 +10,7 @@
} }
], ],
"require": { "require": {
"php": "^5.6 || ^7.0", "php": "^7.0",
"phpdocumentor/reflection-common": "^1.0.0", "phpdocumentor/reflection-common": "^1.0.0",
"phpdocumentor/type-resolver": "^0.4.0", "phpdocumentor/type-resolver": "^0.4.0",
"webmozart/assert": "^1.0" "webmozart/assert": "^1.0"
...@@ -22,7 +22,13 @@ ...@@ -22,7 +22,13 @@
"psr-4": {"phpDocumentor\\Reflection\\": ["tests/unit"]} "psr-4": {"phpDocumentor\\Reflection\\": ["tests/unit"]}
}, },
"require-dev": { "require-dev": {
"mockery/mockery": "^0.9.4", "mockery/mockery": "^1.0",
"phpunit/phpunit": "^4.4" "phpunit/phpunit": "^6.4",
"doctrine/instantiator": "~1.0.5"
},
"extra": {
"branch-alias": {
"dev-master": "4.x-dev"
}
} }
} }
...@@ -24,7 +24,7 @@ final class DocBlock ...@@ -24,7 +24,7 @@ final class DocBlock
private $description = null; private $description = null;
/** @var Tag[] An array containing all the tags in this docblock; except inline. */ /** @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. */ /** @var Types\Context Information about the context of this DocBlock. */
private $context = null; private $context = null;
...@@ -55,8 +55,7 @@ final class DocBlock ...@@ -55,8 +55,7 @@ final class DocBlock
Location $location = null, Location $location = null,
$isTemplateStart = false, $isTemplateStart = false,
$isTemplateEnd = false $isTemplateEnd = false
) ) {
{
Assert::string($summary); Assert::string($summary);
Assert::boolean($isTemplateStart); Assert::boolean($isTemplateStart);
Assert::boolean($isTemplateEnd); Assert::boolean($isTemplateEnd);
...@@ -171,11 +170,11 @@ final class DocBlock ...@@ -171,11 +170,11 @@ final class DocBlock
{ {
Assert::string($name); Assert::string($name);
$result = array(); $result = [];
/** @var Tag $tag */ /** @var Tag $tag */
foreach ($this->getTags() as $tag) { foreach ($this->getTags() as $tag) {
if ($tag->getName() != $name) { if ($tag->getName() !== $name) {
continue; continue;
} }
...@@ -198,7 +197,7 @@ final class DocBlock ...@@ -198,7 +197,7 @@ final class DocBlock
/** @var Tag $tag */ /** @var Tag $tag */
foreach ($this->getTags() as $tag) { foreach ($this->getTags() as $tag) {
if ($tag->getName() == $name) { if ($tag->getName() === $name) {
return true; return true;
} }
} }
...@@ -206,6 +205,23 @@ final class DocBlock ...@@ -206,6 +205,23 @@ final class DocBlock
return false; 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. * Adds a tag to this DocBlock.
* *
......
...@@ -69,7 +69,7 @@ class Description ...@@ -69,7 +69,7 @@ class Description
$this->bodyTemplate = $bodyTemplate; $this->bodyTemplate = $bodyTemplate;
$this->tags = $tags; $this->tags = $tags;
} }
/** /**
* Returns the tags for this DocBlock. * Returns the tags for this DocBlock.
* *
...@@ -98,6 +98,7 @@ class Description ...@@ -98,6 +98,7 @@ class Description
foreach ($this->tags as $tag) { foreach ($this->tags as $tag) {
$tags[] = '{' . $formatter->format($tag) . '}'; $tags[] = '{' . $formatter->format($tag) . '}';
} }
return vsprintf($this->bodyTemplate, $tags); return vsprintf($this->bodyTemplate, $tags);
} }
......
...@@ -188,5 +188,4 @@ class DescriptionFactory ...@@ -188,5 +188,4 @@ class DescriptionFactory
return implode("\n", $lines); return implode("\n", $lines);
} }
} }
...@@ -23,7 +23,7 @@ class ExampleFinder ...@@ -23,7 +23,7 @@ class ExampleFinder
private $sourceDirectory = ''; private $sourceDirectory = '';
/** @var string[] */ /** @var string[] */
private $exampleDirectories = array(); private $exampleDirectories = [];
/** /**
* Attempts to find the example contents for the given descriptor. * Attempts to find the example contents for the given descriptor.
......
...@@ -121,6 +121,7 @@ class Serializer ...@@ -121,6 +121,7 @@ class Serializer
$text = wordwrap($text, $wrapLength); $text = wordwrap($text, $wrapLength);
return $text; return $text;
} }
return $text; return $text;
} }
...@@ -138,6 +139,7 @@ class Serializer ...@@ -138,6 +139,7 @@ class Serializer
if ($wrapLength !== null) { if ($wrapLength !== null) {
$tagText = wordwrap($tagText, $wrapLength); $tagText = wordwrap($tagText, $wrapLength);
} }
$tagText = str_replace("\n", "\n{$indent} * ", $tagText); $tagText = str_replace("\n", "\n{$indent} * ", $tagText);
$comment .= "{$indent} * {$tagText}\n"; $comment .= "{$indent} * {$tagText}\n";
......
...@@ -166,7 +166,7 @@ final class StandardTagFactory implements TagFactory ...@@ -166,7 +166,7 @@ final class StandardTagFactory implements TagFactory
*/ */
private function extractTagParts($tagLine) private function extractTagParts($tagLine)
{ {
$matches = array(); $matches = [];
if (! preg_match('/^@(' . self::REGEX_TAGNAME . ')(?:\s*([^\s].*)|$)/us', $tagLine, $matches)) { if (! preg_match('/^@(' . self::REGEX_TAGNAME . ')(?:\s*([^\s].*)|$)/us', $tagLine, $matches)) {
throw new \InvalidArgumentException( throw new \InvalidArgumentException(
'The tag "' . $tagLine . '" does not seem to be wellformed, please check it for errors' 'The tag "' . $tagLine . '" does not seem to be wellformed, please check it for errors'
...@@ -196,8 +196,7 @@ final class StandardTagFactory implements TagFactory ...@@ -196,8 +196,7 @@ final class StandardTagFactory implements TagFactory
$arguments = $this->getArgumentsForParametersFromWiring( $arguments = $this->getArgumentsForParametersFromWiring(
$this->fetchParametersForHandlerFactoryMethod($handlerClassName), $this->fetchParametersForHandlerFactoryMethod($handlerClassName),
$this->getServiceLocatorWithDynamicParameters($context, $name, $body) $this->getServiceLocatorWithDynamicParameters($context, $name, $body)
) );
;
return call_user_func_array([$handlerClassName, 'create'], $arguments); return call_user_func_array([$handlerClassName, 'create'], $arguments);
} }
......
...@@ -12,11 +12,11 @@ ...@@ -12,11 +12,11 @@
namespace phpDocumentor\Reflection\DocBlock\Tags; namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory; use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\Fqsen; use phpDocumentor\Reflection\Fqsen;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use phpDocumentor\Reflection\FqsenResolver; use phpDocumentor\Reflection\FqsenResolver;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use Webmozart\Assert\Assert; use Webmozart\Assert\Assert;
/** /**
...@@ -49,8 +49,7 @@ final class Covers extends BaseTag implements Factory\StaticMethod ...@@ -49,8 +49,7 @@ final class Covers extends BaseTag implements Factory\StaticMethod
DescriptionFactory $descriptionFactory = null, DescriptionFactory $descriptionFactory = null,
FqsenResolver $resolver = null, FqsenResolver $resolver = null,
TypeContext $context = null TypeContext $context = null
) ) {
{
Assert::string($body); Assert::string($body);
Assert::notEmpty($body); Assert::notEmpty($body);
......
...@@ -12,9 +12,9 @@ ...@@ -12,9 +12,9 @@
namespace phpDocumentor\Reflection\DocBlock\Tags; namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use phpDocumentor\Reflection\DocBlock\Description; use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory; use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use Webmozart\Assert\Assert; use Webmozart\Assert\Assert;
/** /**
......
...@@ -33,12 +33,12 @@ final class Example extends BaseTag ...@@ -33,12 +33,12 @@ final class Example extends BaseTag
private $isURI = false; private $isURI = false;
/** /**
* @var * @var int
*/ */
private $startingLine; private $startingLine;
/** /**
* @var * @var int
*/ */
private $lineCount; private $lineCount;
......
...@@ -135,7 +135,7 @@ final class Method extends BaseTag implements Factory\StaticMethod ...@@ -135,7 +135,7 @@ final class Method extends BaseTag implements Factory\StaticMethod
if (is_string($arguments) && strlen($arguments) > 0) { if (is_string($arguments) && strlen($arguments) > 0) {
$arguments = explode(',', $arguments); $arguments = explode(',', $arguments);
foreach($arguments as &$argument) { foreach ($arguments as &$argument) {
$argument = explode(' ', self::stripRestArg(trim($argument)), 2); $argument = explode(' ', self::stripRestArg(trim($argument)), 2);
if ($argument[0][0] === '$') { if ($argument[0][0] === '$') {
$argumentName = substr($argument[0], 1); $argumentName = substr($argument[0], 1);
...@@ -214,10 +214,13 @@ final class Method extends BaseTag implements Factory\StaticMethod ...@@ -214,10 +214,13 @@ final class Method extends BaseTag implements Factory\StaticMethod
if (is_string($argument)) { if (is_string($argument)) {
$argument = [ 'name' => $argument ]; $argument = [ 'name' => $argument ];
} }
if (! isset($argument['type'])) { if (! isset($argument['type'])) {
$argument['type'] = new Void_(); $argument['type'] = new Void_();
} }
$keys = array_keys($argument); $keys = array_keys($argument);
sort($keys);
if ($keys !== [ 'name', 'type' ]) { if ($keys !== [ 'name', 'type' ]) {
throw new \InvalidArgumentException( throw new \InvalidArgumentException(
'Arguments can only have the "name" and "type" fields, found: ' . var_export($keys, true) '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 ...@@ -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 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); $variableName = array_shift($parts);
array_shift($parts); array_shift($parts);
......
...@@ -70,7 +70,7 @@ class Property extends BaseTag implements Factory\StaticMethod ...@@ -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 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); $variableName = array_shift($parts);
array_shift($parts); array_shift($parts);
......
...@@ -70,7 +70,7 @@ class PropertyRead extends BaseTag implements Factory\StaticMethod ...@@ -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 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); $variableName = array_shift($parts);
array_shift($parts); array_shift($parts);
......
...@@ -70,7 +70,7 @@ class PropertyWrite extends BaseTag implements Factory\StaticMethod ...@@ -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 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); $variableName = array_shift($parts);
array_shift($parts); array_shift($parts);
......
...@@ -17,5 +17,5 @@ namespace phpDocumentor\Reflection\DocBlock\Tags\Reference; ...@@ -17,5 +17,5 @@ namespace phpDocumentor\Reflection\DocBlock\Tags\Reference;
*/ */
interface Reference interface Reference
{ {
public function __toString(); public function __toString();
} }
...@@ -43,8 +43,7 @@ final class Return_ extends BaseTag implements Factory\StaticMethod ...@@ -43,8 +43,7 @@ final class Return_ extends BaseTag implements Factory\StaticMethod
TypeResolver $typeResolver = null, TypeResolver $typeResolver = null,
DescriptionFactory $descriptionFactory = null, DescriptionFactory $descriptionFactory = null,
TypeContext $context = null TypeContext $context = null
) ) {
{
Assert::string($body); Assert::string($body);
Assert::allNotNull([$typeResolver, $descriptionFactory]); Assert::allNotNull([$typeResolver, $descriptionFactory]);
......
...@@ -12,14 +12,13 @@ ...@@ -12,14 +12,13 @@
namespace phpDocumentor\Reflection\DocBlock\Tags; namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory; use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\DocBlock\Tags\Reference\Fqsen as FqsenRef; use phpDocumentor\Reflection\DocBlock\Tags\Reference\Fqsen as FqsenRef;
use phpDocumentor\Reflection\DocBlock\Tags\Reference\Reference; use phpDocumentor\Reflection\DocBlock\Tags\Reference\Reference;
use phpDocumentor\Reflection\DocBlock\Tags\Reference\Url; use phpDocumentor\Reflection\DocBlock\Tags\Reference\Url;
use phpDocumentor\Reflection\Fqsen;
use phpDocumentor\Reflection\FqsenResolver; use phpDocumentor\Reflection\FqsenResolver;
use phpDocumentor\Reflection\Types\Context as TypeContext; use phpDocumentor\Reflection\Types\Context as TypeContext;
use phpDocumentor\Reflection\DocBlock\Description;
use Webmozart\Assert\Assert; use Webmozart\Assert\Assert;
/** /**
......
...@@ -12,9 +12,9 @@ ...@@ -12,9 +12,9 @@
namespace phpDocumentor\Reflection\DocBlock\Tags; namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use phpDocumentor\Reflection\DocBlock\Description; use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory; use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use Webmozart\Assert\Assert; use Webmozart\Assert\Assert;
/** /**
......
...@@ -59,6 +59,7 @@ final class Source extends BaseTag implements Factory\StaticMethod ...@@ -59,6 +59,7 @@ final class Source extends BaseTag implements Factory\StaticMethod
if (isset($matches[2]) && $matches[2] !== '') { if (isset($matches[2]) && $matches[2] !== '') {
$lineCount = (int)$matches[2]; $lineCount = (int)$matches[2];
} }
$description = $matches[3]; $description = $matches[3];
} }
......
...@@ -70,7 +70,7 @@ class Var_ extends BaseTag implements Factory\StaticMethod ...@@ -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 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); $variableName = array_shift($parts);
array_shift($parts); array_shift($parts);
...@@ -111,8 +111,8 @@ class Var_ extends BaseTag implements Factory\StaticMethod ...@@ -111,8 +111,8 @@ class Var_ extends BaseTag implements Factory\StaticMethod
*/ */
public function __toString() public function __toString()
{ {
return ($this->type ? $this->type.' ' : '') return ($this->type ? $this->type . ' ' : '')
.(empty($this->variableName) ? null : ('$'.$this->variableName)) . (empty($this->variableName) ? null : ('$' . $this->variableName))
.($this->description ? ' '.$this->description : ''); . ($this->description ? ' ' . $this->description : '');
} }
} }
...@@ -12,9 +12,9 @@ ...@@ -12,9 +12,9 @@
namespace phpDocumentor\Reflection\DocBlock\Tags; namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use phpDocumentor\Reflection\DocBlock\Description; use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory; use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use Webmozart\Assert\Assert; use Webmozart\Assert\Assert;
/** /**
......
...@@ -93,7 +93,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface ...@@ -93,7 +93,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
return new DocBlock( return new DocBlock(
$summary, $summary,
$description ? $this->descriptionFactory->create($description, $context) : null, $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; return $tag instanceof Tag;
}), }),
$context, $context,
...@@ -120,11 +120,11 @@ final class DocBlockFactory implements DocBlockFactoryInterface ...@@ -120,11 +120,11 @@ final class DocBlockFactory implements DocBlockFactoryInterface
$comment = trim(preg_replace('#[ \t]*(?:\/\*\*|\*\/|\*)?[ \t]{0,1}(.*)?#u', '$1', $comment)); $comment = trim(preg_replace('#[ \t]*(?:\/\*\*|\*\/|\*)?[ \t]{0,1}(.*)?#u', '$1', $comment));
// reg ex above is not able to remove */ from a single line docblock // 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)); $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 ...@@ -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 // 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 // performance impact of running a regular expression
if (strpos($comment, '@') === 0) { if (strpos($comment, '@') === 0) {
return array('', '', '', $comment); return ['', '', '', $comment];
} }
// clears all extra horizontal whitespace from the line endings to prevent parsing issues // clears all extra horizontal whitespace from the line endings to prevent parsing issues
...@@ -241,7 +241,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface ...@@ -241,7 +241,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
*/ */
private function splitTagBlockIntoTagLines($tags) private function splitTagBlockIntoTagLines($tags)
{ {
$result = array(); $result = [];
foreach (explode("\n", $tags) as $tag_line) { foreach (explode("\n", $tags) as $tag_line) {
if (isset($tag_line[0]) && ($tag_line[0] === '@')) { if (isset($tag_line[0]) && ($tag_line[0] === '@')) {
$result[] = $tag_line; $result[] = $tag_line;
......
...@@ -707,7 +707,8 @@ class Inline ...@@ -707,7 +707,8 @@ class Inline
return; return;
case 0 === strpos($scalar, '!php/const'): case 0 === strpos($scalar, '!php/const'):
if (self::$constantSupport) { 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); return constant($const);
} }
......
...@@ -362,8 +362,6 @@ class Parser ...@@ -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); @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 { } 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); $value = $this->parseBlock($this->getRealCurrentLineNb() + 1, $this->getNextEmbedBlock(), $flags);
if ('<<' === $key) { if ('<<' === $key) {
$this->refs[$refMatches['ref']] = $value; $this->refs[$refMatches['ref']] = $value;
...@@ -573,7 +571,27 @@ class Parser ...@@ -573,7 +571,27 @@ class Parser
} }
if (null === $indentation) { 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(); $unindentedEmbedBlock = $this->isStringUnIndentedCollectionItem();
...@@ -587,6 +605,8 @@ class Parser ...@@ -587,6 +605,8 @@ class Parser
$data = array(); $data = array();
if ($this->getCurrentLineIndentation() >= $newIndent) { if ($this->getCurrentLineIndentation() >= $newIndent) {
$data[] = substr($this->currentLine, $newIndent); $data[] = substr($this->currentLine, $newIndent);
} elseif ($this->isCurrentLineEmpty() || $this->isCurrentLineComment()) {
$data[] = $this->currentLine;
} else { } else {
$this->moveToPreviousLine(); $this->moveToPreviousLine();
...@@ -905,11 +925,15 @@ class Parser ...@@ -905,11 +925,15 @@ class Parser
private function isNextLineIndented() private function isNextLineIndented()
{ {
$currentIndentation = $this->getCurrentLineIndentation(); $currentIndentation = $this->getCurrentLineIndentation();
$EOF = !$this->moveToNextLine(); $movements = 0;
while (!$EOF && $this->isCurrentLineEmpty()) { do {
$EOF = !$this->moveToNextLine(); $EOF = !$this->moveToNextLine();
}
if (!$EOF) {
++$movements;
}
} while (!$EOF && ($this->isCurrentLineEmpty() || $this->isCurrentLineComment()));
if ($EOF) { if ($EOF) {
return false; return false;
...@@ -917,7 +941,9 @@ class Parser ...@@ -917,7 +941,9 @@ class Parser
$ret = $this->getCurrentLineIndentation() > $currentIndentation; $ret = $this->getCurrentLineIndentation() > $currentIndentation;
$this->moveToPreviousLine(); for ($i = 0; $i < $movements; ++$i) {
$this->moveToPreviousLine();
}
return $ret; return $ret;
} }
...@@ -1006,19 +1032,25 @@ class Parser ...@@ -1006,19 +1032,25 @@ class Parser
private function isNextLineUnIndentedCollection() private function isNextLineUnIndentedCollection()
{ {
$currentIndentation = $this->getCurrentLineIndentation(); $currentIndentation = $this->getCurrentLineIndentation();
$notEOF = $this->moveToNextLine(); $movements = 0;
while ($notEOF && $this->isCurrentLineEmpty()) { do {
$notEOF = $this->moveToNextLine(); $EOF = !$this->moveToNextLine();
}
if (!$EOF) {
++$movements;
}
} while (!$EOF && ($this->isCurrentLineEmpty() || $this->isCurrentLineComment()));
if (false === $notEOF) { if ($EOF) {
return false; return false;
} }
$ret = $this->getCurrentLineIndentation() === $currentIndentation && $this->isStringUnIndentedCollectionItem(); $ret = $this->getCurrentLineIndentation() === $currentIndentation && $this->isStringUnIndentedCollectionItem();
$this->moveToPreviousLine(); for ($i = 0; $i < $movements; ++$i) {
$this->moveToPreviousLine();
}
return $ret; return $ret;
} }
......
...@@ -58,6 +58,7 @@ class InlineTest extends TestCase ...@@ -58,6 +58,7 @@ class InlineTest extends TestCase
array('!php/const PHP_INT_MAX', PHP_INT_MAX), array('!php/const PHP_INT_MAX', PHP_INT_MAX),
array('[!php/const PHP_INT_MAX]', array(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('{ foo: !php/const PHP_INT_MAX }', array('foo' => PHP_INT_MAX)),
array('!php/const NULL', null),
); );
} }
...@@ -82,10 +83,22 @@ class InlineTest extends TestCase ...@@ -82,10 +83,22 @@ class InlineTest extends TestCase
/** /**
* @group legacy * @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. * @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} } ...@@ -2090,6 +2090,80 @@ foo: { &foo { a: Steve, <<: *foo} }
EOE; EOE;
$this->parser->parse($yaml); $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 class B
......
...@@ -21,3 +21,6 @@ Db::name('demo') ...@@ -21,3 +21,6 @@ Db::name('demo')
->order('id','desc') ->order('id','desc')
->select(); ->select();
~~~ ~~~
1.*版本支持ThinkPHP 5.0
2.*版本支持ThinkPHP 5.1
...@@ -14,6 +14,7 @@ use MongoDB\BSON\ObjectID; ...@@ -14,6 +14,7 @@ use MongoDB\BSON\ObjectID;
use MongoDB\BSON\Regex; use MongoDB\BSON\Regex;
use MongoDB\Driver\BulkWrite; use MongoDB\Driver\BulkWrite;
use MongoDB\Driver\Command; use MongoDB\Driver\Command;
use MongoDB\Driver\Exception\InvalidArgumentException;
use MongoDB\Driver\Query as MongoQuery; use MongoDB\Driver\Query as MongoQuery;
use think\Exception; use think\Exception;
...@@ -69,7 +70,11 @@ class Builder ...@@ -69,7 +70,11 @@ class Builder
protected function parseValue($value, $field = '') protected function parseValue($value, $field = '')
{ {
if ('_id' == $field && 'ObjectID' == $this->connection->getConfig('pk_type') && is_string($value)) { 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; return $value;
} }
...@@ -119,7 +124,7 @@ class Builder ...@@ -119,7 +124,7 @@ class Builder
$result = []; $result = [];
foreach ($data as $key => $val) { foreach ($data as $key => $val) {
$item = $this->parseKey($key); $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); $result[$val[0]][$item] = $this->parseValue($val[1], $key);
} else { } else {
$result['$set'][$item] = $this->parseValue($val, $key); $result['$set'][$item] = $this->parseValue($val, $key);
...@@ -134,7 +139,7 @@ class Builder ...@@ -134,7 +139,7 @@ class Builder
* @param mixed $where * @param mixed $where
* @return array * @return array
*/ */
public function parseWhere($where) public function parseWhere($where, $options = [])
{ {
if (empty($where)) { if (empty($where)) {
$where = []; $where = [];
...@@ -147,7 +152,7 @@ class Builder ...@@ -147,7 +152,7 @@ class Builder
// 使用闭包查询 // 使用闭包查询
$query = new Query($this->connection); $query = new Query($this->connection);
call_user_func_array($value, [ & $query]); call_user_func_array($value, [ & $query]);
$filter[$logic][] = $this->parseWhere($query->getOptions('where')); $filter[$logic][] = $this->parseWhere($query->getOptions('where'), $options);
} else { } else {
if (strpos($field, '|')) { if (strpos($field, '|')) {
// 不同字段使用相同查询条件(OR) // 不同字段使用相同查询条件(OR)
...@@ -169,6 +174,14 @@ class Builder ...@@ -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; return $filter;
} }
...@@ -362,7 +375,7 @@ class Builder ...@@ -362,7 +375,7 @@ class Builder
public function update($data, $options = []) public function update($data, $options = [])
{ {
$data = $this->parseSet($data, $options); $data = $this->parseSet($data, $options);
$where = $this->parseWhere($options['where']); $where = $this->parseWhere($options['where'], $options);
if (1 == $options['limit']) { if (1 == $options['limit']) {
$updateOptions = ['multi' => false]; $updateOptions = ['multi' => false];
...@@ -383,7 +396,7 @@ class Builder ...@@ -383,7 +396,7 @@ class Builder
*/ */
public function delete($options) public function delete($options)
{ {
$where = $this->parseWhere($options['where']); $where = $this->parseWhere($options['where'], $options);
$bulk = new BulkWrite; $bulk = new BulkWrite;
if (1 == $options['limit']) { if (1 == $options['limit']) {
$deleteOptions = ['limit' => 1]; $deleteOptions = ['limit' => 1];
...@@ -403,7 +416,7 @@ class Builder ...@@ -403,7 +416,7 @@ class Builder
*/ */
public function select($options) public function select($options)
{ {
$where = $this->parseWhere($options['where']); $where = $this->parseWhere($options['where'], $options);
$query = new MongoQuery($where, $options); $query = new MongoQuery($where, $options);
$this->log('find', $where, $options); $this->log('find', $where, $options);
return $query; return $query;
...@@ -418,7 +431,7 @@ class Builder ...@@ -418,7 +431,7 @@ class Builder
public function count($options) public function count($options)
{ {
$cmd['count'] = $options['table']; $cmd['count'] = $options['table'];
$cmd['query'] = $this->parseWhere($options['where']); $cmd['query'] = $this->parseWhere($options['where'], $options);
foreach (['hint', 'limit', 'maxTimeMS', 'skip'] as $option) { foreach (['hint', 'limit', 'maxTimeMS', 'skip'] as $option) {
if (isset($options[$option])) { if (isset($options[$option])) {
$cmd[$option] = $options[$option]; $cmd[$option] = $options[$option];
...@@ -440,7 +453,7 @@ class Builder ...@@ -440,7 +453,7 @@ class Builder
{ {
list($fun, $field) = $extra; list($fun, $field) = $extra;
$pipeline = [ $pipeline = [
['$match' => (object) $this->parseWhere($options['where'])], ['$match' => (object) $this->parseWhere($options['where'], $options)],
['$group' => ['_id' => null, 'aggregate' => ['$' . $fun => '$' . $field]]], ['$group' => ['_id' => null, 'aggregate' => ['$' . $fun => '$' . $field]]],
]; ];
$cmd = [ $cmd = [
...@@ -459,6 +472,44 @@ class Builder ...@@ -459,6 +472,44 @@ class Builder
return $command; 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命令 * 生成distinct命令
* @access public * @access public
...@@ -474,7 +525,7 @@ class Builder ...@@ -474,7 +525,7 @@ class Builder
]; ];
if (!empty($options['where'])) { if (!empty($options['where'])) {
$cmd['query'] = $this->parseWhere($options['where']); $cmd['query'] = $this->parseWhere($options['where'], $options);
} }
if (isset($options['maxTimeMS'])) { if (isset($options['maxTimeMS'])) {
......
...@@ -491,6 +491,28 @@ class Query ...@@ -491,6 +491,28 @@ class Query
return $result[0]['n']; 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 * @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