소스 검색

Allow CssXPath updates with composer (#4368)

* Install CssXPath with composer

* Fix code style in tests

* fix pathnames for tests and linting

* add irrelevant files to .gitignore

* Alphabetic order

* let composer sort the packages alphabetically

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
Artur Weigandt 3 년 전
부모
커밋
d6fd78b968

+ 1 - 1
.markdownlintignore

@@ -1,4 +1,4 @@
-lib/CssXPath/
+lib/phpgt/
 lib/phpmailer/
 node_modules/
 p/scripts/vendor/

+ 1 - 1
.typos.toml

@@ -29,7 +29,7 @@ extend-exclude = [
 	"bin/",
 	"data/",
 	"docs/fr/",
-	"lib/CssXPath/",
+	"lib/phpgt/",
 	"lib/phpmailer/",
 	"lib/SimplePie/",
 	"node_modules/",

+ 6 - 0
lib/.gitignore

@@ -1,6 +1,12 @@
 autoload.php
 composer.lock
 composer/
+phpgt/cssxpath/.github/
+phpgt/cssxpath/.gitignore
+phpgt/cssxpath/.scrutinizer.yml
+phpgt/cssxpath/composer.json
+phpgt/cssxpath/CONTRIBUTING.md
+phpgt/cssxpath/test/
 phpmailer/phpmailer/*oauth*
 phpmailer/phpmailer/COMMITMENT*
 phpmailer/phpmailer/composer.*

+ 0 - 4
lib/CssXPath/NotYetImplementedException.php

@@ -1,4 +0,0 @@
-<?php
-namespace Gt\CssXPath;
-
-class NotYetImplementedException extends CssXPathException {}

+ 2 - 0
lib/composer.json

@@ -6,9 +6,11 @@
     "license": "AGPL-3.0",
     "require": {
         "php": ">=7.0.0",
+        "phpgt/cssxpath": "v1.1.4",
         "phpmailer/phpmailer": "6.6.0"
     },
     "config": {
+        "sort-packages": true,
         "vendor-dir": "./"
     },
     "scripts": {

+ 5 - 2
lib/lib_rss.php

@@ -52,8 +52,11 @@ function classAutoloader($class) {
 		include(LIB_PATH . '/' . str_replace('_', '/', $class) . '.php');
 	} elseif (strpos($class, 'SimplePie') === 0) {
 		include(LIB_PATH . '/SimplePie/' . str_replace('_', '/', $class) . '.php');
-	} elseif (strpos($class, 'CssXPath') !== false) {
-		include(LIB_PATH . '/CssXPath/' . basename(str_replace('\\', '/', $class)) . '.php');
+	} elseif (str_starts_with($class, 'Gt\\CssXPath\\')) {
+		$prefix = 'Gt\\CssXPath\\';
+		$base_dir = LIB_PATH . '/phpgt/cssxpath/src/';
+		$relative_class_name = substr($class, strlen($prefix));
+		require $base_dir . str_replace('\\', '/', $relative_class_name) . '.php';
 	} elseif (str_starts_with($class, 'PHPMailer\\PHPMailer\\')) {
 		$prefix = 'PHPMailer\\PHPMailer\\';
 		$base_dir = LIB_PATH . '/phpmailer/phpmailer/src/';

+ 0 - 0
lib/CssXPath/LICENSE → lib/phpgt/cssxpath/LICENSE


+ 0 - 0
lib/CssXPath/README.md → lib/phpgt/cssxpath/README.md


+ 1 - 1
lib/CssXPath/CssXPathException.php → lib/phpgt/cssxpath/src/CssXPathException.php

@@ -3,4 +3,4 @@ namespace Gt\CssXPath;
 
 use RuntimeException;
 
-class CssXPathException extends RuntimeException {}
+class CssXPathException extends RuntimeException {}

+ 4 - 0
lib/phpgt/cssxpath/src/NotYetImplementedException.php

@@ -0,0 +1,4 @@
+<?php
+namespace Gt\CssXPath;
+
+class NotYetImplementedException extends CssXPathException {}

+ 0 - 0
lib/CssXPath/Translator.php → lib/phpgt/cssxpath/src/Translator.php


+ 1 - 1
phpcs.xml

@@ -3,8 +3,8 @@
 	<description>Created with the PHP Coding Standard Generator. https://edorian.github.com/php-coding-standard-generator/</description>
 	<arg name="extensions" value="php,phtml,css,js"/>
 	<arg name="tab-width" value="4"/>
-	<exclude-pattern>./lib/CssXPath/</exclude-pattern>
 	<exclude-pattern>./lib/SimplePie/</exclude-pattern>
+	<exclude-pattern>./lib/phpgt/</exclude-pattern>
 	<exclude-pattern>./lib/phpmailer/</exclude-pattern>
 	<exclude-pattern>./lib/http-conditional.php</exclude-pattern>
 	<exclude-pattern>./node_modules/</exclude-pattern>

+ 8 - 0
tests/lib/CssXPath/CssXPathTest.php

@@ -0,0 +1,8 @@
+<?php
+
+class CssXPathTest extends PHPUnit\Framework\TestCase
+{
+	public function testCssXPathTranslatorClassExists() {
+		$this->assertTrue(class_exists('Gt\\CssXPath\\Translator'));
+	}
+}

+ 2 - 2
tests/lib/PHPMailer/PHPMailerTest.php

@@ -1,7 +1,7 @@
 <?php
 
-class PHPMailerTest extends PHPUnit\Framework\TestCase {
-
+class PHPMailerTest extends PHPUnit\Framework\TestCase
+{
 	public function testPHPMailerClassExists() {
 		$this->assertTrue(class_exists('PHPMailer\\PHPMailer\\PHPMailer'));
 	}