GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
PPIx::Utils::Classification(3) User Contributed Perl Documentation PPIx::Utils::Classification(3)

PPIx::Utils::Classification - Utility functions for classification of PPI elements

    use PPIx::Utils::Classification ':all';

This package is a component of PPIx::Utils that contains functions for classification of PPI elements.

All functions can be imported by name, or with the tag ":all".

    my $bool = is_assignment_operator($element);

Given a PPI::Token::Operator or a string, returns true if that token represents one of the assignment operators (e.g. "= &&= ||= //= += -=" etc.).

    my $bool = is_perl_global($element);

Given a PPI::Token::Symbol or a string, returns true if that token represents one of the global variables provided by the English module, or one of the builtin global variables like %SIG, %ENV, or @ARGV. The sigil on the symbol is ignored, so things like $ARGV or $ENV will still return true.

    my $bool = is_perl_builtin($element);

Given a PPI::Token::Word, PPI::Statement::Sub, or string, returns true if that token represents a call to any of the builtin functions defined in Perl 5.8.8.

    my $bool = is_perl_bareword($element);

Given a PPI::Token::Word, PPI::Statement::Sub, or string, returns true if that token represents a bareword (e.g. "if", "else", "sub", "package") defined in Perl 5.8.8.

    my $bool = is_perl_filehandle($element);

Given a PPI::Token::Word, or string, returns true if that token represents one of the global filehandles (e.g. "STDIN", "STDERR", "STDOUT", "ARGV") that are defined in Perl 5.8.8. Note that this function will return false if given a filehandle that is represented as a typeglob (e.g. *STDIN)

    my $bool = is_perl_builtin_with_list_context($element);

Given a PPI::Token::Word, PPI::Statement::Sub, or string, returns true if that token represents a call to any of the builtin functions defined in Perl 5.8.8 that provide a list context to the following tokens.

    my $bool = is_perl_builtin_with_multiple_arguments($element);

Given a PPI::Token::Word, PPI::Statement::Sub, or string, returns true if that token represents a call to any of the builtin functions defined in Perl 5.8.8 that can take multiple arguments.

    my $bool = is_perl_builtin_with_no_arguments($element);

Given a PPI::Token::Word, PPI::Statement::Sub, or string, returns true if that token represents a call to any of the builtin functions defined in Perl 5.8.8 that cannot take any arguments.

    my $bool = is_perl_builtin_with_one_argument($element);

Given a PPI::Token::Word, PPI::Statement::Sub, or string, returns true if that token represents a call to any of the builtin functions defined in Perl 5.8.8 that takes one and only one argument.

    my $bool = is_perl_builtin_with_optional_argument($element);

Given a PPI::Token::Word, PPI::Statement::Sub, or string, returns true if that token represents a call to any of the builtin functions defined in Perl 5.8.8 that takes no more than one argument.

The sets of values for which "is_perl_builtin_with_multiple_arguments", "is_perl_builtin_with_no_arguments", "is_perl_builtin_with_one_argument", and "is_perl_builtin_with_optional_argument" return true are disjoint and their union is precisely the set of values that "is_perl_builtin" will return true for.

    my $bool = is_perl_builtin_with_zero_and_or_one_arguments($element);

Given a PPI::Token::Word, PPI::Statement::Sub, or string, returns true if that token represents a call to any of the builtin functions defined in Perl 5.8.8 that takes no and/or one argument.

Returns true if any of "is_perl_builtin_with_no_arguments", "is_perl_builtin_with_one_argument", and "is_perl_builtin_with_optional_argument" returns true.

    my $bool = is_qualified_name($name);

Given a string, PPI::Token::Word, or PPI::Token::Symbol, answers whether it has a module component, i.e. contains "::".

    my $bool = is_hash_key($element);

Given a PPI::Element, returns true if the element is a literal hash key. PPI doesn't distinguish between regular barewords (like keywords or subroutine calls) and barewords in hash subscripts (which are considered literal). So this subroutine is useful if your Policy is searching for PPI::Token::Word elements and you want to filter out the hash subscript variety. In both of the following examples, "foo" is considered a hash key:

    $hash1{foo} = 1;
    %hash2 = (foo => 1);

