Skip to content

Commit

Permalink
Remove PHP 7 workarounds (#11324)
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabus authored Mar 1, 2024
1 parent 20a6efd commit 694413a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
5 changes: 0 additions & 5 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,4 @@
<!-- https://github.com/doctrine/orm/issues/8537 -->
<exclude-pattern>src/QueryBuilder.php</exclude-pattern>
</rule>

<rule ref="SlevomatCodingStandard.PHP.UselessParentheses">
<!-- We need those parentheses to make enum access seem like valid syntax on PHP 7 -->
<exclude-pattern>src/Mapping/Driver/XmlDriver.php</exclude-pattern>
</rule>
</ruleset>
8 changes: 2 additions & 6 deletions src/Internal/CriteriaOrderings.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ private static function getCriteriaOrderings(Criteria $criteria): array
}

return array_map(
static function (Order $order): string {
return $order->value;
},
static fn (Order $order): string => $order->value,
$criteria->orderings(),
);
}
Expand All @@ -45,9 +43,7 @@ private static function mapToOrderEnumIfAvailable(array $orderings): array
}

return array_map(
static function (string $order): Order {
return Order::from(strtoupper($order));
},
static fn (string $order): Order => Order::from(strtoupper($order)),
$orderings,
);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Mapping/Driver/XmlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
use SimpleXMLElement;

use function assert;
use function class_exists;
use function constant;
use function count;
use function defined;
use function enum_exists;
use function explode;
use function extension_loaded;
use function file_get_contents;
Expand Down Expand Up @@ -408,7 +408,7 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad
/** @psalm-suppress DeprecatedConstant */
$orderBy[(string) $orderByField['name']] = isset($orderByField['direction'])
? (string) $orderByField['direction']
: (class_exists(Order::class) ? (Order::Ascending)->value : Criteria::ASC);
: (enum_exists(Order::class) ? Order::Ascending->value : Criteria::ASC);
}

$mapping['orderBy'] = $orderBy;
Expand Down Expand Up @@ -537,7 +537,7 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad
/** @psalm-suppress DeprecatedConstant */
$orderBy[(string) $orderByField['name']] = isset($orderByField['direction'])
? (string) $orderByField['direction']
: (class_exists(Order::class) ? (Order::Ascending)->value : Criteria::ASC);
: (enum_exists(Order::class) ? Order::Ascending->value : Criteria::ASC);
}

$mapping['orderBy'] = $orderBy;
Expand Down

0 comments on commit 694413a

Please sign in to comment.