@author Leo Fajardo (@leorw)
@since 2.2.1

@param FS_Plugin_License $license
@param bool|string       $hmm_text
@param bool              $show_notice
431948
private function handle_license_deactivation_result( $license, $hmm_text = false, $show_notice = true ) {
            if ( isset( $license->error ) ) {
                $this->_admin_notices->add(
                    $this->get_text_inline( 'It looks like the license deactivation failed.', 'license-deactivation-failed-message' ) . '<br> ' .
                    $this->get_text_inline( 'Error received from the server:', 'server-error-message' ) . ' ' . var_export( $license->error, true ),
                    $hmm_text,
                    'error'
                );

                return;
            }

            // Update license cache.
            if ( is_array( $this->_licenses ) ) {
                for ( $i = 0, $len = count( $this->_licenses ); $i < $len; $i ++ ) {
                    if ( $license->id == $this->_licenses[ $i ]->id ) {
                        $this->_licenses[ $i ] = new FS_Plugin_License( $license );
                    }
                }
            }

            // Update site plan to default.
            $this->_sync_plans();
            $this->_site->plan_id = $this->_plans[0]->id;
            // Unlink license from site.
            $this->_update_site_license( null );

            $this->_store_account();

            if ( $show_notice ) {
                $this->_admin_notices->add(
                    sprintf( $this->get_text_inline( 'Your license was successfully deactivated, you are back to the %s plan.', 'license-deactivation-message' ), $this->get_plan_title() ),
                    $this->get_text_inline( 'O.K', 'ok' )
                );
            }

            $this->_admin_notices->remove_sticky( array(
                'plan_upgraded',
                'license_activated',
            ) );
        }
634130
protected function addCustomFileDocBlock(File $phpCsFile, int $stackPointer, string $license): void
    {
        $phpCsFile->fixer->beginChangeset();

        $this->clearFileDocBlock($phpCsFile, $stackPointer);

        $tokens = $phpCsFile->getTokens();
        $line = $tokens[$stackPointer]['line'];
        $fileDocBlockStartPosition = $stackPointer;
        while ($tokens[$fileDocBlockStartPosition + 1]['line'] === $line) {
            $fileDocBlockStartPosition++;
        }

        $phpCsFile->fixer->addNewline($fileDocBlockStartPosition);
        $phpCsFile->fixer->addContent($fileDocBlockStartPosition, $license);
        $phpCsFile->fixer->addNewline($fileDocBlockStartPosition);

        $phpCsFile->fixer->endChangeset();
    }
885194
private function checkFile(SplFileInfo $file)
    {
        $tokens = token_get_all($file->getContents());
        $licenseTokenIndex = $this->getLicenseTokenIndex($tokens);

        if ($licenseTokenIndex === null) {
            $this->log(sprintf('Missing license header in "%s"', $file->getRealPath()));
        } elseif ($tokens[$licenseTokenIndex][1] != $this->getLicenseAsComment()) {
            $this->log(sprintf('Different license header in "%s"', $file->getRealPath()));
        }
    }
1176525
public static function notice($message = '', array $data = [], $is_replace = false, $modular = 'unknown_module')
    {
        return parent::log('notice', $message, $data, $is_replace, $modular);
    }
69795
private void generateLicenses(final Metadata m, final Element e) {
        for (final License license : m.getLicenses()) {
            final Element licenseElement = new Element("license", NS);
            addNotNullAttribute(licenseElement, "type", license.getType());
            addNotNullAttribute(licenseElement, "href", license.getHref());
            if (license.getValue() != null) {
                licenseElement.addContent(license.getValue());
            }
            if (licenseElement.hasAttributes() || !licenseElement.getTextTrim().isEmpty()) {
                e.addContent(licenseElement);
            }
        }
    }
721018
public void showLicenseFile(InputStream licenseFile) {
        Object e = SelfExtract.class;
        if (licenseFile != null) {
            e = SelfExtractUtils.showLicenseFile(licenseFile);
        }
        if (e != null) {
            SelfExtract.err("licenseNotFound");
            System.exit(ReturnCode.UNREADABLE);
        }
    }
282843
private function isValidLicenseString($license)
    {
        $tokens = array(
            'po' => '\(',
            'pc' => '\)',
            'op' => '(?:or|and)',
            'lix' => '(?:NONE|NOASSERTION)',
            'lir' => 'LicenseRef-\d+',
            'lic' => '[-+_.a-zA-Z0-9]{3,}',
            'ws' => '\s+',
            '_' => '.',
        );

        $next = function () use ($license, $tokens) {
            static $offset = 0;

            if ($offset >= strlen($license)) {
                return null;
            }

            foreach ($tokens as $name => $token) {
                if (false === $r = preg_match('{' . $token . '}', $license, $matches, PREG_OFFSET_CAPTURE, $offset)) {
                    throw new \RuntimeException('Pattern for token %s failed (regex error).', $name);
                }
                if ($r === 0) {
                    continue;
                }
                if ($matches[0][1] !== $offset) {
                    continue;
                }
                $offset += strlen($matches[0][0]);

                return array($name, $matches[0][0]);
            }

            throw new \RuntimeException('At least the last pattern needs to match, but it did not (dot-match-all is missing?).');
        };

        $open = 0;
        $require = 1;
        $lastop = null;

        while (list($token, $string) = $next()) {
            switch ($token) {
                case 'po':
                    if ($open || !$require) {
                        return false;
                    }
                    $open = 1;
                    break;
                case 'pc':
                    if ($open !== 1 || $require || !$lastop) {
                        return false;
                    }
                    $open = 2;
                    break;
                case 'op':
                    if ($require || !$open) {
                        return false;
                    }
                    $lastop || $lastop = $string;
                    if ($lastop !== $string) {
                        return false;
                    }
                    $require = 1;
                    break;
                case 'lix':
                    if ($open) {
                        return false;
                    }
                    goto lir;
                case 'lic':
                    if (!$this->isValidLicenseIdentifier($string)) {
                        return false;
                    }
                    // Fall-through intended
                case 'lir':
                    lir:
                    if (!$require) {
                        return false;
                    }
                    $require = 0;
                    break;
                case 'ws':
                    break;
                case '_':
                    return false;
                default:
                    throw new \RuntimeException(sprintf('Unparsed token: %s.', print_r($token, true)));
            }
        }

        return !($open % 2 || $require);
    }
