1
0
mirror of https://github.com/cydrobolt/polr.git synced 2024-11-09 19:52:28 +01:00

Attempt to fix tests css-selector

This commit is contained in:
Chaoyi Zha 2016-02-13 22:53:46 -05:00
parent 95d26c0834
commit 72f14b944d
668 changed files with 11396 additions and 12204 deletions

View File

@ -1,6 +1,5 @@
language: php language: php
php: php:
- '5.4'
- '5.5' - '5.5'
- '5.6' - '5.6'
- '7.0' - '7.0'
@ -10,3 +9,5 @@ before_script:
- mv tests/test_env .env - mv tests/test_env .env
- mysql -e 'CREATE DATABASE polrci;' - mysql -e 'CREATE DATABASE polrci;'
- composer install - composer install
notifications:
email: false

View File

@ -10,8 +10,9 @@
"vlucas/phpdotenv": "~1.0" "vlucas/phpdotenv": "~1.0"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "~4.0", "fzaninotto/faker": "~1.0",
"fzaninotto/faker": "~1.0" "phpunit/phpunit": "^5.2",
"symfony/css-selector": "^3.0"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {

777
composer.lock generated

File diff suppressed because it is too large Load Diff

18
tests/AuthTest.php Normal file
View File

@ -0,0 +1,18 @@
<?php
class AuthTest extends TestCase
{
/**
* Test Authentication (sign up and sign in)
*
* @return void
*/
public function testLogin() {
// $this->visit('/')
// ->type('polrci', 'username')
// ->type('polrci', 'password ')
// ->press('Sign In')
// ->dontSee('name="login" value="Sign In" />')
// ->see('>Dashboard</a>');
}
}

View File

@ -1,15 +0,0 @@
<?php
class ExampleTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testBasicExample()
{
$this->visit('/')
->see('Lumen.');
}
}

17
tests/IndexTest.php Normal file
View File

@ -0,0 +1,17 @@
<?php
class IndexTest extends TestCase
{
/**
* Test Index
*
* @return void
*/
public function testIndex() {
$this->visit('/')
->see('<h1 class=\'title\'>'. env('APP_NAME') .'</h1>') // Ensure page loads correctly
->see('<meta name="csrf-token"') // Ensure CSRF protection is enabled
->see('>Sign In</a>') // Ensure log in buttons are shown when user is logged out
->dontSee('SQLSTATE'); // Ensure database connection is correct
}
}

View File

@ -7,7 +7,7 @@ APP_DEBUG=false
APP_KEY=a5bd6a61b1327670bedd712a358d9c2b APP_KEY=a5bd6a61b1327670bedd712a358d9c2b
# Your app's name (shown on interface) # Your app's name (shown on interface)
APP_NAME=Polr APP_NAME=Polr CI
# Protocol to access your app. e.g https:// # Protocol to access your app. e.g https://
APP_PROTOCOL=http:// APP_PROTOCOL=http://

View File

@ -13,9 +13,7 @@
namespace Composer\Autoload; namespace Composer\Autoload;
/** /**
* ClassLoader implements a PSR-0 class loader * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
*
* See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md
* *
* $loader = new \Composer\Autoload\ClassLoader(); * $loader = new \Composer\Autoload\ClassLoader();
* *
@ -39,6 +37,8 @@ namespace Composer\Autoload;
* *
* @author Fabien Potencier <fabien@symfony.com> * @author Fabien Potencier <fabien@symfony.com>
* @author Jordi Boggiano <j.boggiano@seld.be> * @author Jordi Boggiano <j.boggiano@seld.be>
* @see http://www.php-fig.org/psr/psr-0/
* @see http://www.php-fig.org/psr/psr-4/
*/ */
class ClassLoader class ClassLoader
{ {
@ -147,7 +147,7 @@ class ClassLoader
* appending or prepending to the ones previously set for this namespace. * appending or prepending to the ones previously set for this namespace.
* *
* @param string $prefix The prefix/namespace, with trailing '\\' * @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-0 base directories * @param array|string $paths The PSR-4 base directories
* @param bool $prepend Whether to prepend the directories * @param bool $prepend Whether to prepend the directories
* *
* @throws \InvalidArgumentException * @throws \InvalidArgumentException

View File

@ -6,11 +6,10 @@ $vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
return array( return array(
'AddVotesToUsersTable' => $baseDir . '/database/migrations/2015_11_04_015656_add_votes_to_users_table.php', 'AuthTest' => $baseDir . '/tests/AuthTest.php',
'CreateLinkTable' => $baseDir . '/database/migrations/2015_11_04_015813_create_link_table.php', 'CreateLinkTable' => $baseDir . '/database/migrations/2015_11_04_015813_create_link_table.php',
'CreateUsersTable' => $baseDir . '/database/migrations/2015_11_04_015823_create_users_table.php', 'CreateUsersTable' => $baseDir . '/database/migrations/2015_11_04_015823_create_users_table.php',
'DatabaseSeeder' => $baseDir . '/database/seeds/DatabaseSeeder.php', 'DatabaseSeeder' => $baseDir . '/database/seeds/DatabaseSeeder.php',
'ExampleTest' => $baseDir . '/tests/ExampleTest.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',
@ -20,6 +19,7 @@ return array(
'Illuminate\\Foundation\\Testing\\DatabaseMigrations' => $vendorDir . '/laravel/lumen-framework/src/Foundation/Testing/DatabaseMigrations.php', 'Illuminate\\Foundation\\Testing\\DatabaseMigrations' => $vendorDir . '/laravel/lumen-framework/src/Foundation/Testing/DatabaseMigrations.php',
'Illuminate\\Foundation\\Testing\\DatabaseTransactions' => $vendorDir . '/laravel/lumen-framework/src/Foundation/Testing/DatabaseTransactions.php', 'Illuminate\\Foundation\\Testing\\DatabaseTransactions' => $vendorDir . '/laravel/lumen-framework/src/Foundation/Testing/DatabaseTransactions.php',
'Illuminate\\Foundation\\Testing\\WithoutMiddleware' => $vendorDir . '/laravel/lumen-framework/src/Foundation/Testing/WithoutMiddleware.php', 'Illuminate\\Foundation\\Testing\\WithoutMiddleware' => $vendorDir . '/laravel/lumen-framework/src/Foundation/Testing/WithoutMiddleware.php',
'IndexTest' => $baseDir . '/tests/IndexTest.php',
'PHPUnit_Exception' => $vendorDir . '/phpunit/phpunit/src/Exception.php', 'PHPUnit_Exception' => $vendorDir . '/phpunit/phpunit/src/Exception.php',
'PHPUnit_Extensions_GroupTestSuite' => $vendorDir . '/phpunit/phpunit/src/Extensions/GroupTestSuite.php', 'PHPUnit_Extensions_GroupTestSuite' => $vendorDir . '/phpunit/phpunit/src/Extensions/GroupTestSuite.php',
'PHPUnit_Extensions_PhptTestCase' => $vendorDir . '/phpunit/phpunit/src/Extensions/PhptTestCase.php', 'PHPUnit_Extensions_PhptTestCase' => $vendorDir . '/phpunit/phpunit/src/Extensions/PhptTestCase.php',
@ -51,9 +51,12 @@ return array(
'PHPUnit_Framework_Constraint_IsEmpty' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsEmpty.php', 'PHPUnit_Framework_Constraint_IsEmpty' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsEmpty.php',
'PHPUnit_Framework_Constraint_IsEqual' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsEqual.php', 'PHPUnit_Framework_Constraint_IsEqual' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsEqual.php',
'PHPUnit_Framework_Constraint_IsFalse' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsFalse.php', 'PHPUnit_Framework_Constraint_IsFalse' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsFalse.php',
'PHPUnit_Framework_Constraint_IsFinite' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsFinite.php',
'PHPUnit_Framework_Constraint_IsIdentical' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsIdentical.php', 'PHPUnit_Framework_Constraint_IsIdentical' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsIdentical.php',
'PHPUnit_Framework_Constraint_IsInfinite' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsInfinite.php',
'PHPUnit_Framework_Constraint_IsInstanceOf' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsInstanceOf.php', 'PHPUnit_Framework_Constraint_IsInstanceOf' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsInstanceOf.php',
'PHPUnit_Framework_Constraint_IsJson' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsJson.php', 'PHPUnit_Framework_Constraint_IsJson' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsJson.php',
'PHPUnit_Framework_Constraint_IsNan' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsNan.php',
'PHPUnit_Framework_Constraint_IsNull' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsNull.php', 'PHPUnit_Framework_Constraint_IsNull' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsNull.php',
'PHPUnit_Framework_Constraint_IsTrue' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsTrue.php', 'PHPUnit_Framework_Constraint_IsTrue' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsTrue.php',
'PHPUnit_Framework_Constraint_IsType' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsType.php', 'PHPUnit_Framework_Constraint_IsType' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsType.php',
@ -72,6 +75,7 @@ return array(
'PHPUnit_Framework_Constraint_TraversableContains' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/TraversableContains.php', 'PHPUnit_Framework_Constraint_TraversableContains' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/TraversableContains.php',
'PHPUnit_Framework_Constraint_TraversableContainsOnly' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/TraversableContainsOnly.php', 'PHPUnit_Framework_Constraint_TraversableContainsOnly' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/TraversableContainsOnly.php',
'PHPUnit_Framework_Constraint_Xor' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/Xor.php', 'PHPUnit_Framework_Constraint_Xor' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/Xor.php',
'PHPUnit_Framework_CoveredCodeNotExecutedException' => $vendorDir . '/phpunit/phpunit/src/Framework/PHPUnit_Framework_CoveredCodeNotExecutedException.php',
'PHPUnit_Framework_Error' => $vendorDir . '/phpunit/phpunit/src/Framework/Error.php', 'PHPUnit_Framework_Error' => $vendorDir . '/phpunit/phpunit/src/Framework/Error.php',
'PHPUnit_Framework_Error_Deprecated' => $vendorDir . '/phpunit/phpunit/src/Framework/Error/Deprecated.php', 'PHPUnit_Framework_Error_Deprecated' => $vendorDir . '/phpunit/phpunit/src/Framework/Error/Deprecated.php',
'PHPUnit_Framework_Error_Notice' => $vendorDir . '/phpunit/phpunit/src/Framework/Error/Notice.php', 'PHPUnit_Framework_Error_Notice' => $vendorDir . '/phpunit/phpunit/src/Framework/Error/Notice.php',
@ -144,6 +148,7 @@ return array(
'PHPUnit_Framework_TestSuite_DataProvider' => $vendorDir . '/phpunit/phpunit/src/Framework/TestSuite/DataProvider.php', 'PHPUnit_Framework_TestSuite_DataProvider' => $vendorDir . '/phpunit/phpunit/src/Framework/TestSuite/DataProvider.php',
'PHPUnit_Framework_UnintentionallyCoveredCodeError' => $vendorDir . '/phpunit/phpunit/src/Framework/UnintentionallyCoveredCodeError.php', 'PHPUnit_Framework_UnintentionallyCoveredCodeError' => $vendorDir . '/phpunit/phpunit/src/Framework/UnintentionallyCoveredCodeError.php',
'PHPUnit_Framework_Warning' => $vendorDir . '/phpunit/phpunit/src/Framework/Warning.php', 'PHPUnit_Framework_Warning' => $vendorDir . '/phpunit/phpunit/src/Framework/Warning.php',
'PHPUnit_Framework_WarningTestCase' => $vendorDir . '/phpunit/phpunit/src/Framework/WarningTestCase.php',
'PHPUnit_Runner_BaseTestRunner' => $vendorDir . '/phpunit/phpunit/src/Runner/BaseTestRunner.php', 'PHPUnit_Runner_BaseTestRunner' => $vendorDir . '/phpunit/phpunit/src/Runner/BaseTestRunner.php',
'PHPUnit_Runner_Exception' => $vendorDir . '/phpunit/phpunit/src/Runner/Exception.php', 'PHPUnit_Runner_Exception' => $vendorDir . '/phpunit/phpunit/src/Runner/Exception.php',
'PHPUnit_Runner_Filter_Factory' => $vendorDir . '/phpunit/phpunit/src/Runner/Filter/Factory.php', 'PHPUnit_Runner_Filter_Factory' => $vendorDir . '/phpunit/phpunit/src/Runner/Filter/Factory.php',
@ -169,6 +174,7 @@ return array(
'PHPUnit_Util_Log_JSON' => $vendorDir . '/phpunit/phpunit/src/Util/Log/JSON.php', 'PHPUnit_Util_Log_JSON' => $vendorDir . '/phpunit/phpunit/src/Util/Log/JSON.php',
'PHPUnit_Util_Log_JUnit' => $vendorDir . '/phpunit/phpunit/src/Util/Log/JUnit.php', 'PHPUnit_Util_Log_JUnit' => $vendorDir . '/phpunit/phpunit/src/Util/Log/JUnit.php',
'PHPUnit_Util_Log_TAP' => $vendorDir . '/phpunit/phpunit/src/Util/Log/TAP.php', 'PHPUnit_Util_Log_TAP' => $vendorDir . '/phpunit/phpunit/src/Util/Log/TAP.php',
'PHPUnit_Util_Log_TeamCity' => $vendorDir . '/phpunit/phpunit/src/Util/Log/TeamCity.php',
'PHPUnit_Util_PHP' => $vendorDir . '/phpunit/phpunit/src/Util/PHP.php', 'PHPUnit_Util_PHP' => $vendorDir . '/phpunit/phpunit/src/Util/PHP.php',
'PHPUnit_Util_PHP_Default' => $vendorDir . '/phpunit/phpunit/src/Util/PHP/Default.php', 'PHPUnit_Util_PHP_Default' => $vendorDir . '/phpunit/phpunit/src/Util/PHP/Default.php',
'PHPUnit_Util_PHP_Windows' => $vendorDir . '/phpunit/phpunit/src/Util/PHP/Windows.php', 'PHPUnit_Util_PHP_Windows' => $vendorDir . '/phpunit/phpunit/src/Util/PHP/Windows.php',
@ -184,13 +190,15 @@ return array(
'PHPUnit_Util_Type' => $vendorDir . '/phpunit/phpunit/src/Util/Type.php', 'PHPUnit_Util_Type' => $vendorDir . '/phpunit/phpunit/src/Util/Type.php',
'PHPUnit_Util_XML' => $vendorDir . '/phpunit/phpunit/src/Util/XML.php', 'PHPUnit_Util_XML' => $vendorDir . '/phpunit/phpunit/src/Util/XML.php',
'PHP_CodeCoverage' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage.php', 'PHP_CodeCoverage' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage.php',
'PHP_CodeCoverage_CoveredCodeNotExecutedException' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Exception/CoveredCodeNotExecutedException.php',
'PHP_CodeCoverage_Driver' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Driver.php', 'PHP_CodeCoverage_Driver' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Driver.php',
'PHP_CodeCoverage_Driver_HHVM' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Driver/HHVM.php', 'PHP_CodeCoverage_Driver_HHVM' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Driver/HHVM.php',
'PHP_CodeCoverage_Driver_PHPDBG' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Driver/PHPDBG.php', 'PHP_CodeCoverage_Driver_PHPDBG' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Driver/PHPDBG.php',
'PHP_CodeCoverage_Driver_Xdebug' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Driver/Xdebug.php', 'PHP_CodeCoverage_Driver_Xdebug' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Driver/Xdebug.php',
'PHP_CodeCoverage_Exception' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Exception.php', 'PHP_CodeCoverage_Exception' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Exception/Exception.php',
'PHP_CodeCoverage_Exception_UnintentionallyCoveredCode' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Exception/UnintentionallyCoveredCode.php',
'PHP_CodeCoverage_Filter' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Filter.php', 'PHP_CodeCoverage_Filter' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Filter.php',
'PHP_CodeCoverage_InvalidArgumentException' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Exception/InvalidArgumentException.php',
'PHP_CodeCoverage_MissingCoversAnnotationException' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Exception/MissingCoversAnnotationException.php',
'PHP_CodeCoverage_Report_Clover' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/Clover.php', 'PHP_CodeCoverage_Report_Clover' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/Clover.php',
'PHP_CodeCoverage_Report_Crap4j' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/Crap4j.php', 'PHP_CodeCoverage_Report_Crap4j' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/Crap4j.php',
'PHP_CodeCoverage_Report_Factory' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/Factory.php', 'PHP_CodeCoverage_Report_Factory' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/Factory.php',
@ -216,8 +224,9 @@ return array(
'PHP_CodeCoverage_Report_XML_Project' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/XML/Project.php', 'PHP_CodeCoverage_Report_XML_Project' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/XML/Project.php',
'PHP_CodeCoverage_Report_XML_Tests' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/XML/Tests.php', 'PHP_CodeCoverage_Report_XML_Tests' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/XML/Tests.php',
'PHP_CodeCoverage_Report_XML_Totals' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/XML/Totals.php', 'PHP_CodeCoverage_Report_XML_Totals' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/XML/Totals.php',
'PHP_CodeCoverage_RuntimeException' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Exception/RuntimeException.php',
'PHP_CodeCoverage_UnintentionallyCoveredCodeException' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Exception/UnintentionallyCoveredCodeException.php',
'PHP_CodeCoverage_Util' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Util.php', 'PHP_CodeCoverage_Util' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Util.php',
'PHP_CodeCoverage_Util_InvalidArgumentHelper' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Util/InvalidArgumentHelper.php',
'PHP_Timer' => $vendorDir . '/phpunit/php-timer/src/Timer.php', 'PHP_Timer' => $vendorDir . '/phpunit/php-timer/src/Timer.php',
'PHP_Token' => $vendorDir . '/phpunit/php-token-stream/src/Token.php', 'PHP_Token' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_TokenWithScope' => $vendorDir . '/phpunit/php-token-stream/src/Token.php', 'PHP_TokenWithScope' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
@ -415,6 +424,7 @@ 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',
'SebastianBergmann\\CodeUnitReverseLookup\\Wizard' => $vendorDir . '/sebastian/code-unit-reverse-lookup/src/Wizard.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,6 +460,7 @@ return array(
'SebastianBergmann\\RecursionContext\\Context' => $vendorDir . '/sebastian/recursion-context/src/Context.php', 'SebastianBergmann\\RecursionContext\\Context' => $vendorDir . '/sebastian/recursion-context/src/Context.php',
'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\\ResourceOperations\\ResourceOperations' => $vendorDir . '/sebastian/resource-operations/src/ResourceOperations.php',
'SebastianBergmann\\Version' => $vendorDir . '/sebastian/version/src/Version.php', 'SebastianBergmann\\Version' => $vendorDir . '/sebastian/version/src/Version.php',
'SessionHandlerInterface' => $vendorDir . '/symfony/http-foundation/Resources/stubs/SessionHandlerInterface.php', 'SessionHandlerInterface' => $vendorDir . '/symfony/http-foundation/Resources/stubs/SessionHandlerInterface.php',
'TestCase' => $baseDir . '/tests/TestCase.php', 'TestCase' => $baseDir . '/tests/TestCase.php',

View File

@ -6,10 +6,10 @@ $vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
return array( return array(
$vendorDir . '/danielstjules/stringy/src/Create.php', '65fec9ebcfbb3cbb4fd0d519687aea01' => $vendorDir . '/danielstjules/stringy/src/Create.php',
$vendorDir . '/illuminate/support/helpers.php', '72579e7bd17821bb1321b87411366eae' => $vendorDir . '/illuminate/support/helpers.php',
$vendorDir . '/symfony/var-dumper/Resources/functions/dump.php', '667aeda72477189d0494fecd327c3641' => $vendorDir . '/symfony/var-dumper/Resources/functions/dump.php',
$vendorDir . '/paragonie/random_compat/lib/random.php', '5255c38a0faeba867671b61dfda6d864' => $vendorDir . '/paragonie/random_compat/lib/random.php',
$vendorDir . '/nikic/fast-route/src/functions.php', '253c157292f75eb38082b5acb06f3f01' => $vendorDir . '/nikic/fast-route/src/functions.php',
$vendorDir . '/laravel/lumen-framework/src/helpers.php', 'bee9632da3ca00a99623b9c35d0c4f8b' => $vendorDir . '/laravel/lumen-framework/src/helpers.php',
); );

View File

@ -12,5 +12,4 @@ return array(
'Dotenv' => array($vendorDir . '/vlucas/phpdotenv/src'), 'Dotenv' => array($vendorDir . '/vlucas/phpdotenv/src'),
'Doctrine\\Common\\Inflector\\' => array($vendorDir . '/doctrine/inflector/lib'), 'Doctrine\\Common\\Inflector\\' => array($vendorDir . '/doctrine/inflector/lib'),
'Cron' => array($vendorDir . '/mtdowling/cron-expression/src'), 'Cron' => array($vendorDir . '/mtdowling/cron-expression/src'),
'Carbon' => array($vendorDir . '/nesbot/carbon/src'),
); );

View File

@ -17,6 +17,7 @@ return array(
'Symfony\\Component\\EventDispatcher\\' => array($vendorDir . '/symfony/event-dispatcher'), 'Symfony\\Component\\EventDispatcher\\' => array($vendorDir . '/symfony/event-dispatcher'),
'Symfony\\Component\\DomCrawler\\' => array($vendorDir . '/symfony/dom-crawler'), 'Symfony\\Component\\DomCrawler\\' => array($vendorDir . '/symfony/dom-crawler'),
'Symfony\\Component\\Debug\\' => array($vendorDir . '/symfony/debug'), 'Symfony\\Component\\Debug\\' => array($vendorDir . '/symfony/debug'),
'Symfony\\Component\\CssSelector\\' => array($vendorDir . '/symfony/css-selector'),
'Symfony\\Component\\Console\\' => array($vendorDir . '/symfony/console'), 'Symfony\\Component\\Console\\' => array($vendorDir . '/symfony/console'),
'Stringy\\' => array($vendorDir . '/danielstjules/stringy/src'), 'Stringy\\' => array($vendorDir . '/danielstjules/stringy/src'),
'Monolog\\' => array($vendorDir . '/monolog/monolog/src/Monolog'), 'Monolog\\' => array($vendorDir . '/monolog/monolog/src/Monolog'),
@ -47,5 +48,7 @@ return array(
'FastRoute\\' => array($vendorDir . '/nikic/fast-route/src'), 'FastRoute\\' => array($vendorDir . '/nikic/fast-route/src'),
'Faker\\' => array($vendorDir . '/fzaninotto/faker/src/Faker'), 'Faker\\' => array($vendorDir . '/fzaninotto/faker/src/Faker'),
'Doctrine\\Instantiator\\' => array($vendorDir . '/doctrine/instantiator/src/Doctrine/Instantiator'), 'Doctrine\\Instantiator\\' => array($vendorDir . '/doctrine/instantiator/src/Doctrine/Instantiator'),
'DeepCopy\\' => array($vendorDir . '/myclabs/deep-copy/src/DeepCopy'),
'Carbon\\' => array($vendorDir . '/nesbot/carbon/src/Carbon'),
'App\\' => array($baseDir . '/app'), 'App\\' => array($baseDir . '/app'),
); );

View File

@ -41,15 +41,19 @@ class ComposerAutoloaderInit1022d009db9f708df68c1991f93b734b
$loader->register(true); $loader->register(true);
$includeFiles = require __DIR__ . '/autoload_files.php'; $includeFiles = require __DIR__ . '/autoload_files.php';
foreach ($includeFiles as $file) { foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire1022d009db9f708df68c1991f93b734b($file); composerRequire1022d009db9f708df68c1991f93b734b($fileIdentifier, $file);
} }
return $loader; return $loader;
} }
} }
function composerRequire1022d009db9f708df68c1991f93b734b($file) function composerRequire1022d009db9f708df68c1991f93b734b($fileIdentifier, $file)
{ {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file; require $file;
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
}
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,21 @@
language: php language: php
sudo: false
cache:
directory:
- $HOME/.composer/cache
php: php:
- 5.3 - 5.3
- 5.4 - 5.4
- 5.5 - 5.5
- 5.6 - 5.6
- 7.0
- hhvm - hhvm
install: install:
- composer --prefer-source install - composer install -n
script:
- phpunit

View File

@ -1,4 +1,4 @@
Copyright (c) 2006-2013 Doctrine Project Copyright (c) 2006-2015 Doctrine Project
Permission is hereby granted, free of charge, to any person obtaining a copy of Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in this software and associated documentation files (the "Software"), to deal in

View File

@ -23,7 +23,7 @@
}, },
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.0.x-dev" "dev-master": "1.1.x-dev"
} }
} }
} }

