From d36b71662543fa85c8919951a687d99cc504c244 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 15 Nov 2018 01:00:15 +0100 Subject: [PATCH] Continued: - improved find-bad-php.sh - RegistryIterator->rewind() doesn't need to rewind when there is nothing to iterate - imported deprecated class --- contrib/find-bad-php.sh | 13 ++++++------- .../directory/class_FrameworkDirectoryPointer.php | 3 +++ .../iterator/registry/class_RegistryIterator.php | 14 ++++++++++---- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/contrib/find-bad-php.sh b/contrib/find-bad-php.sh index 6febfcfc..45d6e7af 100755 --- a/contrib/find-bad-php.sh +++ b/contrib/find-bad-php.sh @@ -5,18 +5,17 @@ PHP=$(find -type f -name "*.php" 2>&1 | grep -v "third_party" | grep -v "/vendor for SCRIPT in ${PHP}; do - HEADER=$(cat ${SCRIPT} | head -n 1 | grep -v "") - FOOTER=$(cat ${SCRIPT} | tail -n 1 | grep "?>") - - if [ -n "${HEADER}" ]; + if [ -n "${SHORT_OPEN_TAG}" ]; then - echo "$0: Script '${SCRIPT}' has non-typical header." + echo "$0: Script '${SCRIPT}' has short opening tag ()." fi LINT=$(php -l "${SCRIPT}" 2>&1 | grep -v "Constant FUSE_EDEADLK already defined in Unknown on line 0" | grep -v "No syntax errors detected in") diff --git a/framework/main/classes/file_directories/directory/class_FrameworkDirectoryPointer.php b/framework/main/classes/file_directories/directory/class_FrameworkDirectoryPointer.php index d7f346a1..4b2e1107 100644 --- a/framework/main/classes/file_directories/directory/class_FrameworkDirectoryPointer.php +++ b/framework/main/classes/file_directories/directory/class_FrameworkDirectoryPointer.php @@ -7,6 +7,9 @@ use Org\Mxchange\CoreFramework\Filesystem\FrameworkDirectory; use Org\Mxchange\CoreFramework\Generic\NullPointerException; use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem; +// Deprecated imports +use Org\Mxchange\CoreFramework\Deprecated\PathIsNoDirectoryException; + // Import SPL stuff use \DirectoryIterator; diff --git a/framework/main/classes/iterator/registry/class_RegistryIterator.php b/framework/main/classes/iterator/registry/class_RegistryIterator.php index 93d54fa8..c01722ad 100644 --- a/framework/main/classes/iterator/registry/class_RegistryIterator.php +++ b/framework/main/classes/iterator/registry/class_RegistryIterator.php @@ -39,7 +39,7 @@ class RegistryIterator extends BaseIterator implements IteratableRegistry { /** * All found registry keys */ - private $registryKeys = array(); + private $registryKeys = []; /** * Current array key @@ -109,7 +109,7 @@ class RegistryIterator extends BaseIterator implements IteratableRegistry { $entries = $this->getRegistryInstance()->getGenericRegistry(); // Init registry keys array - $this->registryKeys['generic'] = array(); + $this->registryKeys['generic'] = []; // Anything in there? if (count($entries) > 0) { @@ -121,7 +121,7 @@ class RegistryIterator extends BaseIterator implements IteratableRegistry { $entries = $this->getRegistryInstance()->getInstanceRegistry(); // Init registry keys array - $this->registryKeys['instance'] = array(); + $this->registryKeys['instance'] = []; // Anything in there? if (count($entries) > 0) { @@ -178,7 +178,7 @@ class RegistryIterator extends BaseIterator implements IteratableRegistry { //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('REGISTRY-ITERATOR[instance]: key=%s,entry[]=%s - Adding ...', $key, gettype($entry))); // Add key to array - $this->registryKeys['instance'][$key] = array(); + $this->registryKeys['instance'][$key] = []; } // END - foreach } // END - if } @@ -233,6 +233,12 @@ class RegistryIterator extends BaseIterator implements IteratableRegistry { * @return void */ public function rewind () { + // Is the registry empty? + if (count($this->registryKeys) == 0) { + // Then no need to continue + return; + } // END - if + // Debugging: /* DEBUG-DIE: */ die(sprintf('[%s:%d]: this->key(%d)[%s]=%s,this->valid=%d,this->registryKeys=%s', __METHOD__, __LINE__, strlen($this->key()), gettype($this->key()), $this->key(), intval($this->valid()), print_r($this->registryKeys, TRUE))); } -- 2.39.5