Created
March 23, 2012 08:27
-
-
Save thekid/2168311 to your computer and use it in GitHub Desktop.
ThrowableSecurityExtensions - alternative to pull request #136
This file contains hidden or 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
| <?php | |
| /* This class is part of the XP framework | |
| * | |
| * $Id$ | |
| */ | |
| /** | |
| * Throwable extension methods | |
| * | |
| * @see https://github.com/xp-framework/xp-framework/pull/136 | |
| */ | |
| class ThrowableSecurityExtensions extends Object { | |
| static function __import($scope) { | |
| xp::extensions(__CLASS__, $scope); | |
| } | |
| /** | |
| * Clears stacktrace | |
| * | |
| * @param lang.Throwable self | |
| */ | |
| public static function clearStackTraceArguments(Throwable $self) { | |
| foreach ($self->getStackTrace() as $element) { | |
| $element->args= array(sizeof($element->args).' arg(s)'); | |
| } | |
| } | |
| } | |
| ?> |
This file contains hidden or 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
| <?php | |
| /* This class is part of the XP framework | |
| * | |
| * $Id$ | |
| */ | |
| uses('issue136.ThrowableSecurityExtensions'); | |
| /** | |
| * Demonstrates ThrowableSecurityExtensions | |
| * | |
| */ | |
| class ThrowableTest extends Object { | |
| /** | |
| * Throws an exception | |
| * | |
| * @param var info1 | |
| */ | |
| protected static function calledWithSensitiveInformation($info1) { | |
| throw new Throwable('This contains no sensitive information.'); | |
| } | |
| /** | |
| * Main | |
| * | |
| * @param string[] args | |
| */ | |
| public static function main($args) { | |
| try { | |
| self::calledWithSensitiveInformation('Could be a password...'); | |
| } catch (Throwable $t) { | |
| $t->clearStackTraceArguments(); | |
| $t->printStackTrace(); | |
| } | |
| } | |
| } | |
| ?> |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is how the output looks when executing the test class:
🔑