723299
function checkModuleLicense(folder) {

    var licensePath = folder + "/LICENSE",
        readMePath = folder + "/README.md",
        licenseContent;

    //check for LICENSE File First
    if(fs.existsSync(licensePath)){
        licenseContent = fs.readFileSync(licensePath, "utf-8");
        return { isMIT : isLicense.mit(licenseContent), content : licenseContent };
    }
    //Maybe in the README
    else if(fs.existsSync(readMePath)) {
        licenseContent = fs.readFileSync(readMePath, "utf-8");
        return { isMIT : isLicense.mit(licenseContent), content : "Check the README" };
    }
    else {
        return { isMIT : false, content : "not found" };
    }
}
1288061
protected void executeLicenseGoal(String goal) throws MojoExecutionException
    {
        // Find the license plugin (it's project's responsibility to make sure the License plugin is properly setup in
        // its <pluginManagement>, for most XWiki projects it just mean inherits from xwiki-commons-pom)
        Plugin licensePlugin =
            this.project.getPluginManagement().getPluginsAsMap().get("com.mycila:license-maven-plugin");

        if (licensePlugin == null) {
            throw new MojoExecutionException("License plugin could not be found in <pluginManagement>");
        }

        executeMojo(
            licensePlugin,
            goal(goal),
            configuration(
                element(name("header"), "license.txt"),
                element(name("strictCheck"), "true"),
                element(name("headerDefinitions"),
                    element(name("headerDefinition"), "license-xml-definition.xml")),
                element(name("includes"),
                    element(name("include"), "src/main/resources/**/*.xml"))
            ),
            executionEnvironment(
                this.project,
                this.mavenSession,
                this.pluginManager
            )
        );
    }
534535
public function licenses(OutputInterface $output, array $response)
    {
        $table = $this->createTable($output);
        $table->setHeaders(['license', 'name']);

        foreach ($response['licenses'] as $license => $projects) {
            foreach ($projects as $project) {
                $name    = $license === 'unknown' ? '<error>' . $project['name'] . '</error>' : $project['name'];
                $license = $license === 'unknown' ? '<error>unknown</error>' : $license;

                $table->addRow([$license, $name]);
            }
        }

        $table->render($output);
    }
423199
static public function disable($license) {
        global $DB, $CFG;
        // Site default license cannot be disabled!
        if ($license == $CFG->sitedefaultlicense) {
            print_error('error');
        }
        if ($license = self::get_license_by_shortname($license)) {
            $license->enabled = 0;
            $DB->update_record('license', $license);
        }
        self::set_active_licenses();
        return true;
    }
1302410
protected function addNotice($notice)
    {
        if (!$this->variant) {
            $notice       = trim($notice);
            $this->notice = strlen($notice) ? $this->exportNotice($notice) : null;
        }
    }
150095
public function notice($message, array $context = []) : void
    {
        /** @psalm-suppress UndefinedClass */
        SspLogger::notice($message.($context ? " ".var_export($context, true) : ""));
    }
393511
function notice( $string = false, $addEOL = true )
    {
        fputs( STDERR, $string );
        if ( $addEOL )
            fputs( STDERR, $this->endlineString() );
    }
296411
private function _fetch_site_license_subscription( $license_id = false ) {
            $this->_logger->entrance();
            $api = $this->get_api_site_scope();

            if ( ! is_numeric( $license_id ) ) {
                $license_id = $this->_license->id;
            }

            $result = $api->get( "/licenses/{$license_id}/subscriptions.json", true );

            return ! isset( $result->error ) ?
                ( ( is_array( $result->subscriptions ) && 0 < count( $result->subscriptions ) ) ?
                    new FS_Subscription( $result->subscriptions[0] ) :
                    false
                ) :
                $result;
        }
793674
private void addLicenses(MavenPomDescriptor pomDescriptor, Model model, Store store) {
        List<License> licenses = model.getLicenses();
        for (License license : licenses) {
            MavenLicenseDescriptor licenseDescriptor = store.create(MavenLicenseDescriptor.class);
            licenseDescriptor.setUrl(license.getUrl());
            licenseDescriptor.setComments(license.getComments());
            licenseDescriptor.setName(license.getName());
            licenseDescriptor.setDistribution(license.getDistribution());

            pomDescriptor.getLicenses().add(licenseDescriptor);
        }
    }
452083
public function setLicense($license, $uri=null)
    {
        $this->_packageXml->license = $license;
        if ($uri) {
            $this->_packageXml->license['uri'] = $uri;
        }
        return $this;
    }