1
0
Fork 0
mirror of synced 2025-04-10 04:21:01 +00:00

custom autoloader for annotations, move constraints to annotations

This commit is contained in:
Alex Lushpai 2019-04-05 18:22:50 +03:00
parent c43b5cf194
commit 3e4e08d2cc
3 changed files with 157 additions and 84 deletions

201
composer.lock generated
View file

@ -2251,39 +2251,36 @@
},
{
"name": "nette/bootstrap",
"version": "v2.4.6",
"version": "v3.0.0",
"source": {
"type": "git",
"url": "https://github.com/nette/bootstrap.git",
"reference": "268816e3f1bb7426c3a4ceec2bd38a036b532543"
"reference": "e1075af05c211915e03e0c86542f3ba5433df4a3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nette/bootstrap/zipball/268816e3f1bb7426c3a4ceec2bd38a036b532543",
"reference": "268816e3f1bb7426c3a4ceec2bd38a036b532543",
"url": "https://api.github.com/repos/nette/bootstrap/zipball/e1075af05c211915e03e0c86542f3ba5433df4a3",
"reference": "e1075af05c211915e03e0c86542f3ba5433df4a3",
"shasum": ""
},
"require": {
"nette/di": "~2.4.7",
"nette/utils": "~2.4",
"php": ">=5.6.0"
},
"conflict": {
"nette/nette": "<2.2"
"nette/di": "^3.0",
"nette/utils": "^3.0",
"php": ">=7.1"
},
"require-dev": {
"latte/latte": "~2.2",
"nette/application": "~2.3",
"nette/caching": "~2.3",
"nette/database": "~2.3",
"nette/forms": "~2.3",
"nette/http": "~2.4.0",
"nette/mail": "~2.3",
"nette/robot-loader": "^2.4.2 || ^3.0",
"nette/safe-stream": "~2.2",
"nette/security": "~2.3",
"nette/tester": "~2.0",
"tracy/tracy": "^2.4.1"
"latte/latte": "^2.2",
"nette/application": "^3.0",
"nette/caching": "^3.0",
"nette/database": "^3.0",
"nette/forms": "^3.0",
"nette/http": "^3.0",
"nette/mail": "^3.0",
"nette/robot-loader": "^3.0",
"nette/safe-stream": "^2.2",
"nette/security": "^3.0",
"nette/tester": "^2.0",
"tracy/tracy": "^2.6"
},
"suggest": {
"nette/robot-loader": "to use Configurator::createRobotLoader()",
@ -2292,7 +2289,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.4-dev"
"dev-master": "3.0-dev"
}
},
"autoload": {
@ -2316,53 +2313,57 @@
"homepage": "https://nette.org/contributors"
}
],
"description": "? Nette Bootstrap: the simple way to configure and bootstrap your Nette application.",
"description": "🅱 Nette Bootstrap: the simple way to configure and bootstrap your Nette application.",
"homepage": "https://nette.org",
"keywords": [
"bootstrapping",
"configurator",
"nette"
],
"time": "2018-05-17T12:52:20+00:00"
"time": "2019-03-26T12:59:07+00:00"
},
{
"name": "nette/di",
"version": "v2.4.15",
"version": "v3.0.0",
"source": {
"type": "git",
"url": "https://github.com/nette/di.git",
"reference": "d0561b8f77e8ef2ed6d83328860e16c81a5a8649"
"reference": "19d83539245aaacb59470828919182411061841f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nette/di/zipball/d0561b8f77e8ef2ed6d83328860e16c81a5a8649",
"reference": "d0561b8f77e8ef2ed6d83328860e16c81a5a8649",
"url": "https://api.github.com/repos/nette/di/zipball/19d83539245aaacb59470828919182411061841f",
"reference": "19d83539245aaacb59470828919182411061841f",
"shasum": ""
},
"require": {
"ext-tokenizer": "*",
"nette/neon": "^2.3.3 || ~3.0.0",
"nette/php-generator": "^2.6.1 || ^3.0.0",
"nette/utils": "^2.5.0 || ~3.0.0",
"php": ">=5.6.0"
"nette/neon": "^3.0",
"nette/php-generator": "^3.2.2",
"nette/robot-loader": "^3.2",
"nette/schema": "^1.0",
"nette/utils": "^3.0",
"php": ">=7.1"
},
"conflict": {
"nette/bootstrap": "<2.4",
"nette/nette": "<2.2"
"nette/bootstrap": "<3.0"
},
"require-dev": {
"nette/tester": "^2.0",
"nette/tester": "^2.2",
"tracy/tracy": "^2.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.4-dev"
"dev-master": "3.0-dev"
}
},
"autoload": {
"classmap": [
"src/"
],
"files": [
"src/compatibility.php"
]
},
"notification-url": "https://packagist.org/downloads/",
@ -2381,7 +2382,7 @@
"homepage": "https://nette.org/contributors"
}
],
"description": "? Nette Dependency Injection Container: Flexible, compiled and full-featured DIC with perfectly usable autowiring and support for all new PHP 7.1 features.",
"description": "💎 Nette Dependency Injection Container: Flexible, compiled and full-featured DIC with perfectly usable autowiring and support for all new PHP 7.1 features.",
"homepage": "https://nette.org",
"keywords": [
"compiled",
@ -2392,7 +2393,7 @@
"nette",
"static"
],
"time": "2019-01-30T13:26:05+00:00"
"time": "2019-04-03T19:35:46+00:00"
},
{
"name": "nette/finder",
@ -2581,26 +2582,23 @@
},
{
"name": "nette/robot-loader",
"version": "v3.1.1",
"version": "v3.2.0",
"source": {
"type": "git",
"url": "https://github.com/nette/robot-loader.git",
"reference": "3e8d75d6d976e191bdf46752ca40a286671219d2"
"reference": "0712a0e39ae7956d6a94c0ab6ad41aa842544b5c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nette/robot-loader/zipball/3e8d75d6d976e191bdf46752ca40a286671219d2",
"reference": "3e8d75d6d976e191bdf46752ca40a286671219d2",
"url": "https://api.github.com/repos/nette/robot-loader/zipball/0712a0e39ae7956d6a94c0ab6ad41aa842544b5c",
"reference": "0712a0e39ae7956d6a94c0ab6ad41aa842544b5c",
"shasum": ""
},
"require": {
"ext-tokenizer": "*",
"nette/finder": "^2.3 || ^3.0",
"nette/utils": "^2.4 || ^3.0",
"php": ">=5.6.0"
},
"conflict": {
"nette/nette": "<2.2"
"nette/finder": "^2.5",
"nette/utils": "^3.0",
"php": ">=7.1"
},
"require-dev": {
"nette/tester": "^2.0",
@ -2609,7 +2607,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.1-dev"
"dev-master": "3.2-dev"
}
},
"autoload": {
@ -2642,52 +2640,39 @@
"nette",
"trait"
],
"time": "2019-03-01T20:23:02+00:00"
"time": "2019-03-08T21:57:24+00:00"
},
{
"name": "nette/utils",
"version": "v2.5.3",
"name": "nette/schema",
"version": "v1.0.0",
"source": {
"type": "git",
"url": "https://github.com/nette/utils.git",
"reference": "17b9f76f2abd0c943adfb556e56f2165460b15ce"
"url": "https://github.com/nette/schema.git",
"reference": "6241d8d4da39e825dd6cb5bfbe4242912f4d7e4d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nette/utils/zipball/17b9f76f2abd0c943adfb556e56f2165460b15ce",
"reference": "17b9f76f2abd0c943adfb556e56f2165460b15ce",
"url": "https://api.github.com/repos/nette/schema/zipball/6241d8d4da39e825dd6cb5bfbe4242912f4d7e4d",
"reference": "6241d8d4da39e825dd6cb5bfbe4242912f4d7e4d",
"shasum": ""
},
"require": {
"php": ">=5.6.0"
},
"conflict": {
"nette/nette": "<2.2"
"nette/utils": "^3.0.1",
"php": ">=7.1"
},
"require-dev": {
"nette/tester": "~2.0",
"nette/tester": "^2.2",
"tracy/tracy": "^2.3"
},
"suggest": {
"ext-gd": "to use Image",
"ext-iconv": "to use Strings::webalize() and toAscii()",
"ext-intl": "for script transliteration in Strings::webalize() and toAscii()",
"ext-json": "to use Nette\\Utils\\Json",
"ext-mbstring": "to use Strings::lower() etc...",
"ext-xml": "to use Strings::length() etc. when mbstring is not available"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.5-dev"
"dev-master": "1.0-dev"
}
},
"autoload": {
"classmap": [
"src/"
],
"files": [
"src/loader.php"
]
},
"notification-url": "https://packagist.org/downloads/",
@ -2706,7 +2691,71 @@
"homepage": "https://nette.org/contributors"
}
],
"description": "? Nette Utils: lightweight utilities for string & array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.",
"description": "📐 Nette Schema: validating data structures against a given Schema.",
"homepage": "https://nette.org",
"keywords": [
"config",
"nette"
],
"time": "2019-04-03T15:53:25+00:00"
},
{
"name": "nette/utils",
"version": "v3.0.1",
"source": {
"type": "git",
"url": "https://github.com/nette/utils.git",
"reference": "bd961f49b211997202bda1d0fbc410905be370d4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nette/utils/zipball/bd961f49b211997202bda1d0fbc410905be370d4",
"reference": "bd961f49b211997202bda1d0fbc410905be370d4",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
"require-dev": {
"nette/tester": "~2.0",
"tracy/tracy": "^2.3"
},
"suggest": {
"ext-gd": "to use Image",
"ext-iconv": "to use Strings::webalize() and toAscii()",
"ext-intl": "to use Strings::webalize(), toAscii(), normalize() and compare()",
"ext-json": "to use Nette\\Utils\\Json",
"ext-mbstring": "to use Strings::lower() etc...",
"ext-xml": "to use Strings::length() etc. when mbstring is not available"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause",
"GPL-2.0",
"GPL-3.0"
],
"authors": [
{
"name": "David Grudl",
"homepage": "https://davidgrudl.com"
},
{
"name": "Nette Community",
"homepage": "https://nette.org/contributors"
}
],
"description": "🛠 Nette Utils: lightweight utilities for string & array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.",
"homepage": "https://nette.org",
"keywords": [
"array",
@ -2724,7 +2773,7 @@
"utility",
"validation"
],
"time": "2018-09-18T10:22:16+00:00"
"time": "2019-03-22T01:00:30+00:00"
},
{
"name": "nikic/php-parser",

View file

@ -83,8 +83,6 @@ class Request
$parameters = $this->serialize($request, $serializeTo);
$url = $this->buildUrl($path, $method, $parameters);
var_dump($url);
$curlHandler = curl_init();
curl_setopt($curlHandler, CURLOPT_URL, $url);
curl_setopt($curlHandler, CURLOPT_RETURNTRANSFER, 1);
@ -181,7 +179,7 @@ class Request
private function validateRequest($class)
{
$validator = Validation::createValidatorBuilder()
->addMethodMapping('loadValidatorMetadata')
->enableAnnotationMapping()
->getValidator();
$errors = $validator->validate($class);
@ -206,7 +204,8 @@ class Request
switch ($serialize) {
case self::S_ARRAY:
$serialized = (array)$request;
$serializer = SerializerBuilder::create()->build();
$serialized = $serializer->toArray($request);
break;
case self::S_JSON:
$serializer = SerializerBuilder::create()->build();

View file

@ -14,6 +14,8 @@
namespace RetailCrm\Mg\Bot\Tests;
use InvalidArgumentException;
use RetailCrm\Mg\Bot\Model\Constants;
use RetailCrm\Mg\Bot\Model\Request\BotsRequest;
use RetailCrm\Mg\Bot\Model\Request\ChannelsRequest;
use RetailCrm\Mg\Bot\Model\Request\CommandEditRequest;
use RetailCrm\Mg\Bot\Test\TestCase;
@ -40,11 +42,9 @@ class ClientTest extends TestCase
$client = self::getApiClient();
$request = new ChannelsRequest();
$request->setActive(true);
$request->setTypes(['viber']);
$request->setTypes([Constants::CHANNEL_TYPE_FACEBOOK]);
$channels = $client->channels($request);
var_dump($channels->getResponse());
self::assertTrue($channels->isSuccessful() == true);
}
@ -68,6 +68,9 @@ class ClientTest extends TestCase
self::assertTrue(1 == 1);
}
/**
* @throws \Exception
*/
public function testCommandEditException()
{
self::expectException(InvalidArgumentException::class);
@ -79,9 +82,31 @@ class ClientTest extends TestCase
$client->commandEdit($command);
}
/**
* @throws \Exception
*/
public function testCommandDeleteException()
{
self::expectException(\Exception::class);
$client = self::getApiClient();
$command = "qwerty";
$client->commandDelete($command);
}
/**
* @throws \Exception
*/
public function testBots()
{
self::assertTrue(1 == 1);
$client = self::getApiClient();
$request = new BotsRequest();
$request->setActive(1);
$request->setRoles([Constants::BOT_ROLE_RESPONSIBLE]);
$bots = $client->bots($request);
self::assertTrue($bots->isSuccessful() == true);
}
public function testUsers()