But if the bareword is followed by an argument list, then perl treats it as a function call. So in these examples, "foo" is not considered a hash key:

    $hash1{ foo() } = 1;
    &hash2 = (foo() => 1);

    my $bool = is_included_module_name($element);

Given a PPI::Token::Word, returns true if the element is the name of a module that is being included via "use", "require", or "no".

    my $bool = is_integer($value);

Answers whether the parameter, as a string, looks like an integral value.

    my $bool = is_class_name($element);

Given a PPI::Token::Word, returns true if the element that immediately follows this element is the dereference operator "->". When a bareword has a "->" on the right side, it usually means that it is the name of the class (from which a method is being called).

    my $bool = is_label_pointer($element);

Given a PPI::Token::Word, returns true if the element is the label in a "next", "last", "redo", or "goto" statement. Note this is not the same thing as the label declaration.

    my $bool = is_method_call($element);

Given a PPI::Token::Word, returns true if the element that immediately precedes this element is the dereference operator "->". When a bareword has a "->" on the left side, it usually means that it is the name of a method (that is being called from a class).

    my $bool = is_package_declaration($element);

Given a PPI::Token::Word, returns true if the element is the name of a package that is being declared.

    my $bool = is_subroutine_name($element);

Given a PPI::Token::Word, returns true if the element is the name of a subroutine declaration. This is useful for distinguishing barewords and from function calls from subroutine declarations.

    my $bool = is_function_call($element);

Given a PPI::Token::Word returns true if the element appears to be call to a static function. Specifically, this function returns true if "is_hash_key", "is_method_call", "is_subroutine_name", "is_included_module_name", "is_package_declaration", "is_perl_bareword", "is_perl_filehandle", "is_label_pointer" and "is_subroutine_name" all return false for the given element.

    my $bool = is_in_void_context($token);

Given a PPI::Token, answer whether it appears to be in a void context.

    my $bool = is_unchecked_call($element);

Given a PPI::Element, test to see if it contains a function call whose return value is not checked.

    my $bool = is_ppi_expression_or_generic_statement($element);

Answers whether the parameter is an expression or an undifferentiated statement. I.e. the parameter either is a PPI::Statement::Expression or the class of the parameter is PPI::Statement and not one of its subclasses other than "Expression".

    my $bool = is_ppi_generic_statement($element);

Answers whether the parameter is an undifferentiated statement, i.e. the parameter is a PPI::Statement but not one of its subclasses.

    my $bool = is_ppi_statement_subclass($element);

Answers whether the parameter is a specialized statement, i.e. the parameter is a PPI::Statement but the class of the parameter is not PPI::Statement.

    my $bool = is_ppi_simple_statement($element);

Answers whether the parameter represents a simple statement, i.e. whether the parameter is a PPI::Statement, PPI::Statement::Break, PPI::Statement::Include, PPI::Statement::Null, PPI::Statement::Package, or PPI::Statement::Variable.

    my $bool = is_ppi_constant_element($element);

Answers whether the parameter represents a constant value, i.e. whether the parameter is a PPI::Token::Number, PPI::Token::Quote::Literal, PPI::Token::Quote::Single, or PPI::Token::QuoteLike::Words, or is a PPI::Token::Quote::Double or PPI::Token::Quote::Interpolate which does not in fact contain any interpolated variables.

This subroutine does not interpret any form of here document as a constant value, and may not until PPI::Token::HereDoc acquires the relevant portions of the PPI::Token::Quote interface.

This subroutine also does not interpret entities created by the ReadonlyX module (or similar) or the constant pragma as constants.

    my $bool = is_subroutine_declaration($element);

Is the parameter a subroutine declaration, named or not?

    my $bool = is_in_subroutine($element);

Is the parameter a subroutine or inside one?

Report any issues on the public bugtracker.

Dan Book <dbook@cpan.org>

Code originally from Perl::Critic::Utils by Jeffrey Ryan Thalhammer <jeff@imaginative-software.com> and Perl::Critic::Utils::PPI by Elliot Shank <perl@galumph.com>

This software is copyright (c) 2005-2011 Imaginative Software Systems, 2007-2011 Elliot Shank, 2017 Dan Book.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

Perl::Critic::Utils, Perl::Critic::Utils::PPI
2019-04-26 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.