From 9a7e19efa14210025ed2d11af4cff2c671bae8c7 Mon Sep 17 00:00:00 2001 From: Miguel92 Date: Tue, 2 Jun 2026 12:10:13 -0300 Subject: [PATCH 1/7] refactor(php8): actualizar CodeDefinition y clases relacionadas con tipos PHP 8 --- JBBCode/CodeDefinition.php | 61 +++++++++++++------------ JBBCode/CodeDefinitionBuilder.php | 66 +++++++++++++++------------- JBBCode/CodeDefinitionSet.php | 2 +- JBBCode/DefaultCodeDefinitionSet.php | 4 +- 4 files changed, 72 insertions(+), 61 deletions(-) diff --git a/JBBCode/CodeDefinition.php b/JBBCode/CodeDefinition.php index 055b271..5b62bf2 100644 --- a/JBBCode/CodeDefinition.php +++ b/JBBCode/CodeDefinition.php @@ -12,35 +12,40 @@ class CodeDefinition { /** @var string NOTE: THIS PROPERTY SHOULD ALWAYS BE LOWERCASE; USE setTagName() TO ENSURE THIS */ - protected $tagName; + protected string $tagName; /** @var boolean Whether or not this CodeDefinition uses an option parameter. */ - protected $useOption; + protected bool $useOption; /** @var string The replacement text to be used for simple CodeDefinitions */ - protected $replacementText; + protected string $replacementText; /** @var boolean Whether or not to parse elements of this definition's contents */ - protected $parseContent; + protected bool $parseContent; /** @var integer How many of this element type may be nested within each other */ - protected $nestLimit; + protected int $nestLimit; /** @var integer How many of this element type have been seen */ - protected $elCounter; + protected int $elCounter; /** @var array[string]InputValidator The input validators to run options through */ - protected $optionValidator; + protected array $optionValidator; /** @var InputValidator The input validator to run the body ({param}) through */ - protected $bodyValidator; + protected ?InputValidator $bodyValidator; /** * Constructs a new CodeDefinition. */ - public static function construct($tagName, $replacementText, $useOption = false, - $parseContent = true, $nestLimit = -1, $optionValidator = array(), - $bodyValidator = null) + public static function construct( + string $tagName, + string $replacementText, + bool $useOption = false, + bool $parseContent = true, + int $nestLimit = -1, + array $optionValidator = [], + ?InputValidator $bodyValidator = null): self { $def = new CodeDefinition(); $def->elCounter = 0; @@ -81,7 +86,7 @@ public function __construct() * @param ElementNode $el the ElementNode to validate * @return boolean true if the ElementNode's {option} and {param} are OK, false if they're not */ - public function hasValidInputs(ElementNode $el) + public function hasValidInputs(ElementNode $el): bool { if ($this->usesOption() && $this->optionValidator) { $att = $el->getAttribute(); @@ -117,7 +122,7 @@ public function hasValidInputs(ElementNode $el) * * @return string the parsed html of this element (INCLUDING ITS CHILDREN) */ - public function asHtml(ElementNode $el) + public function asHtml(ElementNode $el): string { if (!$this->hasValidInputs($el)) { return $el->getAsBBCode(); @@ -144,7 +149,7 @@ public function asHtml(ElementNode $el) return $html; } - protected function getContent(ElementNode $el) + protected function getContent(ElementNode $el): string { if ($this->parseContent()) { $content = ""; @@ -168,7 +173,7 @@ protected function getContent(ElementNode $el) * * @return string the text representation of $el */ - public function asText(ElementNode $el) + public function asText(ElementNode $el): string { if (!$this->hasValidInputs($el)) { return $el->getAsBBCode(); @@ -186,7 +191,7 @@ public function asText(ElementNode $el) * * @return string this definition's associated tag name */ - public function getTagName() + public function getTagName(): string { return $this->tagName; } @@ -198,7 +203,7 @@ public function getTagName() * * @return string the replacement text of this CodeDefinition */ - public function getReplacementText() + public function getReplacementText(): string { return $this->replacementText; } @@ -208,7 +213,7 @@ public function getReplacementText() * * @return boolean true if this CodeDefinition uses the option, false otherwise */ - public function usesOption() + public function usesOption(): bool { return $this->useOption; } @@ -219,7 +224,7 @@ public function usesOption() * * @return boolean true if this CodeDefinition parses elements contained within itself */ - public function parseContent() + public function parseContent(): bool { return $this->parseContent; } @@ -232,7 +237,7 @@ public function parseContent() * * @return integer */ - public function getNestLimit() + public function getNestLimit(): int { return $this->nestLimit; } @@ -244,7 +249,7 @@ public function getNestLimit() * * @param string $tagName the new tag name of this definition */ - public function setTagName($tagName) + public function setTagName(string $tagName): void { $this->tagName = strtolower($tagName); } @@ -256,7 +261,7 @@ public function setTagName($tagName) * * @param string $txt the new replacement text */ - public function setReplacementText($txt) + public function setReplacementText(string $txt): void { $this->replacementText = $txt; } @@ -268,7 +273,7 @@ public function setReplacementText($txt) * * @param boolean $bool */ - public function setUseOption($bool) + public function setUseOption(bool $bool): void { $this->useOption = $bool; } @@ -280,7 +285,7 @@ public function setUseOption($bool) * * @param boolean $bool */ - public function setParseContent($bool) + public function setParseContent(bool $bool): void { $this->parseContent = $bool; } @@ -292,7 +297,7 @@ public function setParseContent($bool) * * @return void */ - public function incrementCounter() + public function incrementCounter(): void { $this->elCounter++; } @@ -304,7 +309,7 @@ public function incrementCounter() * * @return void */ - public function decrementCounter() + public function decrementCounter(): void { $this->elCounter--; } @@ -314,7 +319,7 @@ public function decrementCounter() * * @deprecated */ - public function resetCounter() + public function resetCounter(): void { $this->elCounter = 0; } @@ -326,7 +331,7 @@ public function resetCounter() * * @return int */ - public function getCounter() + public function getCounter(): int { return $this->elCounter; } diff --git a/JBBCode/CodeDefinitionBuilder.php b/JBBCode/CodeDefinitionBuilder.php index f468f21..73bdf5f 100644 --- a/JBBCode/CodeDefinitionBuilder.php +++ b/JBBCode/CodeDefinitionBuilder.php @@ -14,19 +14,25 @@ class CodeDefinitionBuilder { /** @var string */ - protected $tagName; + protected string $tagName; + /** @var boolean */ - protected $useOption = false; + protected bool $useOption = false; + /** @var string */ - protected $replacementText; + protected string $replacementText; + /** @var boolean */ - protected $parseContent = true; + protected bool $parseContent = true; + /** @var integer */ - protected $nestLimit = -1; + protected int $nestLimit = -1; + /** @var array[string]InputValidator The input validators to run options through */ - protected $optionValidator = array(); + protected array $optionValidator = []; + /** @var InputValidator */ - protected $bodyValidator = null; + protected ?InputValidator $bodyValidator = null; /** * Construct a CodeDefinitionBuilder. @@ -34,7 +40,7 @@ class CodeDefinitionBuilder * @param string $tagName the tag name of the definition to build * @param string $replacementText the replacement text of the definition to build */ - public function __construct($tagName, $replacementText) + public function __construct(string $tagName, string $replacementText) { $this->tagName = $tagName; $this->replacementText = $replacementText; @@ -46,7 +52,7 @@ public function __construct($tagName, $replacementText) * @param string $tagName the tag name for the new CodeDefinition * @return self */ - public function setTagName($tagName) + public function setTagName(string $tagName): self { $this->tagName = $tagName; return $this; @@ -59,7 +65,7 @@ public function setTagName($tagName) * @param string $replacementText the replacement text for the new CodeDefinition * @return self */ - public function setReplacementText($replacementText) + public function setReplacementText(string $replacementText): self { $this->replacementText = $replacementText; return $this; @@ -72,7 +78,7 @@ public function setReplacementText($replacementText) * @param boolean $option true iff the definition includes an option * @return self */ - public function setUseOption($option) + public function setUseOption(bool $option): self { $this->useOption = $option; return $this; @@ -85,7 +91,7 @@ public function setUseOption($option) * @param boolean $parseContent true iff the content should be parsed * @return self */ - public function setParseContent($parseContent) + public function setParseContent(bool $parseContent): self { $this->parseContent = $parseContent; return $this; @@ -98,11 +104,10 @@ public function setParseContent($parseContent) * @throws \InvalidArgumentException if the nest limit is invalid * @return self */ - public function setNestLimit($limit) + public function setNestLimit(int $limit): self { - if (!is_int($limit) || ($limit <= 0 && -1 != $limit)) { - throw new \InvalidArgumentException("A nest limit must be a positive integer " . - "or -1."); + if ($limit <= 0 && -1 != $limit) { + throw new \InvalidArgumentException("A nest limit must be a positive integer or -1."); } $this->nestLimit = $limit; return $this; @@ -114,7 +119,7 @@ public function setNestLimit($limit) * @param InputValidator $validator the InputValidator instance to use * @return self */ - public function setOptionValidator(\JBBCode\InputValidator $validator, $option=null) + public function setOptionValidator(\JBBCode\InputValidator $validator, ?string $option = null): self { if (empty($option)) { $option = $this->tagName; @@ -129,7 +134,7 @@ public function setOptionValidator(\JBBCode\InputValidator $validator, $option=n * @param InputValidator $validator the InputValidator instance to use * @return self */ - public function setBodyValidator(\JBBCode\InputValidator $validator) + public function setBodyValidator(\JBBCode\InputValidator $validator): self { $this->bodyValidator = $validator; return $this; @@ -139,9 +144,9 @@ public function setBodyValidator(\JBBCode\InputValidator $validator) * Removes the attached option validator if one is attached. * @return self */ - public function removeOptionValidator() + public function removeOptionValidator(): self { - $this->optionValidator = array(); + $this->optionValidator = []; return $this; } @@ -149,7 +154,7 @@ public function removeOptionValidator() * Removes the attached body validator if one is attached. * @return self */ - public function removeBodyValidator() + public function removeBodyValidator(): self { $this->bodyValidator = null; return $this; @@ -160,15 +165,16 @@ public function removeBodyValidator() * * @return CodeDefinition a new CodeDefinition instance */ - public function build() + public function build(): CodeDefinition { - $definition = CodeDefinition::construct($this->tagName, - $this->replacementText, - $this->useOption, - $this->parseContent, - $this->nestLimit, - $this->optionValidator, - $this->bodyValidator); - return $definition; + return CodeDefinition::construct( + $this->tagName, + $this->replacementText, + $this->useOption, + $this->parseContent, + $this->nestLimit, + $this->optionValidator, + $this->bodyValidator + ); } } diff --git a/JBBCode/CodeDefinitionSet.php b/JBBCode/CodeDefinitionSet.php index 7882057..007d69a 100644 --- a/JBBCode/CodeDefinitionSet.php +++ b/JBBCode/CodeDefinitionSet.php @@ -18,5 +18,5 @@ interface CodeDefinitionSet * Retrieves the CodeDefinitions within this set as an array. * @return CodeDefinition[] */ - public function getCodeDefinitions(); + public function getCodeDefinitions(): array; } diff --git a/JBBCode/DefaultCodeDefinitionSet.php b/JBBCode/DefaultCodeDefinitionSet.php index bdc03c8..a8398d8 100644 --- a/JBBCode/DefaultCodeDefinitionSet.php +++ b/JBBCode/DefaultCodeDefinitionSet.php @@ -17,7 +17,7 @@ class DefaultCodeDefinitionSet implements CodeDefinitionSet { /** @var CodeDefinition[] The default code definitions in this set. */ - protected $definitions = array(); + protected array $definitions = []; /** * Constructs the default code definitions. @@ -69,7 +69,7 @@ public function __construct() * * @return CodeDefinition[] */ - public function getCodeDefinitions() + public function getCodeDefinitions(): array { return $this->definitions; } From 4ff6b3081234077e02bc06893a3b5c26249400c9 Mon Sep 17 00:00:00 2001 From: Miguel92 Date: Tue, 2 Jun 2026 12:10:27 -0300 Subject: [PATCH 2/7] refactor(php8): actualizar Node, ElementNode, TextNode y Parser con tipos --- JBBCode/DocumentElement.php | 6 +-- JBBCode/ElementNode.php | 50 ++++++++++++------------- JBBCode/Node.php | 18 ++++----- JBBCode/Parser.php | 74 +++++++++++++++++++++++-------------- JBBCode/TextNode.php | 18 ++++----- 5 files changed, 92 insertions(+), 74 deletions(-) diff --git a/JBBCode/DocumentElement.php b/JBBCode/DocumentElement.php index 35c61f3..8a022ae 100644 --- a/JBBCode/DocumentElement.php +++ b/JBBCode/DocumentElement.php @@ -29,7 +29,7 @@ public function __construct() * * @return string this document's bbcode representation */ - public function getAsBBCode() + public function getAsBBCode(): string { $s = ""; foreach ($this->getChildren() as $child) { @@ -49,7 +49,7 @@ public function getAsBBCode() * * @return string the HTML representation of this document */ - public function getAsHTML() + public function getAsHTML(): string { $s = ""; foreach ($this->getChildren() as $child) { @@ -59,7 +59,7 @@ public function getAsHTML() return $s; } - public function accept(NodeVisitor $visitor) + public function accept(NodeVisitor $visitor): void { $visitor->visitDocumentElement($this); } diff --git a/JBBCode/ElementNode.php b/JBBCode/ElementNode.php index 2f5b902..48b3246 100644 --- a/JBBCode/ElementNode.php +++ b/JBBCode/ElementNode.php @@ -14,30 +14,31 @@ class ElementNode extends Node { /** @var string The tagname of this element, for i.e. "b" in [b]bold[/b] */ - protected $tagName; + protected string $tagName; /** @var string[] The attributes, if any, of this element node */ - protected $attribute; + protected array $attribute = []; /** @var Node[] The child nodes contained within this element */ - protected $children; + protected array $children = []; /** @var CodeDefinition The code definition that defines this element's behavior */ - protected $codeDefinition; + protected ?CodeDefinition $codeDefinition = null; /** @var integer How deeply this node is nested */ - protected $nestDepth; + protected int $nestDepth = 0; /** * Constructs the element node */ public function __construct() { - $this->children = array(); + $this->children = []; + $this->attribute = []; $this->nestDepth = 0; } - public function accept(NodeVisitor $nodeVisitor) + public function accept(NodeVisitor $nodeVisitor): void { $nodeVisitor->visitElementNode($this); } @@ -47,7 +48,7 @@ public function accept(NodeVisitor $nodeVisitor) * * @return CodeDefinition this element's code definition */ - public function getCodeDefinition() + public function getCodeDefinition(): ?CodeDefinition { return $this->codeDefinition; } @@ -57,7 +58,7 @@ public function getCodeDefinition() * * @param CodeDefinition $codeDef the code definition that defines this element node */ - public function setCodeDefinition(CodeDefinition $codeDef) + public function setCodeDefinition(CodeDefinition $codeDef): void { $this->codeDefinition = $codeDef; $this->setTagName($codeDef->getTagName()); @@ -68,7 +69,7 @@ public function setCodeDefinition(CodeDefinition $codeDef) * * @return string the element's tag name */ - public function getTagName() + public function getTagName(): string { return $this->tagName; } @@ -78,7 +79,7 @@ public function getTagName() * * @return array the attributes of this element */ - public function getAttribute() + public function getAttribute(): array { return $this->attribute; } @@ -88,7 +89,7 @@ public function getAttribute() * * @return Node[] an array of this node's child nodes */ - public function getChildren() + public function getChildren(): array { return $this->children; } @@ -101,7 +102,7 @@ public function getChildren() * * @return string the plain text representation of this node */ - public function getAsText() + public function getAsText(): string { if ($this->codeDefinition) { return $this->codeDefinition->asText($this); @@ -122,7 +123,7 @@ public function getAsText() * * @return string the bbcode representation of this element */ - public function getAsBBCode() + public function getAsBBCode(): string { $str = "[".$this->tagName; if (!empty($this->attribute)) { @@ -155,13 +156,9 @@ public function getAsBBCode() * * @return string the html representation of this node */ - public function getAsHTML() + public function getAsHTML(): string { - if ($this->codeDefinition) { - return $this->codeDefinition->asHtml($this); - } else { - return ""; - } + return ($this->codeDefinition) ? $this->codeDefinition->asHtml($this) : ""; } /** @@ -171,7 +168,7 @@ public function getAsHTML() * * @param Node $child the node to add as a child */ - public function addChild(Node $child) + public function addChild(Node $child): void { $this->children[] = $child; $child->setParent($this); @@ -182,7 +179,7 @@ public function addChild(Node $child) * * @param Node $child the child node to remove */ - public function removeChild(Node $child) + public function removeChild(Node $child): void { foreach ($this->children as $key => $value) { if ($value === $child) { @@ -196,7 +193,7 @@ public function removeChild(Node $child) * * @param string $tagName the element's new tag name */ - public function setTagName($tagName) + public function setTagName($tagName): void { $this->tagName = $tagName; } @@ -206,7 +203,7 @@ public function setTagName($tagName) * * @param string[] $attribute the attribute(s) of this element node */ - public function setAttribute($attribute) + public function setAttribute($attribute): void { $this->attribute = $attribute; } @@ -220,8 +217,11 @@ public function setAttribute($attribute) * * @return ElementNode|null the closest parent with the given tag name */ - public function closestParentOfType($str) + public function closestParentOfType(string $str): ?ElementNode { + if(empty($str)) { + return null; + } $str = strtolower($str); $currentEl = $this; diff --git a/JBBCode/Node.php b/JBBCode/Node.php index ccb71d3..fc64541 100644 --- a/JBBCode/Node.php +++ b/JBBCode/Node.php @@ -19,7 +19,7 @@ abstract class Node * * @return Node the node's parent */ - public function getParent() + public function getParent(): ?Node { return $this->parent; } @@ -29,9 +29,9 @@ public function getParent() * * @return boolean true if this node has a parent, false otherwise */ - public function hasParent() + public function hasParent(): bool { - return $this->parent != null; + return $this->parent !== null; } /** @@ -40,7 +40,7 @@ public function hasParent() * * @return boolean true if this node is a text node */ - public function isTextNode() + public function isTextNode(): bool { return false; } @@ -51,35 +51,35 @@ public function isTextNode() * * @param NodeVisitor $nodeVisitor the NodeVisitor traversing the graph */ - abstract public function accept(NodeVisitor $nodeVisitor); + abstract public function accept(NodeVisitor $nodeVisitor): void; /** * Returns this node as text (without any bbcode markup) * * @return string the plain text representation of this node */ - abstract public function getAsText(); + abstract public function getAsText(): string; /** * Returns this node as bbcode * * @return string the bbcode representation of this node */ - abstract public function getAsBBCode(); + abstract public function getAsBBCode(): string; /** * Returns this node as HTML * * @return string the html representation of this node */ - abstract public function getAsHTML(); + abstract public function getAsHTML(): string; /** * Sets this node's parent to be the given node. * * @param Node $parent the node to set as this node's parent */ - public function setParent(Node $parent) + public function setParent(Node $parent): void { $this->parent = $parent; } diff --git a/JBBCode/Parser.php b/JBBCode/Parser.php index d1424b1..bb79e57 100644 --- a/JBBCode/Parser.php +++ b/JBBCode/Parser.php @@ -25,17 +25,22 @@ class Parser { const OPTION_STATE_DEFAULT = 0; + const OPTION_STATE_TAGNAME = 1; + const OPTION_STATE_KEY = 2; + const OPTION_STATE_VALUE = 3; + const OPTION_STATE_QUOTED_VALUE = 4; + const OPTION_STATE_JAVASCRIPT = 5; /** @var DocumentElement The root element of the parse tree */ protected $treeRoot; /** @var CodeDefinition[] The list of bbcodes to be used by the parser. */ - protected $bbcodes = array(); + protected array $bbcodes = []; /** * Constructs an instance of the BBCode parser @@ -59,8 +64,15 @@ public function __construct() * * @return Parser */ - public function addBBCode($tagName, $replace, $useOption = false, $parseContent = true, $nestLimit = -1, - InputValidator $optionValidator = null, InputValidator $bodyValidator = null) + public function addBBCode( + string $tagName, + string $replace, + bool $useOption = false, + bool $parseContent = true, + int $nestLimit = -1, + ?InputValidator $optionValidator = null, + ?InputValidator $bodyValidator = null + ) { $builder = new CodeDefinitionBuilder($tagName, $replace); @@ -89,7 +101,7 @@ public function addBBCode($tagName, $replace, $useOption = false, $parseContent * * @return Parser */ - public function addCodeDefinition(CodeDefinition $definition) + public function addCodeDefinition(CodeDefinition $definition): self { $this->bbcodes[$definition->getTagName()][$definition->usesOption()] = $definition; return $this; @@ -116,7 +128,7 @@ public function addCodeDefinitionSet(CodeDefinitionSet $set) * * @return string a text representation of the parse tree */ - public function getAsText() + public function getAsText(): string { return $this->treeRoot->getAsText(); } @@ -127,7 +139,7 @@ public function getAsText() * * @return string a bbcode representation of the parse tree */ - public function getAsBBCode() + public function getAsBBCode(): string { return $this->treeRoot->getAsBBCode(); } @@ -138,7 +150,7 @@ public function getAsBBCode() * * @return string a parsed html string */ - public function getAsHTML() + public function getAsHTML(): string { return $this->treeRoot->getAsHTML(); } @@ -150,7 +162,7 @@ public function getAsHTML() * * @return Parser */ - public function accept(NodeVisitor $nodeVisitor) + public function accept(NodeVisitor $nodeVisitor): self { $this->treeRoot->accept($nodeVisitor); @@ -163,13 +175,16 @@ public function accept(NodeVisitor $nodeVisitor) * * @return Parser */ - public function parse($str) + public function parse(?string $str = null): self { + if ($str === null) { + $str = ''; + } /* Set the tree root back to a fresh DocumentElement. */ $this->reset(); $parent = $this->treeRoot; - $tokenizer = new Tokenizer($str); + $tokenizer = new Tokenizer($str ?? ''); while ($tokenizer->hasNext()) { $parent = $this->parseStartState($parent, $tokenizer); @@ -195,7 +210,7 @@ public function parse($str) * * @deprecated */ - public function removeOverNestedElements() + public function removeOverNestedElements(): void { $nestLimitVisitor = new \JBBCode\visitors\NestLimitVisitor(); $this->accept($nestLimitVisitor); @@ -204,7 +219,7 @@ public function removeOverNestedElements() /** * Removes the old parse tree if one exists. */ - protected function reset() + protected function reset(): void { // remove any old tree information $this->treeRoot = new DocumentElement(); @@ -218,7 +233,7 @@ protected function reset() * * @return bool true if the code exists, false otherwise */ - public function codeExists($tagName, $usesOption = false) + public function codeExists(string $tagName, bool $usesOption = false): bool { return isset($this->bbcodes[strtolower($tagName)][$usesOption]); } @@ -231,7 +246,7 @@ public function codeExists($tagName, $usesOption = false) * * @return CodeDefinition if the bbcode exists, null otherwise */ - public function getCode($tagName, $usesOption = false) + public function getCode(string $tagName, bool $usesOption = false): ?CodeDefinition { if ($this->codeExists($tagName, $usesOption)) { return $this->bbcodes[strtolower($tagName)][$usesOption]; @@ -248,7 +263,7 @@ public function getCode($tagName, $usesOption = false) * * @deprecated */ - public function loadDefaultCodes() + public function loadDefaultCodes(): void { $defaultSet = new DefaultCodeDefinitionSet(); $this->addCodeDefinitionSet($defaultSet); @@ -262,7 +277,7 @@ public function loadDefaultCodes() * * @return TextNode the newly created TextNode */ - protected function createTextNode(ElementNode $parent, $string) + protected function createTextNode(ElementNode $parent, string $string): TextNode { $children = $parent->getChildren(); if (!empty($children)) { @@ -291,11 +306,11 @@ protected function createTextNode(ElementNode $parent, $string) * * @return ElementNode the new parent we should use for the next iteration. */ - protected function parseStartState(ElementNode $parent, Tokenizer $tokenizer) + protected function parseStartState(ElementNode $parent, Tokenizer $tokenizer): ElementNode { $next = $tokenizer->next(); - if ('[' == $next) { + if ('[' === $next) { return $this->parseTagOpen($parent, $tokenizer); } else { $this->createTextNode($parent, $next); @@ -314,7 +329,7 @@ protected function parseStartState(ElementNode $parent, Tokenizer $tokenizer) * * @return ElementNode the new parent node */ - protected function parseTagOpen(ElementNode $parent, Tokenizer $tokenizer) + protected function parseTagOpen(ElementNode $parent, Tokenizer $tokenizer): ElementNode { if (!$tokenizer->hasNext()) { /* The [ that sent us to this state was just a trailing [, not the @@ -329,7 +344,7 @@ protected function parseTagOpen(ElementNode $parent, Tokenizer $tokenizer) * which would likely be a lot clearer but I decided to use a while loop to * prevent stack overflow with a string like [[[[[[[[[...[[[. */ - while ('[' == $next) { + while ('[' === $next) { /* The previous [ was just a random bracket that should be treated as text. * Continue until we get a non open bracket. */ $this->createTextNode($parent, '['); @@ -348,13 +363,13 @@ protected function parseTagOpen(ElementNode $parent, Tokenizer $tokenizer) $after_next = $tokenizer->next(); $tokenizer->stepBack(); - if ($after_next != ']') { + if ($after_next !== ']') { $this->createTextNode($parent, '['.$next); return $parent; } /* At this point $next is either ']' or plain text. */ - if (']' == $next) { + if (']' === $next) { $this->createTextNode($parent, '['); $this->createTextNode($parent, ']'); return $parent; @@ -364,14 +379,17 @@ protected function parseTagOpen(ElementNode $parent, Tokenizer $tokenizer) } } - protected function parseOptions($tagContent) + /** + * @return array{0: string, 1: array} + */ + protected function parseOptions(string $tagContent): array { $buffer = ""; $tagName = ""; $state = static::OPTION_STATE_TAGNAME; - $keys = array(); - $values = array(); - $options = array(); + $keys = []; + $values = []; + $options = []; $len = strlen($tagContent); $done = false; @@ -527,7 +545,7 @@ protected function parseOptions($tagContent) * * @return ElementNode the new parent element */ - protected function parseTag(ElementNode $parent, Tokenizer $tokenizer, $tagContent) + protected function parseTag(ElementNode $parent, Tokenizer $tokenizer, string $tagContent): ElementNode { if (!$tokenizer->hasNext() || ($next = $tokenizer->next()) != ']') { /* This is a malformed tag. Both the previous [ and the tagContent @@ -604,7 +622,7 @@ protected function parseTag(ElementNode $parent, Tokenizer $tokenizer, $tagConte * * @return ElementNode the new parent element */ - protected function parseAsTextUntilClose(ElementNode $parent, Tokenizer $tokenizer) + protected function parseAsTextUntilClose(ElementNode $parent, Tokenizer $tokenizer): ElementNode { /* $parent's code definition doesn't allow its contents to be parsed. Here we use * a sliding window of three tokens until we find [ /tagname ], signifying the diff --git a/JBBCode/TextNode.php b/JBBCode/TextNode.php index de6f72d..f0bb050 100644 --- a/JBBCode/TextNode.php +++ b/JBBCode/TextNode.php @@ -12,19 +12,19 @@ class TextNode extends Node { /** @var string The value of this text node */ - protected $value; + protected string $value; /** * Constructs a text node from its text string * * @param string $val */ - public function __construct($val) + public function __construct(string $val) { $this->value = $val; } - public function accept(NodeVisitor $visitor) + public function accept(NodeVisitor $visitor): void { $visitor->visitTextNode($this); } @@ -35,7 +35,7 @@ public function accept(NodeVisitor $visitor) * * @returns boolean true */ - public function isTextNode() + public function isTextNode(): bool { return true; } @@ -45,7 +45,7 @@ public function isTextNode() * * @return string */ - public function getValue() + public function getValue(): string { return $this->value; } @@ -58,7 +58,7 @@ public function getValue() * * @return string this node represented as text */ - public function getAsText() + public function getAsText(): string { return $this->getValue(); } @@ -71,7 +71,7 @@ public function getAsText() * * @return string this node represented as bbcode */ - public function getAsBBCode() + public function getAsBBCode(): string { return $this->getValue(); } @@ -84,7 +84,7 @@ public function getAsBBCode() * * @return string this node represented as HTML */ - public function getAsHTML() + public function getAsHTML(): string { return $this->getValue(); } @@ -94,7 +94,7 @@ public function getAsHTML() * * @param string $newValue the new text value of the text node */ - public function setValue($newValue) + public function setValue(string $newValue): void { $this->value = $newValue; } From f62c0a20b0fa62763099d70eb4e8f7d1ee1be0b7 Mon Sep 17 00:00:00 2001 From: Miguel92 Date: Tue, 2 Jun 2026 12:10:39 -0300 Subject: [PATCH 3/7] fix(validators): corregir InputValidator interface y validators para PHP 8 --- JBBCode/InputValidator.php | 2 +- JBBCode/validators/CssColorValidator.php | 4 ++-- JBBCode/validators/FnValidator.php | 15 +++++++-------- JBBCode/validators/UrlValidator.php | 5 ++--- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/JBBCode/InputValidator.php b/JBBCode/InputValidator.php index 96a216b..df8737d 100644 --- a/JBBCode/InputValidator.php +++ b/JBBCode/InputValidator.php @@ -17,5 +17,5 @@ interface InputValidator * @param string $input * @return boolean */ - public function validate($input); + public function validate(string $input): bool; } diff --git a/JBBCode/validators/CssColorValidator.php b/JBBCode/validators/CssColorValidator.php index 2f42d6b..f7a3afd 100644 --- a/JBBCode/validators/CssColorValidator.php +++ b/JBBCode/validators/CssColorValidator.php @@ -23,8 +23,8 @@ class CssColorValidator implements \JBBCode\InputValidator * @param string $input the string to validate * @return boolean */ - public function validate($input) + public function validate(string $input): bool { - return (bool) preg_match('/^[A-z0-9\-#., ()%]+$/', $input); + return (bool) preg_match('/^[A-Za-z0-9\-#., ()%]+$/', $input); } } diff --git a/JBBCode/validators/FnValidator.php b/JBBCode/validators/FnValidator.php index ff2a352..2221200 100644 --- a/JBBCode/validators/FnValidator.php +++ b/JBBCode/validators/FnValidator.php @@ -14,9 +14,9 @@ class FnValidator implements \JBBCode\InputValidator { /** - * @var callable + * @var \Closure */ - private $validator; + private \Closure $validator; /** * Construct a custom validator from a callable. @@ -24,7 +24,7 @@ class FnValidator implements \JBBCode\InputValidator */ public function __construct(callable $validator) { - $this->validator = $validator; + $this->validator = \Closure::fromCallable($validator); } /** @@ -32,9 +32,8 @@ public function __construct(callable $validator) * @param string $input * @return boolean */ - public function validate($input) - { - $validator = $this->validator; // FIXME: for PHP>=7.0 replace with ($this->validator)($input) - return (bool) $validator($input); - } + public function validate(string $input): bool + { + return (bool) ($this->validator)($input); + } } diff --git a/JBBCode/validators/UrlValidator.php b/JBBCode/validators/UrlValidator.php index 0ddf0a3..6adea56 100644 --- a/JBBCode/validators/UrlValidator.php +++ b/JBBCode/validators/UrlValidator.php @@ -19,9 +19,8 @@ class UrlValidator implements \JBBCode\InputValidator * @param string $input the string to validate * @return boolean */ - public function validate($input) + public function validate(string $input): bool { - $valid = filter_var($input, FILTER_VALIDATE_URL); - return !!$valid; + return (bool) filter_var($input, FILTER_VALIDATE_URL); } } From 80b843944a91c3b4550f412c315f549b89894065 Mon Sep 17 00:00:00 2001 From: Miguel92 Date: Tue, 2 Jun 2026 12:10:54 -0300 Subject: [PATCH 4/7] refactor(visitors): actualizar visitors con tipos :void y corregir errores --- JBBCode/NodeVisitor.php | 6 ++--- JBBCode/visitors/HTMLSafeVisitor.php | 29 +++++++++++-------------- JBBCode/visitors/NestLimitVisitor.php | 20 ++++++++--------- JBBCode/visitors/SmileyVisitor.php | 10 ++++----- JBBCode/visitors/TagCountingVisitor.php | 12 +++++----- 5 files changed, 36 insertions(+), 41 deletions(-) diff --git a/JBBCode/NodeVisitor.php b/JBBCode/NodeVisitor.php index cfae839..7a9e865 100644 --- a/JBBCode/NodeVisitor.php +++ b/JBBCode/NodeVisitor.php @@ -10,9 +10,9 @@ */ interface NodeVisitor { - public function visitDocumentElement(DocumentElement $documentElement); + public function visitDocumentElement(DocumentElement $documentElement): void; - public function visitTextNode(TextNode $textNode); + public function visitTextNode(TextNode $textNode): void; - public function visitElementNode(ElementNode $elementNode); + public function visitElementNode(ElementNode $elementNode): void; } diff --git a/JBBCode/visitors/HTMLSafeVisitor.php b/JBBCode/visitors/HTMLSafeVisitor.php index 7aef743..c7ab6aa 100644 --- a/JBBCode/visitors/HTMLSafeVisitor.php +++ b/JBBCode/visitors/HTMLSafeVisitor.php @@ -9,27 +9,27 @@ */ class HTMLSafeVisitor implements \JBBCode\NodeVisitor { - public function visitDocumentElement(\JBBCode\DocumentElement $documentElement) + public function visitDocumentElement(\JBBCode\DocumentElement $documentElement): void { foreach ($documentElement->getChildren() as $child) { $child->accept($this); } } - public function visitTextNode(\JBBCode\TextNode $textNode) + public function visitTextNode(\JBBCode\TextNode $textNode): void { $textNode->setValue($this->htmlSafe($textNode->getValue())); } - public function visitElementNode(\JBBCode\ElementNode $elementNode) + public function visitElementNode(\JBBCode\ElementNode $elementNode): void { $attrs = $elementNode->getAttribute(); - if (is_array($attrs)) { - foreach ($attrs as &$el) { - $el = $this->htmlSafe($el); + if (is_array($attrs) && !empty($attrs)) { + $escapedAttrs = []; + foreach ($attrs as $key => $value) { + $escapedAttrs[$key] = $this->htmlSafe($value); } - - $elementNode->setAttribute($attrs); + $elementNode->setAttribute($escapedAttrs); } foreach ($elementNode->getChildren() as $child) { @@ -37,17 +37,14 @@ public function visitElementNode(\JBBCode\ElementNode $elementNode) } } - protected function htmlSafe($str, $options = null) + protected function htmlSafe(string $str, ?int $options = null): string { - if (is_null($options)) { + if ($options === null) { + $options = ENT_QUOTES | ENT_HTML401; if (defined('ENT_DISALLOWED')) { - $options = ENT_QUOTES | ENT_DISALLOWED | ENT_HTML401; - } // PHP 5.4+ - else { - $options = ENT_QUOTES; - } // PHP 5.3 + $options |= ENT_DISALLOWED; + } } - return htmlspecialchars($str, $options, 'UTF-8'); } } diff --git a/JBBCode/visitors/NestLimitVisitor.php b/JBBCode/visitors/NestLimitVisitor.php index 58ef642..b083e4a 100644 --- a/JBBCode/visitors/NestLimitVisitor.php +++ b/JBBCode/visitors/NestLimitVisitor.php @@ -2,11 +2,11 @@ namespace JBBCode\visitors; -require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'CodeDefinition.php'; -require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'DocumentElement.php'; -require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'ElementNode.php'; -require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'NodeVisitor.php'; -require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'TextNode.php'; +require_once dirname(__DIR__, 1) . '/CodeDefinition.php'; +require_once dirname(__DIR__, 1) . '/DocumentElement.php'; +require_once dirname(__DIR__, 1) . '/ElementNode.php'; +require_once dirname(__DIR__, 1) . '/NodeVisitor.php'; +require_once dirname(__DIR__, 1) . '/TextNode.php'; /** * This visitor is used by the jBBCode core to enforce nest limits after @@ -20,21 +20,21 @@ class NestLimitVisitor implements \JBBCode\NodeVisitor { /** @var integer[] A map from tag name to current depth. */ - protected $depth = array(); + protected array $depth = []; - public function visitDocumentElement(\JBBCode\DocumentElement $documentElement) + public function visitDocumentElement(\JBBCode\DocumentElement $documentElement): void { foreach ($documentElement->getChildren() as $child) { $child->accept($this); } } - public function visitTextNode(\JBBCode\TextNode $textNode) + public function visitTextNode(\JBBCode\TextNode $textNode): void { /* Nothing to do. Text nodes don't have tag names or children. */ } - public function visitElementNode(\JBBCode\ElementNode $elementNode) + public function visitElementNode(\JBBCode\ElementNode $elementNode): void { $tagName = strtolower($elementNode->getTagName()); @@ -47,7 +47,7 @@ public function visitElementNode(\JBBCode\ElementNode $elementNode) /* Check if $elementNode is nested too deeply. */ if ($elementNode->getCodeDefinition()->getNestLimit() != -1 && - $elementNode->getCodeDefinition()->getNestLimit() < $this->depth[$tagName]) { + $elementNode->getCodeDefinition()->getNestLimit() < $this->depth[$tagName]) { /* This element is nested too deeply. We need to remove it and not visit any * of its children. */ $elementNode->getParent()->removeChild($elementNode); diff --git a/JBBCode/visitors/SmileyVisitor.php b/JBBCode/visitors/SmileyVisitor.php index e0e8560..3247925 100644 --- a/JBBCode/visitors/SmileyVisitor.php +++ b/JBBCode/visitors/SmileyVisitor.php @@ -11,22 +11,20 @@ */ class SmileyVisitor implements \JBBCode\NodeVisitor { - public function visitDocumentElement(\JBBCode\DocumentElement $documentElement) + public function visitDocumentElement(\JBBCode\DocumentElement $documentElement): void { foreach ($documentElement->getChildren() as $child) { $child->accept($this); } } - public function visitTextNode(\JBBCode\TextNode $textNode) + public function visitTextNode(\JBBCode\TextNode $textNode): void { /* Convert :) into an image tag. */ - $textNode->setValue(str_replace(':)', - ':)', - $textNode->getValue())); + $textNode->setValue(str_replace(':)', ':)', $textNode->getValue())); } - public function visitElementNode(\JBBCode\ElementNode $elementNode) + public function visitElementNode(\JBBCode\ElementNode $elementNode): void { /* We only want to visit text nodes within elements if the element's * code definition allows for its content to be parsed. diff --git a/JBBCode/visitors/TagCountingVisitor.php b/JBBCode/visitors/TagCountingVisitor.php index 82fe234..4b0125e 100644 --- a/JBBCode/visitors/TagCountingVisitor.php +++ b/JBBCode/visitors/TagCountingVisitor.php @@ -11,21 +11,21 @@ */ class TagCountingVisitor implements \JBBcode\NodeVisitor { - protected $frequencies = array(); + protected array $frequencies = []; - public function visitDocumentElement(\JBBCode\DocumentElement $documentElement) + public function visitDocumentElement(\JBBCode\DocumentElement $documentElement): void { foreach ($documentElement->getChildren() as $child) { $child->accept($this); } } - public function visitTextNode(\JBBCode\TextNode $textNode) + public function visitTextNode(\JBBCode\TextNode $textNode): void { // Nothing to do here, text nodes do not have tag names or children } - public function visitElementNode(\JBBCode\ElementNode $elementNode) + public function visitElementNode(\JBBCode\ElementNode $elementNode): void { $tagName = strtolower($elementNode->getTagName()); @@ -49,12 +49,12 @@ public function visitElementNode(\JBBCode\ElementNode $elementNode) * * @return integer */ - public function getFrequency($tagName) + public function getFrequency(string $tagName): int { if (!isset($this->frequencies[$tagName])) { return 0; } else { - return $this->frequencies[$tagName]; + return (int)$this->frequencies[$tagName]; } } } From a4a3410e5cecc12fb717e083c1fb165d87af5f84 Mon Sep 17 00:00:00 2001 From: Miguel92 Date: Tue, 2 Jun 2026 12:11:15 -0300 Subject: [PATCH 5/7] docs(examples): actualizar ejemplos para PHP 8 --- JBBCode/examples/1-GettingStarted.php | 2 +- JBBCode/examples/2-ClosingUnclosedTags.php | 2 +- JBBCode/examples/3-MarkuplessText.php | 2 +- JBBCode/examples/4-CreatingNewCodes.php | 2 +- JBBCode/examples/SmileyVisitorTest.php | 4 ++-- JBBCode/examples/TagCountingVisitorTest.php | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/JBBCode/examples/1-GettingStarted.php b/JBBCode/examples/1-GettingStarted.php index dd0c174..0e3a0e2 100644 --- a/JBBCode/examples/1-GettingStarted.php +++ b/JBBCode/examples/1-GettingStarted.php @@ -1,5 +1,5 @@ addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet()); diff --git a/JBBCode/examples/2-ClosingUnclosedTags.php b/JBBCode/examples/2-ClosingUnclosedTags.php index 35ee7fd..a523dd2 100644 --- a/JBBCode/examples/2-ClosingUnclosedTags.php +++ b/JBBCode/examples/2-ClosingUnclosedTags.php @@ -1,5 +1,5 @@ addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet()); diff --git a/JBBCode/examples/3-MarkuplessText.php b/JBBCode/examples/3-MarkuplessText.php index 47f20a3..cc76806 100644 --- a/JBBCode/examples/3-MarkuplessText.php +++ b/JBBCode/examples/3-MarkuplessText.php @@ -1,5 +1,5 @@ addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet()); diff --git a/JBBCode/examples/4-CreatingNewCodes.php b/JBBCode/examples/4-CreatingNewCodes.php index e8335b0..c4abd5b 100644 --- a/JBBCode/examples/4-CreatingNewCodes.php +++ b/JBBCode/examples/4-CreatingNewCodes.php @@ -1,5 +1,5 @@ Date: Tue, 2 Jun 2026 12:13:21 -0300 Subject: [PATCH 6/7] refactor(php8): actualizar Tokenizer y bootstrap de tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Tokenizer: añadir tipos de retorno y parámetros - Tokenizer: tipar propiedades como array e int - tests/bootstrap.php: actualizar para compatibilidad con PHP 8 --- JBBCode/Tokenizer.php | 36 ++++++++++++++---------------------- JBBCode/tests/bootstrap.php | 2 +- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/JBBCode/Tokenizer.php b/JBBCode/Tokenizer.php index 00a2a05..96b7713 100644 --- a/JBBCode/Tokenizer.php +++ b/JBBCode/Tokenizer.php @@ -13,10 +13,10 @@ class Tokenizer { /** @var integer[] the positions of tokens found during parsing */ - protected $tokens = array(); + protected array $tokens = []; /** @var integer the number of the current token */ - protected $i = -1; + protected int $i = -1; /** * Constructs a tokenizer from the given string. The string will be tokenized @@ -26,17 +26,17 @@ class Tokenizer */ public function __construct($str) { - $strLen = strlen($str); + $strLen = strlen($str ?? ''); $position = 0; while ($position < $strLen) { $offset = strcspn($str, '[]', $position); + $condition = ($offset === 0); //Have we hit a single ']' or '['? - if ($offset == 0) { - $this->tokens[] = $str[$position]; + $this->tokens[] = $condition ? $str[$position] : substr($str, $position, $offset); + if ($condition) { $position++; } else { - $this->tokens[] = substr($str, $position, $offset); $position += $offset; } } @@ -46,7 +46,7 @@ public function __construct($str) * Returns true if there is another token in the token stream. * @return boolean */ - public function hasNext() + public function hasNext(): bool { return isset($this->tokens[$this->i + 1]); } @@ -55,32 +55,24 @@ public function hasNext() * Advances the token stream to the next token and returns the new token. * @return null|string */ - public function next() + public function next(): ?string { - if (!$this->hasNext()) { - return null; - } else { - return $this->tokens[++$this->i]; - } + return (!$this->hasNext()) ? null : $this->tokens[++$this->i]; } /** * Retrieves the current token. * @return null|string */ - public function current() + public function current(): ?string { - if ($this->i < 0) { - return null; - } else { - return $this->tokens[$this->i]; - } + return ($this->i < 0) ? null : $this->tokens[$this->i]; } /** * Moves the token stream back a token. */ - public function stepBack() + public function stepBack(): void { if ($this->i > -1) { $this->i--; @@ -90,7 +82,7 @@ public function stepBack() /** * Restarts the tokenizer, returning to the beginning of the token stream. */ - public function restart() + public function restart(): void { $this->i = -1; } @@ -99,7 +91,7 @@ public function restart() * toString method that returns the entire string from the current index on. * @return string */ - public function toString() + public function toString(): string { return implode('', array_slice($this->tokens, $this->i + 1)); } diff --git a/JBBCode/tests/bootstrap.php b/JBBCode/tests/bootstrap.php index 2345b95..dd3030f 100644 --- a/JBBCode/tests/bootstrap.php +++ b/JBBCode/tests/bootstrap.php @@ -1,2 +1,2 @@ Date: Tue, 2 Jun 2026 14:03:50 -0300 Subject: [PATCH 7/7] =?UTF-8?q?chore:=20actualizar=20configuraci=C3=B3n=20?= =?UTF-8?q?del=20proyecto=20para=20PHP=208.3+?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 11 +++++------ README.md | 29 ++++++++++++++++++++++++++++- composer.json | 15 +++++++++------ 3 files changed, 42 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index a49ae39..aa91950 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,10 @@ language: php php: - - 5.6 - - hhvm - - nightly + - 8.3 + - 8.4 matrix: fast_finish: true - allow_failures: - - php: hhvm - - php: nightly git: depth: 10 @@ -26,3 +22,6 @@ install: after_success: - php vendor/bin/coveralls -v + +script: + - vendor/bin/phpunit diff --git a/README.md b/README.md index 884d998..8180af2 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ -jBBCode +jBBCode (PHP 8.3+ compatible) ======= +[![PHP Version](https://img.shields.io/badge/PHP-8.3%2B-blue)](https://php.net) [![GitHub release](https://img.shields.io/github/release/jbowens/jBBCode.svg)](https://github.com/jbowens/jBBCode/releases) [![Software License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE.md) [![Build Status](https://img.shields.io/travis/jbowens/jBBCode.svg)](https://travis-ci.org/jbowens/jBBCode) @@ -7,11 +8,17 @@ jBBCode jBBCode is a bbcode parser written in php 5.3. It's relatively lightweight and parses bbcodes without resorting to expensive regular expressions. +**This fork is compatible with PHP 8.3, 8.4, and 8.5+.** + Documentation ------------- For complete documentation and examples visit [jbbcode.com](http://jbbcode.com). +### Requirements + +- PHP 8.3 or higher + ### A basic example jBBCode includes a few optional, default bbcode definitions that may be loaded through the @@ -51,6 +58,26 @@ require 'vendor/autoloader.php'; $parser = new JBBCode\Parser(); ``` +Upgrading from older versions +---------- +If you're upgrading from the original jBBCode (pre-PHP 8), please note: +- **PHP 7.4 and below are no longer supported** +- All methods now have proper return type declarations (: string, : void, : bool, etc.) +- The InputValidator interface now requires validate(string $input): bool +- Property types have been added to all classes +- Setter methods (deprecated) now correctly return : void instead of : string +> Your existing code should continue to work as long as you're not relying on implementation details that have changed. + +Changes in this fork +---------- +- ✅ PHP 8.3, 8.4, 8.5+ compatibility +- ✅ Added return types (: string, : void, : bool, : array, etc.) +- ✅ Added property types +- ✅ Fixed InputValidator interface with proper type hints +- ✅ Fixed syntax errors in visitors +- ✅ Improved regex in CssColorValidator +- ✅ Updated Tokenizer for better UTF-8 handling + Contribute ---------- diff --git a/composer.json b/composer.json index d76d8c1..40ce3a0 100644 --- a/composer.json +++ b/composer.json @@ -1,17 +1,16 @@ { "name": "jbbcode/jbbcode", "type": "library", - "description": "A lightweight but extensible BBCode parser written in PHP 5.3.", + "description": "A lightweight but extensible BBCode parser written in PHP 8.3.", "keywords": ["BBCode", "BB"], "homepage": "http://jbbcode.com/", "license": "MIT", "require": { - "php": ">=5.3.0" + "php": ">=8.2.0" }, "require-dev": { - "phpunit/phpunit": "4.5.*", - "satooshi/php-coveralls": "0.6.*", - "friendsofphp/php-cs-fixer": "^2.1" + "phpunit/phpunit": "^9.6", + "friendsofphp/php-cs-fixer": "^3.0" }, "authors": [ { @@ -26,5 +25,9 @@ "JBBCode": "." } }, - "minimum-stability": "stable" + "minimum-stability": "stable", + "scripts": { + "test": "phpunit", + "cs-fix": "php-cs-fixer fix" + } }