PEAR_Validate::_validPackageName

PEAR_Validate::_validPackageName() – Override this method to handle validation of normal package names

Synopsis

require_once '/Validate.php';

bool PEAR_Validate::_validPackageName ( string $name )

Description

This protected method can be used to change the normal package validation scheme. By default, all packages must begin with a letter and contain only letters, numbers and underscores. Using this method, it is possible to change this entirely to enforce another scheme.

For instance, enforcing java-style com.blah.package package names can be done simply by this code:

<?php
require_once 'PEAR/Validate.php';
class 
MyChannel_Validate extends PEAR_Validate
{
    function 
_validPackageName($name)
    {
        return 
preg_match('/[a-zA-Z][a-zA-Z0-9_]*(\.[a-zA-Z0-9_]+)*/'$name);
    }
}
?>

Then, by using a customized channel validation package, the installer will enforce java-style package names for your channel.

Parameter

string $name

package name string to test for validity.

Throws

throws no exceptions thrown

Note

This function can not be called statically.

Determine whether a version is a properly formatted version number that can be used by version_compare (Previous) Constants defined in and used by PEAR (Next)
Last updated: Tue, 29 Jul 2014 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report or add a note.
View this page in:

User Notes:

There are no user contributed notes for this page.