Skip to content

Commit

Permalink
remove runtime Sentry support
Browse files Browse the repository at this point in the history
  • Loading branch information
VasekPurchart committed Dec 31, 2018
1 parent 0a27595 commit 8ed8059
Show file tree
Hide file tree
Showing 16 changed files with 0 additions and 1,078 deletions.
82 changes: 0 additions & 82 deletions src/Runtime/RuntimeHelper.php

This file was deleted.

41 changes: 0 additions & 41 deletions src/Runtime/RuntimeHelperBridge.php

This file was deleted.

18 changes: 0 additions & 18 deletions src/Runtime/exceptions/RuntimeHelperNotInitializedException.php

This file was deleted.

19 changes: 0 additions & 19 deletions src/SentryObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,7 @@

namespace Consistence\Sentry;

use Consistence\Sentry\Runtime\RuntimeHelperBridge;
use Consistence\Type\ObjectMixin;

/**
* @codeCoverageIgnore has dependency on global state
*/
abstract class SentryObject extends \Consistence\ObjectPrototype implements \Consistence\Sentry\SentryAware
{

/**
* @param string $method
* @param mixed[] $args
* @return mixed
*/
public function __call($method, array $args)
{
$helper = RuntimeHelperBridge::getHelper();
return $helper->run($this, $method, $args, function (SentryAware $object, $methodName) {
ObjectMixin::magicCall($object, $methodName);
});
}

}
38 changes: 0 additions & 38 deletions src/Type/AbstractSentry.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Consistence\Sentry\Metadata\PropertyMetadata;
use Consistence\Sentry\Metadata\SentryAccess;
use Consistence\Sentry\Metadata\SentryMethod;
use Consistence\Sentry\SentryAware;
use Consistence\Type\ArrayType\ArrayType;

/**
Expand All @@ -31,22 +30,6 @@ public function getSupportedAccess()
];
}

/**
* Redirects process requests to methods named {sentryAccess}(...)
*
* @param \Consistence\Sentry\Metadata\PropertyMetadata $propertyMetadata
* @param \Consistence\Sentry\SentryAware $object
* @param \Consistence\Sentry\Metadata\SentryMethod $sentryMethod
* @param mixed[] $args
* @return mixed
*/
public function processMethod(PropertyMetadata $propertyMetadata, SentryAware $object, SentryMethod $sentryMethod, array $args)
{
$this->checkSupportedSentryAccess($propertyMetadata, $sentryMethod->getSentryAccess());

return $this->{lcfirst($sentryMethod->getSentryAccess()->getName())}($propertyMetadata, $object, $args);
}

/**
* Redirects generate requests to methods named generate{SentryAccess}(...)
*
Expand Down Expand Up @@ -101,27 +84,6 @@ public function getTargetAssociationAccessForAccess(SentryAccess $sentryAccess,
return [];
}

/**
* @param \Consistence\Sentry\Metadata\PropertyMetadata $property
* @param \Consistence\Sentry\SentryAware $object
* @param mixed[] $args
* @return mixed
*/
public function get(PropertyMetadata $property, SentryAware $object, array $args)
{
return TypeHelper::getPropertyValue($property, $object);
}

/**
* @param \Consistence\Sentry\Metadata\PropertyMetadata $property
* @param \Consistence\Sentry\SentryAware $object
* @param mixed[] $args
*/
public function set(PropertyMetadata $property, SentryAware $object, array $args)
{
TypeHelper::setPropertyValue($property, $object, TypeHelper::getFirstArg($args));
}

public function generateGet(PropertyMetadata $property, SentryMethod $sentryMethod): string
{
return TypeHelper::generateGet($property, $sentryMethod);
Expand Down
96 changes: 0 additions & 96 deletions src/Type/CollectionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Consistence\Sentry\Metadata\PropertyMetadata;
use Consistence\Sentry\Metadata\SentryAccess;
use Consistence\Sentry\Metadata\SentryMethod;
use Consistence\Sentry\SentryAware;
use Consistence\Type\ArrayType\ArrayType;
use Consistence\Type\Type;
use Doctrine\Common\Inflector\Inflector;
Expand Down Expand Up @@ -47,101 +46,6 @@ public function getDefaultMethodName(SentryAccess $sentryAccess, string $propert
}
}

/**
* @param \Consistence\Sentry\Metadata\PropertyMetadata $property
* @param \Consistence\Sentry\SentryAware $object
* @param mixed[] $args
*/
public function set(PropertyMetadata $property, SentryAware $object, array $args)
{
$newValues = TypeHelper::getFirstArg($args);
Type::checkType($newValues, 'array');

$collection = [];
foreach ($newValues as $item) {
$this->addValue($collection, $property, $item);
}
TypeHelper::setPropertyValue($property, $object, $collection);
}