View File

@ -56,11 +56,12 @@ class Inflector
'/(p)erson$/i' => '\1eople', '/(p)erson$/i' => '\1eople',
'/(m)an$/i' => '\1en', '/(m)an$/i' => '\1en',
'/(c)hild$/i' => '\1hildren', '/(c)hild$/i' => '\1hildren',
'/(buffal|tomat)o$/i' => '\1\2oes', '/(f)oot$/i' => '\1eet',
'/(buffal|her|potat|tomat|volcan)o$/i' => '\1\2oes',
'/(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin|vir)us$/i' => '\1i', '/(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin|vir)us$/i' => '\1i',
'/us$/i' => 'uses', '/us$/i' => 'uses',
'/(alias)$/i' => '\1es', '/(alias)$/i' => '\1es',
'/(ax|cris|test)is$/i' => '\1es', '/(analys|ax|cris|test|thes)is$/i' => '\1es',
'/s$/' => 's', '/s$/' => 's',
'/^$/' => '', '/^$/' => '',
'/$/' => 's', '/$/' => 's',
@ -70,27 +71,42 @@ class Inflector
), ),
'irregular' => array( 'irregular' => array(
'atlas' => 'atlases', 'atlas' => 'atlases',
'axe' => 'axes',
'beef' => 'beefs', 'beef' => 'beefs',
'brother' => 'brothers', 'brother' => 'brothers',
'cafe' => 'cafes', 'cafe' => 'cafes',
'chateau' => 'chateaux',
'child' => 'children', 'child' => 'children',
'cookie' => 'cookies', 'cookie' => 'cookies',
'corpus' => 'corpuses', 'corpus' => 'corpuses',
'cow' => 'cows', 'cow' => 'cows',
'criteria' => 'criterion', 'criterion' => 'criteria',
'curriculum' => 'curricula',
'demo' => 'demos',
'domino' => 'dominoes',
'echo' => 'echoes',
'foot' => 'feet',
'fungus' => 'fungi',
'ganglion' => 'ganglions', 'ganglion' => 'ganglions',
'genie' => 'genies', 'genie' => 'genies',
'genus' => 'genera', 'genus' => 'genera',
'graffito' => 'graffiti', 'graffito' => 'graffiti',
'hippopotamus' => 'hippopotami',
'hoof' => 'hoofs', 'hoof' => 'hoofs',
'human' => 'humans', 'human' => 'humans',
'iris' => 'irises',
'leaf' => 'leaves',
'loaf' => 'loaves', 'loaf' => 'loaves',
'man' => 'men', 'man' => 'men',
'medium' => 'media',
'memorandum' => 'memoranda',
'money' => 'monies', 'money' => 'monies',
'mongoose' => 'mongooses', 'mongoose' => 'mongooses',
'motto' => 'mottoes',
'move' => 'moves', 'move' => 'moves',
'mythos' => 'mythoi', 'mythos' => 'mythoi',
'niche' => 'niches', 'niche' => 'niches',
'nucleus' => 'nuclei',
'numen' => 'numina', 'numen' => 'numina',
'occiput' => 'occiputs', 'occiput' => 'occiputs',
'octopus' => 'octopuses', 'octopus' => 'octopuses',
@ -98,11 +114,19 @@ class Inflector
'ox' => 'oxen', 'ox' => 'oxen',
'penis' => 'penises', 'penis' => 'penises',
'person' => 'people', 'person' => 'people',
'plateau' => 'plateaux',
'runner-up' => 'runners-up',
'sex' => 'sexes', 'sex' => 'sexes',
'soliloquy' => 'soliloquies', 'soliloquy' => 'soliloquies',
'son-in-law' => 'sons-in-law',
'syllabus' => 'syllabi',
'testis' => 'testes', 'testis' => 'testes',
'thief' => 'thieves',
'tooth' => 'teeth',
'tornado' => 'tornadoes',
'trilby' => 'trilbys', 'trilby' => 'trilbys',
'turf' => 'turfs', 'turf' => 'turfs',
'volcano' => 'volcanoes',
) )
); );
@ -120,9 +144,10 @@ class Inflector
'/(vert|ind)ices$/i' => '\1ex', '/(vert|ind)ices$/i' => '\1ex',
'/^(ox)en/i' => '\1', '/^(ox)en/i' => '\1',
'/(alias)(es)*$/i' => '\1', '/(alias)(es)*$/i' => '\1',
'/(buffal|her|potat|tomat|volcan)oes$/i' => '\1o',
'/(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin|viri?)i$/i' => '\1us', '/(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin|viri?)i$/i' => '\1us',
'/([ftw]ax)es/i' => '\1', '/([ftw]ax)es/i' => '\1',
'/(cris|ax|test)es$/i' => '\1is', '/(analys|ax|cris|test|thes)es$/i' => '\1is',
'/(shoe|slave)s$/i' => '\1', '/(shoe|slave)s$/i' => '\1',
'/(o)es$/i' => '\1', '/(o)es$/i' => '\1',
'/ouses$/' => 'ouse', '/ouses$/' => 'ouse',
@ -143,6 +168,7 @@ class Inflector
'/(p)eople$/i' => '\1\2erson', '/(p)eople$/i' => '\1\2erson',
'/(m)en$/i' => '\1an', '/(m)en$/i' => '\1an',
'/(c)hildren$/i' => '\1\2hild', '/(c)hildren$/i' => '\1\2hild',
'/(f)eet$/i' => '\1oot',
'/(n)ews$/i' => '\1\2ews', '/(n)ews$/i' => '\1\2ews',
'/eaus$/' => 'eau', '/eaus$/' => 'eau',
'/^(.*us)$/' => '\\1', '/^(.*us)$/' => '\\1',
@ -159,10 +185,15 @@ class Inflector
'.*ss', '.*ss',
), ),
'irregular' => array( 'irregular' => array(
'criterion' => 'criteria', 'criteria' => 'criterion',
'curves' => 'curve', 'curves' => 'curve',
'emphases' => 'emphasis',
'foes' => 'foe', 'foes' => 'foe',
'hoaxes' => 'hoax',
'media' => 'medium',
'neuroses' => 'neurosis',
'waves' => 'wave', 'waves' => 'wave',
'oases' => 'oasis',
) )
); );
@ -236,6 +267,42 @@ class Inflector
return lcfirst(self::classify($word)); return lcfirst(self::classify($word));
} }
/**
* Uppercases words with configurable delimeters between words.
*
* Takes a string and capitalizes all of the words, like PHP's built-in
* ucwords function. This extends that behavior, however, by allowing the
* word delimeters to be configured, rather than only separating on
* whitespace.
*
* Here is an example:
* <code>
* <?php
* $string = 'top-o-the-morning to all_of_you!';
* echo \Doctrine\Common\Inflector\Inflector::ucwords($string);
* // Top-O-The-Morning To All_of_you!
*
* echo \Doctrine\Common\Inflector\Inflector::ucwords($string, '-_ ');
* // Top-O-The-Morning To All_Of_You!
* ?>
* </code>
*
* @param string $string The string to operate on.
* @param string $delimiters A list of word separators.
*
* @return string The string with all delimeter-separated words capitalized.
*/
public static function ucwords($string, $delimiters = " \n\t\r\0\x0B-")
{
return preg_replace_callback(
'/[^' . preg_quote($delimiters, '/') . ']+/',
function($matches) {
return ucfirst($matches[0]);
},
$string
);
}
/** /**
* Clears Inflectors inflected value caches, and resets the inflection * Clears Inflectors inflected value caches, and resets the inflection
* rules to the initial values. * rules to the initial values.

View File

@ -16,52 +16,131 @@ class InflectorTest extends DoctrineTestCase
{ {
Inflector::reset(); Inflector::reset();
// in the format array('singular', 'plural') // In the format array('singular', 'plural')
return array( return array(
array('categoria', 'categorias'),
array('house', 'houses'),
array('powerhouse', 'powerhouses'),
array('Bus', 'Buses'),
array('bus', 'buses'),
array('menu', 'menus'),
array('news', 'news'),
array('food_menu', 'food_menus'),
array('Menu', 'Menus'),
array('FoodMenu', 'FoodMenus'),
array('quiz', 'quizzes'),
array('matrix_row', 'matrix_rows'),
array('matrix', 'matrices'),
array('vertex', 'vertices'),
array('index', 'indices'),
array('Alias', 'Aliases'),
array('Media', 'Media'),
array('NodeMedia', 'NodeMedia'),
array('alumnus', 'alumni'),
array('bacillus', 'bacilli'),
array('cactus', 'cacti'),
array('focus', 'foci'),
array('fungus', 'fungi'),
array('nucleus', 'nuclei'),
array('octopus', 'octopuses'),
array('radius', 'radii'),
array('stimulus', 'stimuli'),
array('syllabus', 'syllabi'),
array('terminus', 'termini'),
array('virus', 'viri'),
array('person', 'people'),
array('glove', 'gloves'),
array('crisis', 'crises'),
array('tax', 'taxes'),
array('wave', 'waves'),
array('bureau', 'bureaus'),
array('cafe', 'cafes'),
array('roof', 'roofs'),
array('foe', 'foes'),
array('cookie', 'cookies'),
array('identity', 'identities'),
array('criteria', 'criterion'),
array('curve', 'curves'),
array('', ''), array('', ''),
array('Alias', 'Aliases'),
array('alumnus', 'alumni'),
array('analysis', 'analyses'),
array('aquarium', 'aquaria'),
array('arch', 'arches'),
array('atlas', 'atlases'),
array('axe', 'axes'),
array('baby', 'babies'),
array('bacillus', 'bacilli'),
array('bacterium', 'bacteria'),
array('bureau', 'bureaus'),
array('bus', 'buses'),
array('Bus', 'Buses'),
array('cactus', 'cacti'),
array('cafe', 'cafes'),
array('calf', 'calves'),
array('categoria', 'categorias'),
array('chateau', 'chateaux'),
array('cherry', 'cherries'),
array('child', 'children'),
array('church', 'churches'),
array('circus', 'circuses'),
array('city', 'cities'),
array('cod', 'cod'),
array('cookie', 'cookies'),
array('copy', 'copies'),
array('crisis', 'crises'),
array('criterion', 'criteria'),
array('curriculum', 'curricula'),
array('curve', 'curves'),
array('deer', 'deer'),
array('demo', 'demos'),
array('dictionary', 'dictionaries'),
array('domino', 'dominoes'),
array('dwarf', 'dwarves'),
array('echo', 'echoes'),
array('elf', 'elves'),
array('emphasis', 'emphases'),
array('family', 'families'),
array('fax', 'faxes'),
array('fish', 'fish'),
array('flush', 'flushes'),
array('fly', 'flies'),
array('focus', 'foci'),
array('foe', 'foes'),
array('food_menu', 'food_menus'),
array('FoodMenu', 'FoodMenus'),
array('foot', 'feet'),
array('fungus', 'fungi'),
array('glove', 'gloves'),
array('half', 'halves'),
array('hero', 'heroes'),
array('hippopotamus', 'hippopotami'),
array('hoax', 'hoaxes'),
array('house', 'houses'),
array('human', 'humans'),
array('identity', 'identities'),
array('index', 'indices'),
array('iris', 'irises'),
array('kiss', 'kisses'),
array('knife', 'knives'),
array('leaf', 'leaves'),
array('life', 'lives'),
array('loaf', 'loaves'),
array('man', 'men'),
array('matrix', 'matrices'),
array('matrix_row', 'matrix_rows'),
array('medium', 'media'),
array('memorandum', 'memoranda'),
array('menu', 'menus'),
array('Menu', 'Menus'),
array('mess', 'messes'),
array('moose', 'moose'),
array('motto', 'mottoes'),
array('mouse', 'mice'),
array('neurosis', 'neuroses'),
array('news', 'news'),
array('NodeMedia', 'NodeMedia'),
array('nucleus', 'nuclei'),
array('oasis', 'oases'),
array('octopus', 'octopuses'),
array('pass', 'passes'),
array('person', 'people'),
array('plateau', 'plateaux'),
array('potato', 'potatoes'),
array('powerhouse', 'powerhouses'),
array('quiz', 'quizzes'),
array('radius', 'radii'),
array('reflex', 'reflexes'),
array('roof', 'roofs'),
array('runner-up', 'runners-up'),
array('scarf', 'scarves'),
array('scratch', 'scratches'),
array('series', 'series'),
array('sheep', 'sheep'),
array('shelf', 'shelves'),
array('shoe', 'shoes'),
array('son-in-law', 'sons-in-law'),
array('species', 'species'),
array('splash', 'splashes'),
array('spy', 'spies'),
array('stimulus', 'stimuli'),
array('stitch', 'stitches'),
array('story', 'stories'),
array('syllabus', 'syllabi'),
array('tax', 'taxes'),
array('terminus', 'termini'),
array('thesis', 'theses'),
array('thief', 'thieves'),
array('tomato', 'tomatoes'),
array('tooth', 'teeth'),
array('tornado', 'tornadoes'),
array('try', 'tries'),
array('vertex', 'vertices'),
array('virus', 'viri'),
array('volcano', 'volcanoes'),
array('wash', 'washes'),
array('watch', 'watches'),
array('wave', 'waves'),
array('wharf', 'wharves'),
array('wife', 'wives'),
array('woman', 'women'),
); );
} }
@ -206,5 +285,25 @@ class InflectorTest extends DoctrineTestCase
$this->assertEquals(Inflector::singularize('Alcoois'), 'Alcool'); $this->assertEquals(Inflector::singularize('Alcoois'), 'Alcool');
$this->assertEquals(Inflector::singularize('Atlas'), 'Atlas'); $this->assertEquals(Inflector::singularize('Atlas'), 'Atlas');
} }
/**
* Test basic ucwords functionality.
*
* @return void
*/
public function testUcwords()
{
$this->assertSame('Top-O-The-Morning To All_of_you!', Inflector::ucwords( 'top-o-the-morning to all_of_you!'));
}
/**
* Test ucwords functionality with custom delimeters.
*
* @return void
*/
public function testUcwordsWithCustomDelimeters()
{
$this->assertSame('Top-O-The-Morning To All_Of_You!', Inflector::ucwords( 'top-o-the-morning to all_of_you!', '-_ '));
}
} }

