From 9964e37b473d8fa774201cef9144bb49d7a497c9 Mon Sep 17 00:00:00 2001 From: Matt Stauffer Date: Tue, 30 Nov 2021 12:33:01 -0500 Subject: [PATCH] Update upgrade.sh to work with extracted Collections --- .gitattributes | 2 -- composer.json | 6 +++++- stubs/src/Collect/Support/alias.php | 3 +++ stubs/src/Collect/Support/helpers.php | 15 +++++++++++++++ upgrade.sh | 26 ++++++++++++++++++++++++++ 5 files changed, 49 insertions(+), 3 deletions(-) diff --git a/.gitattributes b/.gitattributes index 00ac6e1..65307ea 100644 --- a/.gitattributes +++ b/.gitattributes @@ -9,5 +9,3 @@ /phpunit.xml.dist export-ignore /readme.md export-ignore /upgrade.sh export-ignore -/tests/files/Support/Carbon.php export-ignore -/tests/files/Support/HtmlString.php export-ignore diff --git a/composer.json b/composer.json index 58e5f6c..8016e99 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,11 @@ "tests/files/Support/HtmlString.php", "tests/files/Support/HigherOrderTapProxy.php", "tests/files/Support/Str.php", - "tests/files/Support/Stringable.php" + "tests/files/Support/Traits/Conditionable.php", + "tests/files/Support/Stringable.php", + "tests/files/Support/ItemNotFoundException.php", + "tests/files/Support/MultipleItemsFoundException.php", + "tests/Support/Concerns/CountsEnumerations.php" ] }, "scripts": { diff --git a/stubs/src/Collect/Support/alias.php b/stubs/src/Collect/Support/alias.php index 6ad0cdc..c0f9c0e 100644 --- a/stubs/src/Collect/Support/alias.php +++ b/stubs/src/Collect/Support/alias.php @@ -2,8 +2,11 @@ $aliases = [/*--- ALIASES ---*/]; +# echo "\n\n-- Aliasing....\n---------------------------------------------\n\n"; + foreach ($aliases as $tighten => $illuminate) { if (! class_exists($illuminate) && ! interface_exists($illuminate) && ! trait_exists($illuminate)) { + # echo "Aliasing {$tighten} to {$illuminate}.\n"; class_alias($tighten, $illuminate); } } diff --git a/stubs/src/Collect/Support/helpers.php b/stubs/src/Collect/Support/helpers.php index 4160770..01613e1 100755 --- a/stubs/src/Collect/Support/helpers.php +++ b/stubs/src/Collect/Support/helpers.php @@ -136,4 +136,19 @@ function dd(...$args) die(1); } } + + if (! function_exists('class_basename')) { + /** + * Get the class "basename" of the given object / class. + * + * @param string|object $class + * @return string + */ + function class_basename($class) + { + $class = is_object($class) ? get_class($class) : $class; + + return basename(str_replace('\\', '/', $class)); + } + } } diff --git a/upgrade.sh b/upgrade.sh index d85b745..c245064 100755 --- a/upgrade.sh +++ b/upgrade.sh @@ -134,6 +134,7 @@ carriageReturn=" 'Contracts/Support/Arrayable' 'Contracts/Support/Jsonable' 'Contracts/Support/Htmlable' + 'Contracts/Support/CanBeEscapedWhenCastToString' ) tests=( @@ -142,6 +143,7 @@ carriageReturn=" 'Support/SupportMacroableTest.php' 'Support/SupportLazyCollectionTest.php' 'Support/SupportLazyCollectionIsLazyTest.php' + 'Support/Concerns/CountsEnumerations.php' ) testSupportClasses=( @@ -150,6 +152,12 @@ carriageReturn=" 'Support/HtmlString' 'Support/Str' 'Support/Stringable' + 'Support/Traits/Conditionable' + ) + + testSupportClassesInExtractedCollections=( + 'Support/ItemNotFoundException' + 'Support/MultipleItemsFoundException' ) stubs=( @@ -395,6 +403,22 @@ function copyTestSupportClasses() chmod 644 ${testSupportDirectory}/${class}.php done + for class in ${testSupportClassesInExtractedCollections[@]}; do + echo "Copying ${oldNamespaceDir}/${class} (from extracted Collections)..." + + mkdir -p $(dirname $testSupportDirectory/$class) + + # Extract these classes from Illuminate/Collections, even though they end up in + # the Illuminate/Support namespace + movedClassFilename=${class/Support/Collections} + + cp ${oldNamespaceDir}/${movedClassFilename}.php ${testSupportDirectory}/$class.php + + chmod 644 ${testSupportDirectory}/${class}.php + done + + testSupportClassesInExtractedCollections + # @todo: do this more cleanly find ./tests/files -name "*.php" -exec sed -i "" -e "s|Illuminate\\\Support|/\*--- OLDNAMESPACE ---\*/\\\Support|g" {} \; } @@ -426,6 +450,8 @@ function renameNamespace() find ${testsDir} -name "*.php" -exec sed -i "" -e "s|Illuminate\\\Support\\\Traits\\\Tappable|Tightenco\\\Collect\\\Support\\\Traits\\\Tappable|g" {} \; find ${testSupportDirectory} -name "HigherOrderTapProxy.php" -exec sed -i "" -e "s|Illuminate\\\Support|Tightenco\\\Collect\\\Support|g" {} \; + find ${testSupportDirectory} -name "ItemNotFoundException.php" -exec sed -i "" -e "s|Illuminate\\\Support|Tightenco\\\Collect\\\Support|g" {} \; + find ${testSupportDirectory} -name "MultipleItemsFoundException.php" -exec sed -i "" -e "s|Illuminate\\\Support|Tightenco\\\Collect\\\Support|g" {} \; } ##