mirror of
https://github.com/php/php-src.git
synced 2025-08-17 14:38:49 +02:00

This patch adds missing newlines, trims multiple redundant final newlines into a single one, and trims redundant leading newlines. According to POSIX, a line is a sequence of zero or more non-' <newline>' characters plus a terminating '<newline>' character. [1] Files should normally have at least one final newline character. C89 [2] and later standards [3] mention a final newline: "A source file that is not empty shall end in a new-line character, which shall not be immediately preceded by a backslash character." Although it is not mandatory for all files to have a final newline fixed, a more consistent and homogeneous approach brings less of commit differences issues and a better development experience in certain text editors and IDEs. [1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206 [2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2 [3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
121 lines
4.4 KiB
PHP
121 lines
4.4 KiB
PHP
<?php
|
|
function inspectClass($class) {
|
|
|
|
/* not used: public ReflectionClass[] getInterfaces() */
|
|
|
|
printf("\nInspecting class '%s'\n", $class->getName());
|
|
printf("isInternal: %s\n", ($class->isInternal()) ? 'yes' : 'no');
|
|
printf("isUserDefined: %s\n", ($class->isUserDefined()) ? 'yes' : 'no');
|
|
printf("isInstantiable: %s\n", ($class->isInstantiable()) ? 'yes' : 'no');
|
|
printf("isInterface: %s\n", ($class->isInterface()) ? 'yes' : 'no');
|
|
printf("isAbstract: %s\n", ($class->isAbstract()) ? 'yes' : 'no');
|
|
printf("isFinal: %s\n", ($class->isFinal()) ? 'yes' : 'no');
|
|
printf("isIteratable: %s\n", ($class->isIterateable()) ? 'yes' : 'no');
|
|
printf("Modifiers: '%d'\n", $class->getModifiers());
|
|
printf("Parent Class: '%s'\n", $class->getParentClass());
|
|
printf("Extension: '%s'\n", $class->getExtensionName());
|
|
|
|
if ($method = $class->getConstructor())
|
|
inspectMethod($method);
|
|
|
|
if ($methods = $class->getMethods()) {
|
|
$tmp = array();
|
|
foreach ($methods as $method)
|
|
$tmp[$method->getName()] = $method;
|
|
|
|
ksort($tmp, SORT_STRING);
|
|
foreach ($tmp as $method)
|
|
inspectMethod($method);
|
|
}
|
|
|
|
if ($properties = $class->getProperties()) {
|
|
$tmp = array();
|
|
foreach ($properties as $prop)
|
|
$tmp[$prop->getName()] = $prop;
|
|
ksort($tmp, SORT_STRING);
|
|
foreach ($tmp as $prop)
|
|
inspectProperty($prop);
|
|
}
|
|
|
|
|
|
if ($properties = $class->getDefaultProperties()) {
|
|
ksort($properties, SORT_STRING);
|
|
foreach ($properties as $name => $v)
|
|
printf("Default property '%s'\n", $name);
|
|
}
|
|
|
|
if ($properties = $class->getStaticProperties()) {
|
|
ksort($properties, SORT_STRING);
|
|
foreach ($properties as $name => $v)
|
|
printf("Static property '%s'\n", $name);
|
|
}
|
|
|
|
if ($constants = $class->getConstants()) {
|
|
ksort($constants, SORT_STRING);
|
|
foreach ($constant as $name => $value)
|
|
printf("Constant '%s' = '%s'\n", $name, $value);
|
|
}
|
|
|
|
}
|
|
|
|
function inspectProperty(&$prop) {
|
|
|
|
printf("\nInspecting property '%s'\n", $prop->getName());
|
|
printf("isPublic: %s\n", ($prop->isPublic()) ? 'yes' : 'no');
|
|
printf("isPrivate: %s\n", ($prop->isPrivate()) ? 'yes' : 'no');
|
|
printf("isProtected: %s\n", ($prop->isProtected()) ? 'yes' : 'no');
|
|
printf("isStatic: %s\n", ($prop->isStatic()) ? 'yes' : 'no');
|
|
printf("isDefault: %s\n", ($prop->isDefault()) ? 'yes' : 'no');
|
|
printf("Modifiers: %d\n", $prop->getModifiers());
|
|
// printf("Value\n"); var_export($prop->getValue());
|
|
|
|
}
|
|
|
|
function inspectMethod(&$method) {
|
|
|
|
printf("\nInspecting method '%s'\n", $method->getName());
|
|
printf("isFinal: %s\n", ($method->isFinal()) ? 'yes' : 'no');
|
|
printf("isAbstract: %s\n", ($method->isAbstract()) ? 'yes' : 'no');
|
|
printf("isPublic: %s\n", ($method->isPublic()) ? 'yes' : 'no');
|
|
printf("isPrivate: %s\n", ($method->isPrivate()) ? 'yes' : 'no');
|
|
printf("isProtected: %s\n", ($method->isProtected()) ? 'yes' : 'no');
|
|
printf("isStatic: %s\n", ($method->isStatic()) ? 'yes' : 'no');
|
|
printf("isConstructor: %s\n", ($method->isConstructor()) ? 'yes' : 'no');
|
|
printf("isDestructor: %s\n", ($method->isDestructor()) ? 'yes' : 'no');
|
|
printf("isInternal: %s\n", ($method->isInternal()) ? 'yes' : 'no');
|
|
printf("isUserDefined: %s\n", ($method->isUserDefined()) ? 'yes' : 'no');
|
|
printf("returnsReference: %s\n", ($method->returnsReference()) ? 'yes' : 'no');
|
|
printf("Modifiers: %d\n", $method->getModifiers());
|
|
printf("Number of Parameters: %d\n", $method->getNumberOfParameters());
|
|
printf("Number of Required Parameters: %d\n", $method->getNumberOfRequiredParameters());
|
|
|
|
if ($params = $method->getParameters()) {
|
|
$tmp = array();
|
|
foreach ($params as $k => $param)
|
|
$tmp[$param->getName()] = $param;
|
|
|
|
// ksort($tmp, SORT_STRING);
|
|
foreach ($tmp as $param)
|
|
inspectParameter($method, $param);
|
|
}
|
|
|
|
if ($static = $method->getStaticVariables()) {
|
|
sort($static, SORT_STRING);
|
|
printf("Static variables: %s\n", implode('/', $static));
|
|
}
|
|
|
|
}
|
|
|
|
function inspectParameter(&$method, &$param) {
|
|
|
|
printf("\nInspecting parameter '%s' of method '%s'\n",
|
|
$param->getName(), $method->getName());
|
|
printf("isArray: %s\n", ($param->isArray()) ? 'yes': 'no');
|
|
printf("allowsNull: %s\n", ($param->allowsNull()) ? 'yes' : 'no');
|
|
printf("isPassedByReference: %s\n", ($param->isPassedByReference()) ? 'yes' : 'no');
|
|
printf("isOptional: %s\n", ($param->isOptional()) ? 'yes' : 'no');
|
|
printf("isDefaultValueAvailable: %s\n", ($param->isDefaultValueAvailable()) ? 'yes' : 'no');
|
|
// printf("getDefaultValue: %s\n", ($param->getDefaultValue()) ? 'yes' : 'no');
|
|
|
|
}
|
|
?>
|