Skip to content

Commit

Permalink
Drop support for XP < 9
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Oct 21, 2021
1 parent cadebec commit 797c8fd
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 51 deletions.
6 changes: 6 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ XML APIs for the XP Framework ChangeLog

## ?.?.? / ????-??-??

## 11.0.0 / 2021-10-21

* Made compatible with XP 11 - @thekid
* Implemented xp-framework/rfc#341, dropping compatibility with XP 9
(@thekid)

## 10.0.0 / 2020-04-10

* Implemented xp-framework/rfc#334: Drop PHP 5.6:
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
"description" : "XML APIs for the XP Framework",
"keywords": ["module", "xp"],
"require" : {
"xp-framework/core": "^10.0 | ^9.0 | ^8.0 | ^7.0",
"xp-framework/collections": "^9.0 | ^8.0 | ^7.0",
"xp-framework/core": "^11.0 | ^10.0",
"xp-framework/collections": "^10.0 | ^9.0 | ^8.0",
"php" : ">=7.0.0"
},
"require-dev" : {
"xp-framework/unittest": "^11.0 | ^10.0 | ^9.0 | ^8.0 | ^7.0"
"xp-framework/unittest": "^11.0 | ^10.0"
},
"autoload" : {
"files" : ["src/main/php/autoload.php"]
Expand Down
2 changes: 1 addition & 1 deletion src/main/php/xml/Node.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public function getSource($indent= INDENT_WRAPPED, $encoding= \xp::ENCODING, $in
}

// No content and no children => close tag
if (0 == strlen($content)) {
if (null === $content || 0 === strlen($content)) {
if (!$this->children) return $xml."/>\n";
$xml.= '>';
} else {
Expand Down
5 changes: 3 additions & 2 deletions src/main/php/xml/xslt/XSLDateCallback.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use lang\{Enum, XPClass};
use util\{Date, DateMath, TimeInterval, TimeZone};
use xml\Xslmethod;

/**
* XSL callbacks for Date operations
Expand All @@ -22,7 +23,7 @@ class XSLDateCallback {
* @param string timezone default NULL
* @return string
*/
#[@xslmethod]
#[Xslmethod]
public function format($date, $format, $timezone= null) {
$timezone= empty($timezone) ? null : $timezone;
return (new Date($date))->toString($format, new TimeZone($timezone));
Expand All @@ -36,7 +37,7 @@ public function format($date, $format, $timezone= null) {
* @param string strdate2
* @return int
*/
#[@xslmethod]
#[Xslmethod]
public function diff($type, $strdate1, $strdate2) {
return DateMath::diff(
Enum::valueOf(XPClass::forName('util.TimeInterval'), strtoupper($type)),
Expand Down
16 changes: 9 additions & 7 deletions src/main/php/xml/xslt/XSLStringCallback.class.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php namespace xml\xslt;

use xml\Xslmethod;

/**
* XSL callbacks for string operations
*
Expand All @@ -14,7 +16,7 @@ class XSLStringCallback {
* @param string string
* @return string
*/
#[@xslmethod]
#[Xslmethod]
public function urlencode($string) {
return urlencode($string);
}
Expand All @@ -25,7 +27,7 @@ public function urlencode($string) {
* @param string string
* @return string
*/
#[@xslmethod]
#[Xslmethod]
public function urldecode($string) {
return urldecode($string);
}
Expand All @@ -36,7 +38,7 @@ public function urldecode($string) {
* @param string string
* @return string
*/
#[@xslmethod]
#[Xslmethod]
public function strtolower($string) {
return strtolower($string);
}
Expand All @@ -47,7 +49,7 @@ public function strtolower($string) {
* @param string string
* @return string
*/
#[@xslmethod]
#[Xslmethod]
public function strtoupper($string) {
return strtoupper($string);
}
Expand All @@ -60,7 +62,7 @@ public function strtoupper($string) {
* @param string replace
* @return string
*/
#[@xslmethod]
#[Xslmethod]
public function replace($str, $search, $replace) {
return str_replace($search, $replace, $str);
}
Expand All @@ -71,7 +73,7 @@ public function replace($str, $search, $replace) {
* @param string string
* @return string
*/
#[@xslmethod]
#[Xslmethod]
public function nl2br($string) {
return nl2br($string);
}
Expand All @@ -85,7 +87,7 @@ public function nl2br($string) {
* @param bool cut Do word wrapping within words (defaults to TRUE)
* @return string
*/
#[@xslmethod]
#[Xslmethod]
public function wordwrap($string, $width, $break= "\n", $cut= true) {
return wordwrap($string, $width, $break, $cut);
}
Expand Down
11 changes: 0 additions & 11 deletions src/test/php/xml/unittest/DomXslProcessorTest.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
use lang\{ElementNotFoundException, IllegalArgumentException};
use unittest\{Expect, Test, Xslmethod};
use xml\{DomXSLProcessor, TransformerException};
new import('lang.ResourceProvider');

/**
* ProcessorTest implementation that tests the DomXSL processor
Expand Down Expand Up @@ -257,14 +256,4 @@ public function processDocuments() {
$this->processor->run();
$this->assertEquals('document', $this->processor->output());
}

#[Test]
public function loadXSLFromStreamWrapper() {
$this->processor->setXSLFile('res://xml/unittest/include.xsl');
}

#[Test, Expect(FileNotFoundException::class)]
public function loadNonexistantXSLFromStreamWrapper() {
$this->processor->setXSLFile('res://nonexistant.xsl');
}
}
2 changes: 1 addition & 1 deletion src/test/php/xml/unittest/XslCallbackTest.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public function dateFormatCallbackWithTZ() {
$this->assertEquals($date->toString('Y-m-d H:i:s T', $tz), $this->runTransformation(
Node::fromObject($date, 'date')->getSource(),
'xp.date::format',
['string(/date/value)', "'Y-m-d H:i:s T'", "'".$tz->getName()."'"]
['string(/date/value)', "'Y-m-d H:i:s T'", "'".$tz->name()."'"]
));
}

Expand Down
Loading

0 comments on commit 797c8fd

Please sign in to comment.