Skip to content

Commit

Permalink
Non-iterable interface deprecated and removed from all classes
Browse files Browse the repository at this point in the history
  • Loading branch information
paranoiq committed Dec 6, 2019
1 parent aabb0b7 commit a1054d7
Show file tree
Hide file tree
Showing 13 changed files with 12 additions and 25 deletions.
2 changes: 0 additions & 2 deletions src/Enum/EnumMixin.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Dogma\InvalidTypeException;
use Dogma\InvalidValueException;
use Dogma\NonCloneableMixin;
use Dogma\NonIterableMixin;
use Dogma\NonSerializableMixin;
use Dogma\StrictBehaviorMixin;
use function count;
Expand All @@ -27,7 +26,6 @@
trait EnumMixin
{
use StrictBehaviorMixin;
use NonIterableMixin;
use NonCloneableMixin;
use NonSerializableMixin;

Expand Down
3 changes: 1 addition & 2 deletions src/Enum/IntEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@

use Dogma\Arr;
use Dogma\InvalidValueException;
use Dogma\NonIterable;

abstract class IntEnum implements NonIterable
abstract class IntEnum
{
use EnumMixin;

Expand Down
2 changes: 0 additions & 2 deletions src/Enum/SetMixin.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Dogma\InvalidTypeException;
use Dogma\InvalidValueException;
use Dogma\NonCloneableMixin;
use Dogma\NonIterableMixin;
use Dogma\NonSerializableMixin;
use Dogma\StrictBehaviorMixin;
use function count;
Expand All @@ -27,7 +26,6 @@
trait SetMixin
{
use StrictBehaviorMixin;
use NonIterableMixin;
use NonCloneableMixin;
use NonSerializableMixin;

Expand Down
3 changes: 1 addition & 2 deletions src/Enum/StringEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@

use Dogma\Arr;
use Dogma\InvalidValueException;
use Dogma\NonIterable;

abstract class StringEnum implements NonIterable
abstract class StringEnum
{
use EnumMixin;

Expand Down
5 changes: 1 addition & 4 deletions src/Geolocation/Position.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,16 @@
use Dogma\Mapping\Type\Exportable;
use Dogma\Math\Constant;
use Dogma\Math\Vector\Vector3;
use Dogma\NonIterable;
use Dogma\NonIterableMixin;
use Dogma\StrictBehaviorMixin;
use function deg2rad;
use function rad2deg;

/**
* http://www.movable-type.co.uk/scripts/latlong.html
*/
class Position implements NonIterable, Exportable
class Position
{
use StrictBehaviorMixin;
use NonIterableMixin;

public const PLANET_EARTH_RADIUS = 6371000.0;

Expand Down
5 changes: 1 addition & 4 deletions src/Reflection/MethodTypeParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

namespace Dogma\Reflection;

use Dogma\NonIterable;
use Dogma\NonIterableMixin;
use Dogma\ShouldNotHappenException;
use Dogma\StrictBehaviorMixin;
use Dogma\Type;
Expand All @@ -34,10 +32,9 @@
use function strtolower;
use function trim;

class MethodTypeParser implements NonIterable
class MethodTypeParser
{
use StrictBehaviorMixin;
use NonIterableMixin;

/**
* @param \ReflectionMethod $method
Expand Down
2 changes: 0 additions & 2 deletions src/Time/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Dogma\Check;
use Dogma\Comparable;
use Dogma\Equalable;
use Dogma\NonIterableMixin;
use Dogma\Order;
use Dogma\Pokeable;
use Dogma\StrictBehaviorMixin;
Expand All @@ -36,7 +35,6 @@
class Date implements DateOrDateTime, Pokeable
{
use StrictBehaviorMixin;
use NonIterableMixin;

public const MIN = '0001-01-01';
public const MAX = '9999-12-31';
Expand Down
3 changes: 1 addition & 2 deletions src/Time/DateOrTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@

use Dogma\Comparable;
use Dogma\Equalable;
use Dogma\NonIterable;
use Dogma\Time\Format\DateTimeFormatter;
use Dogma\Time\Format\DateTimeValues;

interface DateOrTime extends NonIterable, Equalable, Comparable
interface DateOrTime extends Equalable, Comparable
{

public function format(string $format = '', ?DateTimeFormatter $formatter = null): string;
Expand Down
2 changes: 0 additions & 2 deletions src/Time/DateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use Dogma\Check;
use Dogma\Comparable;
use Dogma\Equalable;
use Dogma\NonIterableMixin;
use Dogma\Str;
use Dogma\StrictBehaviorMixin;
use Dogma\Time\Format\DateTimeFormatter;
Expand Down Expand Up @@ -40,7 +39,6 @@
class DateTime extends \DateTimeImmutable implements DateOrDateTime, DateTimeOrTime, \DateTimeInterface
{
use StrictBehaviorMixin;
use NonIterableMixin;

public const MIN = '0001-01-01 00:00:00.000000';
public const MAX = '9999-12-31 23:59:59.999999';
Expand Down
2 changes: 0 additions & 2 deletions src/Time/Time.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Dogma\Check;
use Dogma\Comparable;
use Dogma\Equalable;
use Dogma\NonIterableMixin;
use Dogma\Order;
use Dogma\Pokeable;
use Dogma\Str;
Expand All @@ -39,7 +38,6 @@
class Time implements DateTimeOrTime, Pokeable
{
use StrictBehaviorMixin;
use NonIterableMixin;

public const MIN = '00:00:00.000000';
public const MAX = '23:59:59.999999';
Expand Down
3 changes: 3 additions & 0 deletions src/common/mixins/NonIterable.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

namespace Dogma;

/**
* @deprecated PHPStan reports invalid usage of iteration. Use it instead
*/
interface NonIterable extends \IteratorAggregate
{

Expand Down
3 changes: 3 additions & 0 deletions src/common/mixins/NonIterableMixin.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

namespace Dogma;

/**
* @deprecated PHPStan reports invalid usage of iteration. Use it instead
*/
trait NonIterableMixin
{

Expand Down
2 changes: 1 addition & 1 deletion src/common/types/Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,7 @@ public static function isIterable($value): bool
{
return is_array($value)
|| $value instanceof \stdClass
|| ($value instanceof \Traversable && !$value instanceof NonIterable);
|| ($value instanceof \Traversable);
}

/**
Expand Down

0 comments on commit a1054d7

Please sign in to comment.