From c3b8bf210db90581ad894db454fbdba42ce12110 Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Wed, 17 Jan 2018 09:57:24 +0200 Subject: [PATCH 01/29] 0.9 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3ce4390..de315b3 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "0.8.x-dev" + "dev-master": "0.9.x-dev" } } } From 7d34b9f8208c4bd447dbd5b532097a41a6eb6d6c Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Mon, 13 Aug 2018 22:29:00 +0300 Subject: [PATCH 02/29] prepare redis interface and impl to consume from multiple queues. --- RedisExtension.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RedisExtension.php b/RedisExtension.php index 0740c8f..5652a19 100644 --- a/RedisExtension.php +++ b/RedisExtension.php @@ -18,7 +18,7 @@ private function buildPhpRedisContext() $config = [ 'host' => getenv('REDIS_HOST'), - 'port' => getenv('REDIS_PORT'), + 'port' => (int) getenv('REDIS_PORT'), 'vendor' => 'phpredis', 'lazy' => false, ]; From 6be9cb179c5fe3857c13e885598af1f635fa8f85 Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Thu, 30 Aug 2018 13:05:11 +0300 Subject: [PATCH 03/29] Add tests. --- ClassExtensionTrait.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ClassExtensionTrait.php b/ClassExtensionTrait.php index b9dea0c..e2bd840 100644 --- a/ClassExtensionTrait.php +++ b/ClassExtensionTrait.php @@ -23,4 +23,14 @@ public function assertClassImplements($expected, $actual) sprintf('Failed assert that class %s implements %s interface.', $actual, $expected) ); } + + public function assertClassFinal($actual) + { + $rc = new \ReflectionClass($actual); + + $this->assertTrue( + $rc->isFinal(), + sprintf('Failed assert that class %s is final.', $actual) + ); + } } From 011f4be8ab0f5613a09561c54dd8c47a15acaa76 Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Sat, 8 Sep 2018 00:02:14 +0300 Subject: [PATCH 04/29] [redis] fix tests. --- RedisExtension.php | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/RedisExtension.php b/RedisExtension.php index 5652a19..cb32382 100644 --- a/RedisExtension.php +++ b/RedisExtension.php @@ -2,46 +2,42 @@ namespace Enqueue\Test; +use Enqueue\Redis\PhpRedis; +use Enqueue\Redis\PRedis; use Enqueue\Redis\RedisConnectionFactory; use Enqueue\Redis\RedisContext; trait RedisExtension { - /** - * @return RedisContext - */ - private function buildPhpRedisContext() + private function buildPhpRedisContext(): RedisContext { - if (false == getenv('REDIS_HOST')) { + if (false == getenv('PHPREDIS_DSN')) { throw new \PHPUnit_Framework_SkippedTestError('Functional tests are not allowed in this environment'); } - $config = [ - 'host' => getenv('REDIS_HOST'), - 'port' => (int) getenv('REDIS_PORT'), - 'vendor' => 'phpredis', - 'lazy' => false, - ]; + $config = getenv('PHPREDIS_DSN'); - return (new RedisConnectionFactory($config))->createContext(); + $context = (new RedisConnectionFactory($config))->createContext(); + + //guard + $this->assertInstanceOf(PhpRedis::class, $context->getRedis()); + + return $context; } - /** - * @return RedisContext - */ - private function buildPRedisContext() + private function buildPRedisContext(): RedisContext { - if (false == getenv('REDIS_HOST')) { + if (false == getenv('PREDIS_DSN')) { throw new \PHPUnit_Framework_SkippedTestError('Functional tests are not allowed in this environment'); } - $config = [ - 'host' => getenv('REDIS_HOST'), - 'port' => getenv('REDIS_PORT'), - 'vendor' => 'predis', - 'lazy' => false, - ]; + $config = getenv('PREDIS_DSN'); + + $context = (new RedisConnectionFactory($config))->createContext(); + + //guard + $this->assertInstanceOf(PRedis::class, $context->getRedis()); - return (new RedisConnectionFactory($config))->createContext(); + return $context; } } From 951041219e31cde84d18bcba505717794e1251b5 Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Tue, 11 Sep 2018 16:08:43 +0300 Subject: [PATCH 05/29] fix tests. --- GpsExtension.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 GpsExtension.php diff --git a/GpsExtension.php b/GpsExtension.php new file mode 100644 index 0000000..6d9c412 --- /dev/null +++ b/GpsExtension.php @@ -0,0 +1,20 @@ +createContext(); + } +} From 26a34b932a3b5da76b84e1791028671572812ca5 Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Tue, 11 Sep 2018 16:39:50 +0300 Subject: [PATCH 06/29] remove RABBITMQ_HOST,PORT etc env vars. --- MongodbExtensionTrait.php | 3 ++- RabbitManagementExtensionTrait.php | 24 ++++++++++-------------- RabbitmqAmqpExtension.php | 22 +--------------------- RabbitmqStompExtension.php | 18 +++--------------- SqsExtension.php | 5 +---- composer.json | 3 +++ 6 files changed, 20 insertions(+), 55 deletions(-) diff --git a/MongodbExtensionTrait.php b/MongodbExtensionTrait.php index 4d94fca..29c146c 100644 --- a/MongodbExtensionTrait.php +++ b/MongodbExtensionTrait.php @@ -3,10 +3,11 @@ namespace Enqueue\Test; use Enqueue\Mongodb\MongodbConnectionFactory; +use Enqueue\Mongodb\MongodbContext; trait MongodbExtensionTrait { - protected function buildMongodbContext() + protected function buildMongodbContext(): MongodbContext { if (false == $env = getenv('MONGO_DSN')) { $this->markTestSkipped('The MONGO_DSN env is not available. Skip tests'); diff --git a/RabbitManagementExtensionTrait.php b/RabbitManagementExtensionTrait.php index c766588..0940874 100644 --- a/RabbitManagementExtensionTrait.php +++ b/RabbitManagementExtensionTrait.php @@ -2,6 +2,8 @@ namespace Enqueue\Test; +use Enqueue\Dsn\Dsn; + trait RabbitManagementExtensionTrait { /** @@ -9,15 +11,12 @@ trait RabbitManagementExtensionTrait */ private function removeQueue($queueName) { - $rabbitmqHost = getenv('RABBITMQ_HOST'); - $rabbitmqUser = getenv('RABBITMQ_USER'); - $rabbitmqPassword = getenv('RABBITMQ_PASSWORD'); - $rabbitmqVhost = getenv('RABBITMQ_VHOST'); + $dsn = new Dsn(getenv('RABBITMQ_AMQP_DSN')); $url = sprintf( 'http://%s:15672/api/queues/%s/%s', - $rabbitmqHost, - urlencode($rabbitmqVhost), + $dsn->getHost(), + urlencode(ltrim($dsn->getPath(), '/')), $queueName ); @@ -26,7 +25,7 @@ private function removeQueue($queueName) curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); - curl_setopt($ch, CURLOPT_USERPWD, $rabbitmqUser.':'.$rabbitmqPassword); + curl_setopt($ch, CURLOPT_USERPWD, $dsn->getUser().':'.$dsn->getPassword()); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type' => 'application/json', ]); @@ -46,15 +45,12 @@ private function removeQueue($queueName) */ private function removeExchange($exchangeName) { - $rabbitmqHost = getenv('RABBITMQ_HOST'); - $rabbitmqUser = getenv('RABBITMQ_USER'); - $rabbitmqPassword = getenv('RABBITMQ_PASSWORD'); - $rabbitmqVhost = getenv('RABBITMQ_VHOST'); + $dsn = new Dsn(getenv('RABBITMQ_AMQP_DSN')); $url = sprintf( 'http://%s:15672/api/exchanges/%s/%s', - $rabbitmqHost, - urlencode($rabbitmqVhost), + $dsn->getHost(), + urlencode(ltrim($dsn->getPath(), '/')), $exchangeName ); @@ -63,7 +59,7 @@ private function removeExchange($exchangeName) curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); - curl_setopt($ch, CURLOPT_USERPWD, $rabbitmqUser.':'.$rabbitmqPassword); + curl_setopt($ch, CURLOPT_USERPWD, $dsn->getUser().':'.$dsn->getPassword()); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type' => 'application/json', ]); diff --git a/RabbitmqAmqpExtension.php b/RabbitmqAmqpExtension.php index 1a4da0e..f99dcac 100644 --- a/RabbitmqAmqpExtension.php +++ b/RabbitmqAmqpExtension.php @@ -12,27 +12,7 @@ trait RabbitmqAmqpExtension */ private function buildAmqpContext() { - if (false == getenv('RABBITMQ_HOST')) { - throw new \PHPUnit_Framework_SkippedTestError('Functional tests are not allowed in this environment'); - } - - $config = [ - 'host' => getenv('RABBITMQ_HOST'), - 'port' => getenv('RABBITMQ_AMQP__PORT'), - 'user' => getenv('RABBITMQ_USER'), - 'pass' => getenv('RABBITMQ_PASSWORD'), - 'vhost' => getenv('RABBITMQ_VHOST'), - ]; - - return (new AmqpConnectionFactory($config))->createContext(); - } - - /** - * @return AmqpContext - */ - private function buildAmqpContextFromDsn() - { - if (false == $dsn = getenv('AMQP_DSN')) { + if (false == $dsn = getenv('RABBITMQ_AMQP_DSN')) { throw new \PHPUnit_Framework_SkippedTestError('Functional tests are not allowed in this environment'); } diff --git a/RabbitmqStompExtension.php b/RabbitmqStompExtension.php index ae2bf4b..2ce2dfa 100644 --- a/RabbitmqStompExtension.php +++ b/RabbitmqStompExtension.php @@ -7,24 +7,12 @@ trait RabbitmqStompExtension { - /** - * @return StompContext - */ - private function buildStompContext() + private function buildStompContext(): StompContext { - if (false == getenv('RABBITMQ_HOST')) { + if (false == $dsn = getenv('RABITMQ_STOMP_DSN')) { throw new \PHPUnit_Framework_SkippedTestError('Functional tests are not allowed in this environment'); } - $config = [ - 'host' => getenv('RABBITMQ_HOST'), - 'port' => getenv('RABBITMQ_STOMP_PORT'), - 'login' => getenv('RABBITMQ_USER'), - 'password' => getenv('RABBITMQ_PASSWORD'), - 'vhost' => getenv('RABBITMQ_VHOST'), - 'sync' => true, - ]; - - return (new StompConnectionFactory($config))->createContext(); + return (new StompConnectionFactory($dsn))->createContext(); } } diff --git a/SqsExtension.php b/SqsExtension.php index dacb183..ec8a7fc 100644 --- a/SqsExtension.php +++ b/SqsExtension.php @@ -7,10 +7,7 @@ trait SqsExtension { - /** - * @return SqsContext - */ - private function buildSqsContext() + private function buildSqsContext(): SqsContext { if (false == getenv('AWS_SQS_ENDPOINT') && false == getenv('AWS_SQS_KEY')) { throw new \PHPUnit_Framework_SkippedTestError('Functional tests are not allowed in this environment'); diff --git a/composer.json b/composer.json index de315b3..1cf9f54 100644 --- a/composer.json +++ b/composer.json @@ -9,6 +9,9 @@ "source": "https://github.com/php-enqueue/enqueue-dev", "docs": "https://github.com/php-enqueue/enqueue-dev/blob/master/docs/index.md" }, + "require": { + "enqueue/dsn": "0.9.x-dev" + }, "autoload": { "psr-4": { "Enqueue\\Test\\": "" } }, From 5a67368cd18d44321553f26fae66ea04b8722fde Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Tue, 11 Sep 2018 16:52:34 +0300 Subject: [PATCH 07/29] remove other not used env vars. --- SqsExtension.php | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/SqsExtension.php b/SqsExtension.php index ec8a7fc..3cc17e4 100644 --- a/SqsExtension.php +++ b/SqsExtension.php @@ -9,19 +9,10 @@ trait SqsExtension { private function buildSqsContext(): SqsContext { - if (false == getenv('AWS_SQS_ENDPOINT') && false == getenv('AWS_SQS_KEY')) { + if (false == $dsn = getenv('SQS_DSN')) { throw new \PHPUnit_Framework_SkippedTestError('Functional tests are not allowed in this environment'); } - $config = [ - 'key' => getenv('AWS_SQS_KEY'), - 'secret' => getenv('AWS_SQS_SECRET'), - 'region' => getenv('AWS_SQS_REGION'), - 'version' => getenv('AWS_SQS_VERSION'), - 'endpoint' => getenv('AWS_SQS_ENDPOINT'), - 'lazy' => false, - ]; - - return (new SqsConnectionFactory($config))->createContext(); + return (new SqsConnectionFactory($dsn))->createContext(); } } From a44efd4ff2168f88dceadbcb82caa11da9a15e39 Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Tue, 11 Sep 2018 17:03:47 +0300 Subject: [PATCH 08/29] fix tests. --- RabbitmqAmqpExtension.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RabbitmqAmqpExtension.php b/RabbitmqAmqpExtension.php index f99dcac..3581478 100644 --- a/RabbitmqAmqpExtension.php +++ b/RabbitmqAmqpExtension.php @@ -12,7 +12,7 @@ trait RabbitmqAmqpExtension */ private function buildAmqpContext() { - if (false == $dsn = getenv('RABBITMQ_AMQP_DSN')) { + if (false == $dsn = getenv('AMQP_DSN')) { throw new \PHPUnit_Framework_SkippedTestError('Functional tests are not allowed in this environment'); } From a219343b3bf885baaff5f24edcba7d69788433bb Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Fri, 5 Oct 2018 10:34:47 +0300 Subject: [PATCH 09/29] [consumption] fix onStart extension tests. --- ClassExtensionTrait.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ClassExtensionTrait.php b/ClassExtensionTrait.php index e2bd840..75d70ae 100644 --- a/ClassExtensionTrait.php +++ b/ClassExtensionTrait.php @@ -33,4 +33,14 @@ public function assertClassFinal($actual) sprintf('Failed assert that class %s is final.', $actual) ); } + + public function assertClassNotFinal($actual) + { + $rc = new \ReflectionClass($actual); + + $this->assertFalse( + $rc->isFinal(), + sprintf('Failed assert that class %s is final.', $actual) + ); + } } From 7e81d6544f23eccc36db759fb5026561baa37c03 Mon Sep 17 00:00:00 2001 From: Roman Samarsky Date: Thu, 18 Oct 2018 02:56:40 +0300 Subject: [PATCH 10/29] MongoDB Subscription Consumer feature --- MongodbExtensionTrait.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MongodbExtensionTrait.php b/MongodbExtensionTrait.php index 29c146c..3ba9e93 100644 --- a/MongodbExtensionTrait.php +++ b/MongodbExtensionTrait.php @@ -1,5 +1,7 @@ Date: Mon, 22 Oct 2018 15:22:55 +0300 Subject: [PATCH 11/29] wamp --- WampExtension.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 WampExtension.php diff --git a/WampExtension.php b/WampExtension.php new file mode 100644 index 0000000..eab5d42 --- /dev/null +++ b/WampExtension.php @@ -0,0 +1,18 @@ +createContext(); + } +} From 4c20673f9304bf6510bf716422010bd566cb8d20 Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Tue, 6 Nov 2018 18:06:13 +0200 Subject: [PATCH 12/29] [doc][skip ci] Add sponsoring section. --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index cb8ded2..4fcc87d 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,12 @@ +

Supporting Enqueue

+ +Enqueue is an MIT-licensed open source project with its ongoing development made possible entirely by the support of community and our customers. If you'd like to join them, please consider: + +- [Become a sponsor](https://www.patreon.com/makasim). +- [Become our client](http://forma-pro.com/) + +--- + # Message Queue. Test utils [![Gitter](https://badges.gitter.im/php-enqueue/Lobby.svg)](https://gitter.im/php-enqueue/Lobby) From cb120791c9847fa91c5188248841c4338cc52201 Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Tue, 6 Nov 2018 18:12:08 +0200 Subject: [PATCH 13/29] [docs][skip ci] Add sponsoring to docs. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4fcc87d..b9bb44f 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Enqueue is an MIT-licensed open source project with its ongoing development made possible entirely by the support of community and our customers. If you'd like to join them, please consider: -- [Become a sponsor](https://www.patreon.com/makasim). +- [Become a sponsor](https://www.patreon.com/makasim) - [Become our client](http://forma-pro.com/) --- From b9e5d4448af78e7eb1d300ab5a76af894a5e3d95 Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Sat, 17 Nov 2018 16:22:43 +0200 Subject: [PATCH 14/29] [dsn] Cluster DSN --- RabbitManagementExtensionTrait.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RabbitManagementExtensionTrait.php b/RabbitManagementExtensionTrait.php index 0940874..82bdd07 100644 --- a/RabbitManagementExtensionTrait.php +++ b/RabbitManagementExtensionTrait.php @@ -11,7 +11,7 @@ trait RabbitManagementExtensionTrait */ private function removeQueue($queueName) { - $dsn = new Dsn(getenv('RABBITMQ_AMQP_DSN')); + $dsn = Dsn::parseFirst(getenv('RABBITMQ_AMQP_DSN')); $url = sprintf( 'http://%s:15672/api/queues/%s/%s', @@ -45,7 +45,7 @@ private function removeQueue($queueName) */ private function removeExchange($exchangeName) { - $dsn = new Dsn(getenv('RABBITMQ_AMQP_DSN')); + $dsn = Dsn::parseFirst(getenv('RABBITMQ_AMQP_DSN')); $url = sprintf( 'http://%s:15672/api/exchanges/%s/%s', From 7f09ab8faea779547ea244f3a11ea17a89b17ff6 Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Thu, 6 Dec 2018 08:45:25 +0200 Subject: [PATCH 15/29] Amazon SNS transport. --- SnsExtension.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 SnsExtension.php diff --git a/SnsExtension.php b/SnsExtension.php new file mode 100644 index 0000000..6c01abe --- /dev/null +++ b/SnsExtension.php @@ -0,0 +1,18 @@ +createContext(); + } +} From 8f6b7735ba4f834e16185e3fc97f40354100607c Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Mon, 17 Dec 2018 15:33:23 +0200 Subject: [PATCH 16/29] Allow stable dsn pkg version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 1cf9f54..52a5e36 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ "docs": "https://github.com/php-enqueue/enqueue-dev/blob/master/docs/index.md" }, "require": { - "enqueue/dsn": "0.9.x-dev" + "enqueue/dsn": "^0.9" }, "autoload": { "psr-4": { "Enqueue\\Test\\": "" } From 8027be9baebc047866a6a49044abdef0d90dee30 Mon Sep 17 00:00:00 2001 From: Alexander Kozienko Date: Tue, 19 Feb 2019 13:24:41 +0200 Subject: [PATCH 17/29] snsqs tests --- SnsQsExtension.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 SnsQsExtension.php diff --git a/SnsQsExtension.php b/SnsQsExtension.php new file mode 100644 index 0000000..8bbc2d7 --- /dev/null +++ b/SnsQsExtension.php @@ -0,0 +1,21 @@ + $snsDsn, 'sqs' => $sqsDsn]))->createContext(); + } +} From 658ccd6d4ed4ee1fa780d788975c9104100a19cf Mon Sep 17 00:00:00 2001 From: Alexander Kozienko Date: Tue, 19 Feb 2019 18:15:00 +0200 Subject: [PATCH 18/29] snsqs client driver --- SnsQsExtension.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/SnsQsExtension.php b/SnsQsExtension.php index 8bbc2d7..719f5ce 100644 --- a/SnsQsExtension.php +++ b/SnsQsExtension.php @@ -9,13 +9,10 @@ trait SnsQsExtension { private function buildSnsQsContext(): SnsQsContext { - $snsDsn = getenv('SNS_DSN'); - $sqsDsn = getenv('SQS_DSN'); - - if (false == $snsDsn || false == $sqsDsn) { + if (false == $dsn = getenv('SNSQS_DSN')) { throw new \PHPUnit_Framework_SkippedTestError('Functional tests are not allowed in this environment'); } - return (new SnsQsConnectionFactory(['sns' => $snsDsn, 'sqs' => $sqsDsn]))->createContext(); + return (new SnsQsConnectionFactory($dsn))->createContext(); } } From 284e6dee0c13fc918bf16877ee731a7e77f9fa66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Niedzielski?= Date: Mon, 27 May 2019 15:12:22 +0200 Subject: [PATCH 19/29] Prefer github pages in packages' readme files --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b9bb44f..0695ba9 100644 --- a/README.md +++ b/README.md @@ -10,24 +10,24 @@ Enqueue is an MIT-licensed open source project with its ongoing development made # Message Queue. Test utils [![Gitter](https://badges.gitter.im/php-enqueue/Lobby.svg)](https://gitter.im/php-enqueue/Lobby) - -Contains stuff needed in tests. Shared among different packages. + +Contains stuff needed in tests. Shared among different packages. ## Resources * [Site](https://enqueue.forma-pro.com/) -* [Documentation](https://github.com/php-enqueue/enqueue-dev/blob/master/docs/index.md) +* [Documentation](https://php-enqueue.github.com/) * [Questions](https://gitter.im/php-enqueue/Lobby) * [Issue Tracker](https://github.com/php-enqueue/enqueue-dev/issues) ## Developed by Forma-Pro -Forma-Pro is a full stack development company which interests also spread to open source development. -Being a team of strong professionals we have an aim an ability to help community by developing cutting edge solutions in the areas of e-commerce, docker & microservice oriented architecture where we have accumulated a huge many-years experience. +Forma-Pro is a full stack development company which interests also spread to open source development. +Being a team of strong professionals we have an aim an ability to help community by developing cutting edge solutions in the areas of e-commerce, docker & microservice oriented architecture where we have accumulated a huge many-years experience. Our main specialization is Symfony framework based solution, but we are always looking to the technologies that allow us to do our job the best way. We are committed to creating solutions that revolutionize the way how things are developed in aspects of architecture & scalability. If you have any questions and inquires about our open source development, this product particularly or any other matter feel free to contact at opensource@forma-pro.com ## License -It is released under the [MIT License](LICENSE). \ No newline at end of file +It is released under the [MIT License](LICENSE). From 443e04dfb516dbd952d355443a98dc6fee545a9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Niedzielski?= Date: Wed, 29 May 2019 17:08:39 +0200 Subject: [PATCH 20/29] Fix documentation links Whoops. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0695ba9..a2411c1 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Contains stuff needed in tests. Shared among different packages. ## Resources * [Site](https://enqueue.forma-pro.com/) -* [Documentation](https://php-enqueue.github.com/) +* [Documentation](https://php-enqueue.github.io/) * [Questions](https://gitter.im/php-enqueue/Lobby) * [Issue Tracker](https://github.com/php-enqueue/enqueue-dev/issues) From 7b4f88a6eddf07303ed1914462dfd644600ad0fe Mon Sep 17 00:00:00 2001 From: Mathieu Lemoine Date: Wed, 11 Dec 2019 16:32:12 +0100 Subject: [PATCH 21/29] Reduced dependency to voryx/Thruway --- GpsExtension.php | 3 ++- RabbitmqAmqpExtension.php | 3 ++- RabbitmqStompExtension.php | 3 ++- RedisExtension.php | 5 +++-- RetryTrait.php | 9 ++++++--- SnsExtension.php | 3 ++- SnsQsExtension.php | 3 ++- SqsExtension.php | 3 ++- WampExtension.php | 3 ++- 9 files changed, 23 insertions(+), 12 deletions(-) diff --git a/GpsExtension.php b/GpsExtension.php index 6d9c412..2b03ef6 100644 --- a/GpsExtension.php +++ b/GpsExtension.php @@ -4,13 +4,14 @@ use Enqueue\Gps\GpsConnectionFactory; use Enqueue\Gps\GpsContext; +use PHPUnit\Framework\SkippedTestError; trait GpsExtension { private function buildGpsContext(): GpsContext { if (false == getenv('GPS_DSN')) { - throw new \PHPUnit_Framework_SkippedTestError('Functional tests are not allowed in this environment'); + throw new SkippedTestError('Functional tests are not allowed in this environment'); } $config = getenv('GPS_DSN'); diff --git a/RabbitmqAmqpExtension.php b/RabbitmqAmqpExtension.php index 3581478..28099f1 100644 --- a/RabbitmqAmqpExtension.php +++ b/RabbitmqAmqpExtension.php @@ -4,6 +4,7 @@ use Enqueue\AmqpExt\AmqpConnectionFactory; use Enqueue\AmqpExt\AmqpContext; +use PHPUnit\Framework\SkippedTestError; trait RabbitmqAmqpExtension { @@ -13,7 +14,7 @@ trait RabbitmqAmqpExtension private function buildAmqpContext() { if (false == $dsn = getenv('AMQP_DSN')) { - throw new \PHPUnit_Framework_SkippedTestError('Functional tests are not allowed in this environment'); + throw new SkippedTestError('Functional tests are not allowed in this environment'); } return (new AmqpConnectionFactory($dsn))->createContext(); diff --git a/RabbitmqStompExtension.php b/RabbitmqStompExtension.php index 2ce2dfa..d381d1f 100644 --- a/RabbitmqStompExtension.php +++ b/RabbitmqStompExtension.php @@ -4,13 +4,14 @@ use Enqueue\Stomp\StompConnectionFactory; use Enqueue\Stomp\StompContext; +use PHPUnit\Framework\SkippedTestError; trait RabbitmqStompExtension { private function buildStompContext(): StompContext { if (false == $dsn = getenv('RABITMQ_STOMP_DSN')) { - throw new \PHPUnit_Framework_SkippedTestError('Functional tests are not allowed in this environment'); + throw new SkippedTestError('Functional tests are not allowed in this environment'); } return (new StompConnectionFactory($dsn))->createContext(); diff --git a/RedisExtension.php b/RedisExtension.php index cb32382..86586d1 100644 --- a/RedisExtension.php +++ b/RedisExtension.php @@ -6,13 +6,14 @@ use Enqueue\Redis\PRedis; use Enqueue\Redis\RedisConnectionFactory; use Enqueue\Redis\RedisContext; +use PHPUnit\Framework\SkippedTestError; trait RedisExtension { private function buildPhpRedisContext(): RedisContext { if (false == getenv('PHPREDIS_DSN')) { - throw new \PHPUnit_Framework_SkippedTestError('Functional tests are not allowed in this environment'); + throw new SkippedTestError('Functional tests are not allowed in this environment'); } $config = getenv('PHPREDIS_DSN'); @@ -28,7 +29,7 @@ private function buildPhpRedisContext(): RedisContext private function buildPRedisContext(): RedisContext { if (false == getenv('PREDIS_DSN')) { - throw new \PHPUnit_Framework_SkippedTestError('Functional tests are not allowed in this environment'); + throw new SkippedTestError('Functional tests are not allowed in this environment'); } $config = getenv('PREDIS_DSN'); diff --git a/RetryTrait.php b/RetryTrait.php index de17565..17c96ae 100644 --- a/RetryTrait.php +++ b/RetryTrait.php @@ -2,9 +2,12 @@ namespace Enqueue\Test; +use PHPUnit\Framework\IncompleteTestError; +use PHPUnit\Framework\SkippedTestError; + trait RetryTrait { - public function runBare() + public function runBare(): void { $e = null; @@ -22,9 +25,9 @@ public function runBare() parent::runBare(); return; - } catch (\PHPUnit_Framework_IncompleteTestError $e) { + } catch (IncompleteTestError $e) { throw $e; - } catch (\PHPUnit_Framework_SkippedTestError $e) { + } catch (SkippedTestError $e) { throw $e; } catch (\Throwable $e) { // last one thrown below diff --git a/SnsExtension.php b/SnsExtension.php index 6c01abe..050f212 100644 --- a/SnsExtension.php +++ b/SnsExtension.php @@ -4,13 +4,14 @@ use Enqueue\Sns\SnsConnectionFactory; use Enqueue\Sns\SnsContext; +use PHPUnit\Framework\SkippedTestError; trait SnsExtension { private function buildSqsContext(): SnsContext { if (false == $dsn = getenv('SNS_DSN')) { - throw new \PHPUnit_Framework_SkippedTestError('Functional tests are not allowed in this environment'); + throw new SkippedTestError('Functional tests are not allowed in this environment'); } return (new SnsConnectionFactory($dsn))->createContext(); diff --git a/SnsQsExtension.php b/SnsQsExtension.php index 719f5ce..6dc7dc9 100644 --- a/SnsQsExtension.php +++ b/SnsQsExtension.php @@ -4,13 +4,14 @@ use Enqueue\SnsQs\SnsQsConnectionFactory; use Enqueue\SnsQs\SnsQsContext; +use PHPUnit\Framework\SkippedTestError; trait SnsQsExtension { private function buildSnsQsContext(): SnsQsContext { if (false == $dsn = getenv('SNSQS_DSN')) { - throw new \PHPUnit_Framework_SkippedTestError('Functional tests are not allowed in this environment'); + throw new SkippedTestError('Functional tests are not allowed in this environment'); } return (new SnsQsConnectionFactory($dsn))->createContext(); diff --git a/SqsExtension.php b/SqsExtension.php index 3cc17e4..c00b42e 100644 --- a/SqsExtension.php +++ b/SqsExtension.php @@ -4,13 +4,14 @@ use Enqueue\Sqs\SqsConnectionFactory; use Enqueue\Sqs\SqsContext; +use PHPUnit\Framework\SkippedTestError; trait SqsExtension { private function buildSqsContext(): SqsContext { if (false == $dsn = getenv('SQS_DSN')) { - throw new \PHPUnit_Framework_SkippedTestError('Functional tests are not allowed in this environment'); + throw new SkippedTestError('Functional tests are not allowed in this environment'); } return (new SqsConnectionFactory($dsn))->createContext(); diff --git a/WampExtension.php b/WampExtension.php index eab5d42..5b17fe7 100644 --- a/WampExtension.php +++ b/WampExtension.php @@ -4,13 +4,14 @@ use Enqueue\Wamp\WampConnectionFactory; use Enqueue\Wamp\WampContext; +use PHPUnit\Framework\SkippedTestError; trait WampExtension { private function buildWampContext(): WampContext { if (false == $dsn = getenv('WAMP_DSN')) { - throw new \PHPUnit_Framework_SkippedTestError('Functional tests are not allowed in this environment'); + throw new SkippedTestError('Functional tests are not allowed in this environment'); } return (new WampConnectionFactory($dsn))->createContext(); From c694c296f0ce3b5c0fc8e412e0e72a2d96466557 Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Thu, 19 Dec 2019 09:01:09 +0200 Subject: [PATCH 22/29] master is 0.10 --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 52a5e36..ad9234c 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ "docs": "https://github.com/php-enqueue/enqueue-dev/blob/master/docs/index.md" }, "require": { - "enqueue/dsn": "^0.9" + "enqueue/dsn": "^0.10" }, "autoload": { "psr-4": { "Enqueue\\Test\\": "" } @@ -18,7 +18,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "0.9.x-dev" + "dev-master": "0.10.x-dev" } } } From c20a10e32cc8ed0d0fbab1fea1e23af1561c85f1 Mon Sep 17 00:00:00 2001 From: vershinin_so Date: Mon, 3 Feb 2020 15:44:04 +0300 Subject: [PATCH 23/29] move to functional test --- RabbitmqStompExtension.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/RabbitmqStompExtension.php b/RabbitmqStompExtension.php index d381d1f..240f67e 100644 --- a/RabbitmqStompExtension.php +++ b/RabbitmqStompExtension.php @@ -8,9 +8,14 @@ trait RabbitmqStompExtension { + private function getDsn() + { + return getenv('RABITMQ_STOMP_DSN'); + } + private function buildStompContext(): StompContext { - if (false == $dsn = getenv('RABITMQ_STOMP_DSN')) { + if (false == $dsn = $this->getDsn()) { throw new SkippedTestError('Functional tests are not allowed in this environment'); } From 9b664c1e745b90c232a325ad0b24ad62dfc61c3f Mon Sep 17 00:00:00 2001 From: Andrew M-Y Date: Sun, 24 Jan 2021 20:35:57 +0200 Subject: [PATCH 24/29] Fix phpunit compatibility - null queues; - array subset; - is array; - is callable; - read attribute; - add ext-pcntl. --- ReadAttributeTrait.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 ReadAttributeTrait.php diff --git a/ReadAttributeTrait.php b/ReadAttributeTrait.php new file mode 100644 index 0000000..7320910 --- /dev/null +++ b/ReadAttributeTrait.php @@ -0,0 +1,36 @@ +setAccessible(true); + $value = $refProperty->getValue($object); + $refProperty->setAccessible(false); + + return $value; + } + + private function assertAttributeSame($expected, string $attribute, object $object): void + { + static::assertSame($expected, $this->readAttribute($object, $attribute)); + } + + private function assertAttributeEquals($expected, string $attribute, object $object): void + { + static::assertEquals($expected, $this->readAttribute($object, $attribute)); + } + + private function assertAttributeInstanceOf(string $expected, string $attribute, object $object): void + { + static::assertInstanceOf($expected, $this->readAttribute($object, $attribute)); + } + + private function assertAttributeCount(int $count, string $attribute, object $object): void + { + static::assertCount($count, $this->readAttribute($object, $attribute)); + } +} From 639090e59202c40a7624808ae90ea08f7aba2b62 Mon Sep 17 00:00:00 2001 From: Andrew M-Y Date: Sun, 24 Jan 2021 21:09:06 +0200 Subject: [PATCH 25/29] Fix annotations --- RetryTrait.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/RetryTrait.php b/RetryTrait.php index 17c96ae..1f1042c 100644 --- a/RetryTrait.php +++ b/RetryTrait.php @@ -4,6 +4,7 @@ use PHPUnit\Framework\IncompleteTestError; use PHPUnit\Framework\SkippedTestError; +use PHPUnit\Util\Test; trait RetryTrait { @@ -46,7 +47,7 @@ public function runBare(): void */ private function getNumberOfRetries() { - $annotations = $this->getAnnotations(); + $annotations = Test::parseTestMethodAnnotations(static::class, $this->getName(false)); if (isset($annotations['method']['retry'][0])) { return $annotations['method']['retry'][0]; From a04ed9079546ca6ff2470715b44ac8acec97c675 Mon Sep 17 00:00:00 2001 From: Andrew M-Y Date: Mon, 25 Jan 2021 09:03:49 +0200 Subject: [PATCH 26/29] Fix reading parent attribute --- ReadAttributeTrait.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/ReadAttributeTrait.php b/ReadAttributeTrait.php index 7320910..381b513 100644 --- a/ReadAttributeTrait.php +++ b/ReadAttributeTrait.php @@ -2,11 +2,13 @@ namespace Enqueue\Test; +use ReflectionProperty; + trait ReadAttributeTrait { public function readAttribute(object $object, string $attribute) { - $refProperty = new \ReflectionProperty(get_class($object), $attribute); + $refProperty = $this->getClassAttribute($object, $attribute); $refProperty->setAccessible(true); $value = $refProperty->getValue($object); $refProperty->setAccessible(false); @@ -14,6 +16,27 @@ public function readAttribute(object $object, string $attribute) return $value; } + private function getClassAttribute( + object $object, + string $attribute, + ?string $class = null + ): ReflectionProperty { + if ($class === null) { + $class = get_class($object); + } + + try { + return new ReflectionProperty($class, $attribute); + } catch (\ReflectionException $exception) { + $parentClass = get_parent_class($object); + if ($parentClass === false) { + throw $exception; + } + + return $this->getClassAttribute($object, $attribute, $parentClass); + } + } + private function assertAttributeSame($expected, string $attribute, object $object): void { static::assertSame($expected, $this->readAttribute($object, $attribute)); From 8c2dc4b87f65904564f76e7110b0f75aaf24c0c1 Mon Sep 17 00:00:00 2001 From: Andrew M-Y Date: Mon, 25 Jan 2021 09:46:24 +0200 Subject: [PATCH 27/29] Fix CS --- ReadAttributeTrait.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ReadAttributeTrait.php b/ReadAttributeTrait.php index 381b513..6938f25 100644 --- a/ReadAttributeTrait.php +++ b/ReadAttributeTrait.php @@ -21,7 +21,7 @@ private function getClassAttribute( string $attribute, ?string $class = null ): ReflectionProperty { - if ($class === null) { + if (null === $class) { $class = get_class($object); } @@ -29,7 +29,7 @@ private function getClassAttribute( return new ReflectionProperty($class, $attribute); } catch (\ReflectionException $exception) { $parentClass = get_parent_class($object); - if ($parentClass === false) { + if (false === $parentClass) { throw $exception; } From 0b869911a9b3cb0b44869b9da8e05406f178f1af Mon Sep 17 00:00:00 2001 From: Andrew M-Y Date: Thu, 10 Feb 2022 18:49:44 +0200 Subject: [PATCH 28/29] Add support for Symfony 6 --- TestLogger.php | 144 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 TestLogger.php diff --git a/TestLogger.php b/TestLogger.php new file mode 100644 index 0000000..d61c679 --- /dev/null +++ b/TestLogger.php @@ -0,0 +1,144 @@ + 0) { + $genericMethod = $matches[1].('Records' !== $matches[3] ? 'Record' : '').$matches[3]; + $level = strtolower($matches[2]); + if (method_exists($this, $genericMethod)) { + $args[] = $level; + + return call_user_func_array([$this, $genericMethod], $args); + } + } + throw new \BadMethodCallException('Call to undefined method TestLogger::'.$method.'()'); + } + + public function log($level, $message, array $context = []): void + { + $record = [ + 'level' => $level, + 'message' => $message, + 'context' => $context, + ]; + + $this->recordsByLevel[$record['level']][] = $record; + $this->records[] = $record; + } + + public function hasRecords($level) + { + return isset($this->recordsByLevel[$level]); + } + + public function hasRecord($record, $level) + { + if (is_string($record)) { + $record = ['message' => $record]; + } + + return $this->hasRecordThatPasses(function ($rec) use ($record) { + if ($rec['message'] !== $record['message']) { + return false; + } + if (isset($record['context']) && $rec['context'] !== $record['context']) { + return false; + } + + return true; + }, $level); + } + + public function hasRecordThatContains($message, $level) + { + return $this->hasRecordThatPasses(function ($rec) use ($message) { + return false !== strpos($rec['message'], $message); + }, $level); + } + + public function hasRecordThatMatches($regex, $level) + { + return $this->hasRecordThatPasses(function ($rec) use ($regex) { + return preg_match($regex, $rec['message']) > 0; + }, $level); + } + + public function hasRecordThatPasses(callable $predicate, $level) + { + if (!isset($this->recordsByLevel[$level])) { + return false; + } + foreach ($this->recordsByLevel[$level] as $i => $rec) { + if (call_user_func($predicate, $rec, $i)) { + return true; + } + } + + return false; + } + + public function reset() + { + $this->records = []; + $this->recordsByLevel = []; + } +} From 93cc939c56c6d1c2fd8e1405b98ed221b6abd9b4 Mon Sep 17 00:00:00 2001 From: James Read Date: Wed, 15 Jan 2025 22:51:32 +0000 Subject: [PATCH 29/29] Running php-cs-fixer Running php-cs-fixer to fix CS drift --- RabbitManagementExtensionTrait.php | 28 ++++++++++++++-------------- ReadAttributeTrait.php | 10 ++++------ RedisExtension.php | 4 ++-- TestLogger.php | 2 +- WriteAttributeTrait.php | 3 +-- 5 files changed, 22 insertions(+), 25 deletions(-) diff --git a/RabbitManagementExtensionTrait.php b/RabbitManagementExtensionTrait.php index 82bdd07..184b175 100644 --- a/RabbitManagementExtensionTrait.php +++ b/RabbitManagementExtensionTrait.php @@ -21,17 +21,17 @@ private function removeQueue($queueName) ); $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); - curl_setopt($ch, CURLOPT_USERPWD, $dsn->getUser().':'.$dsn->getPassword()); - curl_setopt($ch, CURLOPT_HTTPHEADER, [ + curl_setopt($ch, \CURLOPT_URL, $url); + curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, 'DELETE'); + curl_setopt($ch, \CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, \CURLOPT_HTTPAUTH, \CURLAUTH_BASIC); + curl_setopt($ch, \CURLOPT_USERPWD, $dsn->getUser().':'.$dsn->getPassword()); + curl_setopt($ch, \CURLOPT_HTTPHEADER, [ 'Content-Type' => 'application/json', ]); curl_exec($ch); - $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); + $httpCode = curl_getinfo($ch, \CURLINFO_HTTP_CODE); curl_close($ch); @@ -55,17 +55,17 @@ private function removeExchange($exchangeName) ); $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); - curl_setopt($ch, CURLOPT_USERPWD, $dsn->getUser().':'.$dsn->getPassword()); - curl_setopt($ch, CURLOPT_HTTPHEADER, [ + curl_setopt($ch, \CURLOPT_URL, $url); + curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, 'DELETE'); + curl_setopt($ch, \CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, \CURLOPT_HTTPAUTH, \CURLAUTH_BASIC); + curl_setopt($ch, \CURLOPT_USERPWD, $dsn->getUser().':'.$dsn->getPassword()); + curl_setopt($ch, \CURLOPT_HTTPHEADER, [ 'Content-Type' => 'application/json', ]); curl_exec($ch); - $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); + $httpCode = curl_getinfo($ch, \CURLINFO_HTTP_CODE); curl_close($ch); diff --git a/ReadAttributeTrait.php b/ReadAttributeTrait.php index 6938f25..5b9758a 100644 --- a/ReadAttributeTrait.php +++ b/ReadAttributeTrait.php @@ -2,8 +2,6 @@ namespace Enqueue\Test; -use ReflectionProperty; - trait ReadAttributeTrait { public function readAttribute(object $object, string $attribute) @@ -19,14 +17,14 @@ public function readAttribute(object $object, string $attribute) private function getClassAttribute( object $object, string $attribute, - ?string $class = null - ): ReflectionProperty { + ?string $class = null, + ): \ReflectionProperty { if (null === $class) { - $class = get_class($object); + $class = $object::class; } try { - return new ReflectionProperty($class, $attribute); + return new \ReflectionProperty($class, $attribute); } catch (\ReflectionException $exception) { $parentClass = get_parent_class($object); if (false === $parentClass) { diff --git a/RedisExtension.php b/RedisExtension.php index 86586d1..3227785 100644 --- a/RedisExtension.php +++ b/RedisExtension.php @@ -20,7 +20,7 @@ private function buildPhpRedisContext(): RedisContext $context = (new RedisConnectionFactory($config))->createContext(); - //guard + // guard $this->assertInstanceOf(PhpRedis::class, $context->getRedis()); return $context; @@ -36,7 +36,7 @@ private function buildPRedisContext(): RedisContext $context = (new RedisConnectionFactory($config))->createContext(); - //guard + // guard $this->assertInstanceOf(PRedis::class, $context->getRedis()); return $context; diff --git a/TestLogger.php b/TestLogger.php index d61c679..9db2c2a 100644 --- a/TestLogger.php +++ b/TestLogger.php @@ -111,7 +111,7 @@ public function hasRecord($record, $level) public function hasRecordThatContains($message, $level) { return $this->hasRecordThatPasses(function ($rec) use ($message) { - return false !== strpos($rec['message'], $message); + return str_contains($rec['message'], $message); }, $level); } diff --git a/WriteAttributeTrait.php b/WriteAttributeTrait.php index e2e84bd..6f8c1aa 100644 --- a/WriteAttributeTrait.php +++ b/WriteAttributeTrait.php @@ -7,11 +7,10 @@ trait WriteAttributeTrait /** * @param object $object * @param string $attribute - * @param mixed $value */ public function writeAttribute($object, $attribute, $value) { - $refProperty = new \ReflectionProperty(get_class($object), $attribute); + $refProperty = new \ReflectionProperty($object::class, $attribute); $refProperty->setAccessible(true); $refProperty->setValue($object, $value); $refProperty->setAccessible(false);