Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Replace function call with language construct (isset([]) evaluates to…
… true)
  • Loading branch information
Willem Stuursma committed Jul 31, 2018
commit ec1d4fc213648a1c36ab1f619e3461069b0a7d76
2 changes: 1 addition & 1 deletion src/Enum.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public static function values()
public static function toArray()
{
$class = \get_called_class();
if (!\array_key_exists($class, static::$cache)) {
if (!isset(static::$cache[$class])) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this change doesn't introduce BC breaks?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. static::$cache can only be instances of array, for which isset returns the exact values as array_key_exists. The only difference between the two is their behaviour around null values.

$reflection = new \ReflectionClass($class);
static::$cache[$class] = $reflection->getConstants();
}
Expand Down