PSR-2 reformatting PHPDoc corrections
[htmlpurifier.git] / library / HTMLPurifier / Strategy / ValidateAttributes.php
blobb7a1be14a68fe353da7062246d60bb32e34d5c0c
1 <?php
3 /**
4 * Validate all attributes in the tokens.
5 */
7 class HTMLPurifier_Strategy_ValidateAttributes extends HTMLPurifier_Strategy
10 /**
11 * @param HTMLPurifier_Token[] $tokens
12 * @param HTMLPurifier_Config $config
13 * @param HTMLPurifier_Context $context
14 * @return HTMLPurifier_Token[]
16 public function execute($tokens, $config, $context)
18 // setup validator
19 $validator = new HTMLPurifier_AttrValidator();
21 $token = false;
22 $context->register('CurrentToken', $token);
24 foreach ($tokens as $key => $token) {
26 // only process tokens that have attributes,
27 // namely start and empty tags
28 if (!$token instanceof HTMLPurifier_Token_Start && !$token instanceof HTMLPurifier_Token_Empty) {
29 continue;
32 // skip tokens that are armored
33 if (!empty($token->armor['ValidateAttributes'])) {
34 continue;
37 // note that we have no facilities here for removing tokens
38 $validator->validateToken($token, $config, $context);
40 $tokens[$key] = $token; // for PHP 4
42 $context->destroy('CurrentToken');
43 return $tokens;
47 // vim: et sw=4 sts=4