<commit_before><?php

namespace PrettyPrinter\Utils;

class ArrayUtil
{
	static function get( $array, $key, $default = null )
	{
		return isset( $array[ $key ] ) ? $array[ $key ] : $default;
	}

	static function isAssoc( $array )
	{
		$index = 0;

		foreach ( $array as $key => $value )
			if ( $key !== $index++ )
				return true;

		return false;
	}

	static function lastKey( array $array )
	{
		$keys = array_keys( $array );

		assert( !empty( $keys ) );

		return $keys[ count( $keys ) - 1 ];
	}
}
<commit_msg>Made ArrayUtil::isAssoc() and ArrayUtil::lastKey() not copy the given array.<commit_after><?php

namespace PrettyPrinter\Utils;

class ArrayUtil
{
	static function get( $array, $key, $default = null )
	{
		return isset( $array[ $key ] ) ? $array[ $key ] : $default;
	}

	static function isAssoc( array $array )
	{
		$i = 0;

		foreach ( $array as $k => &$v )
			if ( $k !== $i++ )
				return false;

		return true;
	}

	static function lastKey( array $array )
	{
		foreach ( $array as $k => &$v )
			;

		return isset( $k ) ? $k : null;
	}
}

{'fraction_non_alphanumeric': 0.16556291390728478, 'fraction_numerical': 0.002838221381267739, 'mean_word_length': 3.1167315175097277, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6799554', 'n_tokens_mistral': 428, 'n_tokens_neox': 390, 'n_words': 114}