<commit_before><?php
require 'flourish/fLoader.php';
require 'classes/sLoader.php';
sLoader::best();

$exceptions = array(
  'sImage' => array('determineMimeType'),
  'sNumber' => array('ordinalNumberPrefixedCallback'),
  'sORMJSON' => array('JSONToValue', 'valueToJSON'),
  'sProcessException' => array('registerCallback'),
);

foreach (get_declared_classes() as $class_name) {
  $reflect = new ReflectionClass($class_name);
  $methods = $reflect->getMethods(ReflectionMethod::IS_STATIC);

  foreach ($methods as $method) {
    if (isset($exceptions[$class_name]) && in_array($method->name, $exceptions[$class_name])) {
      continue;
    }

    if ($class_name[0] == 's' && $method->isPublic() && !$reflect->hasConstant($method->name)) {
      print $class_name.' lacks constant: '.$method->name."\n";
    }
  }
}<commit_msg>Check that static classes have private __construct() methods (again)<commit_after><?php
require 'flourish/fLoader.php';
require 'classes/sLoader.php';
sLoader::best();

$exceptions = array(
  'sImage' => array('determineMimeType'),
  'sNumber' => array('ordinalNumberPrefixedCallback'),
  'sORMJSON' => array('JSONToValue', 'valueToJSON'),
  'sProcessException' => array('registerCallback'),
);
$classes = get_declared_classes();

foreach ($classes as $class_name) {
  $reflect = new ReflectionClass($class_name);
  $methods = $reflect->getMethods(ReflectionMethod::IS_STATIC);

  foreach ($methods as $method) {
    if (isset($exceptions[$class_name]) && in_array($method->name, $exceptions[$class_name])) {
      continue;
    }

    if ($class_name[0] == 's' && $method->isPublic() && !$reflect->hasConstant($method->name)) {
      print $class_name.' lacks constant: '.$method->name."\n";
    }
  }
}
print "\n";

$exceptions = array(
  'fORMValidation' => TRUE,
);

foreach ($classes as $class_name) {
  if (isset($exceptions[$class_name])) {
    continue;
  }

  $reflect = new ReflectionClass($class_name);

  if ($reflect->isInternal()) {
    continue;
  }

  $methods = $reflect->getMethods();
  $all_static = TRUE;

  foreach ($methods as $method) {
    if (!$method->isStatic() && $method->name !== '__construct') {
      $all_static = FALSE;
    }
  }

  if ($all_static) {
    try {
      $method = $reflect->getMethod('__construct');
      if (!$method->isPrivate()) {
        print 'Static class '.$class_name.'\'s __construct() method must be private.'."\n";
      }
    }
    catch (Exception $e) {
      print $class_name.' has only static methods and lacks a private __construct() method.'."\n";
    }
  }
}
{'fraction_non_alphanumeric': 0.1855912294440094, 'fraction_numerical': 0.0007830853563038371, 'mean_word_length': 4.390295358649789, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 30, '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': '6127464', 'n_tokens_mistral': 837, 'n_tokens_neox': 816, 'n_words': 164}