remove-vendor-prefixing-visitor.php 656 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /**
  3. * Yoast SEO Plugin File.
  4. *
  5. * @package Yoast\YoastSEO\PHP_CodeShift
  6. */
  7. namespace Yoast\WP\Free\PHP_CodeShift;
  8. use PhpParser\Node;
  9. use PhpParser\Node\Name;
  10. use PhpParser\NodeVisitorAbstract;
  11. /**
  12. * Class Vendor_Prefixing_Visitor
  13. */
  14. class Remove_Vendor_Prefixing_Visitor extends NodeVisitorAbstract {
  15. /**
  16. * @param \PhpParser\Node $node The node being visited.
  17. *
  18. * @return \PhpParser\Node The possibly modified node.
  19. */
  20. public function leaveNode( Node $node ) {
  21. if ( ! $node instanceof Name ) {
  22. return $node;
  23. }
  24. if ( $node->getFirst() !== \YOAST_VENDOR_NS_PREFIX ) {
  25. return $node;
  26. }
  27. return $node->slice( 1 );
  28. }
  29. }