-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto-insert 'use Traits' into files via .build.php during build process
- Loading branch information
Showing
6 changed files
with
42 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,26 @@ | ||
<?php | ||
/* | ||
* Generate use-list for Trait files in current directory | ||
* Generate use-list for Trait files in current directory and add the list to the appropriate file(s). | ||
* | ||
* When run inside a directory called `Plugin/`, with a PHP file inside `Plugin/` called `ActionUtils.php`, | ||
* this script will generate `use Traits\Plugin\ActionUtils;`. | ||
* | ||
* @TODO Automatically insert this list into appropriate PHP files. | ||
*/ | ||
$dest_files = [dirname(dirname(dirname(__FILE__))).'/classes/AdvancedCache.php']; | ||
|
||
if ($_handle = opendir(__DIR__)) { | ||
while (false !== ($_file = readdir($_handle))) { | ||
if ($_file != '.' && $_file != '..' && $_file != '.build.php' && stristr($_file, '.php') !== false) { | ||
echo 'use Traits\\'.basename(__DIR__).'\\'.basename($_file, '.php').';'.PHP_EOL; | ||
if ($_file !== '.' && $_file !== '..' && $_file !== '.build.php' && stristr($_file, '.php') !== false) { | ||
$use_traits_list .= 'use Traits\\'.basename(__DIR__).'\\'.basename($_file, '.php').';'.PHP_EOL.' '; | ||
} | ||
} | ||
closedir($_handle); | ||
unset($_file, $_files); | ||
} | ||
|
||
foreach ($dest_files as $file) { | ||
echo 'Updating '.$file.PHP_EOL; | ||
echo ' '.$use_traits_list; | ||
$file_contents = file_get_contents($file); | ||
$file_contents = str_replace('/*[.build.php-auto-generate-use-Traits]*/', $use_traits_list, $file_contents); | ||
file_put_contents($file, $file_contents); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,26 @@ | ||
<?php | ||
/* | ||
* Generate use-list for Trait files in current directory | ||
* Generate use-list for Trait files in current directory and add the list to the appropriate file(s). | ||
* | ||
* When run inside a directory called `Plugin/`, with a PHP file inside `Plugin/` called `ActionUtils.php`, | ||
* this script will generate `use Traits\Plugin\ActionUtils;`. | ||
* | ||
* @TODO Automatically insert this list into appropriate PHP files. | ||
*/ | ||
$dest_files = [dirname(dirname(dirname(__FILE__))).'/classes/Plugin.php']; | ||
|
||
if ($_handle = opendir(__DIR__)) { | ||
while (false !== ($_file = readdir($_handle))) { | ||
if ($_file != '.' && $_file != '..' && $_file != '.build.php' && stristr($_file, '.php') !== false) { | ||
echo 'use Traits\\'.basename(__DIR__).'\\'.basename($_file, '.php').';'.PHP_EOL; | ||
if ($_file !== '.' && $_file !== '..' && $_file !== '.build.php' && stristr($_file, '.php') !== false) { | ||
$use_traits_list .= 'use Traits\\'.basename(__DIR__).'\\'.basename($_file, '.php').';'.PHP_EOL.' '; | ||
} | ||
} | ||
closedir($_handle); | ||
unset($_file, $_files); | ||
} | ||
|
||
foreach ($dest_files as $file) { | ||
echo 'Updating '.$file.PHP_EOL; | ||
echo ' '.$use_traits_list; | ||
$file_contents = file_get_contents($file); | ||
$file_contents = str_replace('/*[.build.php-auto-generate-use-Traits]*/', $use_traits_list, $file_contents); | ||
file_put_contents($file, $file_contents); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,26 @@ | ||
<?php | ||
/* | ||
* Generate use-list for Trait files in current directory | ||
* Generate use-list for Trait files in current directory and add the list to the appropriate file(s). | ||
* | ||
* When run inside a directory called `Plugin/`, with a PHP file inside `Plugin/` called `ActionUtils.php`, | ||
* this script will generate `use Traits\Plugin\ActionUtils;`. | ||
* | ||
* @TODO Automatically insert this list into appropriate PHP files. | ||
*/ | ||
$dest_files = [dirname(dirname(dirname(__FILE__))).'/classes/AbsBaseAp.php']; | ||
|
||
if ($_handle = opendir(__DIR__)) { | ||
while (false !== ($_file = readdir($_handle))) { | ||
if ($_file != '.' && $_file != '..' && $_file != '.build.php' && stristr($_file, '.php') !== false) { | ||
echo 'use Traits\\'.basename(__DIR__).'\\'.basename($_file, '.php').';'.PHP_EOL; | ||
if ($_file !== '.' && $_file !== '..' && $_file !== '.build.php' && stristr($_file, '.php') !== false) { | ||
$use_traits_list .= 'use Traits\\'.basename(__DIR__).'\\'.basename($_file, '.php').';'.PHP_EOL.' '; | ||
} | ||
} | ||
closedir($_handle); | ||
unset($_file, $_files); | ||
} | ||
|
||
foreach ($dest_files as $file) { | ||
echo 'Updating '.$file.PHP_EOL; | ||
echo ' '.$use_traits_list; | ||
$file_contents = file_get_contents($file); | ||
$file_contents = str_replace('/*[.build.php-auto-generate-use-Traits]*/', $use_traits_list, $file_contents); | ||
file_put_contents($file, $file_contents); | ||
} |