View File

@ -321,7 +321,9 @@ class Gate implements GateContract
} elseif (isset($this->abilities[$ability])) { } elseif (isset($this->abilities[$ability])) {
return $this->abilities[$ability]; return $this->abilities[$ability];
} else { } else {
return function () { return false; }; return function () {
return false;
};
} }
} }
@ -429,8 +431,12 @@ class Gate implements GateContract
*/ */
public function forUser($user) public function forUser($user)
{ {
$callback = function () use ($user) {
return $user;
};
return new static( return new static(
$this->container, function () use ($user) { return $user; }, $this->abilities, $this->container, $callback, $this->abilities,
$this->policies, $this->beforeCallbacks, $this->afterCallbacks $this->policies, $this->beforeCallbacks, $this->afterCallbacks
); );
} }

View File

@ -5,6 +5,7 @@ namespace Illuminate\Auth;
use Illuminate\Auth\Access\Gate; use Illuminate\Auth\Access\Gate;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
use Illuminate\Contracts\Auth\Access\Gate as GateContract; use Illuminate\Contracts\Auth\Access\Gate as GateContract;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
class AuthServiceProvider extends ServiceProvider class AuthServiceProvider extends ServiceProvider
{ {
@ -52,7 +53,7 @@ class AuthServiceProvider extends ServiceProvider
*/ */
protected function registerUserResolver() protected function registerUserResolver()
{ {
$this->app->bind('Illuminate\Contracts\Auth\Authenticatable', function ($app) { $this->app->bind(AuthenticatableContract::class, function ($app) {
return $app['auth']->user(); return $app['auth']->user();
}); });
} }
@ -65,7 +66,9 @@ class AuthServiceProvider extends ServiceProvider
protected function registerAccessGate() protected function registerAccessGate()
{ {
$this->app->singleton(GateContract::class, function ($app) { $this->app->singleton(GateContract::class, function ($app) {
return new Gate($app, function () use ($app) { return $app['auth']->user(); }); return new Gate($app, function () use ($app) {
return $app['auth']->user();
});
}); });
} }

View File

@ -571,10 +571,12 @@ class Guard implements GuardContract
{ {
$this->session->remove($this->getName()); $this->session->remove($this->getName());
if (! is_null($this->getRecaller())) {
$recaller = $this->getRecallerName(); $recaller = $this->getRecallerName();
$this->getCookieJar()->queue($this->getCookieJar()->forget($recaller)); $this->getCookieJar()->queue($this->getCookieJar()->forget($recaller));
} }
}
/** /**
* Refresh the "remember me" token for the user. * Refresh the "remember me" token for the user.

View File

@ -3,6 +3,7 @@
namespace Illuminate\Auth\Passwords; namespace Illuminate\Auth\Passwords;
use Closure; use Closure;
use Illuminate\Support\Arr;
use UnexpectedValueException; use UnexpectedValueException;
use Illuminate\Contracts\Auth\UserProvider; use Illuminate\Contracts\Auth\UserProvider;
use Illuminate\Contracts\Mail\Mailer as MailerContract; use Illuminate\Contracts\Mail\Mailer as MailerContract;
@ -229,7 +230,7 @@ class PasswordBroker implements PasswordBrokerContract
*/ */
public function getUser(array $credentials) public function getUser(array $credentials)
{ {
$credentials = array_except($credentials, ['token']); $credentials = Arr::except($credentials, ['token']);
$user = $this->users->retrieveByCredentials($credentials); $user = $this->users->retrieveByCredentials($credentials);

View File

@ -85,6 +85,8 @@ class BroadcastManager implements FactoryContract
* *
* @param string $name * @param string $name
* @return \Illuminate\Contracts\Broadcasting\Broadcaster * @return \Illuminate\Contracts\Broadcasting\Broadcaster
*
* @throws \InvalidArgumentException
*/ */
protected function resolve($name) protected function resolve($name)
{ {
@ -97,7 +99,13 @@ class BroadcastManager implements FactoryContract
if (isset($this->customCreators[$config['driver']])) { if (isset($this->customCreators[$config['driver']])) {
return $this->callCustomCreator($config); return $this->callCustomCreator($config);
} else { } else {
return $this->{'create'.ucfirst($config['driver']).'Driver'}($config); $driverMethod = 'create'.ucfirst($config['driver']).'Driver';
if (method_exists($this, $driverMethod)) {
return $this->{$driverMethod}($config);
} else {
throw new InvalidArgumentException("Driver [{$config['driver']}] not supported.");
}
} }
} }
@ -121,7 +129,7 @@ class BroadcastManager implements FactoryContract
protected function createPusherDriver(array $config) protected function createPusherDriver(array $config)
{ {
return new PusherBroadcaster( return new PusherBroadcaster(
new Pusher($config['key'], $config['secret'], $config['app_id'], array_get($config, 'options', [])) new Pusher($config['key'], $config['secret'], $config['app_id'], Arr::get($config, 'options', []))
); );
} }

View File

@ -32,4 +32,14 @@ class PusherBroadcaster implements Broadcaster
{ {
$this->pusher->trigger($channels, $event, $payload); $this->pusher->trigger($channels, $event, $payload);
} }
/**
* Get the Pusher SDK instance.
*
* @return \Pusher
*/
public function getPusher()
{
return $this->pusher;
}
} }

View File

@ -137,7 +137,7 @@ class Dispatcher implements DispatcherContract, QueueingDispatcher, HandlerResol
} }
/** /**
* Get a parameter value for a marshaled command. * Get a parameter value for a marshalled command.
* *
* @param string $command * @param string $command
* @param \ArrayAccess $source * @param \ArrayAccess $source
@ -145,8 +145,7 @@ class Dispatcher implements DispatcherContract, QueueingDispatcher, HandlerResol
* @param array $extras * @param array $extras
* @return mixed * @return mixed
*/ */
protected function getParameterValueForCommand($command, ArrayAccess $source, protected function getParameterValueForCommand($command, ArrayAccess $source, ReflectionParameter $parameter, array $extras = [])
ReflectionParameter $parameter, array $extras = [])
{ {
if (array_key_exists($parameter->name, $extras)) { if (array_key_exists($parameter->name, $extras)) {
return $extras[$parameter->name]; return $extras[$parameter->name];
@ -254,7 +253,7 @@ class Dispatcher implements DispatcherContract, QueueingDispatcher, HandlerResol
*/ */
protected function pushCommandToQueue($queue, $command) protected function pushCommandToQueue($queue, $command)
{ {
if (isset($command->queue) && isset($command->delay)) { if (isset($command->queue, $command->delay)) {
return $queue->laterOn($command->queue, $command->delay, $command); return $queue->laterOn($command->queue, $command->delay, $command);
} }

View File

@ -82,6 +82,8 @@ class CacheManager implements FactoryContract
* *
* @param string $name * @param string $name
* @return \Illuminate\Contracts\Cache\Repository * @return \Illuminate\Contracts\Cache\Repository
*
* @throws \InvalidArgumentException
*/ */
protected function resolve($name) protected function resolve($name)
{ {
@ -94,7 +96,13 @@ class CacheManager implements FactoryContract
if (isset($this->customCreators[$config['driver']])) { if (isset($this->customCreators[$config['driver']])) {
return $this->callCustomCreator($config); return $this->callCustomCreator($config);
} else { } else {
return $this->{'create'.ucfirst($config['driver']).'Driver'}($config); $driverMethod = 'create'.ucfirst($config['driver']).'Driver';
if (method_exists($this, $driverMethod)) {
return $this->{$driverMethod}($config);
} else {
throw new InvalidArgumentException("Driver [{$config['driver']}] not supported.");
}
} }
} }
@ -200,7 +208,7 @@ class CacheManager implements FactoryContract
{ {
$redis = $this->app['redis']; $redis = $this->app['redis'];
$connection = Arr::get($config, 'connection', 'default') ?: 'default'; $connection = Arr::get($config, 'connection', 'default');
return $this->repository(new RedisStore($redis, $this->getPrefix($config), $connection)); return $this->repository(new RedisStore($redis, $this->getPrefix($config), $connection));
} }

View File

@ -116,15 +116,13 @@ class DatabaseStore implements Store
* *
* @param string $key * @param string $key
* @param mixed $value * @param mixed $value
* @return void * @return int|bool
*/ */
public function increment($key, $value = 1) public function increment($key, $value = 1)
{ {
$this->connection->transaction(function () use ($key, $value) { return $this->incrementOrDecrement($key, $value, function ($current, $value) {
return $this->incrementOrDecrement($key, $value, function ($current) use ($value) {
return $current + $value; return $current + $value;
}); });
});
} }
/** /**
@ -132,15 +130,13 @@ class DatabaseStore implements Store
* *
* @param string $key * @param string $key
* @param mixed $value * @param mixed $value
* @return void * @return int|bool
*/ */
public function decrement($key, $value = 1) public function decrement($key, $value = 1)
{ {
$this->connection->transaction(function () use ($key, $value) { return $this->incrementOrDecrement($key, $value, function ($current, $value) {
return $this->incrementOrDecrement($key, $value, function ($current) use ($value) {
return $current - $value; return $current - $value;
}); });
});
} }
/** /**
@ -149,23 +145,32 @@ class DatabaseStore implements Store
* @param string $key * @param string $key
* @param mixed $value * @param mixed $value
* @param \Closure $callback * @param \Closure $callback
* @return void * @return int|bool
*/ */
protected function incrementOrDecrement($key, $value, Closure $callback) protected function incrementOrDecrement($key, $value, Closure $callback)
{ {
return $this->connection->transaction(function () use ($key, $value, $callback) {
$prefixed = $this->prefix.$key; $prefixed = $this->prefix.$key;
$cache = $this->table()->where('key', $prefixed)->lockForUpdate()->first(); $cache = $this->table()->where('key', $prefixed)->lockForUpdate()->first();
if (! is_null($cache)) { if (is_null($cache)) {
$current = $this->encrypter->decrypt($cache->value); return false;
}
$current = $this->encrypter->decrypt($cache->value);
$new = $callback($current, $value);
if (! is_numeric($current)) {
return false;
}
if (is_numeric($current)) {
$this->table()->where('key', $prefixed)->update([ $this->table()->where('key', $prefixed)->update([
'value' => $this->encrypter->encrypt($callback($current)), 'value' => $this->encrypter->encrypt($new),
]); ]);
}
} return $new;
});
} }
/** /**

View File

@ -209,11 +209,13 @@ class FileStore implements Store
*/ */
protected function expiration($minutes) protected function expiration($minutes)
{ {
if ($minutes === 0) { $time = time() + ($minutes * 60);
if ($minutes === 0 || $time > 9999999999) {
return 9999999999; return 9999999999;
} }
return time() + ($minutes * 60); return $time;
} }
/** /**

View File

@ -13,9 +13,9 @@ class RedisTaggedCache extends TaggedCache
*/ */
public function forever($key, $value) public function forever($key, $value)
{ {
$this->pushForeverKeys($namespace = $this->tags->getNamespace(), $key); $this->pushForeverKeys($this->tags->getNamespace(), $key);
$this->store->forever(sha1($namespace).':'.$key, $value); parent::forever($key, $value);
} }
/** /**

View File

@ -6,6 +6,7 @@ use Closure;
use DateTime; use DateTime;
use ArrayAccess; use ArrayAccess;
use Carbon\Carbon; use Carbon\Carbon;
use BadMethodCallException;
use Illuminate\Contracts\Cache\Store; use Illuminate\Contracts\Cache\Store;
use Illuminate\Support\Traits\Macroable; use Illuminate\Support\Traits\Macroable;
use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Events\Dispatcher;
@ -94,7 +95,7 @@ class Repository implements CacheContract, ArrayAccess
*/ */
public function get($key, $default = null) public function get($key, $default = null)
{ {
$value = $this->store->get($key); $value = $this->store->get($this->itemKey($key));
if (is_null($value)) { if (is_null($value)) {
$this->fireCacheEvent('missed', [$key]); $this->fireCacheEvent('missed', [$key]);
@ -136,7 +137,7 @@ class Repository implements CacheContract, ArrayAccess
$minutes = $this->getMinutes($minutes); $minutes = $this->getMinutes($minutes);
if (! is_null($minutes)) { if (! is_null($minutes)) {
$this->store->put($key, $value, $minutes); $this->store->put($this->itemKey($key), $value, $minutes);
$this->fireCacheEvent('write', [$key, $value, $minutes]); $this->fireCacheEvent('write', [$key, $value, $minutes]);
} }
@ -159,7 +160,7 @@ class Repository implements CacheContract, ArrayAccess
} }
if (method_exists($this->store, 'add')) { if (method_exists($this->store, 'add')) {
return $this->store->add($key, $value, $minutes); return $this->store->add($this->itemKey($key), $value, $minutes);
} }
if (is_null($this->get($key))) { if (is_null($this->get($key))) {
@ -180,7 +181,7 @@ class Repository implements CacheContract, ArrayAccess
*/ */
public function forever($key, $value) public function forever($key, $value)
{ {
$this->store->forever($key, $value); $this->store->forever($this->itemKey($key), $value);
$this->fireCacheEvent('write', [$key, $value, 0]); $this->fireCacheEvent('write', [$key, $value, 0]);
} }
@ -248,13 +249,62 @@ class Repository implements CacheContract, ArrayAccess
*/ */
public function forget($key) public function forget($key)
{ {
$success = $this->store->forget($key); $success = $this->store->forget($this->itemKey($key));
$this->fireCacheEvent('delete', [$key]); $this->fireCacheEvent('delete', [$key]);
return $success; return $success;
} }
/**
* Begin executing a new tags operation if the store supports it.
*
* @param string $name
* @return \Illuminate\Cache\TaggedCache
*
* @deprecated since version 5.1. Use tags instead.
*/
public function section($name)
{
return $this->tags($name);
}
/**
* Begin executing a new tags operation if the store supports it.
*
* @param array|mixed $names
* @return \Illuminate\Cache\TaggedCache
*
* @throws \BadMethodCallException
*/
public function tags($names)
{
if (method_exists($this->store, 'tags')) {
$taggedCache = $this->store->tags($names);
if (! is_null($this->events)) {
$taggedCache->setEventDispatcher($this->events);
}
$taggedCache->setDefaultCacheTime($this->default);
return $taggedCache;
}
throw new BadMethodCallException('This cache store does not support tagging.');
}
/**
* Format the key for a cache item.
*
* @param string $key
* @return string
*/
protected function itemKey($key)
{
return $key;
}
/** /**
* Get the default cache time. * Get the default cache time.
* *

View File

@ -97,4 +97,14 @@ class TagSet
{ {
return 'tag:'.$name.':key'; return 'tag:'.$name.':key';
} }
/**
* Get all of the tag names in the set.
*
* @return array
*/
public function getNames()
{
return $this->names;
}
} }

View File

@ -2,20 +2,10 @@
namespace Illuminate\Cache; namespace Illuminate\Cache;
use Closure;
use DateTime;
use Carbon\Carbon;
use Illuminate\Contracts\Cache\Store; use Illuminate\Contracts\Cache\Store;
class TaggedCache implements Store class TaggedCache extends Repository
{ {
/**
* The cache store implementation.
*
* @var \Illuminate\Contracts\Cache\Store
*/
protected $store;
/** /**
* The tag set instance. * The tag set instance.
* *
@ -32,69 +22,19 @@ class TaggedCache implements Store
*/ */
public function __construct(Store $store, TagSet $tags) public function __construct(Store $store, TagSet $tags)
{ {
parent::__construct($store);
$this->tags = $tags; $this->tags = $tags;
$this->store = $store;
} }
/** /**
* Determine if an item exists in the cache. * {@inheritdoc}
*
* @param string $key
* @return bool
*/ */
public function has($key) protected function fireCacheEvent($event, $payload)
{ {
return ! is_null($this->get($key)); $payload[] = $this->tags->getNames();
}
/** parent::fireCacheEvent($event, $payload);
* Retrieve an item from the cache by key.
*
* @param string $key
* @param mixed $default
* @return mixed
*/
public function get($key, $default = null)
{
$value = $this->store->get($this->taggedItemKey($key));
return ! is_null($value) ? $value : value($default);
}
/**
* Store an item in the cache for a given number of minutes.
*
* @param string $key
* @param mixed $value
* @param \DateTime|int $minutes
* @return void
*/
public function put($key, $value, $minutes)
{
$minutes = $this->getMinutes($minutes);
if (! is_null($minutes)) {
$this->store->put($this->taggedItemKey($key), $value, $minutes);
}
}
/**
* Store an item in the cache if the key does not exist.
*
* @param string $key
* @param mixed $value
* @param \DateTime|int $minutes
* @return bool
*/
public function add($key, $value, $minutes)
{
if (is_null($this->get($key))) {
$this->put($key, $value, $minutes);
return true;
}
return false;
} }
/** /**
@ -106,7 +46,7 @@ class TaggedCache implements Store
*/ */
public function increment($key, $value = 1) public function increment($key, $value = 1)
{ {
$this->store->increment($this->taggedItemKey($key), $value); $this->store->increment($this->itemKey($key), $value);
} }
/** /**
@ -118,30 +58,7 @@ class TaggedCache implements Store
*/ */
public function decrement($key, $value = 1) public function decrement($key, $value = 1)
{ {
$this->store->decrement($this->taggedItemKey($key), $value); $this->store->decrement($this->itemKey($key), $value);
}
/**
* Store an item in the cache indefinitely.
*
* @param string $key
* @param mixed $value
* @return void
*/
public function forever($key, $value)
{
$this->store->forever($this->taggedItemKey($key), $value);
}
/**
* Remove an item from the cache.
*
* @param string $key
* @return bool
*/
public function forget($key)
{
return $this->store->forget($this->taggedItemKey($key));
} }
/** /**
@ -155,58 +72,11 @@ class TaggedCache implements Store
} }
/** /**
* Get an item from the cache, or store the default value. * {@inheritdoc}
*
* @param string $key
* @param \DateTime|int $minutes
* @param \Closure $callback
* @return mixed
*/ */
public function remember($key, $minutes, Closure $callback) protected function itemKey($key)
{ {
// If the item exists in the cache we will just return this immediately return $this->taggedItemKey($key);
// otherwise we will execute the given Closure and cache the result
// of that execution for the given number of minutes in storage.
if (! is_null($value = $this->get($key))) {
return $value;
}
$this->put($key, $value = $callback(), $minutes);
return $value;
}
/**
* Get an item from the cache, or store the default value forever.
*
* @param string $key
* @param \Closure $callback
* @return mixed
*/
public function sear($key, Closure $callback)
{
return $this->rememberForever($key, $callback);
}
/**
* Get an item from the cache, or store the default value forever.
*
* @param string $key
* @param \Closure $callback
* @return mixed
*/
public function rememberForever($key, Closure $callback)
{
// If the item exists in the cache we will just return this immediately
// otherwise we will execute the given Closure and cache the result
// of that execution for an indefinite amount of time. It's easy.
if (! is_null($value = $this->get($key))) {
return $value;
}
$this->forever($key, $value = $callback());
return $value;
} }
/** /**
@ -219,31 +89,4 @@ class TaggedCache implements Store
{ {
return sha1($this->tags->getNamespace()).':'.$key; return sha1($this->tags->getNamespace()).':'.$key;
} }
/**
* Get the cache key prefix.
*
* @return string
*/
public function getPrefix()
{
return $this->store->getPrefix();
}
/**
* Calculate the number of minutes with the given duration.
*
* @param \DateTime|int $duration
* @return int|null
*/
protected function getMinutes($duration)
{
if ($duration instanceof DateTime) {
$fromNow = Carbon::now()->diffInMinutes(Carbon::instance($duration), false);
return $fromNow > 0 ? $fromNow : null;
}
return is_string($duration) ? (int) $duration : $duration;
}
} }

View File

@ -55,11 +55,17 @@ class Application extends SymfonyApplication implements ApplicationContract
*/ */
public function call($command, array $parameters = []) public function call($command, array $parameters = [])
{ {
$parameters['command'] = $command; $parameters = collect($parameters)->prepend($command);
$this->lastOutput = new BufferedOutput; $this->lastOutput = new BufferedOutput;
return $this->find($command)->run(new ArrayInput($parameters), $this->lastOutput); $this->setCatchExceptions(false);
$result = $this->run(new ArrayInput($parameters->toArray()), $this->lastOutput);
$this->setCatchExceptions(true);
return $result;
} }
/** /**

View File

@ -290,7 +290,7 @@ class Command extends SymfonyCommand
* @param string $default * @param string $default
* @param mixed $attempts * @param mixed $attempts
* @param bool $multiple * @param bool $multiple
* @return bool * @return string
*/ */
public function choice($question, array $choices, $default = null, $attempts = null, $multiple = null) public function choice($question, array $choices, $default = null, $attempts = null, $multiple = null)
{ {
@ -305,7 +305,7 @@ class Command extends SymfonyCommand
* Format input to textual table. * Format input to textual table.
* *
* @param array $headers * @param array $headers
* @param array|\Illuminate\Contracts\Support\Arrayable $rows * @param \Illuminate\Contracts\Support\Arrayable|array $rows
* @param string $style * @param string $style
* @return void * @return void
*/ */
@ -383,9 +383,11 @@ class Command extends SymfonyCommand
*/ */
public function warn($string) public function warn($string)
{ {
if (! $this->output->getFormatter()->hasStyle('warning')) {
$style = new OutputFormatterStyle('yellow'); $style = new OutputFormatterStyle('yellow');
$this->output->getFormatter()->setStyle('warning', $style); $this->output->getFormatter()->setStyle('warning', $style);
}
$this->output->writeln("<warning>$string</warning>"); $this->output->writeln("<warning>$string</warning>");
} }

View File

@ -48,6 +48,8 @@ trait ConfirmableTrait
*/ */
protected function getDefaultConfirmCallback() protected function getDefaultConfirmCallback()
{ {
return function () { return $this->getLaravel()->environment() == 'production'; }; return function () {
return $this->getLaravel()->environment() == 'production';
};
} }
} }

View File

@ -76,7 +76,7 @@ abstract class GeneratorCommand extends Command
{ {
$name = $this->parseName($rawName); $name = $this->parseName($rawName);
return $this->files->exists($path = $this->getPath($name)); return $this->files->exists($this->getPath($name));
} }
/** /**

View File

@ -91,7 +91,7 @@ class Parser
case Str::endsWith($token, '?'): case Str::endsWith($token, '?'):
return new InputArgument(trim($token, '?'), InputArgument::OPTIONAL, $description); return new InputArgument(trim($token, '?'), InputArgument::OPTIONAL, $description);
case (preg_match('/(.+)\=(.+)/', $token, $matches)): case preg_match('/(.+)\=(.+)/', $token, $matches):
return new InputArgument($matches[1], InputArgument::OPTIONAL, $description, $matches[2]); return new InputArgument($matches[1], InputArgument::OPTIONAL, $description, $matches[2]);
default: default:
@ -131,7 +131,7 @@ class Parser
case Str::endsWith($token, '=*'): case Str::endsWith($token, '=*'):
return new InputOption(trim($token, '=*'), $shortcut, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, $description); return new InputOption(trim($token, '=*'), $shortcut, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, $description);
case (preg_match('/(.+)\=(.+)/', $token, $matches)): case preg_match('/(.+)\=(.+)/', $token, $matches):
return new InputOption($matches[1], $shortcut, InputOption::VALUE_OPTIONAL, $description, $matches[2]); return new InputOption($matches[1], $shortcut, InputOption::VALUE_OPTIONAL, $description, $matches[2]);
default: default:

View File

@ -9,6 +9,7 @@ use Cron\CronExpression;
use GuzzleHttp\Client as HttpClient; use GuzzleHttp\Client as HttpClient;
use Illuminate\Contracts\Mail\Mailer; use Illuminate\Contracts\Mail\Mailer;
use Symfony\Component\Process\Process; use Symfony\Component\Process\Process;
use Symfony\Component\Process\ProcessUtils;
use Illuminate\Contracts\Container\Container; use Illuminate\Contracts\Container\Container;
use Illuminate\Contracts\Foundation\Application; use Illuminate\Contracts\Foundation\Application;
@ -205,18 +206,20 @@ class Event
} }
/** /**
* Build the comand string. * Build the command string.
* *
* @return string * @return string
*/ */
public function buildCommand() public function buildCommand()
{ {
$output = ProcessUtils::escapeArgument($this->output);
$redirect = $this->shouldAppendOutput ? ' >> ' : ' > '; $redirect = $this->shouldAppendOutput ? ' >> ' : ' > ';
if ($this->withoutOverlapping) { if ($this->withoutOverlapping) {
$command = '(touch '.$this->mutexPath().'; '.$this->command.'; rm '.$this->mutexPath().')'.$redirect.$this->output.' 2>&1 &'; $command = '(touch '.$this->mutexPath().'; '.$this->command.'; rm '.$this->mutexPath().')'.$redirect.$output.' 2>&1 &';
} else { } else {
$command = $this->command.$redirect.$this->output.' 2>&1 &'; $command = $this->command.$redirect.$output.' 2>&1 &';
} }
return $this->user ? 'sudo -u '.$this->user.' '.$command : $command; return $this->user ? 'sudo -u '.$this->user.' '.$command : $command;
@ -731,7 +734,9 @@ class Event
*/ */
public function pingBefore($url) public function pingBefore($url)
{ {
return $this->before(function () use ($url) { (new HttpClient)->get($url); }); return $this->before(function () use ($url) {
(new HttpClient)->get($url);
});
} }
/** /**
@ -755,7 +760,9 @@ class Event
*/ */
public function thenPing($url) public function thenPing($url)
{ {
return $this->then(function () use ($url) { (new HttpClient)->get($url); }); return $this->then(function () use ($url) {
(new HttpClient)->get($url);
});
} }
/** /**

View File

@ -31,7 +31,7 @@
} }
}, },
"suggest": { "suggest": {
"guzzlehttp/guzzle": "Required to use the thenPing method on schedules (~5.3|~6.0).", "guzzlehttp/guzzle": "Required to use the ping methods on schedules (~5.3|~6.0).",
"mtdowling/cron-expression": "Required to use scheduling component (~1.0).", "mtdowling/cron-expression": "Required to use scheduling component (~1.0).",
"symfony/process": "Required to use scheduling component (2.7.*)." "symfony/process": "Required to use scheduling component (2.7.*)."
}, },

View File

@ -142,6 +142,10 @@ class Container implements ArrayAccess, ContainerContract
*/ */
public function resolved($abstract) public function resolved($abstract)
{ {
if ($this->isAlias($abstract)) {
$abstract = $this->getAlias($abstract);
}
return isset($this->resolved[$abstract]) || isset($this->instances[$abstract]); return isset($this->resolved[$abstract]) || isset($this->instances[$abstract]);
} }

View File

@ -22,6 +22,13 @@ class CookieJar implements JarContract
*/ */
protected $domain = null; protected $domain = null;
/**
* The default secure setting (defaults to false).
*
* @var bool
*/
protected $secure = false;
/** /**
* All of the cookies queued for sending. * All of the cookies queued for sending.
* *
@ -43,7 +50,7 @@ class CookieJar implements JarContract
*/ */
public function make($name, $value, $minutes = 0, $path = null, $domain = null, $secure = false, $httpOnly = true) public function make($name, $value, $minutes = 0, $path = null, $domain = null, $secure = false, $httpOnly = true)
{ {
list($path, $domain) = $this->getPathAndDomain($path, $domain); list($path, $domain, $secure) = $this->getPathAndDomain($path, $domain, $secure);
$time = ($minutes == 0) ? 0 : time() + ($minutes * 60); $time = ($minutes == 0) ? 0 : time() + ($minutes * 60);
@ -135,11 +142,12 @@ class CookieJar implements JarContract
* *
* @param string $path * @param string $path
* @param string $domain * @param string $domain
* @param bool $secure
* @return array * @return array
*/ */
protected function getPathAndDomain($path, $domain) protected function getPathAndDomain($path, $domain, $secure = false)
{ {
return [$path ?: $this->path, $domain ?: $this->domain]; return [$path ?: $this->path, $domain ?: $this->domain, $secure ?: $this->secure];
} }
/** /**
@ -147,11 +155,12 @@ class CookieJar implements JarContract
* *
* @param string $path * @param string $path
* @param string $domain * @param string $domain
* @param bool $secure
* @return $this * @return $this
*/ */
public function setDefaultPathAndDomain($path, $domain) public function setDefaultPathAndDomain($path, $domain, $secure = false)
{ {
list($this->path, $this->domain) = [$path, $domain]; list($this->path, $this->domain, $this->secure) = [$path, $domain, $secure];
return $this; return $this;
} }

View File

@ -16,7 +16,7 @@ class CookieServiceProvider extends ServiceProvider
$this->app->singleton('cookie', function ($app) { $this->app->singleton('cookie', function ($app) {
$config = $app['config']['session']; $config = $app['config']['session'];
return (new CookieJar)->setDefaultPathAndDomain($config['path'], $config['domain']); return (new CookieJar)->setDefaultPathAndDomain($config['path'], $config['domain'], $config['secure']);
}); });
} }
} }

View File

@ -106,8 +106,10 @@ class EncryptCookies
$decrypted = []; $decrypted = [];
foreach ($cookie as $key => $value) { foreach ($cookie as $key => $value) {
if (is_string($value)) {
$decrypted[$key] = $this->encrypter->decrypt($value); $decrypted[$key] = $this->encrypter->decrypt($value);
} }
}
return $decrypted; return $decrypted;
} }

View File

@ -145,7 +145,7 @@ class ConnectionFactory
*/ */
protected function mergeReadWriteConfig(array $config, array $merge) protected function mergeReadWriteConfig(array $config, array $merge)
{ {
return array_except(array_merge($config, $merge), ['read', 'write']); return Arr::except(array_merge($config, $merge), ['read', 'write']);
} }
/** /**

View File

@ -39,6 +39,8 @@ class RefreshCommand extends Command
$force = $this->input->getOption('force'); $force = $this->input->getOption('force');
$path = $this->input->getOption('path');
$this->call('migrate:reset', [ $this->call('migrate:reset', [
'--database' => $database, '--force' => $force, '--database' => $database, '--force' => $force,
]); ]);
@ -47,7 +49,9 @@ class RefreshCommand extends Command
// the migration commands and just provides a convenient wrapper to execute // the migration commands and just provides a convenient wrapper to execute
// them in succession. We'll also see if we need to re-seed the database. // them in succession. We'll also see if we need to re-seed the database.
$this->call('migrate', [ $this->call('migrate', [
'--database' => $database, '--force' => $force, '--database' => $database,
'--force' => $force,
'--path' => $path,
]); ]);
if ($this->needsSeeding()) { if ($this->needsSeeding()) {
@ -94,6 +98,8 @@ class RefreshCommand extends Command
['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'], ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'],
['path', null, InputOption::VALUE_OPTIONAL, 'The path of migrations files to be executed.'],
['seed', null, InputOption::VALUE_NONE, 'Indicates if the seed task should be re-run.'], ['seed', null, InputOption::VALUE_NONE, 'Indicates if the seed task should be re-run.'],
['seeder', null, InputOption::VALUE_OPTIONAL, 'The class name of the root seeder.'], ['seeder', null, InputOption::VALUE_OPTIONAL, 'The class name of the root seeder.'],

View File

@ -3,6 +3,7 @@
namespace Illuminate\Database\Console\Migrations; namespace Illuminate\Database\Console\Migrations;
use Illuminate\Database\Migrations\Migrator; use Illuminate\Database\Migrations\Migrator;
use Symfony\Component\Console\Input\InputOption;
class StatusCommand extends BaseCommand class StatusCommand extends BaseCommand
{ {
@ -51,11 +52,19 @@ class StatusCommand extends BaseCommand
return $this->error('No migrations found.'); return $this->error('No migrations found.');
} }
$this->migrator->setConnection($this->input->getOption('database'));
if (! is_null($path = $this->input->getOption('path'))) {
$path = $this->laravel->basePath().'/'.$path;
} else {
$path = $this->getMigrationPath();
}
$ran = $this->migrator->getRepository()->getRan(); $ran = $this->migrator->getRepository()->getRan();
$migrations = []; $migrations = [];
foreach ($this->getAllMigrationFiles() as $migration) { foreach ($this->getAllMigrationFiles($path) as $migration) {
$migrations[] = in_array($migration, $ran) ? ['<info>Y</info>', $migration] : ['<fg=red>N</fg=red>', $migration]; $migrations[] = in_array($migration, $ran) ? ['<info>Y</info>', $migration] : ['<fg=red>N</fg=red>', $migration];
} }
@ -69,10 +78,25 @@ class StatusCommand extends BaseCommand
/** /**
* Get all of the migration files. * Get all of the migration files.
* *
* @param string $path
* @return array * @return array
*/ */
protected function getAllMigrationFiles() protected function getAllMigrationFiles($path)
{ {
return $this->migrator->getMigrationFiles($this->getMigrationPath()); return $this->migrator->getMigrationFiles($path);
}
/**
* Get the console command options.
*
* @return array
*/
protected function getOptions()
{
return [
['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'],
['path', null, InputOption::VALUE_OPTIONAL, 'The path of migrations files to use.'],
];
} }
} }

View File

@ -50,6 +50,10 @@ class DatabaseServiceProvider extends ServiceProvider
$this->app->singleton('db', function ($app) { $this->app->singleton('db', function ($app) {
return new DatabaseManager($app, $app['db.factory']); return new DatabaseManager($app, $app['db.factory']);
}); });
$this->app->bind('db.connection', function ($app) {
return $app['db']->connection();
});
} }
/** /**

View File

@ -23,6 +23,7 @@ trait DetectsLostConnections
'Lost connection', 'Lost connection',
'is dead or not enabled', 'is dead or not enabled',
'Error while sending', 'Error while sending',
'decryption failed or bad record mac',
]); ]);
} }
} }

View File

@ -212,7 +212,7 @@ class Builder
* *
* @param int $count * @param int $count
* @param callable $callback * @param callable $callback
* @return void * @return bool
*/ */
public function chunk($count, callable $callback) public function chunk($count, callable $callback)
{ {
@ -223,20 +223,22 @@ class Builder
// developer take care of everything within the callback, which allows us to // developer take care of everything within the callback, which allows us to
// keep the memory low for spinning through large result sets for working. // keep the memory low for spinning through large result sets for working.
if (call_user_func($callback, $results) === false) { if (call_user_func($callback, $results) === false) {
break; return false;
} }
$page++; $page++;
$results = $this->forPage($page, $count)->get(); $results = $this->forPage($page, $count)->get();
} }
return true;
} }
/** /**
* Get an array with the values of a given column. * Get an array with the values of a given column.
* *
* @param string $column * @param string $column
* @param string $key * @param string|null $key
* @return \Illuminate\Support\Collection * @return \Illuminate\Support\Collection
*/ */
public function lists($column, $key = null) public function lists($column, $key = null)
@ -465,28 +467,28 @@ class Builder
/** /**
* Get the relation instance for the given relation name. * Get the relation instance for the given relation name.
* *
* @param string $relation * @param string $name
* @return \Illuminate\Database\Eloquent\Relations\Relation * @return \Illuminate\Database\Eloquent\Relations\Relation
*/ */
public function getRelation($relation) public function getRelation($name)
{ {
// We want to run a relationship query without any constrains so that we will // We want to run a relationship query without any constrains so that we will
// not have to remove these where clauses manually which gets really hacky // not have to remove these where clauses manually which gets really hacky
// and is error prone while we remove the developer's own where clauses. // and is error prone while we remove the developer's own where clauses.
$query = Relation::noConstraints(function () use ($relation) { $relation = Relation::noConstraints(function () use ($name) {
return $this->getModel()->$relation(); return $this->getModel()->$name();
}); });
$nested = $this->nestedRelations($relation); $nested = $this->nestedRelations($name);
// If there are nested relationships set on the query, we will put those onto // If there are nested relationships set on the query, we will put those onto
// the query instances so that they can be handled after this relationship // the query instances so that they can be handled after this relationship
// is loaded. In this way they will all trickle down as they are loaded. // is loaded. In this way they will all trickle down as they are loaded.
if (count($nested) > 0) { if (count($nested) > 0) {
$query->getQuery()->with($nested); $relation->getQuery()->with($nested);
} }
return $query; return $relation;
} }
/** /**
@ -774,7 +776,9 @@ class Builder
// constraints have been specified for the eager load and we'll just put // constraints have been specified for the eager load and we'll just put
// an empty Closure with the loader so that we can treat all the same. // an empty Closure with the loader so that we can treat all the same.
if (is_numeric($name)) { if (is_numeric($name)) {
$f = function () {}; $f = function () {
//
};
list($name, $constraints) = [$constraints, $f]; list($name, $constraints) = [$constraints, $f];
} }
@ -808,7 +812,9 @@ class Builder
$progress[] = $segment; $progress[] = $segment;
if (! isset($results[$last = implode('.', $progress)])) { if (! isset($results[$last = implode('.', $progress)])) {
$results[$last] = function () {}; $results[$last] = function () {
//
};
} }
} }

View File

@ -104,7 +104,9 @@ class Collection extends BaseCollection
*/ */
public function modelKeys() public function modelKeys()
{ {
return array_map(function ($m) { return $m->getKey(); }, $this->items); return array_map(function ($m) {
return $m->getKey();
}, $this->items);
} }
/** /**
@ -202,7 +204,7 @@ class Collection extends BaseCollection
*/ */
public function except($keys) public function except($keys)
{ {
$dictionary = array_except($this->getDictionary(), $keys); $dictionary = Arr::except($this->getDictionary(), $keys);
return new static(array_values($dictionary)); return new static(array_values($dictionary));
} }