/**
* @param \Consistence\Sentry\Metadata\PropertyMetadata $property
* @param \Consistence\Sentry\SentryAware $object
* @param mixed[] $args
* @return bool was element really added?
*/
public function add(PropertyMetadata $property, SentryAware $object, array $args): bool
{
$value = TypeHelper::getFirstArg($args);

$collection = TypeHelper::getPropertyValue($property, $object);
$changed = $this->addValue($collection, $property, $value);
TypeHelper::setPropertyValue($property, $object, $collection);

return $changed;
}

/**
* @param \Consistence\Sentry\Metadata\PropertyMetadata $property
* @param \Consistence\Sentry\SentryAware $object
* @param mixed[] $args
* @return bool was element really removed?
*/
public function remove(PropertyMetadata $property, SentryAware $object, array $args): bool
{
$value = TypeHelper::getFirstArg($args);

$collection = TypeHelper::getPropertyValue($property, $object);
$changed = $this->removeValue($collection, $property, $value);
TypeHelper::setPropertyValue($property, $object, $collection);

return $changed;
}

/**
* @param \Consistence\Sentry\Metadata\PropertyMetadata $property
* @param \Consistence\Sentry\SentryAware $object
* @param mixed[] $args
* @return bool
*/
public function contains(PropertyMetadata $property, SentryAware $object, array $args): bool
{
$value = TypeHelper::getFirstArg($args);
Type::checkType($value, $property->getType());
$collection = TypeHelper::getPropertyValue($property, $object);

return ArrayType::containsValue($collection, $value);
}

/**
* @param mixed[] $collection
* @param \Consistence\Sentry\Metadata\PropertyMetadata $property
* @param mixed $value
* @return bool was element really added?
*/
private function addValue(array &$collection, PropertyMetadata $property, $value): bool
{
Type::checkType($value, $property->getType());
if (ArrayType::containsValue($collection, $value)) {
return false;
}
$collection[] = $value;

return true;
}

/**
* @param mixed[] $collection
* @param \Consistence\Sentry\Metadata\PropertyMetadata $property
* @param mixed $value
* @return bool was element really removed?
*/
private function removeValue(array &$collection, PropertyMetadata $property, $value): bool
{
Type::checkType($value, $property->getType());
return ArrayType::removeValue($collection, $value);
}

public function generateGet(PropertyMetadata $property, SentryMethod $sentryMethod): string
{
return '
Expand Down
12 changes: 0 additions & 12 deletions src/Type/Sentry.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Consistence\Sentry\Metadata\PropertyMetadata;
use Consistence\Sentry\Metadata\SentryAccess;
use Consistence\Sentry\Metadata\SentryMethod;
use Consistence\Sentry\SentryAware;

interface Sentry
{
Expand All @@ -20,17 +19,6 @@ interface Sentry
*/
public function getSupportedAccess();

/**
* Logic which should be executed while processing SentryMethods in runtime
*
* @param \Consistence\Sentry\Metadata\PropertyMetadata $property
* @param \Consistence\Sentry\SentryAware $object
* @param \Consistence\Sentry\Metadata\SentryMethod $sentryMethod
* @param mixed[] $args arguments given to called method
* @return mixed
*/
public function processMethod(PropertyMetadata $property, SentryAware $object, SentryMethod $sentryMethod, array $args);

/**
* Generate code for a SentryMethod
*
Expand Down
13 changes: 0 additions & 13 deletions src/Type/SimpleType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,11 @@

use Consistence\Sentry\Metadata\PropertyMetadata;
use Consistence\Sentry\Metadata\SentryMethod;
use Consistence\Sentry\SentryAware;
use Consistence\Type\Type;

class SimpleType extends \Consistence\Sentry\Type\AbstractSentry
{

/**
* @param \Consistence\Sentry\Metadata\PropertyMetadata $property
* @param \Consistence\Sentry\SentryAware $object
* @param mixed[] $args
*/
public function set(PropertyMetadata $property, SentryAware $object, array $args)
{
$value = TypeHelper::getFirstArg($args);
Type::checkType($value, TypeHelper::getRequiredTypeString($property));
TypeHelper::setPropertyValue($property, $object, $value);
}

public function generateSet(PropertyMetadata $property, SentryMethod $sentryMethod): string
{
$method = '
Expand Down
Loading

0 comments on commit 8ed8059

Please sign in to comment.