Skip to content

Commit

Permalink
more little steps
Browse files Browse the repository at this point in the history
  • Loading branch information
dcarbone committed Nov 10, 2024
1 parent 70338f5 commit 21e0f0e
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 67 deletions.
8 changes: 1 addition & 7 deletions files/constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@
const PHPFHIR_OUTPUT_TMP_DIR = PHPFHIR_DEFAULT_OUTPUT_DIR . DIRECTORY_SEPARATOR . 'tmp';
const PHPFHIR_FHIR_VALIDATION_JAR = PHPFHIR_BIN_DIR . DIRECTORY_SEPARATOR . 'validator_cli.jar';

// format regex
const PHPFHIR_VARIABLE_NAME_REGEX = '{^[a-zA-Z_][a-zA-Z0-9_]*$}S';
const PHPFHIR_FUNCTION_NAME_REGEX = '{^[a-zA-Z_][a-zA-Z0-9_]*$}S';
const PHPFHIR_CLASSNAME_REGEX = '{^[a-zA-Z_][a-zA-Z0-9_]*$}S';
const PHPFHIR_NAMESPACE_REGEX = '{^[a-zA-Z][a-zA-Z0-9_]*(\\\[a-zA-Z0-9_]+)*[a-zA-Z0-9_]$}';

// type suffixes
const PHPFHIR_PRIMITIVE_SUFFIX = '-primitive';
const PHPFHIR_LIST_SUFFIX = '-list';
Expand Down Expand Up @@ -81,13 +75,13 @@
// Core class names
const PHPFHIR_CLASSNAME_AUTOLOADER = 'Autoloader';
const PHPFHIR_CLASSNAME_CONFIG = 'Config';
const PHPFHIR_CLASSNAME_TYPEMAP = 'TypeMap';
const PHPFHIR_CLASSNAME_RESPONSE_PARSER = 'ResponseParser';
const PHPFHIR_CLASSNAME_CONSTANTS = 'Constants';
const PHPFHIR_CLASSNAME_API_CLIENT = 'ApiClient';
const PHPFHIR_CLASSNAME_API_CLIENT_REQUEST = 'ApiClientRequest';
const PHPFHIR_CLASSNAME_API_CLIENT_RESPONSE = 'ApiClientResponse';
const PHPFHIR_CLASSNAME_XML_WRITER = 'XmlWriter';
const PHPFHIR_CLASSNAME_DEBUG_CLIENT = 'DebugClient';

// Core interface names
const PHPFHIR_INTERFACE_TYPE_MAP = 'TypeMapInterface';
Expand Down
1 change: 0 additions & 1 deletion src/Utilities/FileUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public static function mkdirRecurse(string ...$bits): string
if (!is_dir($path) && !mkdir($path, 0777, true)) {
throw new RuntimeException(sprintf('Unable to create directory at path "%s"', $path));
}
var_dump(realpath($path));
return realpath($path);
}

Expand Down
13 changes: 9 additions & 4 deletions src/Utilities/NameUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
*/
abstract class NameUtils
{
public const VARIABLE_NAME_REGEX = '{^[a-zA-Z_][a-zA-Z0-9_]*$}S';
public const FUNCTION_NAME_REGEX = '{^[a-zA-Z_][a-zA-Z0-9_]*$}S';
public const CLASSNAME_REGEX = '{^[a-zA-Z_][a-zA-Z0-9_]*$}S';
public const NAMESPACE_REGEX = '{^[a-zA-Z][a-zA-Z0-9_]*(\\\[a-zA-Z0-9_]+)*[a-zA-Z0-9_]$}';

/** @var array */
public static array $classNameSearch = [
'.',
Expand Down Expand Up @@ -115,7 +120,7 @@ abstract class NameUtils
*/
public static function isValidVariableName(string $name): bool
{
return (bool)preg_match(PHPFHIR_VARIABLE_NAME_REGEX, $name);
return (bool)preg_match(self::VARIABLE_NAME_REGEX, $name);
}

/**
Expand All @@ -124,7 +129,7 @@ public static function isValidVariableName(string $name): bool
*/
public static function isValidFunctionName(string $name): bool
{
return (bool)preg_match(PHPFHIR_FUNCTION_NAME_REGEX, $name);
return (bool)preg_match(self::FUNCTION_NAME_REGEX, $name);
}

/**
Expand All @@ -133,7 +138,7 @@ public static function isValidFunctionName(string $name): bool
*/
public static function isValidClassName(string $name): bool
{
return (bool)preg_match(PHPFHIR_CLASSNAME_REGEX, $name);
return (bool)preg_match(self::CLASSNAME_REGEX, $name);
}

/**
Expand All @@ -142,7 +147,7 @@ public static function isValidClassName(string $name): bool
*/
public static function isValidNSName(?string $name): bool
{
return null === $name || '' === $name || preg_match(PHPFHIR_NAMESPACE_REGEX, $name);
return null === $name || '' === $name || preg_match(self::NAMESPACE_REGEX, $name);
}

/**
Expand Down
5 changes: 0 additions & 5 deletions template/core/classes/class_autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,6 @@
require __DIR__ . DIRECTORY_SEPARATOR . '<?php echo PHPFHIR_CLASSNAME_API_CLIENT; ?>.php';
}

// debug client
if (!class_exists('<?php echo $config->getFullyQualifiedName(true, PHPFHIR_CLASSNAME_DEBUG_CLIENT); ?>', false)) {
require __DIR__ . DIRECTORY_SEPARATOR . '<?php echo PHPFHIR_CLASSNAME_DEBUG_CLIENT; ?>.php';
}

/**
* Class <?php echo PHPFHIR_CLASSNAME_AUTOLOADER; if ('' !== $namespace) : ?>

Expand Down
47 changes: 0 additions & 47 deletions template/core/classes/class_debug_client.php

This file was deleted.

6 changes: 3 additions & 3 deletions template/versions/types/tests/integration/class.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@

use <?php echo $bundleType->getFullyQualifiedClassName(false); ?>;
use <?php echo $type->getFullyQualifiedClassName(false); ?>;
use <?php echo $config->getFullyQualifiedName(false, PHPFHIR_CLASSNAME_DEBUG_CLIENT); ?>;
use <?php echo $config->getFullyQualifiedName(false, PHPFHIR_CLASSNAME_API_CLIENT); ?>;
use <?php echo $config->getFullyQualifiedName(false, PHPFHIR_ENUM_TYPE); ?>;
use <?php echo $config->getFullyQualifiedName(false, PHPFHIR_CLASSNAME_RESPONSE_PARSER); ?>;
use PHPUnit\Framework\AssertionFailedError;
Expand All @@ -82,8 +82,8 @@
*/
class <?php echo $testClassname; ?> extends TestCase
{
/** @var <?php echo $config->getFullyQualifiedName(true, PHPFHIR_CLASSNAME_DEBUG_CLIENT); ?> */
private <?php echo PHPFHIR_CLASSNAME_DEBUG_CLIENT; ?> $client;
/** @var <?php echo $config->getFullyQualifiedName(true, PHPFHIR_CLASSNAME_API_CLIENT); ?> */
private <?php echo PHPFHIR_CLASSNAME_API_CLIENT; ?> $client;

/** @var array */
private array $_fetchedResources = [];
Expand Down

0 comments on commit 21e0f0e

Please sign in to comment.