diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index b2ea669..5124587 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers\Auth; +use Illuminate\Http\Request; use App\Http\Controllers\Controller; use Illuminate\Foundation\Auth\AuthenticatesUsers; @@ -27,6 +28,11 @@ class LoginController extends Controller */ protected $redirectTo = '/home'; + protected function credentials(Request $request) + { + return [$this->username() => $request->input($this->username()), 'password' => $request->input('password'), 'active' => 1]; + } + /** * Create a new controller instance. * diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 216211d..f0c4698 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -28,8 +28,9 @@ public function __construct() */ public function index() { - if(!Session::has('pwd')){ - Session::put('pwd','~'); + if (!Session::has('pwd')) { + Session::put('pwd', '~'); + Session::put('level', 0); } $user = user::find(Auth::id()); $level = level::find($user['level_id']); diff --git a/app/Http/Controllers/ShellContoller.php b/app/Http/Controllers/ShellContoller.php index e02fce8..7ee470b 100644 --- a/app/Http/Controllers/ShellContoller.php +++ b/app/Http/Controllers/ShellContoller.php @@ -8,7 +8,6 @@ use Illuminate\Support\Facades\Session; use Illuminate\Support\Facades\Storage; use App\Models; -use Psy\Util\Str; use Request; class ShellContoller extends Controller @@ -20,52 +19,75 @@ public function __construct() $this->middleware('auth'); } + /** + *use the arguments to find appropriate function to execute. + @param void + */ public function shell() { if (Request::ajax()) { - $req = Request::all(); $settings = ['CMD_COLOR' => '#FFA500', 'DIR_COLOR' => '#0000FF', 'WORK_DIR' => 'public/']; //whether anything was typed in the terminal if (!isset($req['method'])) { - $msg = ''; - - } - - //method exists or not + } //method exists or not elseif (!method_exists($this, $req['method'])) { - $msg = $req['method'].": command not found\nType [[;".$settings['CMD_COLOR'].";]help] for a list of available commands"; - - } - - //validate the no. of parameters passes to the method + } //validate the no. of parameters passes to the method elseif ($this->check($req)) { - if (!isset($req['args'])) { - $req['args'] = [false]; - } - return call_user_func_array( array($this, $req['method']),[$req['args'], $settings]); - - } - - else { - + return call_user_func_array(array($this, $req['method']), [$req['args'], $settings]); + } else { $msg = $req['method'].": Invalid no. of parameters"; - } return response()->json(['STS' => false, 'MSG' => $msg]); - } } - + /** + * Used for checking if the user leaves his directory + * when using command cd or edit + * + * @param [type] $command + * @param [type] $path + * @return bool + */ + public function pwd($command, $path) + { + $level = Session::get('level'); + $arr = explode('/', $path); + $len = sizeof($arr); + for ($i = 0; $i<$len; $i++) { + if ($arr[$i] === '..') { + $level--; + if ($level < 0) { + return false; + } + } elseif ($arr[$i] === '.' || $arr[$i] === '') { + } else { + $level++; + } + } + switch ($command) { + case 'cd': + Session::put('level', $level ); + break; + case 'edit': + $level = $level - 1; + break; + default: + return false; + break; + } + + return true; + } /** * CHANGE DIR: if arg is .. switch to home else switch to folder if exists @@ -77,49 +99,47 @@ public function shell() public function cd($args, $settings) { - if ($args[0] === false || $args[0] === '..' || $args[0] === '~') { - + if ($args[0] === false || $args[0] === '~') { //move to home directory Session::put('pwd', '~'); - $msg = Auth::user()['name'] . '@Castle:'. session('pwd') . '$ '; + Session::put('level', 0); + $msg = Auth::user()['name'] . '@Castle:' . session('pwd') . '$ '; $sts = true; - } elseif ($args[0] === '.') { - //Keeping it in the same directory $msg = Auth::user()['name'] . '@Castle:~$ '; - //constructing the prompt depending on directory - if (Session::get('pwd') !== '~') - $msg = $msg . "/" . session('pwd') . '$ '; + if (Session::get('pwd') !== '~') { + $msg = Auth::user()['name'] . '@Castle:~/' . session('pwd') . '$ '; + } $sts = true; - } else { + //remove / from end and begining of the argument dir + $args[0] = trim($args[0], '/'); - //ADDRESS TO Users home directory - $user_dir = $settings['WORK_DIR'] .'users/'. Auth::id(); - - //Check if the folder exists if in home - if (Session::get('pwd') === '~') { - - $user_dir = "$user_dir/$args[0]"; - if (is_dir(storage_path().'/app/'.$user_dir) && !strpos($args[0], '/')) { - - Session::put('pwd', $args[0]); - $msg = Auth::user()['name'] . '@Castle:~/' . session('pwd') . '$ '; - $sts = true; - return response()->json(['STS' => $sts, 'MSG' => $msg]); + //ADDRESS TO Users directory + $user_dir = $settings['WORK_DIR'] . 'users/' . Auth::id(); + $cd_dir = ''; - } + /*if (Session::get('pwd') !== '~') { + $cd_dir = Session::get('pwd') ."/$args[0]"; + } else { + $cd_dir = $args[0]; } - + $full_path = storage_path() . "/app/$user_dir/$cd_dir"; + + if (is_dir($full_path) && $this->pwd('cd', $args[0])) { + Session::put('pwd', $cd_dir); + $msg = Auth::user()['name'] . '@Castle:~/' . session('pwd') . '$ '; + $sts = true; + return response()->json(['STS' => $sts, 'MSG' => $msg]); + }*/ + //No Directory by that name $msg = "cd: $args[0]: No such directory"; $sts = false; } - return response()->json( ['STS'=> $sts, 'MSG' => $msg] ); - } /** @@ -135,32 +155,24 @@ public function cat($args, $settings) $user_dir = $user_dir = $settings['WORK_DIR'] .'users/'. Auth::id() . '/'; if (Session::get('pwd') !== '~') { - $user_dir = $user_dir . Session::get('pwd') . '/'; - } $user_dir = "$user_dir$args[0]"; //Check IF file exist and get content if (Storage::has($user_dir)) { - //Check if file is directory - if(!is_dir(storage_path().'/app/'.$user_dir)) { + if (!is_dir(storage_path().'/app/'.$user_dir)) { $msg = Storage::get($user_dir); - } else{ + } else { $msg = "cat: $args[0] is not a file."; } - - } else { - $msg = "cat: $args[0]: No such file"; - } return response()->json([ 'MSG' => $msg , 'STS'=> true]); - } /** @@ -175,7 +187,6 @@ public function help($args, $settings) $msg = "\nUse the following shell commands: \n[[;" . $settings['CMD_COLOR']. ";]cd] - change directory [dir_name] \n[[;" . $settings['CMD_COLOR']. ";]cat] - print file [file_name] \n[[;" . $settings['CMD_COLOR']. ";]clear] - clear the terminal \n[[;" . $settings['CMD_COLOR']. ";]edit] - open file in editor [file_name] \n[[;" . $settings['CMD_COLOR']. ";]help] - display this message \n[[;" . $settings['CMD_COLOR']. ";]ls] - list directory contents [dir_name] \n[[;" . $settings['CMD_COLOR']. ";]logout] - logout from Castle \n[[;" . $settings['CMD_COLOR']. ";]request]- request a new challenge \n[[;" . $settings['CMD_COLOR']. ";]status] - print progress \n[[;" . $settings['CMD_COLOR']. ";]submit] - submit final solution for assessment [file_name] \n[[;" . $settings['CMD_COLOR']. ";]verify] - runs tests on solution file [file_name]\n\nEditor commands\n[[;" . $settings['CMD_COLOR']. ";]Ctrl+S] - save file\n[[;" . $settings['CMD_COLOR']. ";]Ctrl+E] - exit editor"; return response()->json([ 'STS' => true, 'MSG' => $msg]); - } /** @@ -185,54 +196,45 @@ public function help($args, $settings) * @param $settings * @return \Illuminate\Http\JsonResponse */ - public function ls($args,$settings) + public function ls($args, $settings) { //calculating present directory $user_dir = $settings['WORK_DIR'].'users/'.Auth::id().'/'; - if (Session::get('pwd') !== '~' ) { - + if (Session::get('pwd') !== '~') { $user_dir = $user_dir.Session::get('pwd').'/'; - } //modify the path on which ls should operate depending on whether a dir has been passed as arg. - if ($args[0] !== false){ - + if ($args[0] !== false) { $user_dir = "$user_dir$args[0]"; - } $msg =''; - if (is_dir(storage_path().'/app/'.$user_dir) ) { - + if (is_dir(storage_path().'/app/'.$user_dir)) { $files = Storage::files($user_dir); $dirs = Storage::directories($user_dir); //add color to directory - if (sizeof($dirs) > 0) + if (sizeof($dirs) > 0) { $dirs[0] = "[[;".$settings['DIR_COLOR'].";]$dirs[0]]"; + } $all_files = array_merge($files, $dirs); //Fixing Format $count = 0; foreach ($all_files as $file) { - - if ($count !== 0){ + if ($count !== 0) { $msg = "$msg\n"; } $file = strtr($file, [$user_dir => '']); $msg = "$msg$file"; $count++; - } - } else { - $msg = "ls: $args[0]: No such directory"; - } return response()->json([ 'MSG' => $msg , 'STS'=> true]); @@ -251,30 +253,21 @@ public function request($args, $settings) //check if any directories are already present if (sizeof($list) > 0) { - $sts = false; $msg = "You can request a new challenge only after completing the current challenge. \n"; - } else { - $user_level = $this->getLevelData(); //Check the current status of user and increment it unless game is over if ($user_level['status'] === 'COMPLETED') { if ($user_level['level'] == $user_level['max_level'] && $user_level['sublevel'] == $user_level['max_sublevel']) { - $msg = 'No more challenges. You did it.'; return response()->json(['STS' => false, 'MSG' => $msg]); - } elseif ($user_level['sublevel'] == $user_level['max_sublevel']) { - $user_level['sublevel'] = 1; $user_level['level']++; - } else { - $user_level['sublevel']++; - } } @@ -299,7 +292,6 @@ public function request($args, $settings) error_log("TIMR CALCULATED".$time); $sts = true; $msg = 'New challenge added.'; - } return response()->json(['STS' => $sts, 'MSG' => $msg, 'TIME' => $time]); @@ -333,30 +325,33 @@ public function status($args, $settings) //for current level if ($user_level['level'] != 0) { - - if ($user_level['status'] != 'COMPLETED') + if ($user_level['status'] != 'COMPLETED') { $user_level['sublevel']--; + } $per = round($user_level['sublevel'] * 100 / $user_level['max_sublevel']); //to apply color if 100% - if ($per == 100) + if ($per == 100) { $msg = $msg.'[[;#00e575;]'; + } $msg = $msg.'Level '.$user_level['level'].' '.str_pad("$per%", 5, ' ', STR_PAD_RIGHT); $msg = $msg.'['; for ($i = 1; $i <= 20; $i++) { - if ($i <= $per/5) + if ($i <= $per/5) { $msg = $msg.'='; - else + } else { $msg = $msg.'.'; + } } - if ($per == 100) + if ($per == 100) { $msg = $msg."\]\n"; - else + } else { $msg = $msg."]\n"; + } //$msg = "$msg\n"; } @@ -382,7 +377,6 @@ public function submit($args, $settings) //check if verification was successful if ($output['STS'] == true) { - $sts = true; $msg = 'Solution submitted successfully'; $full_path = storage_path().'/app/'.$settings['WORK_DIR']; @@ -396,13 +390,9 @@ public function submit($args, $settings) $user->status = 'COMPLETED'; $user->save(); //add code for removing countdown - - } - else { - + } else { $sts = false; $msg = 'Solution can be submitted only after successful verification'; - } return response()->json(['STS' => $sts, 'MSG' => $msg]); @@ -425,7 +415,6 @@ public function verify($args, $settings) $user_dir = "$user_dir$args[0]"; if (Storage::has($user_dir)) { if (strpos($args[0], 'solution') !== false) { - $level_id = Models\user::find(Auth::id())->level_id; $question_name = Models\level::find($level_id)->name; $full_path = storage_path() . "/app/" . $settings['WORK_DIR']; @@ -435,19 +424,13 @@ public function verify($args, $settings) $output_array = explode("\n", $output); //check the result of execution, if execution has failed or not if ($output_array[0] == 'FAIL') { - $msg = "[[;#FF0000;]$output_array[1]]"; - } else { - //successfull execution, no. of test cases satisfied if ($output_array[1] == '1111111111') { - $msg = "All test cases passed"; $sts = true; - } else { - $msg = "\n"; //customizing color for each test case depending on pass/fail @@ -461,16 +444,12 @@ public function verify($args, $settings) } } } else { - $sts = false; $msg = "./$args[0]: Permission denied"; - } } else { - $sts = false; $msg = "verify: $args[0]: No such file"; - } return response()->json(['STS' => $sts, 'MSG' => $msg]); @@ -509,20 +488,23 @@ function check($req) case 'logout': case 'request': case 'status': - if (!isset($req['args'])) + if (!isset($req['args'])) { return true; + } break; case 'ls': case 'cd': - if (!isset($req['args']) || sizeof($req['args']) <= 1) + if (!isset($req['args']) || sizeof($req['args']) <= 1) { return true; + } break; case 'cat': case 'verify': case 'submit': case 'edit': - if (isset($req['args']) && sizeof($req['args']) == 1) + if (isset($req['args']) && sizeof($req['args']) == 1) { return true; + } break; } return false; @@ -538,27 +520,24 @@ function check($req) public function logout($args, $settings) { if ($args[0] === false) { - Auth::logout(); Session::flush(); return response()->json(['MSG' => 'logged out', 'STS' => true]); - } return response()->json(['MSG' => 'invalid argument', 'STS' => false]); } - public function edit($args, $settings) + public function edit($args, $settings) { $msg = 'No Such File'; $sts = false; $file = false; - if ( $args[0] !== false && !isset($args[1])) { + if ($args[0] !== false && !isset($args[1]) && $this->pwd('edit', $args[0])) { if (strpos($args[0], 'solution') !== false) { - //calculating present directory $user_dir = $settings['WORK_DIR'] . 'users/' . Auth::id() . '/'; if (Session::get('pwd') !== '~') { @@ -567,24 +546,18 @@ public function edit($args, $settings) $user_dir = "$user_dir$args[0]"; if (Storage::has($user_dir)) { - $msg = Storage::get($user_dir); $file = $user_dir; $sts = true; - } } else { - $msg = '[[;#FF0000;]File not editable]'; $sts = false; $file = ''; - } //$msg = $user_dir; } return response()->json(['MSG' => $msg, 'STS' => $sts, 'FILE' => $file]); - } - } diff --git a/vendor/doctrine/instantiator/.gitignore b/vendor/doctrine/instantiator/.gitignore new file mode 100644 index 0000000..e3e368d --- /dev/null +++ b/vendor/doctrine/instantiator/.gitignore @@ -0,0 +1,5 @@ +phpunit.xml +composer.lock +build +vendor +coverage.clover diff --git a/vendor/doctrine/instantiator/.scrutinizer.yml b/vendor/doctrine/instantiator/.scrutinizer.yml new file mode 100644 index 0000000..aad5e40 --- /dev/null +++ b/vendor/doctrine/instantiator/.scrutinizer.yml @@ -0,0 +1,46 @@ +before_commands: + - "composer install --prefer-source" + +tools: + external_code_coverage: + timeout: 600 + php_code_coverage: + enabled: true + test_command: ./vendor/bin/phpunit + php_code_sniffer: + enabled: true + config: + standard: PSR2 + filter: + paths: ["src/*", "tests/*"] + php_cpd: + enabled: true + excluded_dirs: ["build/*", "tests", "vendor"] + php_cs_fixer: + enabled: true + config: + level: all + filter: + paths: ["src/*", "tests/*"] + php_loc: + enabled: true + excluded_dirs: ["build", "tests", "vendor"] + php_mess_detector: + enabled: true + config: + ruleset: phpmd.xml.dist + design_rules: { eval_expression: false } + filter: + paths: ["src/*"] + php_pdepend: + enabled: true + excluded_dirs: ["build", "tests", "vendor"] + php_analyzer: + enabled: true + filter: + paths: ["src/*", "tests/*"] + php_hhvm: + enabled: true + filter: + paths: ["src/*", "tests/*"] + sensiolabs_security_checker: true diff --git a/vendor/doctrine/instantiator/.travis.install.sh b/vendor/doctrine/instantiator/.travis.install.sh new file mode 100755 index 0000000..2819188 --- /dev/null +++ b/vendor/doctrine/instantiator/.travis.install.sh @@ -0,0 +1,14 @@ +#!/bin/sh +set -x +if [ "$TRAVIS_PHP_VERSION" = 'hhvm' ] || [ "$TRAVIS_PHP_VERSION" = 'hhvm-nightly' ] ; then + curl -sS https://getcomposer.org/installer > composer-installer.php + hhvm composer-installer.php + hhvm -v ResourceLimit.SocketDefaultTimeout=30 -v Http.SlowQueryThreshold=30000 composer.phar update --prefer-source +elif [ "$TRAVIS_PHP_VERSION" = '5.3.3' ] ; then + composer self-update + composer update --prefer-source --no-dev + composer dump-autoload +else + composer self-update + composer update --prefer-source +fi diff --git a/vendor/doctrine/instantiator/.travis.yml b/vendor/doctrine/instantiator/.travis.yml new file mode 100644 index 0000000..7f1ec5f --- /dev/null +++ b/vendor/doctrine/instantiator/.travis.yml @@ -0,0 +1,22 @@ +language: php + +php: + - 5.3.3 + - 5.3 + - 5.4 + - 5.5 + - 5.6 + - hhvm + +before_script: + - ./.travis.install.sh + - if [ $TRAVIS_PHP_VERSION = '5.6' ]; then PHPUNIT_FLAGS="--coverage-clover coverage.clover"; else PHPUNIT_FLAGS=""; fi + +script: + - if [ $TRAVIS_PHP_VERSION = '5.3.3' ]; then phpunit; fi + - if [ $TRAVIS_PHP_VERSION != '5.3.3' ]; then ./vendor/bin/phpunit $PHPUNIT_FLAGS; fi + - if [ $TRAVIS_PHP_VERSION != '5.3.3' ]; then ./vendor/bin/phpcs --standard=PSR2 ./src/ ./tests/; fi + - if [[ $TRAVIS_PHP_VERSION != '5.3.3' && $TRAVIS_PHP_VERSION != '5.4.29' && $TRAVIS_PHP_VERSION != '5.5.13' ]]; then php -n ./vendor/bin/athletic -p ./tests/DoctrineTest/InstantiatorPerformance/ -f GroupedFormatter; fi + +after_script: + - if [ $TRAVIS_PHP_VERSION = '5.6' ]; then wget https://scrutinizer-ci.com/ocular.phar; php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi diff --git a/vendor/doctrine/instantiator/phpmd.xml.dist b/vendor/doctrine/instantiator/phpmd.xml.dist new file mode 100644 index 0000000..8254105 --- /dev/null +++ b/vendor/doctrine/instantiator/phpmd.xml.dist @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + diff --git a/vendor/doctrine/instantiator/phpunit.xml.dist b/vendor/doctrine/instantiator/phpunit.xml.dist new file mode 100644 index 0000000..0a8d570 --- /dev/null +++ b/vendor/doctrine/instantiator/phpunit.xml.dist @@ -0,0 +1,22 @@ + + + + ./tests/DoctrineTest/InstantiatorTest + + + + ./src + + + diff --git a/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorPerformance/InstantiatorPerformanceEvent.php b/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorPerformance/InstantiatorPerformanceEvent.php new file mode 100644 index 0000000..3e8fc6f --- /dev/null +++ b/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorPerformance/InstantiatorPerformanceEvent.php @@ -0,0 +1,96 @@ +. + */ + +namespace DoctrineTest\InstantiatorPerformance; + +use Athletic\AthleticEvent; +use Doctrine\Instantiator\Instantiator; + +/** + * Performance tests for {@see \Doctrine\Instantiator\Instantiator} + * + * @author Marco Pivetta + */ +class InstantiatorPerformanceEvent extends AthleticEvent +{ + /** + * @var \Doctrine\Instantiator\Instantiator + */ + private $instantiator; + + /** + * {@inheritDoc} + */ + protected function setUp() + { + $this->instantiator = new Instantiator(); + + $this->instantiator->instantiate(__CLASS__); + $this->instantiator->instantiate('ArrayObject'); + $this->instantiator->instantiate('DoctrineTest\\InstantiatorTestAsset\\SimpleSerializableAsset'); + $this->instantiator->instantiate('DoctrineTest\\InstantiatorTestAsset\\SerializableArrayObjectAsset'); + $this->instantiator->instantiate('DoctrineTest\\InstantiatorTestAsset\\UnCloneableAsset'); + } + + /** + * @iterations 20000 + * @baseline + * @group instantiation + */ + public function testInstantiateSelf() + { + $this->instantiator->instantiate(__CLASS__); + } + + /** + * @iterations 20000 + * @group instantiation + */ + public function testInstantiateInternalClass() + { + $this->instantiator->instantiate('ArrayObject'); + } + + /** + * @iterations 20000 + * @group instantiation + */ + public function testInstantiateSimpleSerializableAssetClass() + { + $this->instantiator->instantiate('DoctrineTest\\InstantiatorTestAsset\\SimpleSerializableAsset'); + } + + /** + * @iterations 20000 + * @group instantiation + */ + public function testInstantiateSerializableArrayObjectAsset() + { + $this->instantiator->instantiate('DoctrineTest\\InstantiatorTestAsset\\SerializableArrayObjectAsset'); + } + + /** + * @iterations 20000 + * @group instantiation + */ + public function testInstantiateUnCloneableAsset() + { + $this->instantiator->instantiate('DoctrineTest\\InstantiatorTestAsset\\UnCloneableAsset'); + } +} diff --git a/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTest/Exception/InvalidArgumentExceptionTest.php b/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTest/Exception/InvalidArgumentExceptionTest.php new file mode 100644 index 0000000..39d9b94 --- /dev/null +++ b/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTest/Exception/InvalidArgumentExceptionTest.php @@ -0,0 +1,83 @@ +. + */ + +namespace DoctrineTest\InstantiatorTest\Exception; + +use Doctrine\Instantiator\Exception\InvalidArgumentException; +use PHPUnit_Framework_TestCase; +use ReflectionClass; + +/** + * Tests for {@see \Doctrine\Instantiator\Exception\InvalidArgumentException} + * + * @author Marco Pivetta + * + * @covers \Doctrine\Instantiator\Exception\InvalidArgumentException + */ +class InvalidArgumentExceptionTest extends PHPUnit_Framework_TestCase +{ + public function testFromNonExistingTypeWithNonExistingClass() + { + $className = __CLASS__ . uniqid(); + $exception = InvalidArgumentException::fromNonExistingClass($className); + + $this->assertInstanceOf('Doctrine\\Instantiator\\Exception\\InvalidArgumentException', $exception); + $this->assertSame('The provided class "' . $className . '" does not exist', $exception->getMessage()); + } + + public function testFromNonExistingTypeWithTrait() + { + if (PHP_VERSION_ID < 50400) { + $this->markTestSkipped('Need at least PHP 5.4.0, as this test requires traits support to run'); + } + + $exception = InvalidArgumentException::fromNonExistingClass( + 'DoctrineTest\\InstantiatorTestAsset\\SimpleTraitAsset' + ); + + $this->assertSame( + 'The provided type "DoctrineTest\\InstantiatorTestAsset\\SimpleTraitAsset" is a trait, ' + . 'and can not be instantiated', + $exception->getMessage() + ); + } + + public function testFromNonExistingTypeWithInterface() + { + $exception = InvalidArgumentException::fromNonExistingClass('Doctrine\\Instantiator\\InstantiatorInterface'); + + $this->assertSame( + 'The provided type "Doctrine\\Instantiator\\InstantiatorInterface" is an interface, ' + . 'and can not be instantiated', + $exception->getMessage() + ); + } + + public function testFromAbstractClass() + { + $reflection = new ReflectionClass('DoctrineTest\\InstantiatorTestAsset\\AbstractClassAsset'); + $exception = InvalidArgumentException::fromAbstractClass($reflection); + + $this->assertSame( + 'The provided class "DoctrineTest\\InstantiatorTestAsset\\AbstractClassAsset" is abstract, ' + . 'and can not be instantiated', + $exception->getMessage() + ); + } +} diff --git a/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTest/Exception/UnexpectedValueExceptionTest.php b/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTest/Exception/UnexpectedValueExceptionTest.php new file mode 100644 index 0000000..84154e7 --- /dev/null +++ b/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTest/Exception/UnexpectedValueExceptionTest.php @@ -0,0 +1,69 @@ +. + */ + +namespace DoctrineTest\InstantiatorTest\Exception; + +use Doctrine\Instantiator\Exception\UnexpectedValueException; +use Exception; +use PHPUnit_Framework_TestCase; +use ReflectionClass; + +/** + * Tests for {@see \Doctrine\Instantiator\Exception\UnexpectedValueException} + * + * @author Marco Pivetta + * + * @covers \Doctrine\Instantiator\Exception\UnexpectedValueException + */ +class UnexpectedValueExceptionTest extends PHPUnit_Framework_TestCase +{ + public function testFromSerializationTriggeredException() + { + $reflectionClass = new ReflectionClass($this); + $previous = new Exception(); + $exception = UnexpectedValueException::fromSerializationTriggeredException($reflectionClass, $previous); + + $this->assertInstanceOf('Doctrine\\Instantiator\\Exception\\UnexpectedValueException', $exception); + $this->assertSame($previous, $exception->getPrevious()); + $this->assertSame( + 'An exception was raised while trying to instantiate an instance of "' + . __CLASS__ . '" via un-serialization', + $exception->getMessage() + ); + } + + public function testFromUncleanUnSerialization() + { + $reflection = new ReflectionClass('DoctrineTest\\InstantiatorTestAsset\\AbstractClassAsset'); + $exception = UnexpectedValueException::fromUncleanUnSerialization($reflection, 'foo', 123, 'bar', 456); + + $this->assertInstanceOf('Doctrine\\Instantiator\\Exception\\UnexpectedValueException', $exception); + $this->assertSame( + 'Could not produce an instance of "DoctrineTest\\InstantiatorTestAsset\\AbstractClassAsset" ' + . 'via un-serialization, since an error was triggered in file "bar" at line "456"', + $exception->getMessage() + ); + + $previous = $exception->getPrevious(); + + $this->assertInstanceOf('Exception', $previous); + $this->assertSame('foo', $previous->getMessage()); + $this->assertSame(123, $previous->getCode()); + } +} diff --git a/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTest/InstantiatorTest.php b/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTest/InstantiatorTest.php new file mode 100644 index 0000000..0a2cb93 --- /dev/null +++ b/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTest/InstantiatorTest.php @@ -0,0 +1,219 @@ +. + */ + +namespace DoctrineTest\InstantiatorTest; + +use Doctrine\Instantiator\Exception\UnexpectedValueException; +use Doctrine\Instantiator\Instantiator; +use PHPUnit_Framework_TestCase; +use ReflectionClass; + +/** + * Tests for {@see \Doctrine\Instantiator\Instantiator} + * + * @author Marco Pivetta + * + * @covers \Doctrine\Instantiator\Instantiator + */ +class InstantiatorTest extends PHPUnit_Framework_TestCase +{ + /** + * @var Instantiator + */ + private $instantiator; + + /** + * {@inheritDoc} + */ + protected function setUp() + { + $this->instantiator = new Instantiator(); + } + + /** + * @param string $className + * + * @dataProvider getInstantiableClasses + */ + public function testCanInstantiate($className) + { + $this->assertInstanceOf($className, $this->instantiator->instantiate($className)); + } + + /** + * @param string $className + * + * @dataProvider getInstantiableClasses + */ + public function testInstantiatesSeparateInstances($className) + { + $instance1 = $this->instantiator->instantiate($className); + $instance2 = $this->instantiator->instantiate($className); + + $this->assertEquals($instance1, $instance2); + $this->assertNotSame($instance1, $instance2); + } + + public function testExceptionOnUnSerializationException() + { + if (defined('HHVM_VERSION')) { + $this->markTestSkipped( + 'As of facebook/hhvm#3432, HHVM has no PDORow, and therefore ' + . ' no internal final classes that cannot be instantiated' + ); + } + + $className = 'DoctrineTest\\InstantiatorTestAsset\\UnserializeExceptionArrayObjectAsset'; + + if (\PHP_VERSION_ID >= 50600) { + $className = 'PDORow'; + } + + if (\PHP_VERSION_ID === 50429 || \PHP_VERSION_ID === 50513) { + $className = 'DoctrineTest\\InstantiatorTestAsset\\SerializableArrayObjectAsset'; + } + + $this->setExpectedException('Doctrine\\Instantiator\\Exception\\UnexpectedValueException'); + + $this->instantiator->instantiate($className); + } + + public function testNoticeOnUnSerializationException() + { + if (\PHP_VERSION_ID >= 50600) { + $this->markTestSkipped( + 'PHP 5.6 supports `ReflectionClass#newInstanceWithoutConstructor()` for some internal classes' + ); + } + + try { + $this->instantiator->instantiate('DoctrineTest\\InstantiatorTestAsset\\WakeUpNoticesAsset'); + + $this->fail('No exception was raised'); + } catch (UnexpectedValueException $exception) { + $wakeUpNoticesReflection = new ReflectionClass('DoctrineTest\\InstantiatorTestAsset\\WakeUpNoticesAsset'); + $previous = $exception->getPrevious(); + + $this->assertInstanceOf('Exception', $previous); + + // in PHP 5.4.29 and PHP 5.5.13, this case is not a notice, but an exception being thrown + if (! (\PHP_VERSION_ID === 50429 || \PHP_VERSION_ID === 50513)) { + $this->assertSame( + 'Could not produce an instance of "DoctrineTest\\InstantiatorTestAsset\WakeUpNoticesAsset" ' + . 'via un-serialization, since an error was triggered in file "' + . $wakeUpNoticesReflection->getFileName() . '" at line "36"', + $exception->getMessage() + ); + + $this->assertSame('Something went bananas while un-serializing this instance', $previous->getMessage()); + $this->assertSame(\E_USER_NOTICE, $previous->getCode()); + } + } + } + + /** + * @param string $invalidClassName + * + * @dataProvider getInvalidClassNames + */ + public function testInstantiationFromNonExistingClass($invalidClassName) + { + $this->setExpectedException('Doctrine\\Instantiator\\Exception\\InvalidArgumentException'); + + $this->instantiator->instantiate($invalidClassName); + } + + public function testInstancesAreNotCloned() + { + $className = 'TemporaryClass' . uniqid(); + + eval('namespace ' . __NAMESPACE__ . '; class ' . $className . '{}'); + + $instance = $this->instantiator->instantiate(__NAMESPACE__ . '\\' . $className); + + $instance->foo = 'bar'; + + $instance2 = $this->instantiator->instantiate(__NAMESPACE__ . '\\' . $className); + + $this->assertObjectNotHasAttribute('foo', $instance2); + } + + /** + * Provides a list of instantiable classes (existing) + * + * @return string[][] + */ + public function getInstantiableClasses() + { + $classes = array( + array('stdClass'), + array(__CLASS__), + array('Doctrine\\Instantiator\\Instantiator'), + array('Exception'), + array('PharException'), + array('DoctrineTest\\InstantiatorTestAsset\\SimpleSerializableAsset'), + array('DoctrineTest\\InstantiatorTestAsset\\ExceptionAsset'), + array('DoctrineTest\\InstantiatorTestAsset\\FinalExceptionAsset'), + array('DoctrineTest\\InstantiatorTestAsset\\PharExceptionAsset'), + array('DoctrineTest\\InstantiatorTestAsset\\UnCloneableAsset'), + array('DoctrineTest\\InstantiatorTestAsset\\XMLReaderAsset'), + ); + + if (\PHP_VERSION_ID === 50429 || \PHP_VERSION_ID === 50513) { + return $classes; + } + + $classes = array_merge( + $classes, + array( + array('PharException'), + array('ArrayObject'), + array('DoctrineTest\\InstantiatorTestAsset\\ArrayObjectAsset'), + array('DoctrineTest\\InstantiatorTestAsset\\SerializableArrayObjectAsset'), + ) + ); + + if (\PHP_VERSION_ID >= 50600) { + $classes[] = array('DoctrineTest\\InstantiatorTestAsset\\WakeUpNoticesAsset'); + $classes[] = array('DoctrineTest\\InstantiatorTestAsset\\UnserializeExceptionArrayObjectAsset'); + } + + return $classes; + } + + /** + * Provides a list of instantiable classes (existing) + * + * @return string[][] + */ + public function getInvalidClassNames() + { + $classNames = array( + array(__CLASS__ . uniqid()), + array('Doctrine\\Instantiator\\InstantiatorInterface'), + array('DoctrineTest\\InstantiatorTestAsset\\AbstractClassAsset'), + ); + + if (\PHP_VERSION_ID >= 50400) { + $classNames[] = array('DoctrineTest\\InstantiatorTestAsset\\SimpleTraitAsset'); + } + + return $classNames; + } +} diff --git a/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTestAsset/AbstractClassAsset.php b/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTestAsset/AbstractClassAsset.php new file mode 100644 index 0000000..fbe28dd --- /dev/null +++ b/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTestAsset/AbstractClassAsset.php @@ -0,0 +1,29 @@ +. + */ + +namespace DoctrineTest\InstantiatorTestAsset; + +/** + * A simple asset for an abstract class + * + * @author Marco Pivetta + */ +abstract class AbstractClassAsset +{ +} diff --git a/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTestAsset/ArrayObjectAsset.php b/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTestAsset/ArrayObjectAsset.php new file mode 100644 index 0000000..56146d7 --- /dev/null +++ b/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTestAsset/ArrayObjectAsset.php @@ -0,0 +1,41 @@ +. + */ + +namespace DoctrineTest\InstantiatorTestAsset; + +use ArrayObject; +use BadMethodCallException; + +/** + * Test asset that extends an internal PHP class + * + * @author Marco Pivetta + */ +class ArrayObjectAsset extends ArrayObject +{ + /** + * Constructor - should not be called + * + * @throws BadMethodCallException + */ + public function __construct() + { + throw new BadMethodCallException('Not supposed to be called!'); + } +} diff --git a/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTestAsset/ExceptionAsset.php b/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTestAsset/ExceptionAsset.php new file mode 100644 index 0000000..43bbe46 --- /dev/null +++ b/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTestAsset/ExceptionAsset.php @@ -0,0 +1,41 @@ +. + */ + +namespace DoctrineTest\InstantiatorTestAsset; + +use BadMethodCallException; +use Exception; + +/** + * Test asset that extends an internal PHP base exception + * + * @author Marco Pivetta + */ +class ExceptionAsset extends Exception +{ + /** + * Constructor - should not be called + * + * @throws BadMethodCallException + */ + public function __construct() + { + throw new BadMethodCallException('Not supposed to be called!'); + } +} diff --git a/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTestAsset/FinalExceptionAsset.php b/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTestAsset/FinalExceptionAsset.php new file mode 100644 index 0000000..7d268f5 --- /dev/null +++ b/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTestAsset/FinalExceptionAsset.php @@ -0,0 +1,41 @@ +. + */ + +namespace DoctrineTest\InstantiatorTestAsset; + +use BadMethodCallException; +use Exception; + +/** + * Test asset that extends an internal PHP base exception + * + * @author Marco Pivetta + */ +final class FinalExceptionAsset extends Exception +{ + /** + * Constructor - should not be called + * + * @throws BadMethodCallException + */ + public function __construct() + { + throw new BadMethodCallException('Not supposed to be called!'); + } +} diff --git a/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTestAsset/PharAsset.php b/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTestAsset/PharAsset.php new file mode 100644 index 0000000..553fd56 --- /dev/null +++ b/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTestAsset/PharAsset.php @@ -0,0 +1,41 @@ +. + */ + +namespace DoctrineTest\InstantiatorTestAsset; + +use BadMethodCallException; +use Phar; + +/** + * Test asset that extends an internal PHP class + * + * @author Marco Pivetta + */ +class PharAsset extends Phar +{ + /** + * Constructor - should not be called + * + * @throws BadMethodCallException + */ + public function __construct() + { + throw new BadMethodCallException('Not supposed to be called!'); + } +} diff --git a/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTestAsset/PharExceptionAsset.php b/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTestAsset/PharExceptionAsset.php new file mode 100644 index 0000000..42bf73e --- /dev/null +++ b/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTestAsset/PharExceptionAsset.php @@ -0,0 +1,44 @@ +. + */ + +namespace DoctrineTest\InstantiatorTestAsset; + +use BadMethodCallException; +use PharException; + +/** + * Test asset that extends an internal PHP class + * This class should be serializable without problems + * and without getting the "Erroneous data format for unserializing" + * error + * + * @author Marco Pivetta + */ +class PharExceptionAsset extends PharException +{ + /** + * Constructor - should not be called + * + * @throws BadMethodCallException + */ + public function __construct() + { + throw new BadMethodCallException('Not supposed to be called!'); + } +} diff --git a/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTestAsset/SerializableArrayObjectAsset.php b/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTestAsset/SerializableArrayObjectAsset.php new file mode 100644 index 0000000..ba19aaf --- /dev/null +++ b/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTestAsset/SerializableArrayObjectAsset.php @@ -0,0 +1,62 @@ +. + */ + +namespace DoctrineTest\InstantiatorTestAsset; + +use ArrayObject; +use BadMethodCallException; +use Serializable; + +/** + * Serializable test asset that also extends an internal class + * + * @author Marco Pivetta + */ +class SerializableArrayObjectAsset extends ArrayObject implements Serializable +{ + /** + * Constructor - should not be called + * + * @throws BadMethodCallException + */ + public function __construct() + { + throw new BadMethodCallException('Not supposed to be called!'); + } + + /** + * {@inheritDoc} + */ + public function serialize() + { + return ''; + } + + /** + * {@inheritDoc} + * + * Should not be called + * + * @throws BadMethodCallException + */ + public function unserialize($serialized) + { + throw new BadMethodCallException('Not supposed to be called!'); + } +} diff --git a/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTestAsset/SimpleSerializableAsset.php b/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTestAsset/SimpleSerializableAsset.php new file mode 100644 index 0000000..39f84a6 --- /dev/null +++ b/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTestAsset/SimpleSerializableAsset.php @@ -0,0 +1,61 @@ +. + */ + +namespace DoctrineTest\InstantiatorTestAsset; + +use BadMethodCallException; +use Serializable; + +/** + * Base serializable test asset + * + * @author Marco Pivetta + */ +class SimpleSerializableAsset implements Serializable +{ + /** + * Constructor - should not be called + * + * @throws BadMethodCallException + */ + public function __construct() + { + throw new BadMethodCallException('Not supposed to be called!'); + } + + /** + * {@inheritDoc} + */ + public function serialize() + { + return ''; + } + + /** + * {@inheritDoc} + * + * Should not be called + * + * @throws BadMethodCallException + */ + public function unserialize($serialized) + { + throw new BadMethodCallException('Not supposed to be called!'); + } +} diff --git a/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTestAsset/SimpleTraitAsset.php b/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTestAsset/SimpleTraitAsset.php new file mode 100644 index 0000000..04e7806 --- /dev/null +++ b/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTestAsset/SimpleTraitAsset.php @@ -0,0 +1,29 @@ +. + */ + +namespace DoctrineTest\InstantiatorTestAsset; + +/** + * A simple trait with no attached logic + * + * @author Marco Pivetta + */ +trait SimpleTraitAsset +{ +} diff --git a/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTestAsset/UnCloneableAsset.php b/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTestAsset/UnCloneableAsset.php new file mode 100644 index 0000000..7d03bda --- /dev/null +++ b/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTestAsset/UnCloneableAsset.php @@ -0,0 +1,50 @@ +. + */ + +namespace DoctrineTest\InstantiatorTestAsset; + +use BadMethodCallException; + +/** + * Base un-cloneable asset + * + * @author Marco Pivetta + */ +class UnCloneableAsset +{ + /** + * Constructor - should not be called + * + * @throws BadMethodCallException + */ + public function __construct() + { + throw new BadMethodCallException('Not supposed to be called!'); + } + + /** + * Magic `__clone` - should not be invoked + * + * @throws BadMethodCallException + */ + public function __clone() + { + throw new BadMethodCallException('Not supposed to be called!'); + } +} diff --git a/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTestAsset/UnserializeExceptionArrayObjectAsset.php b/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTestAsset/UnserializeExceptionArrayObjectAsset.php new file mode 100644 index 0000000..b348a40 --- /dev/null +++ b/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTestAsset/UnserializeExceptionArrayObjectAsset.php @@ -0,0 +1,39 @@ +. + */ + +namespace DoctrineTest\InstantiatorTestAsset; + +use ArrayObject; +use BadMethodCallException; + +/** + * A simple asset for an abstract class + * + * @author Marco Pivetta + */ +class UnserializeExceptionArrayObjectAsset extends ArrayObject +{ + /** + * {@inheritDoc} + */ + public function __wakeup() + { + throw new BadMethodCallException(); + } +} diff --git a/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTestAsset/WakeUpNoticesAsset.php b/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTestAsset/WakeUpNoticesAsset.php new file mode 100644 index 0000000..18dc671 --- /dev/null +++ b/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTestAsset/WakeUpNoticesAsset.php @@ -0,0 +1,38 @@ +. + */ + +namespace DoctrineTest\InstantiatorTestAsset; + +use ArrayObject; + +/** + * A simple asset for an abstract class + * + * @author Marco Pivetta + */ +class WakeUpNoticesAsset extends ArrayObject +{ + /** + * Wakeup method called after un-serialization + */ + public function __wakeup() + { + trigger_error('Something went bananas while un-serializing this instance'); + } +} diff --git a/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTestAsset/XMLReaderAsset.php b/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTestAsset/XMLReaderAsset.php new file mode 100644 index 0000000..39ee699 --- /dev/null +++ b/vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTestAsset/XMLReaderAsset.php @@ -0,0 +1,41 @@ +. + */ + +namespace DoctrineTest\InstantiatorTestAsset; + +use BadMethodCallException; +use XMLReader; + +/** + * Test asset that extends an internal PHP class + * + * @author Dave Marshall + */ +class XMLReaderAsset extends XMLReader +{ + /** + * Constructor - should not be called + * + * @throws BadMethodCallException + */ + public function __construct() + { + throw new BadMethodCallException('Not supposed to be called!'); + } +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Auth/AuthenticatesUsers.php b/vendor/laravel/framework/src/Illuminate/Foundation/Auth/AuthenticatesUsers.php index e774e69..5ca24b3 100644 --- a/vendor/laravel/framework/src/Illuminate/Foundation/Auth/AuthenticatesUsers.php +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Auth/AuthenticatesUsers.php @@ -87,7 +87,7 @@ protected function attemptLogin(Request $request) */ protected function credentials(Request $request) { - return [$this->username() => $request->input($this->username()), 'password' => $request->input('password'), 'active' => 1]; + return [$this->username() => $request->input($this->username()), 'password' => $request->input('password')]; } /** diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Console/ExceptionMakeCommand.php b/vendor/laravel/framework/src/Illuminate/Foundation/Console/ExceptionMakeCommand.php new file mode 100644 index 0000000..d81476d --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Console/ExceptionMakeCommand.php @@ -0,0 +1,84 @@ +option('render')) { + return $this->option('report') + ? __DIR__.'/stubs/exception-render-report.stub' + : __DIR__.'/stubs/exception-render.stub'; + } + + return $this->option('report') + ? __DIR__.'/stubs/exception-report.stub' + : __DIR__.'/stubs/exception.stub'; + } + + /** + * Determine if the class already exists. + * + * @param string $rawName + * @return bool + */ + protected function alreadyExists($rawName) + { + return class_exists($this->rootNamespace().'Exceptions\\'.$rawName); + } + + /** + * Get the default namespace for the class. + * + * @param string $rootNamespace + * @return string + */ + protected function getDefaultNamespace($rootNamespace) + { + return $rootNamespace.'\Exceptions'; + } + + /** + * Get the console command options. + * + * @return array + */ + protected function getOptions() + { + return [ + ['render', null, InputOption::VALUE_NONE, 'Create the exception with an empty render method.'], + + ['report', null, InputOption::VALUE_NONE, 'Create the exception with an empty report method.'], + ]; + } +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Console/stubs/exception-render-report.stub b/vendor/laravel/framework/src/Illuminate/Foundation/Console/stubs/exception-render-report.stub new file mode 100644 index 0000000..cf877ec --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Console/stubs/exception-render-report.stub @@ -0,0 +1,29 @@ + $value) { + $index++; + + if (is_array($value)) { + $data[$key] = $this->filter($value); + + continue; + } + + if (is_numeric($key) && $value instanceof MergeValue) { + return $this->merge($data, $index, $this->filter($value->data)); + } + + if (($value instanceof PotentiallyMissing && $value->isMissing()) || + ($value instanceof self && + $value->resource instanceof PotentiallyMissing && + $value->isMissing())) { + unset($data[$key]); + + $index--; + } + + if ($value instanceof self && is_null($value->resource)) { + $data[$key] = null; + } + } + + return $data; + } + + /** + * Merge the given data in at the given index. + * + * @param array $data + * @param int $index + * @param array $merge + * @return array + */ + protected function merge($data, $index, $merge) + { + if (array_values($data) === $data) { + return array_merge( + array_merge(array_slice($data, 0, $index, true), $merge), + $this->filter(array_slice($data, $index + 1, null, true)) + ); + } + + return array_slice($data, 0, $index, true) + + $merge + + $this->filter(array_slice($data, $index + 1, null, true)); + } + + /** + * Retrieve a value based on a given condition. + * + * @param bool $condition + * @param mixed $value + * @param mixed $default + * @return \Illuminate\Http\Resources\MissingValue|mixed + */ + protected function when($condition, $value, $default = null) + { + if ($condition) { + return value($value); + } + + return func_num_args() === 3 ? value($default) : new MissingValue; + } + + /** + * Merge a value based on a given condition. + * + * @param bool $condition + * @param mixed $value + * @return \Illuminate\Http\Resources\MissingValue|mixed + */ + protected function mergeWhen($condition, $value) + { + return $condition ? new MergeValue(value($value)) : new MissingValue; + } + + /** + * Merge the given attributes. + * + * @param array $attributes + * @return \Illuminate\Http\Resources\MergeValue + */ + protected function attributes($attributes) + { + return new MergeValue( + Arr::only($this->resource->toArray(), $attributes) + ); + } + + /** + * Retrieve a relationship if it has been loaded. + * + * @param string $relationship + * @param mixed $value + * @param mixed $default + * @return \Illuminate\Http\Resources\MissingValue|mixed + */ + protected function whenLoaded($relationship, $value = null, $default = null) + { + if (func_num_args() < 3) { + $default = new MissingValue; + } + + if (! $this->resource->relationLoaded($relationship)) { + return $default; + } + + if (func_num_args() === 1) { + return $this->resource->{$relationship}; + } + + if ($this->resource->{$relationship} === null) { + return null; + } + + return value($value); + } + + /** + * Execute a callback if the given pivot table has been loaded. + * + * @param string $table + * @param mixed $value + * @param mixed $default + * @return \Illuminate\Http\Resources\MissingValue|mixed + */ + protected function whenPivotLoaded($table, $value, $default = null) + { + if (func_num_args() === 2) { + $default = new MissingValue; + } + + return $this->when( + $this->resource->pivot && + ($this->resource->pivot instanceof $table || + $this->resource->pivot->getTable() === $table), + ...[$value, $default] + ); + } + + /** + * Transform the given value if it is present. + * + * @param mixed $value + * @param callable $callback + * @param mixed $default + * @return mixed + */ + protected function transform($value, callable $callback, $default = null) + { + return transform( + $value, $callback, func_num_args() === 3 ? $default : new MissingValue + ); + } +} diff --git a/vendor/laravel/framework/src/Illuminate/Http/Resources/Json/AnonymousResourceCollection.php b/vendor/laravel/framework/src/Illuminate/Http/Resources/Json/AnonymousResourceCollection.php new file mode 100644 index 0000000..a583136 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Http/Resources/Json/AnonymousResourceCollection.php @@ -0,0 +1,27 @@ +collects = $collects; + + parent::__construct($resource); + } +} diff --git a/vendor/laravel/framework/src/Illuminate/Http/Resources/PotentiallyMissing.php b/vendor/laravel/framework/src/Illuminate/Http/Resources/PotentiallyMissing.php new file mode 100644 index 0000000..6ed7f3c --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Http/Resources/PotentiallyMissing.php @@ -0,0 +1,13 @@ +stripParentheses($expression)); + + $options = $parts[1] ?? 0; + + $depth = $parts[2] ?? 512; + + return ""; + } +} diff --git a/vendor/nikic/php-parser/test/code/parser/stmt/namespace/commentAfterNamespace.test b/vendor/nikic/php-parser/test/code/parser/stmt/namespace/commentAfterNamespace.test new file mode 100644 index 0000000..3f379b7 --- /dev/null +++ b/vendor/nikic/php-parser/test/code/parser/stmt/namespace/commentAfterNamespace.test @@ -0,0 +1,22 @@ +Trailing comment after braced namespace declaration +----- + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\Framework; + +trait TestListenerDefaultImplementation +{ + public function addError(Test $test, \Exception $e, $time) + { + } + + public function addWarning(Test $test, Warning $e, $time) + { + } + + public function addFailure(Test $test, AssertionFailedError $e, $time) + { + } + + public function addIncompleteTest(Test $test, \Exception $e, $time) + { + } + + public function addRiskyTest(Test $test, \Exception $e, $time) + { + } + + public function addSkippedTest(Test $test, \Exception $e, $time) + { + } + + public function startTestSuite(TestSuite $suite) + { + } + + public function endTestSuite(TestSuite $suite) + { + } + + public function startTest(Test $test) + { + } + + public function endTest(Test $test, $time) + { + } +} diff --git a/vendor/phpunit/phpunit/src/Util/TextTestListRenderer.php b/vendor/phpunit/phpunit/src/Util/TextTestListRenderer.php new file mode 100644 index 0000000..4ee6ac7 --- /dev/null +++ b/vendor/phpunit/phpunit/src/Util/TextTestListRenderer.php @@ -0,0 +1,44 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace PHPUnit\Util; + +use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\TestSuite; +use PHPUnit\Runner\PhptTestCase; + +class TextTestListRenderer +{ + public function render(TestSuite $suite): string + { + $buffer = 'Available test(s):' . PHP_EOL; + + foreach (new \RecursiveIteratorIterator($suite->getIterator()) as $test) { + if ($test instanceof TestCase) { + $name = \sprintf( + '%s::%s', + \get_class($test), + \str_replace(' with data set ', '', $test->getName()) + ); + } elseif ($test instanceof PhptTestCase) { + $name = $test->getName(); + } else { + continue; + } + + $buffer .= \sprintf( + ' - %s' . PHP_EOL, + $name + ); + } + + return $buffer; + } +} diff --git a/vendor/phpunit/phpunit/src/Util/XmlTestListRenderer.php b/vendor/phpunit/phpunit/src/Util/XmlTestListRenderer.php new file mode 100644 index 0000000..2d758d5 --- /dev/null +++ b/vendor/phpunit/phpunit/src/Util/XmlTestListRenderer.php @@ -0,0 +1,82 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace PHPUnit\Util; + +use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\TestSuite; +use PHPUnit\Runner\PhptTestCase; + +class XmlTestListRenderer +{ + public function render(TestSuite $suite): string + { + $writer = new \XmlWriter; + + $writer->openMemory(); + $writer->setIndent(true); + $writer->startDocument(); + $writer->startElement('tests'); + + $currentTestCase = null; + + foreach (new \RecursiveIteratorIterator($suite->getIterator()) as $test) { + if ($test instanceof TestCase) { + if (\get_class($test) !== $currentTestCase) { + if ($currentTestCase !== null) { + $writer->endElement(); + } + + $writer->startElement('testCaseClass'); + $writer->writeAttribute('name', \get_class($test)); + + $currentTestCase = \get_class($test); + } + + $writer->startElement('testCaseMethod'); + $writer->writeAttribute('name', $test->getName(false)); + $writer->writeAttribute('groups', \implode(',', $test->getGroups())); + + if (!empty($test->getDataSetAsString(false))) { + $writer->writeAttribute( + 'dataSet', + \str_replace( + ' with data set ', + '', + $test->getDataSetAsString(false) + ) + ); + } + + $writer->endElement(); + } elseif ($test instanceof PhptTestCase) { + if ($currentTestCase !== null) { + $writer->endElement(); + + $currentTestCase = null; + } + + $writer->startElement('phptFile'); + $writer->writeAttribute('path', $test->getName()); + $writer->endElement(); + } else { + continue; + } + } + + if ($currentTestCase !== null) { + $writer->endElement(); + } + + $writer->endElement(); + + return $writer->outputMemory(); + } +} diff --git a/vendor/phpunit/phpunit/tests/TextUI/list-tests-dataprovider.phpt b/vendor/phpunit/phpunit/tests/TextUI/list-tests-dataprovider.phpt new file mode 100644 index 0000000..5474b75 --- /dev/null +++ b/vendor/phpunit/phpunit/tests/TextUI/list-tests-dataprovider.phpt @@ -0,0 +1,19 @@ +--TEST-- +phpunit --list-tests DataProviderTest ../_files/DataProviderTest.php +--FILE-- + + + + + + + + + \ No newline at end of file diff --git a/vendor/swiftmailer/swiftmailer/.github/ISSUE_TEMPLATE.md b/vendor/swiftmailer/swiftmailer/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..5db6524 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,19 @@ + + +| Q | A +| ------------------- | ----- +| Bug report? | yes/no +| Feature request? | yes/no +| RFC? | yes/no +| How used? | Standalone/Symfony/3party +| Swiftmailer version | x.y.z +| PHP version | x.y.z + +### Observed behaviour + + +### Expected behaviour + + +### Example + diff --git a/vendor/swiftmailer/swiftmailer/.github/PULL_REQUEST_TEMPLATE.md b/vendor/swiftmailer/swiftmailer/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..4b39510 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,14 @@ + + +| Q | A +| ------------- | --- +| Bug fix? | yes/no +| New feature? | yes/no +| Doc update? | yes/no +| BC breaks? | yes/no +| Deprecations? | yes/no +| Fixed tickets | #... +| License | MIT + + + diff --git a/vendor/symfony/console/Tests/Fixtures/application_renderexception_linebreaks.txt b/vendor/symfony/console/Tests/Fixtures/application_renderexception_linebreaks.txt new file mode 100644 index 0000000..e9a9518 --- /dev/null +++ b/vendor/symfony/console/Tests/Fixtures/application_renderexception_linebreaks.txt @@ -0,0 +1,11 @@ + + + [InvalidArgumentException] + line 1 with extra spaces + line 2 + + line 4 + + +foo + diff --git a/vendor/symfony/http-kernel/Tests/DataCollector/Compiler.log b/vendor/symfony/http-kernel/Tests/DataCollector/Compiler.log new file mode 100644 index 0000000..88b6840 --- /dev/null +++ b/vendor/symfony/http-kernel/Tests/DataCollector/Compiler.log @@ -0,0 +1,4 @@ +Symfony\Component\DependencyInjection\Compiler\RemovePrivateAliasesPass: Removed service "Psr\Container\ContainerInterface"; reason: private alias. +Symfony\Component\DependencyInjection\Compiler\RemovePrivateAliasesPass: Removed service "Symfony\Component\DependencyInjection\ContainerInterface"; reason: private alias. +Some custom logging message +With ending :