View File

@ -44,15 +44,7 @@ class Factory implements ArrayAccess
{ {
$pathToFactories = $pathToFactories ?: database_path('factories'); $pathToFactories = $pathToFactories ?: database_path('factories');
$factory = new static($faker); return (new static($faker))->load($pathToFactories);
if (is_dir($pathToFactories)) {
foreach (Finder::create()->files()->in($pathToFactories) as $file) {
require $file->getRealPath();
}
}
return $factory;
} }
/** /**
@ -106,6 +98,25 @@ class Factory implements ArrayAccess
return $this->of($class, $name)->create($attributes); return $this->of($class, $name)->create($attributes);
} }
/**
* Load factories from path.
*
* @param string $path
* @return $this
*/
public function load($path)
{
$factory = $this;
if (is_dir($path)) {
foreach (Finder::create()->files()->in($path) as $file) {
require $file->getRealPath();
}
}
return $factory;
}
/** /**
* Create an instance of the given model. * Create an instance of the given model.
* *

View File

@ -145,7 +145,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
protected $dateFormat; protected $dateFormat;
/** /**
* The attributes that should be casted to native types. * The attributes that should be cast to native types.
* *
* @var array * @var array
*/ */
@ -370,7 +370,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
/** /**
* Get the global scopes for this class instance. * Get the global scopes for this class instance.
* *
* @return \Illuminate\Database\Eloquent\ScopeInterface[] * @return array
*/ */
public function getGlobalScopes() public function getGlobalScopes()
{ {
@ -574,7 +574,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
*/ */
public static function firstOrCreate(array $attributes) public static function firstOrCreate(array $attributes)
{ {
if (! is_null($instance = static::where($attributes)->first())) { if (! is_null($instance = (new static)->newQueryWithoutScopes()->where($attributes)->first())) {
return $instance; return $instance;
} }
@ -589,7 +589,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
*/ */
public static function firstOrNew(array $attributes) public static function firstOrNew(array $attributes)
{ {
if (! is_null($instance = static::where($attributes)->first())) { if (! is_null($instance = (new static)->newQueryWithoutScopes()->where($attributes)->first())) {
return $instance; return $instance;
} }
@ -812,7 +812,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
// the calling method's name and use that as the relationship name as most // the calling method's name and use that as the relationship name as most
// of the time this will be what we desire to use for the relationships. // of the time this will be what we desire to use for the relationships.
if (is_null($relation)) { if (is_null($relation)) {
list($current, $caller) = debug_backtrace(false, 2); list($current, $caller) = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
$relation = $caller['function']; $relation = $caller['function'];
} }
@ -850,7 +850,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
// since that is most likely the name of the polymorphic interface. We can // since that is most likely the name of the polymorphic interface. We can
// use that to get both the class and foreign key that will be utilized. // use that to get both the class and foreign key that will be utilized.
if (is_null($name)) { if (is_null($name)) {
list($current, $caller) = debug_backtrace(false, 2); list($current, $caller) = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
$name = Str::snake($caller['function']); $name = Str::snake($caller['function']);
} }
@ -1070,7 +1070,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
{ {
$self = __FUNCTION__; $self = __FUNCTION__;
$caller = Arr::first(debug_backtrace(false), function ($key, $trace) use ($self) { $caller = Arr::first(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS), function ($key, $trace) use ($self) {
$caller = $trace['function']; $caller = $trace['function'];
return ! in_array($caller, Model::$manyMethods) && $caller != $self; return ! in_array($caller, Model::$manyMethods) && $caller != $self;
@ -1139,6 +1139,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
* Delete the model from the database. * Delete the model from the database.
* *
* @return bool|null * @return bool|null
*
* @throws \Exception * @throws \Exception
*/ */
public function delete() public function delete()
@ -1520,6 +1521,21 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
return $saved; return $saved;
} }
/**
* Save the model to the database using transaction.
*
* @param array $options
* @return bool
*
* @throws \Throwable
*/
public function saveOrFail(array $options = [])
{
return $this->getConnection()->transaction(function () use ($options) {
return $this->save($options);
});
}
/** /**
* Finish processing on a successful save operation. * Finish processing on a successful save operation.
* *
@ -1651,6 +1667,8 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
$this->$relation()->touch(); $this->$relation()->touch();
if ($this->$relation instanceof self) { if ($this->$relation instanceof self) {
$this->$relation->fireModelEvent('saved', false);
$this->$relation->touchOwners(); $this->$relation->touchOwners();
} elseif ($this->$relation instanceof Collection) { } elseif ($this->$relation instanceof Collection) {
$this->$relation->each(function (Model $relation) { $this->$relation->each(function (Model $relation) {
@ -2759,7 +2777,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
} }
/** /**
* Determine whether an attribute should be casted to a native type. * Determine whether an attribute should be cast to a native type.
* *
* @param string $key * @param string $key
* @return bool * @return bool
@ -3019,7 +3037,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
/** /**
* Clone the model into a new, non-existing instance. * Clone the model into a new, non-existing instance.
* *
* @param array $except * @param array|null $except
* @return \Illuminate\Database\Eloquent\Model * @return \Illuminate\Database\Eloquent\Model
*/ */
public function replicate(array $except = null) public function replicate(array $except = null)
@ -3030,7 +3048,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
$this->getUpdatedAtColumn(), $this->getUpdatedAtColumn(),
]; ];
$attributes = array_except($this->attributes, $except); $attributes = Arr::except($this->attributes, $except);
with($instance = new static)->setRawAttributes($attributes); with($instance = new static)->setRawAttributes($attributes);
@ -3068,7 +3086,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
/** /**
* Get the model's original attribute values. * Get the model's original attribute values.
* *
* @param string $key * @param string|null $key
* @param mixed $default * @param mixed $default
* @return array * @return array
*/ */
@ -3260,7 +3278,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
/** /**
* Resolve a connection instance. * Resolve a connection instance.
* *
* @param string $connection * @param string|null $connection
* @return \Illuminate\Database\Connection * @return \Illuminate\Database\Connection
*/ */
public static function resolveConnection($connection = null) public static function resolveConnection($connection = null)
@ -3359,14 +3377,13 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
// Here we will extract all of the mutated attributes so that we can quickly // Here we will extract all of the mutated attributes so that we can quickly
// spin through them after we export models to their array form, which we // spin through them after we export models to their array form, which we
// need to be fast. This'll let us know the attributes that can mutate. // need to be fast. This'll let us know the attributes that can mutate.
foreach (get_class_methods($class) as $method) { if (preg_match_all('/(?<=^|;)get([^;]+?)Attribute(;|$)/', implode(';', get_class_methods($class)), $matches)) {
if (strpos($method, 'Attribute') !== false && foreach ($matches[1] as $match) {
preg_match('/^get(.+)Attribute$/', $method, $matches)) {
if (static::$snakeAttributes) { if (static::$snakeAttributes) {
$matches[1] = Str::snake($matches[1]); $match = Str::snake($match);
} }
$mutatedAttributes[] = lcfirst($matches[1]); $mutatedAttributes[] = lcfirst($match);
} }
} }

View File

@ -229,16 +229,16 @@ class BelongsToMany extends Relation
* *
* @param int $count * @param int $count
* @param callable $callback * @param callable $callback
* @return void * @return bool
*/ */
public function chunk($count, callable $callback) public function chunk($count, callable $callback)
{ {
$this->query->addSelect($this->getSelectColumns()); $this->query->addSelect($this->getSelectColumns());
$this->query->chunk($count, function ($results) use ($callback) { return $this->query->chunk($count, function ($results) use ($callback) {
$this->hydratePivotRelation($results->all()); $this->hydratePivotRelation($results->all());
call_user_func($callback, $results); return $callback($results);
}); });
} }

View File

@ -27,7 +27,7 @@ abstract class Grammar
/** /**
* Wrap a table in keyword identifiers. * Wrap a table in keyword identifiers.
* *
* @param string|\Illuminate\Database\Query\Expression $table * @param \Illuminate\Database\Query\Expression|string $table
* @return string * @return string
*/ */
public function wrapTable($table) public function wrapTable($table)
@ -42,7 +42,7 @@ abstract class Grammar
/** /**
* Wrap a value in keyword identifiers. * Wrap a value in keyword identifiers.
* *
* @param string|\Illuminate\Database\Query\Expression $value * @param \Illuminate\Database\Query\Expression|string $value
* @param bool $prefixAlias * @param bool $prefixAlias
* @return string * @return string
*/ */

View File

@ -765,6 +765,12 @@ class Builder
{ {
$type = $not ? 'NotIn' : 'In'; $type = $not ? 'NotIn' : 'In';
if ($values instanceof static) {
return $this->whereInExistingQuery(
$column, $values, $boolean, $not
);
}
// If the value of the where in clause is actually a Closure, we will assume that // If the value of the where in clause is actually a Closure, we will assume that
// the developer is using a full sub-select for this "in" statement, and will // the developer is using a full sub-select for this "in" statement, and will
// execute those Closures, then we can re-construct the entire sub-selects. // execute those Closures, then we can re-construct the entire sub-selects.
@ -845,6 +851,26 @@ class Builder
return $this; return $this;
} }
/**
* Add a external sub-select to the query.
*
* @param string $column
* @param \Illuminate\Database\Query\Builder|static $query
* @param string $boolean
* @param bool $not
* @return $this
*/
protected function whereInExistingQuery($column, $query, $boolean, $not)
{
$type = $not ? 'NotInSub' : 'InSub';
$this->wheres[] = compact('type', 'column', 'query', 'boolean');
$this->addBinding($query->getBindings(), 'where');
return $this;
}
/** /**
* Add a "where null" clause to the query. * Add a "where null" clause to the query.
* *
@ -1207,7 +1233,7 @@ class Builder
{ {
$property = $this->unions ? 'unionLimit' : 'limit'; $property = $this->unions ? 'unionLimit' : 'limit';
if ($value > 0) { if ($value >= 0) {
$this->$property = $value; $this->$property = $value;
} }
@ -1560,7 +1586,7 @@ class Builder
* Get an array with the values of a given column. * Get an array with the values of a given column.
* *
* @param string $column * @param string $column
* @param string $key * @param string|null $key
* @return array * @return array
*/ */
public function lists($column, $key = null) public function lists($column, $key = null)
@ -1608,7 +1634,7 @@ class Builder
/** /**
* Determine if any rows exist for the current query. * Determine if any rows exist for the current query.
* *
* @return bool|null * @return bool
*/ */
public function exists() public function exists()
{ {
@ -1621,6 +1647,8 @@ class Builder
return (bool) $results['exists']; return (bool) $results['exists'];
} }
return false;
} }
/** /**

View File

@ -169,6 +169,10 @@ class Grammar extends BaseGrammar
*/ */
protected function compileJoinConstraint(array $clause) protected function compileJoinConstraint(array $clause)
{ {
if ($clause['nested']) {
return $this->compileNestedJoinConstraint($clause);
}
$first = $this->wrap($clause['first']); $first = $this->wrap($clause['first']);
if ($clause['where']) { if ($clause['where']) {
@ -184,6 +188,27 @@ class Grammar extends BaseGrammar
return "{$clause['boolean']} $first {$clause['operator']} $second"; return "{$clause['boolean']} $first {$clause['operator']} $second";
} }
/**
* Create a nested join clause constraint segment.
*
* @param array $clause
* @return string
*/
protected function compileNestedJoinConstraint(array $clause)
{
$clauses = [];
foreach ($clause['join']->clauses as $nestedClause) {
$clauses[] = $this->compileJoinConstraint($nestedClause);
}
$clauses[0] = $this->removeLeadingBoolean($clauses[0]);
$clauses = implode(' ', $clauses);
return "{$clause['boolean']} ({$clauses})";
}
/** /**
* Compile the "where" portions of the query. * Compile the "where" portions of the query.
* *

View File

@ -33,6 +33,71 @@ class PostgresGrammar extends Grammar
return $value ? 'for update' : 'for share'; return $value ? 'for update' : 'for share';
} }
/**
* Compile a "where date" clause.
*
* @param \Illuminate\Database\Query\Builder $query
* @param array $where
* @return string
*/
protected function whereDate(Builder $query, $where)
{
$value = $this->parameter($where['value']);
return $this->wrap($where['column']).' '.$where['operator'].' '.$value.'::date';
}
/**
* Compile a "where day" clause.
*
* @param \Illuminate\Database\Query\Builder $query
* @param array $where
* @return string
*/
protected function whereDay(Builder $query, $where)
{
return $this->dateBasedWhere('day', $query, $where);
}
/**
* Compile a "where month" clause.
*
* @param \Illuminate\Database\Query\Builder $query
* @param array $where
* @return string
*/
protected function whereMonth(Builder $query, $where)
{
return $this->dateBasedWhere('month', $query, $where);
}
/**
* Compile a "where year" clause.
*
* @param \Illuminate\Database\Query\Builder $query
* @param array $where
* @return string
*/
protected function whereYear(Builder $query, $where)
{
return $this->dateBasedWhere('year', $query, $where);
}
/**
* Compile a date based where clause.
*
* @param string $type
* @param \Illuminate\Database\Query\Builder $query
* @param array $where
* @return string
*/
protected function dateBasedWhere($type, Builder $query, $where)
{
$value = $this->parameter($where['value']);
return 'extract('.$type.' from '.$this->wrap($where['column']).') '.$where['operator'].' '.$value;
}
/** /**
* Compile an update statement into SQL. * Compile an update statement into SQL.
* *

View File

@ -211,9 +211,11 @@ class SqlServerGrammar extends Grammar
*/ */
public function compileExists(Builder $query) public function compileExists(Builder $query)
{ {
$select = $this->compileSelect($query); $existsQuery = clone $query;
return "select cast(case when exists($select) then 1 else 0 end as bit) as {$this->wrap('exists')}"; $existsQuery->columns = [];
return $this->compileSelect($existsQuery->selectRaw('1 [exists]')->limit(1));
} }
/** /**
@ -264,4 +266,79 @@ class SqlServerGrammar extends Grammar
return '['.str_replace(']', ']]', $value).']'; return '['.str_replace(']', ']]', $value).']';
} }
/**
* Compile an update statement into SQL.
*
* @param \Illuminate\Database\Query\Builder $query
* @param array $values
* @return string
*/
public function compileUpdate(Builder $query, $values)
{
$table = $alias = $this->wrapTable($query->from);
if (strpos(strtolower($table), '] as [') !== false) {
$segments = explode('] as [', $table);
$alias = '['.$segments[1];
}
// Each one of the columns in the update statements needs to be wrapped in the
// keyword identifiers, also a place-holder needs to be created for each of
// the values in the list of bindings so we can make the sets statements.
$columns = [];
foreach ($values as $key => $value) {
$columns[] = $this->wrap($key).' = '.$this->parameter($value);
}
$columns = implode(', ', $columns);
// If the query has any "join" clauses, we will setup the joins on the builder
// and compile them so we can attach them to this update, as update queries
// can get join statements to attach to other tables when they're needed.
if (isset($query->joins)) {
$joins = ' '.$this->compileJoins($query, $query->joins);
} else {
$joins = '';
}
// Of course, update queries may also be constrained by where clauses so we'll
// need to compile the where clauses and attach it to the query so only the
// intended records are updated by the SQL statements we generate to run.
$where = $this->compileWheres($query);
if (! empty($joins)) {
return trim("update {$alias} set {$columns} from {$table}{$joins} {$where}");
}
return trim("update {$table}{$joins} set $columns $where");
}
/**
* Wrap a table in keyword identifiers.
*
* @param \Illuminate\Database\Query\Expression|string $table
* @return string
*/
public function wrapTable($table)
{
return $this->wrapTableValuedFunction(parent::wrapTable($table));
}
/**
* Wrap a table in keyword identifiers.
*
* @param string $table
* @return string
*/
protected function wrapTableValuedFunction($table)
{
if (preg_match('/^(.+?)(\(.*?\))]$/', $table, $matches) === 1) {
$table = $matches[1].']'.$matches[2];
}
return $table;
}
} }

View File

@ -2,6 +2,9 @@
namespace Illuminate\Database\Query; namespace Illuminate\Database\Query;
use Closure;
use InvalidArgumentException;
class JoinClause class JoinClause
{ {
/** /**
@ -57,15 +60,25 @@ class JoinClause
* *
* on `contacts`.`user_id` = `users`.`id` and `contacts`.`info_id` = `info`.`id` * on `contacts`.`user_id` = `users`.`id` and `contacts`.`info_id` = `info`.`id`
* *
* @param string $first * @param \Closure|string $first
* @param string $operator * @param string|null $operator
* @param string $second * @param string|null $second
* @param string $boolean * @param string $boolean
* @param bool $where * @param bool $where
* @return $this * @return $this
*
* @throws \InvalidArgumentException
*/ */
public function on($first, $operator, $second, $boolean = 'and', $where = false) public function on($first, $operator = null, $second = null, $boolean = 'and', $where = false)
{ {
if ($first instanceof Closure) {
return $this->nest($first, $boolean);
}
if (func_num_args() < 3) {
throw new InvalidArgumentException('Not enough arguments for the on clause.');
}
if ($where) { if ($where) {
$this->bindings[] = $second; $this->bindings[] = $second;
} }
@ -74,7 +87,9 @@ class JoinClause
$second = count($second); $second = count($second);
} }
$this->clauses[] = compact('first', 'operator', 'second', 'boolean', 'where'); $nested = false;
$this->clauses[] = compact('first', 'operator', 'second', 'boolean', 'where', 'nested');
return $this; return $this;
} }
@ -82,12 +97,12 @@ class JoinClause
/** /**
* Add an "or on" clause to the join. * Add an "or on" clause to the join.
* *
* @param string $first * @param \Closure|string $first
* @param string $operator * @param string|null $operator
* @param string $second * @param string|null $second
* @return \Illuminate\Database\Query\JoinClause * @return \Illuminate\Database\Query\JoinClause
*/ */
public function orOn($first, $operator, $second) public function orOn($first, $operator = null, $second = null)
{ {
return $this->on($first, $operator, $second, 'or'); return $this->on($first, $operator, $second, 'or');
} }
@ -95,13 +110,13 @@ class JoinClause
/** /**
* Add an "on where" clause to the join. * Add an "on where" clause to the join.
* *
* @param string $first * @param \Closure|string $first
* @param string $operator * @param string|null $operator
* @param string $second * @param string|null $second
* @param string $boolean * @param string $boolean
* @return \Illuminate\Database\Query\JoinClause * @return \Illuminate\Database\Query\JoinClause
*/ */
public function where($first, $operator, $second, $boolean = 'and') public function where($first, $operator = null, $second = null, $boolean = 'and')
{ {
return $this->on($first, $operator, $second, $boolean, true); return $this->on($first, $operator, $second, $boolean, true);
} }
@ -109,12 +124,12 @@ class JoinClause
/** /**
* Add an "or on where" clause to the join. * Add an "or on where" clause to the join.
* *
* @param string $first * @param \Closure|string $first
* @param string $operator * @param string|null $operator
* @param string $second * @param string|null $second
* @return \Illuminate\Database\Query\JoinClause * @return \Illuminate\Database\Query\JoinClause
*/ */
public function orWhere($first, $operator, $second) public function orWhere($first, $operator = null, $second = null)
{ {
return $this->on($first, $operator, $second, 'or', true); return $this->on($first, $operator, $second, 'or', true);
} }
@ -212,4 +227,27 @@ class JoinClause
{ {
return $this->on($column, 'not in', $values, 'or', true); return $this->on($column, 'not in', $values, 'or', true);
} }
/**
* Add a nested where statement to the query.
*
* @param \Closure $callback
* @param string $boolean
* @return \Illuminate\Database\Query\JoinClause
*/
public function nest(Closure $callback, $boolean = 'and')
{
$join = new static($this->type, $this->table);
$callback($join);
if (count($join->clauses)) {
$nested = true;
$this->clauses[] = compact('nested', 'join', 'boolean');
$this->bindings = array_merge($this->bindings, $join->bindings);
}
return $this;
}
} }

View File

@ -47,6 +47,13 @@ class Blueprint
*/ */
public $collation; public $collation;
/**
* Whether to make the table temporary.
*
* @var bool
*/
public $temporary = false;
/** /**
* Create a new schema blueprint. * Create a new schema blueprint.
* *
@ -180,6 +187,16 @@ class Blueprint
return $this->addCommand('create'); return $this->addCommand('create');
} }
/**
* Indicate that the table needs to be temporary.
*
* @return void
*/
public function temporary()
{
$this->temporary = true;
}
/** /**
* Indicate that the table should be dropped. * Indicate that the table should be dropped.
* *
@ -1017,7 +1034,7 @@ class Blueprint
public function getChangedColumns() public function getChangedColumns()
{ {
return array_filter($this->columns, function ($column) { return array_filter($this->columns, function ($column) {
return ! ! $column->change; return (bool) $column->change;
}); });
} }
} }

View File

@ -54,7 +54,9 @@ class MySqlGrammar extends Grammar
{ {
$columns = implode(', ', $this->getColumns($blueprint)); $columns = implode(', ', $this->getColumns($blueprint));
$sql = 'create table '.$this->wrapTable($blueprint)." ($columns)"; $sql = $blueprint->temporary ? 'create temporary' : 'create';
$sql .= ' table '.$this->wrapTable($blueprint)." ($columns)";
// Once we have the primary SQL, we can add the encoding option to the SQL for // Once we have the primary SQL, we can add the encoding option to the SQL for
// the table. Then, we can check if a storage engine has been supplied for // the table. Then, we can check if a storage engine has been supplied for
@ -161,7 +163,7 @@ class MySqlGrammar extends Grammar
$table = $this->wrapTable($blueprint); $table = $this->wrapTable($blueprint);
return "alter table {$table} add {$type} {$command->index}($columns)"; return "alter table {$table} add {$type} `{$command->index}`($columns)";
} }
/** /**
@ -227,7 +229,7 @@ class MySqlGrammar extends Grammar
{ {
$table = $this->wrapTable($blueprint); $table = $this->wrapTable($blueprint);
return "alter table {$table} drop index {$command->index}"; return "alter table {$table} drop index `{$command->index}`";
} }
/** /**
@ -241,7 +243,7 @@ class MySqlGrammar extends Grammar
{ {
$table = $this->wrapTable($blueprint); $table = $this->wrapTable($blueprint);
return "alter table {$table} drop index {$command->index}"; return "alter table {$table} drop index `{$command->index}`";
} }
/** /**
@ -255,7 +257,7 @@ class MySqlGrammar extends Grammar
{ {
$table = $this->wrapTable($blueprint); $table = $this->wrapTable($blueprint);
return "alter table {$table} drop foreign key {$command->index}"; return "alter table {$table} drop foreign key `{$command->index}`";
} }
/** /**
@ -526,6 +528,10 @@ class MySqlGrammar extends Grammar
*/ */
protected function typeTimestamp(Fluent $column) protected function typeTimestamp(Fluent $column)
{ {
if ($column->useCurrent) {
return 'timestamp default CURRENT_TIMESTAMP';
}
if (! $column->nullable && $column->default === null) { if (! $column->nullable && $column->default === null) {
return 'timestamp default 0'; return 'timestamp default 0';
} }
@ -541,6 +547,10 @@ class MySqlGrammar extends Grammar
*/ */
protected function typeTimestampTz(Fluent $column) protected function typeTimestampTz(Fluent $column)
{ {
if ($column->useCurrent) {
return 'timestamp default CURRENT_TIMESTAMP';
}
if (! $column->nullable && $column->default === null) { if (! $column->nullable && $column->default === null) {
return 'timestamp default 0'; return 'timestamp default 0';
} }

View File

@ -53,7 +53,11 @@ class PostgresGrammar extends Grammar
{ {
$columns = implode(', ', $this->getColumns($blueprint)); $columns = implode(', ', $this->getColumns($blueprint));
return 'create table '.$this->wrapTable($blueprint)." ($columns)"; $sql = $blueprint->temporary ? 'create temporary' : 'create';
$sql .= ' table '.$this->wrapTable($blueprint)." ($columns)";
return $sql;
} }
/** /**
@ -386,7 +390,9 @@ class PostgresGrammar extends Grammar
*/ */
protected function typeEnum(Fluent $column) protected function typeEnum(Fluent $column)
{ {
$allowed = array_map(function ($a) { return "'".$a."'"; }, $column->allowed); $allowed = array_map(function ($a) {
return "'".$a."'";
}, $column->allowed);
return "varchar(255) check (\"{$column->name}\" in (".implode(', ', $allowed).'))'; return "varchar(255) check (\"{$column->name}\" in (".implode(', ', $allowed).'))';
} }
@ -476,6 +482,10 @@ class PostgresGrammar extends Grammar
*/ */
protected function typeTimestamp(Fluent $column) protected function typeTimestamp(Fluent $column)
{ {
if ($column->useCurrent) {
return 'timestamp(0) without time zone default CURRENT_TIMESTAMP(0)';
}
return 'timestamp(0) without time zone'; return 'timestamp(0) without time zone';
} }
@ -487,6 +497,10 @@ class PostgresGrammar extends Grammar
*/ */
protected function typeTimestampTz(Fluent $column) protected function typeTimestampTz(Fluent $column)
{ {
if ($column->useCurrent) {
return 'timestamp(0) with time zone default CURRENT_TIMESTAMP(0)';
}
return 'timestamp(0) with time zone'; return 'timestamp(0) with time zone';
} }

View File

@ -54,7 +54,9 @@ class SQLiteGrammar extends Grammar
{ {
$columns = implode(', ', $this->getColumns($blueprint)); $columns = implode(', ', $this->getColumns($blueprint));
$sql = 'create table '.$this->wrapTable($blueprint)." ($columns"; $sql = $blueprint->temporary ? 'create temporary' : 'create';
$sql .= ' table '.$this->wrapTable($blueprint)." ($columns";
// SQLite forces primary keys to be added when the table is initially created // SQLite forces primary keys to be added when the table is initially created
// so we will need to check for a primary key commands and add the columns // so we will need to check for a primary key commands and add the columns
@ -435,7 +437,7 @@ class SQLiteGrammar extends Grammar
*/ */
protected function typeBoolean(Fluent $column) protected function typeBoolean(Fluent $column)
{ {
return 'tinyint'; return 'tinyint(1)';
} }
/** /**
@ -537,6 +539,10 @@ class SQLiteGrammar extends Grammar
*/ */
protected function typeTimestamp(Fluent $column) protected function typeTimestamp(Fluent $column)
{ {
if ($column->useCurrent) {
return 'datetime default CURRENT_TIMESTAMP';
}
return 'datetime'; return 'datetime';
} }
@ -548,6 +554,10 @@ class SQLiteGrammar extends Grammar
*/ */
protected function typeTimestampTz(Fluent $column) protected function typeTimestampTz(Fluent $column)
{ {
if ($column->useCurrent) {
return 'datetime default CURRENT_TIMESTAMP';
}
return 'datetime'; return 'datetime';
} }

View File

@ -482,6 +482,10 @@ class SqlServerGrammar extends Grammar
*/ */
protected function typeTimestamp(Fluent $column) protected function typeTimestamp(Fluent $column)
{ {
if ($column->useCurrent) {
return 'datetime default CURRENT_TIMESTAMP';
}
return 'datetime'; return 'datetime';
} }
@ -495,6 +499,10 @@ class SqlServerGrammar extends Grammar
*/ */
protected function typeTimestampTz(Fluent $column) protected function typeTimestampTz(Fluent $column)
{ {
if ($column->useCurrent) {
return 'datetimeoffset(0) default CURRENT_TIMESTAMP';
}
return 'datetimeoffset(0)'; return 'datetimeoffset(0)';
} }

View File

@ -36,7 +36,8 @@
"fzaninotto/faker": "Required to use the eloquent factory builder (~1.4).", "fzaninotto/faker": "Required to use the eloquent factory builder (~1.4).",
"illuminate/console": "Required to use the database commands (5.1.*).", "illuminate/console": "Required to use the database commands (5.1.*).",
"illuminate/events": "Required to use the observers with Eloquent (5.1.*).", "illuminate/events": "Required to use the observers with Eloquent (5.1.*).",
"illuminate/filesystem": "Required to use the migrations (5.1.*)." "illuminate/filesystem": "Required to use the migrations (5.1.*).",
"illuminate/pagination": "Required to paginate the result set (5.1.*)."
}, },
"minimum-stability": "dev" "minimum-stability": "dev"
} }

View File

@ -23,6 +23,8 @@ class Encrypter extends BaseEncrypter implements EncrypterContract
* @param string $key * @param string $key
* @param string $cipher * @param string $cipher
* @return void * @return void
*
* @throws \RuntimeException
*/ */
public function __construct($key, $cipher = 'AES-128-CBC') public function __construct($key, $cipher = 'AES-128-CBC')
{ {
@ -55,6 +57,8 @@ class Encrypter extends BaseEncrypter implements EncrypterContract
* *
* @param string $value * @param string $value
* @return string * @return string
*
* @throws \Illuminate\Contracts\Encryption\EncryptException
*/ */
public function encrypt($value) public function encrypt($value)
{ {
@ -71,7 +75,13 @@ class Encrypter extends BaseEncrypter implements EncrypterContract
// authenticity. Then, we'll JSON encode the data in a "payload" array. // authenticity. Then, we'll JSON encode the data in a "payload" array.
$mac = $this->hash($iv = base64_encode($iv), $value); $mac = $this->hash($iv = base64_encode($iv), $value);
return base64_encode(json_encode(compact('iv', 'value', 'mac'))); $json = json_encode(compact('iv', 'value', 'mac'));
if (! is_string($json)) {
throw new EncryptException('Could not encrypt the data.');
}
return base64_encode($json);
} }
/** /**
@ -79,6 +89,8 @@ class Encrypter extends BaseEncrypter implements EncrypterContract
* *
* @param string $payload * @param string $payload
* @return string * @return string
*
* @throws \Illuminate\Contracts\Encryption\DecryptException
*/ */
public function decrypt($payload) public function decrypt($payload)
{ {

View File

@ -5,6 +5,7 @@ namespace Illuminate\Encryption;
use Exception; use Exception;
use RuntimeException; use RuntimeException;
use Illuminate\Contracts\Encryption\DecryptException; use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Contracts\Encryption\EncryptException;
use Illuminate\Contracts\Encryption\Encrypter as EncrypterContract; use Illuminate\Contracts\Encryption\Encrypter as EncrypterContract;
/** /**
@ -32,6 +33,8 @@ class McryptEncrypter extends BaseEncrypter implements EncrypterContract
* @param string $key * @param string $key
* @param string $cipher * @param string $cipher
* @return void * @return void
*
* @throws \RuntimeException
*/ */
public function __construct($key, $cipher = MCRYPT_RIJNDAEL_128) public function __construct($key, $cipher = MCRYPT_RIJNDAEL_128)
{ {
@ -64,6 +67,8 @@ class McryptEncrypter extends BaseEncrypter implements EncrypterContract
* *
* @param string $value * @param string $value
* @return string * @return string
*
* @throws \Illuminate\Contracts\Encryption\EncryptException
*/ */
public function encrypt($value) public function encrypt($value)
{ {
@ -76,7 +81,13 @@ class McryptEncrypter extends BaseEncrypter implements EncrypterContract
// authenticity. Then, we'll JSON encode the data in a "payload" array. // authenticity. Then, we'll JSON encode the data in a "payload" array.
$mac = $this->hash($iv = base64_encode($iv), $value); $mac = $this->hash($iv = base64_encode($iv), $value);
return base64_encode(json_encode(compact('iv', 'value', 'mac'))); $json = json_encode(compact('iv', 'value', 'mac'));
if (! is_string($json)) {
throw new EncryptException('Could not encrypt the data.');
}
return base64_encode($json);
} }
/** /**

View File

@ -31,7 +31,7 @@
} }
}, },
"suggest": { "suggest": {
"paragonie/random_compat": "Provides a compatible interface like PHP7's random_bytes() in PHP 5 projects (^1.0.6)." "paragonie/random_compat": "Provides a compatible interface like PHP7's random_bytes() in PHP 5 projects (~1.1)."
}, },
"minimum-stability": "dev" "minimum-stability": "dev"
} }

View File

@ -427,7 +427,9 @@ class Dispatcher implements DispatcherContract
*/ */
protected function cloneArgumentsForQueueing(array $arguments) protected function cloneArgumentsForQueueing(array $arguments)
{ {
return array_map(function ($a) { return is_object($a) ? clone $a : $a; }, $arguments); return array_map(function ($a) {
return is_object($a) ? clone $a : $a;
}, $arguments);
} }
/** /**

View File

@ -13,7 +13,7 @@ class Filesystem
use Macroable; use Macroable;
/** /**
* Determine if a file exists. * Determine if a file or directory exists.
* *
* @param string $path * @param string $path
* @return bool * @return bool

View File

@ -69,7 +69,11 @@ class FilesystemAdapter implements FilesystemContract, CloudFilesystemContract
*/ */
public function put($path, $contents, $visibility = null) public function put($path, $contents, $visibility = null)
{ {
$config = ['visibility' => $this->parseVisibility($visibility)]; if ($visibility = $this->parseVisibility($visibility)) {
$config = ['visibility' => $visibility];
} else {
$config = [];
}
if (is_resource($contents)) { if (is_resource($contents)) {
return $this->driver->putStream($path, $contents, $config); return $this->driver->putStream($path, $contents, $config);

View File

@ -6,6 +6,8 @@ use Closure;
use Aws\S3\S3Client; use Aws\S3\S3Client;
use OpenCloud\Rackspace; use OpenCloud\Rackspace;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use InvalidArgumentException;
use League\Flysystem\AdapterInterface;
use League\Flysystem\FilesystemInterface; use League\Flysystem\FilesystemInterface;
use League\Flysystem\Filesystem as Flysystem; use League\Flysystem\Filesystem as Flysystem;
use League\Flysystem\Adapter\Ftp as FtpAdapter; use League\Flysystem\Adapter\Ftp as FtpAdapter;
@ -88,6 +90,8 @@ class FilesystemManager implements FactoryContract
* *
* @param string $name * @param string $name
* @return \Illuminate\Contracts\Filesystem\Filesystem * @return \Illuminate\Contracts\Filesystem\Filesystem
*
* @throws \InvalidArgumentException
*/ */
protected function resolve($name) protected function resolve($name)
{ {
@ -97,7 +101,13 @@ class FilesystemManager implements FactoryContract
return $this->callCustomCreator($config); return $this->callCustomCreator($config);
} }
return $this->{'create'.ucfirst($config['driver']).'Driver'}($config); $driverMethod = 'create'.ucfirst($config['driver']).'Driver';
if (method_exists($this, $driverMethod)) {
return $this->{$driverMethod}($config);
} else {
throw new InvalidArgumentException("Driver [{$config['driver']}] not supported.");
}
} }
/** /**
@ -127,9 +137,13 @@ class FilesystemManager implements FactoryContract
{ {
$permissions = isset($config['permissions']) ? $config['permissions'] : []; $permissions = isset($config['permissions']) ? $config['permissions'] : [];
return $this->adapt(new Flysystem(new LocalAdapter( $links = Arr::get($config, 'links') === 'skip'
$config['root'], LOCK_EX, LocalAdapter::DISALLOW_LINKS, $permissions ? LocalAdapter::SKIP_LINKS
))); : LocalAdapter::DISALLOW_LINKS;
return $this->adapt($this->createFlysystem(new LocalAdapter(
$config['root'], LOCK_EX, $links, $permissions
), $config));
} }
/** /**
@ -144,7 +158,9 @@ class FilesystemManager implements FactoryContract
'host', 'username', 'password', 'port', 'root', 'passive', 'ssl', 'timeout', 'host', 'username', 'password', 'port', 'root', 'passive', 'ssl', 'timeout',
]); ]);
return $this->adapt(new Flysystem(new FtpAdapter($ftpConfig))); return $this->adapt($this->createFlysystem(
new FtpAdapter($ftpConfig), $config
));
} }
/** /**
@ -155,13 +171,13 @@ class FilesystemManager implements FactoryContract
*/ */
public function createS3Driver(array $config) public function createS3Driver(array $config)
{ {
$config = $this->formatS3Config($config); $s3Config = $this->formatS3Config($config);
$root = isset($config['root']) ? $config['root'] : null; $root = isset($s3Config['root']) ? $s3Config['root'] : null;
return $this->adapt( return $this->adapt($this->createFlysystem(
new Flysystem(new S3Adapter(new S3Client($config), $config['bucket'], $root)) new S3Adapter(new S3Client($s3Config), $s3Config['bucket'], $root), $config
); ));
} }
/** /**
@ -193,8 +209,8 @@ class FilesystemManager implements FactoryContract
'username' => $config['username'], 'apiKey' => $config['key'], 'username' => $config['username'], 'apiKey' => $config['key'],
]); ]);
return $this->adapt(new Flysystem( return $this->adapt($this->createFlysystem(
new RackspaceAdapter($this->getRackspaceContainer($client, $config)) new RackspaceAdapter($this->getRackspaceContainer($client, $config)), $config
)); ));
} }
@ -214,6 +230,20 @@ class FilesystemManager implements FactoryContract
return $store->getContainer($config['container']); return $store->getContainer($config['container']);
} }
/**
* Create a Flysystem instance with the given adapter.
*
* @param \League\Flysystem\AdapterInterface $adapter
* @param array $config
* @return \Leage\Flysystem\FlysystemInterface
*/
protected function createFlysystem(AdapterInterface $adapter, array $config)
{
$config = Arr::only($config, ['visibility']);
return new Flysystem($adapter, count($config) > 0 ? $config : null);
}
/** /**
* Adapt the filesystem implementation. * Adapt the filesystem implementation.
* *

View File

@ -25,7 +25,9 @@ class FilesystemServiceProvider extends ServiceProvider
*/ */
protected function registerNativeFilesystem() protected function registerNativeFilesystem()
{ {
$this->app->singleton('files', function () { return new Filesystem; }); $this->app->singleton('files', function () {
return new Filesystem;
});
} }
/** /**

View File

@ -20,7 +20,9 @@ class HashServiceProvider extends ServiceProvider
*/ */
public function register() public function register()
{ {
$this->app->singleton('hash', function () { return new BcryptHasher; }); $this->app->singleton('hash', function () {
return new BcryptHasher;
});
} }
/** /**

View File

@ -141,7 +141,9 @@ class Request extends SymfonyRequest implements ArrayAccess
{ {
$segments = explode('/', $this->path()); $segments = explode('/', $this->path());
return array_values(array_filter($segments, function ($v) { return $v != ''; })); return array_values(array_filter($segments, function ($v) {
return $v != '';
}));
} }
/** /**
@ -595,7 +597,7 @@ class Request extends SymfonyRequest implements ArrayAccess
*/ */
public function isJson() public function isJson()
{ {
return Str::contains($this->header('CONTENT_TYPE'), '/json'); return Str::contains($this->header('CONTENT_TYPE'), ['/json', '+json']);
} }
/** /**
@ -607,7 +609,7 @@ class Request extends SymfonyRequest implements ArrayAccess
{ {
$acceptable = $this->getAcceptableContentTypes(); $acceptable = $this->getAcceptableContentTypes();
return isset($acceptable[0]) && $acceptable[0] === 'application/json'; return isset($acceptable[0]) && Str::contains($acceptable[0], ['/json', '+json']);
} }
/** /**
@ -796,7 +798,9 @@ class Request extends SymfonyRequest implements ArrayAccess
*/ */
public function getUserResolver() public function getUserResolver()
{ {
return $this->userResolver ?: function () {}; return $this->userResolver ?: function () {
//
};
} }
/** /**
@ -819,7 +823,9 @@ class Request extends SymfonyRequest implements ArrayAccess
*/ */
public function getRouteResolver() public function getRouteResolver()
{ {
return $this->routeResolver ?: function () {}; return $this->routeResolver ?: function () {
//
};
} }
/** /**

View File

@ -46,8 +46,8 @@ class LengthAwarePaginator extends AbstractPaginator implements Arrayable, Array
$this->total = $total; $this->total = $total;
$this->perPage = $perPage; $this->perPage = $perPage;
$this->lastPage = (int) ceil($total / $perPage); $this->lastPage = (int) ceil($total / $perPage);
$this->path = $this->path != '/' ? rtrim($this->path, '/') : $this->path;
$this->currentPage = $this->setCurrentPage($currentPage, $this->lastPage); $this->currentPage = $this->setCurrentPage($currentPage, $this->lastPage);
$this->path = $this->path != '/' ? rtrim($this->path, '/').'/' : $this->path;
$this->items = $items instanceof Collection ? $items : Collection::make($items); $this->items = $items instanceof Collection ? $items : Collection::make($items);
} }

View File

@ -18,7 +18,13 @@ class PaginationServiceProvider extends ServiceProvider
}); });
Paginator::currentPageResolver(function ($pageName = 'page') { Paginator::currentPageResolver(function ($pageName = 'page') {
return $this->app['request']->input($pageName); $page = $this->app['request']->input($pageName);
if (filter_var($page, FILTER_VALIDATE_INT) !== false && (int) $page >= 1) {
return $page;
}
return 1;
}); });
} }
} }

View File

@ -37,7 +37,7 @@ class Paginator extends AbstractPaginator implements Arrayable, ArrayAccess, Cou
$this->perPage = $perPage; $this->perPage = $perPage;
$this->currentPage = $this->setCurrentPage($currentPage); $this->currentPage = $this->setCurrentPage($currentPage);
$this->path = $this->path != '/' ? rtrim($this->path, '/').'/' : $this->path; $this->path = $this->path != '/' ? rtrim($this->path, '/') : $this->path;
$this->items = $items instanceof Collection ? $items : Collection::make($items); $this->items = $items instanceof Collection ? $items : Collection::make($items);
$this->checkForMorePages(); $this->checkForMorePages();

View File

@ -16,14 +16,31 @@ class SqsConnector implements ConnectorInterface
*/ */
public function connect(array $config) public function connect(array $config)
{ {
$config = array_merge([ $config = $this->getDefaultConfiguration($config);
'version' => 'latest', 'http' => ['connect_timeout' => 60],
], $config);
if ($config['key'] && $config['secret']) { if ($config['key'] && $config['secret']) {
$config['credentials'] = Arr::only($config, ['key', 'secret']); $config['credentials'] = Arr::only($config, ['key', 'secret']);
} }
return new SqsQueue(new SqsClient($config), $config['queue']); return new SqsQueue(
new SqsClient($config), $config['queue'], Arr::get($config, 'prefix', '')
);
}
/**
* Get the default configuration for SQS.
*
* @param array $config
* @return array
*/
protected function getDefaultConfiguration(array $config)
{
return array_merge([
'version' => 'latest',
'http' => [
'timeout' => 60,
'connect_timeout' => 60,
],
], $config);
} }
} }

View File

@ -68,7 +68,7 @@ class ListFailedCommand extends Command
*/ */
protected function parseFailedJob(array $failed) protected function parseFailedJob(array $failed)
{ {
$row = array_values(array_except($failed, ['payload'])); $row = array_values(Arr::except($failed, ['payload']));
array_splice($row, 3, 0, $this->extractJobName($failed['payload'])); array_splice($row, 3, 0, $this->extractJobName($failed['payload']));

View File

@ -2,6 +2,7 @@
namespace Illuminate\Queue\Console; namespace Illuminate\Queue\Console;
use Illuminate\Support\Arr;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
@ -28,20 +29,40 @@ class RetryCommand extends Command
*/ */
public function fire() public function fire()
{ {
$failed = $this->laravel['queue.failer']->find($this->argument('id')); $ids = $this->argument('id');
if (count($ids) === 1 && $ids[0] === 'all') {
$ids = Arr::pluck($this->laravel['queue.failer']->all(), 'id');
}
foreach ($ids as $id) {
$this->retryJob($id);
}
}
/**
* Retry the queue job with the given ID.
*
* @param string $id
* @return void
*/
protected function retryJob($id)
{
$failed = $this->laravel['queue.failer']->find($id);
if (! is_null($failed)) { if (! is_null($failed)) {
$failed = (object) $failed; $failed = (object) $failed;
$failed->payload = $this->resetAttempts($failed->payload); $failed->payload = $this->resetAttempts($failed->payload);
$this->laravel['queue']->connection($failed->connection)->pushRaw($failed->payload, $failed->queue); $this->laravel['queue']->connection($failed->connection)
->pushRaw($failed->payload, $failed->queue);
$this->laravel['queue.failer']->forget($failed->id); $this->laravel['queue.failer']->forget($failed->id);
$this->info('The failed job has been pushed back onto the queue!'); $this->info("The failed job [{$id}] has been pushed back onto the queue!");
} else { } else {
$this->error('No failed job matches the given ID.'); $this->error("No failed job matches the given ID [{$id}].");
} }
} }
@ -70,7 +91,7 @@ class RetryCommand extends Command
protected function getArguments() protected function getArguments()
{ {
return [ return [
['id', InputArgument::REQUIRED, 'The ID of the failed job'], ['id', InputArgument::IS_ARRAY, 'The ID of the failed job'],
]; ];
} }
} }

View File

@ -93,7 +93,7 @@ class IronQueue extends Queue implements QueueContract
* @param int $delay * @param int $delay
* @return mixed * @return mixed
*/ */
public function recreate($payload, $queue = null, $delay) public function recreate($payload, $queue, $delay)
{ {
$options = ['delay' => $this->getSeconds($delay)]; $options = ['delay' => $this->getSeconds($delay)];

View File

@ -24,7 +24,9 @@ trait SerializesModels
)); ));
} }
return array_map(function ($p) { return $p->getName(); }, $properties); return array_map(function ($p) {
return $p->getName();
}, $properties);
} }
/** /**

View File

@ -22,6 +22,13 @@ class SqsQueue extends Queue implements QueueContract
*/ */
protected $default; protected $default;
/**
* The sqs prefix url.
*
* @var string
*/
protected $prefix;
/** /**
* The job creator callback. * The job creator callback.
* *
@ -34,11 +41,13 @@ class SqsQueue extends Queue implements QueueContract
* *
* @param \Aws\Sqs\SqsClient $sqs * @param \Aws\Sqs\SqsClient $sqs
* @param string $default * @param string $default
* @param string $prefix
* @return void * @return void
*/ */
public function __construct(SqsClient $sqs, $default) public function __construct(SqsClient $sqs, $default, $prefix = '')
{ {
$this->sqs = $sqs; $this->sqs = $sqs;
$this->prefix = $prefix;
$this->default = $default; $this->default = $default;
} }
@ -136,7 +145,13 @@ class SqsQueue extends Queue implements QueueContract
*/ */
public function getQueue($queue) public function getQueue($queue)
{ {
return $queue ?: $this->default; $queue = $queue ?: $this->default;
if (filter_var($queue, FILTER_VALIDATE_URL) !== false) {
return $queue;
}
return rtrim($this->prefix, '/').'/'.($queue);
} }
/** /**

View File

@ -283,7 +283,11 @@ class Store implements SessionInterface
protected function addBagDataToSession() protected function addBagDataToSession()
{ {
foreach (array_merge($this->bags, [$this->metaBag]) as $bag) { foreach (array_merge($this->bags, [$this->metaBag]) as $bag) {
$this->put($bag->getStorageKey(), $this->bagData[$bag->getStorageKey()]); $key = $bag->getStorageKey();
if (isset($this->bagData[$key])) {
$this->put($key, $this->bagData[$key]);
}
} }
} }
@ -294,9 +298,7 @@ class Store implements SessionInterface
*/ */
public function ageFlashData() public function ageFlashData()
{ {
foreach ($this->get('flash.old', []) as $old) { $this->forget($this->get('flash.old', []));
$this->forget($old);
}
$this->put('flash.old', $this->get('flash.new', [])); $this->put('flash.old', $this->get('flash.new', []));
@ -419,6 +421,21 @@ class Store implements SessionInterface
$this->removeFromOldFlashData([$key]); $this->removeFromOldFlashData([$key]);
} }
/**
* Flash a key / value pair to the session
* for immediate use.
*
* @param string $key
* @param mixed $value
* @return void
*/
public function now($key, $value)
{
$this->put($key, $value);
$this->push('flash.old', $key);
}
/** /**
* Flash an input array to the session. * Flash an input array to the session.
* *
@ -506,14 +523,14 @@ class Store implements SessionInterface
} }
/** /**
* Remove an item from the session. * Remove one or many items from the session.
* *
* @param string $key * @param string|array $keys
* @return void * @return void
*/ */
public function forget($key) public function forget($keys)
{ {
Arr::forget($this->attributes, $key); Arr::forget($this->attributes, $keys);
} }
/** /**

View File

@ -48,7 +48,7 @@ class Arr
/** /**
* Collapse an array of arrays into a single array. * Collapse an array of arrays into a single array.
* *
* @param array|\ArrayAccess $array * @param \ArrayAccess|array $array
* @return array * @return array
*/ */
public static function collapse($array) public static function collapse($array)
@ -181,7 +181,9 @@ class Arr
{ {
$return = []; $return = [];
array_walk_recursive($array, function ($x) use (&$return) { $return[] = $x; }); array_walk_recursive($array, function ($x) use (&$return) {
$return[] = $x;
});
return $return; return $return;
} }
@ -197,7 +199,13 @@ class Arr
{ {
$original = &$array; $original = &$array;
foreach ((array) $keys as $key) { $keys = (array) $keys;
if (count($keys) === 0) {
return;
}
foreach ($keys as $key) {
$parts = explode('.', $key); $parts = explode('.', $key);
while (count($parts) > 1) { while (count($parts) > 1) {
@ -349,6 +357,25 @@ class Arr
return [$value, $key]; return [$value, $key];
} }
/**
* Push an item onto the beginning of an array.
*
* @param array $array
* @param mixed $value
* @param mixed $key
* @return array
*/
public static function prepend($array, $value, $key = null)
{
if (is_null($key)) {
array_unshift($array, $value);
} else {
$array = [$key => $value] + $array;
}
return $array;
}
/** /**
* Get a value from the array, and remove it. * Get a value from the array, and remove it.
* *

View File

@ -62,7 +62,7 @@ class ClassLoader
public static function register() public static function register()
{ {
if (! static::$registered) { if (! static::$registered) {
static::$registered = spl_autoload_register(['\Illuminate\Support\ClassLoader', 'load']); static::$registered = spl_autoload_register([static::class, 'load']);
} }
} }

View File

@ -9,11 +9,14 @@ use CachingIterator;
use JsonSerializable; use JsonSerializable;
use IteratorAggregate; use IteratorAggregate;
use InvalidArgumentException; use InvalidArgumentException;
use Illuminate\Support\Traits\Macroable;
use Illuminate\Contracts\Support\Jsonable; use Illuminate\Contracts\Support\Jsonable;
use Illuminate\Contracts\Support\Arrayable; use Illuminate\Contracts\Support\Arrayable;
class Collection implements ArrayAccess, Arrayable, Countable, IteratorAggregate, Jsonable, JsonSerializable class Collection implements ArrayAccess, Arrayable, Countable, IteratorAggregate, Jsonable, JsonSerializable
{ {
use Macroable;
/** /**
* The items contained in the collection. * The items contained in the collection.
* *
@ -161,6 +164,19 @@ class Collection implements ArrayAccess, Arrayable, Countable, IteratorAggregate
return new static($new); return new static($new);
} }
/**
* Get all items except for those with the specified keys.
*
* @param mixed $keys
* @return static
*/
public function except($keys)
{
$keys = is_array($keys) ? $keys : func_get_args();
return new static(Arr::except($this->items, $keys));
}
/** /**
* Fetch a nested element of the collection. * Fetch a nested element of the collection.
* *
@ -417,10 +433,10 @@ class Collection implements ArrayAccess, Arrayable, Countable, IteratorAggregate
} }
/** /**
* Get an array with the values of a given key. * Get the values of a given key.
* *
* @param string $value * @param string $value
* @param string $key * @param string|null $key
* @return static * @return static
*/ */
public function pluck($value, $key = null) public function pluck($value, $key = null)
@ -432,7 +448,7 @@ class Collection implements ArrayAccess, Arrayable, Countable, IteratorAggregate
* Alias for the "pluck" method. * Alias for the "pluck" method.
* *
* @param string $value * @param string $value
* @param string $key * @param string|null $key
* @return static * @return static
*/ */
public function lists($value, $key = null) public function lists($value, $key = null)
@ -455,6 +471,17 @@ class Collection implements ArrayAccess, Arrayable, Countable, IteratorAggregate
return new static(array_combine($keys, $items)); return new static(array_combine($keys, $items));
} }
/**
* Map a collection and flatten the result by a single level.
*
* @param callable $callback
* @return static
*/
public function flatMap(callable $callback)
{
return $this->map($callback)->collapse();
}
/** /**
* Get the max value of a given key. * Get the max value of a given key.
* *
@ -496,6 +523,19 @@ class Collection implements ArrayAccess, Arrayable, Countable, IteratorAggregate
}); });
} }
/**
* Get the items with the specified keys.
*
* @param mixed $keys
* @return static
*/
public function only($keys)
{
$keys = is_array($keys) ? $keys : func_get_args();
return new static(Arr::only($this->items, $keys));
}
/** /**
* "Paginate" the collection by slicing it into a smaller collection. * "Paginate" the collection by slicing it into a smaller collection.
* *
@ -522,11 +562,12 @@ class Collection implements ArrayAccess, Arrayable, Countable, IteratorAggregate
* Push an item onto the beginning of the collection. * Push an item onto the beginning of the collection.
* *
* @param mixed $value * @param mixed $value
* @param mixed $key
* @return $this * @return $this
*/ */
public function prepend($value) public function prepend($value, $key = null)
{ {
array_unshift($this->items, $value); $this->items = Arr::prepend($this->items, $value, $key);
return $this; return $this;
} }

View File

@ -15,8 +15,12 @@ class Dumper
*/ */
public function dump($value) public function dump($value)
{ {
if (class_exists(CliDumper::class)) {
$dumper = 'cli' === PHP_SAPI ? new CliDumper : new HtmlDumper; $dumper = 'cli' === PHP_SAPI ? new CliDumper : new HtmlDumper;
$dumper->dump((new VarCloner)->cloneVar($value)); $dumper->dump((new VarCloner)->cloneVar($value));
} else {
var_dump($value);
}
} }
} }

View File

@ -64,6 +64,8 @@ abstract class Facade
{ {
static::$resolvedInstance[$name] = $mock = static::createMockByName($name); static::$resolvedInstance[$name] = $mock = static::createMockByName($name);
$mock->shouldAllowMockingProtectedMethods();
if (isset(static::$app)) { if (isset(static::$app)) {
static::$app->instance($name, $mock); static::$app->instance($name, $mock);
} }

View File

@ -24,6 +24,9 @@ class Pluralizer
'fish', 'fish',
'gold', 'gold',
'information', 'information',
'knowledge',
'love',
'rain',
'money', 'money',
'moose', 'moose',
'offspring', 'offspring',

View File

@ -33,7 +33,7 @@ class ViewErrorBag implements Countable
*/ */
public function getBag($key) public function getBag($key)
{ {
return Arr::get($this->bags, $key, new MessageBag); return Arr::get($this->bags, $key) ?: new MessageBag;
} }
/** /**
@ -90,7 +90,7 @@ class ViewErrorBag implements Countable
*/ */
public function __get($key) public function __get($key)
{ {
return Arr::get($this->bags, $key, new MessageBag); return $this->getBag($key);
} }
/** /**
@ -102,6 +102,6 @@ class ViewErrorBag implements Countable
*/ */
public function __set($key, $value) public function __set($key, $value)
{ {
Arr::set($this->bags, $key, $value); $this->put($key, $value);
} }
} }

View File

@ -35,8 +35,8 @@
}, },
"suggest": { "suggest": {
"jeremeamia/superclosure": "Required to be able to serialize closures (~2.0).", "jeremeamia/superclosure": "Required to be able to serialize closures (~2.0).",
"paragonie/random_compat": "Provides a compatible interface like PHP7's random_bytes() in PHP 5 projects (^1.0.6).", "paragonie/random_compat": "Provides a compatible interface like PHP7's random_bytes() in PHP 5 projects (~1.1).",
"symfony/var-dumper": "Required to use the dd function (2.7.*)." "symfony/var-dumper": "Improves the dd function (2.7.*)."
}, },
"minimum-stability": "dev" "minimum-stability": "dev"
} }

View File

@ -62,7 +62,7 @@ if (! function_exists('array_collapse')) {
/** /**
* Collapse an array of arrays into a single array. * Collapse an array of arrays into a single array.
* *
* @param array|\ArrayAccess $array * @param \ArrayAccess|array $array
* @return array * @return array
*/ */
function array_collapse($array) function array_collapse($array)
@ -243,6 +243,21 @@ if (! function_exists('array_pluck')) {
} }
} }
if (! function_exists('array_prepend')) {
/**
* Push an item onto the beginning of an array.
*
* @param array $array
* @param mixed $value
* @param mixed $key
* @return array
*/
function array_prepend($array, $value, $key = null)
{
return Arr::prepend($array, $value, $key);
}
}
if (! function_exists('array_pull')) { if (! function_exists('array_pull')) {
/** /**
* Get a value from the array, and remove it. * Get a value from the array, and remove it.
@ -442,7 +457,7 @@ if (! function_exists('e')) {
/** /**
* Escape HTML entities in a string. * Escape HTML entities in a string.
* *
* @param \Illuminate\Support\Htmlable|string $value * @param \Illuminate\Contracts\Support\Htmlable|string $value
* @return string * @return string
*/ */
function e($value) function e($value)

View File

@ -51,16 +51,29 @@ class Translator extends NamespacedItemResolver implements TranslatorInterface
$this->locale = $locale; $this->locale = $locale;
} }
/**
* Determine if a translation exists for a given locale.
*
* @param string $key
* @param string|null $locale
* @return bool
*/
public function hasForLocale($key, $locale = null)
{
return $this->has($key, $locale, false);
}
/** /**
* Determine if a translation exists. * Determine if a translation exists.
* *
* @param string $key * @param string $key
* @param string $locale * @param string|null $locale
* @param bool $fallback
* @return bool * @return bool
*/ */
public function has($key, $locale = null) public function has($key, $locale = null, $fallback = true)
{ {
return $this->get($key, [], $locale) !== $key; return $this->get($key, [], $locale, $fallback) !== $key;
} }
/** /**
@ -68,17 +81,20 @@ class Translator extends NamespacedItemResolver implements TranslatorInterface
* *
* @param string $key * @param string $key
* @param array $replace * @param array $replace
* @param string $locale * @param string|null $locale
* @param bool $fallback
* @return string * @return string
*/ */
public function get($key, array $replace = [], $locale = null) public function get($key, array $replace = [], $locale = null, $fallback = true)
{ {
list($namespace, $group, $item) = $this->parseKey($key); list($namespace, $group, $item) = $this->parseKey($key);
// Here we will get the locale that should be used for the language line. If one // Here we will get the locale that should be used for the language line. If one
// was not passed, we will use the default locales which was given to us when // was not passed, we will use the default locales which was given to us when
// the translator was instantiated. Then, we can load the lines and return. // the translator was instantiated. Then, we can load the lines and return.
foreach ($this->parseLocale($locale) as $locale) { $locales = $fallback ? $this->parseLocale($locale) : [$locale ?: $this->locale];
foreach ($locales as $locale) {
$this->load($namespace, $group, $locale); $this->load($namespace, $group, $locale);
$line = $this->getLine( $line = $this->getLine(

View File

@ -147,7 +147,7 @@ class Validator implements ValidatorContract
* @var array * @var array
*/ */
protected $implicitRules = [ protected $implicitRules = [
'Required', 'RequiredWith', 'RequiredWithAll', 'RequiredWithout', 'RequiredWithoutAll', 'RequiredIf', 'Accepted', 'Required', 'RequiredWith', 'RequiredWithAll', 'RequiredWithout', 'RequiredWithoutAll', 'RequiredIf', 'RequiredUnless', 'Accepted',
]; ];
/** /**
@ -685,6 +685,29 @@ class Validator implements ValidatorContract
return true; return true;
} }
/**
* Validate that an attribute exists when another attribute does not have a given value.
*
* @param string $attribute
* @param mixed $value
* @param mixed $parameters
* @return bool
*/
protected function validateRequiredUnless($attribute, $value, $parameters)
{
$this->requireParameterCount(2, $parameters, 'required_unless');
$data = Arr::get($this->data, $parameters[0]);
$values = array_slice($parameters, 1);
if (! in_array($data, $values)) {
return $this->validateRequired($attribute, $value);
}
return true;
}
/** /**
* Get the number of attributes in a list that are present. * Get the number of attributes in a list that are present.
* *
@ -1212,9 +1235,11 @@ class Validator implements ValidatorContract
*/ */
protected function validateActiveUrl($attribute, $value) protected function validateActiveUrl($attribute, $value)
{ {
$url = str_replace(['http://', 'https://', 'ftp://'], '', strtolower($value)); if ($url = parse_url($value, PHP_URL_HOST)) {
return count(dns_get_record($url, DNS_A | DNS_AAAA)) > 0;
}
return checkdnsrr($url, 'A'); return false;
} }
/** /**
@ -1945,6 +1970,22 @@ class Validator implements ValidatorContract
return str_replace([':other', ':value'], $parameters, $message); return str_replace([':other', ':value'], $parameters, $message);
} }
/**
* Replace all place-holders for the required_unless rule.
*
* @param string $message
* @param string $attribute
* @param string $rule
* @param array $parameters
* @return string
*/
protected function replaceRequiredUnless($message, $attribute, $rule, $parameters)
{
$other = $this->getAttribute(array_shift($parameters));
return str_replace([':other', ':values'], [$other, implode(', ', $parameters)], $message);
}
/** /**
* Replace all place-holders for the same rule. * Replace all place-holders for the same rule.
* *

View File

@ -544,6 +544,10 @@ class Factory implements FactoryContract
*/ */
public function yieldSection() public function yieldSection()
{ {
if (empty($this->sectionStack)) {
return '';
}
return $this->yieldContent($this->stopSection()); return $this->yieldContent($this->stopSection());
} }
@ -552,9 +556,14 @@ class Factory implements FactoryContract
* *
* @param bool $overwrite * @param bool $overwrite
* @return string * @return string
* @throws \InvalidArgumentException
*/ */
public function stopSection($overwrite = false) public function stopSection($overwrite = false)
{ {
if (empty($this->sectionStack)) {
throw new InvalidArgumentException('Cannot end a section without first starting one.');
}
$last = array_pop($this->sectionStack); $last = array_pop($this->sectionStack);
if ($overwrite) { if ($overwrite) {
@ -570,9 +579,14 @@ class Factory implements FactoryContract
* Stop injecting content into a section and append it. * Stop injecting content into a section and append it.
* *
* @return string * @return string
* @throws \InvalidArgumentException
*/ */
public function appendSection() public function appendSection()
{ {
if (empty($this->sectionStack)) {
throw new InvalidArgumentException('Cannot end a section without first starting one.');
}
$last = array_pop($this->sectionStack); $last = array_pop($this->sectionStack);
if (isset($this->sections[$last])) { if (isset($this->sections[$last])) {

View File

@ -53,7 +53,9 @@ class ViewServiceProvider extends ServiceProvider
*/ */
public function registerPhpEngine($resolver) public function registerPhpEngine($resolver)
{ {
$resolver->register('php', function () { return new PhpEngine; }); $resolver->register('php', function () {
return new PhpEngine;
});
} }
/** /**

View File

@ -69,14 +69,3 @@ Requirements
- PHP 5.3+ - PHP 5.3+
- PHPUnit is required to run the unit tests - PHPUnit is required to run the unit tests
- Composer is required to run the unit tests - Composer is required to run the unit tests
CHANGELOG
=========
1.0.3 (2013-11-23)
------------------
* Only set default timezone if the given $currentTime is not a DateTime instance ([#34](https://github.com/mtdowling/cron-expression/issues/34))
* Fixes issue [#28](https://github.com/mtdowling/cron-expression/issues/28) where PHP increments of ranges were failing due to PHP casting hyphens to 0
* Now supports expressions with any number of extra spaces, tabs, or newlines
* Using static instead of self in `CronExpression::factory`

Some files were not shown because too many files have changed in this diff Show More