Skip to content

Commit 45c9277

Browse files
committed
Add PHONY targets to Makefile and improve code robustness
Enhances Makefile maintainability by explicitly declaring PHONY targets and adding descriptive comments for each target. Improves code robustness in `AbraFlexi/RO` by adding a null check to prevent potential errors when processing values. Refines unit testing in `DateTest` by implementing and validating the `timestampToFlexiDate` method, ensuring proper functionality and type safety.
1 parent 4a7b69d commit 45c9277

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

Makefile

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ static: ## Generate Static files by api structure
3939
cd tools/ ; ./update_all.sh ; cd ..
4040
make cssilent
4141

42-
clean:
42+
.PHONY: clean
43+
clean: ## Clean up build artifacts
4344
rm -rf debian/php-abraflexi
4445
rm -rf debian/flexipeehp .phpunit.result.cache debian/flexipeehp.debhelper.log
4546
rm -rf debian/flexipeehp-doc
@@ -49,36 +50,44 @@ clean:
4950
rm -f debianTest/composer.lock
5051
rm -rf vendor/* composer.lock
5152

52-
apigen:
53+
.PHONY: apigen
54+
apigen: ## Generate API documentation
5355
VERSION=`cat debian/composer.json | grep version | awk -F'"' '{print $4}'`; \
5456
apigen generate --destination=docs -- src
5557

5658
.PHONY: phpdoc
5759
phpdoc: ## Generate dev docs
5860
phpdoc -d src
5961

60-
pretest:
62+
.PHONY: pretest
63+
pretest: ## Prepare for tests
6164
composer --ansi --no-interaction update
6265
php -f tests/PrepareForTest.php
6366

64-
deb:
67+
.PHONY: deb
68+
deb: ## Build Debian package
6569
dpkg-buildpackage -A -us -uc
6670

67-
rpm:
71+
.PHONY: rpm
72+
rpm: ## Build RPM package
6873
rpmdev-bumpspec --comment="Build" --userstring="Vítězslav Dvořák <[email protected]>" flexipeehp.spec
69-
rpmbuild -ba flexipeehp.spec
74+
rpmbuild -ba flexipeehp.spec
7075

71-
release:
76+
.PHONY: release
77+
release: ## Release a new version
7278
echo Release v$(nextversion)
7379
dch -v $(nextversion) `git log -1 --pretty=%B | head -n 1`
7480
debuild -i -us -uc -b
7581
git commit -a -m "Release v$(nextversion)"
7682
git tag -a $(nextversion) -m "version $(nextversion)"
7783

78-
dimage:
84+
.PHONY: dimage
85+
dimage: ## Build Docker image
7986
docker build -t vitexsoftware/flexipeehp .
8087

8188
.PHONY: all pretest clean static release verup deb
8289

90+
8391
.PHONY: cs
92+
cs: ## Update Coding Standards
8493
vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php --diff --verbose

src/AbraFlexi/RO.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2057,7 +2057,7 @@ public function getExternalID($want = null)
20572057
}
20582058
} else {
20592059
foreach ($values as $id) {
2060-
if (strstr($id, 'ext:'.$want)) {
2060+
if ($id && strstr($id, 'ext:'.$want)) {
20612061
if (null === $extid) {
20622062
$extid = str_replace('ext:'.$want.':', '', $id);
20632063
} else {

tests/src/AbraFlexi/DateTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ public function testToString(): void
5555
*/
5656
public function testtimestampToFlexiDate(): void
5757
{
58-
$this->assertEquals('', $this->object->timestampToFlexiDate());
59-
// Remove the following lines when you implement this test.
60-
$this->markTestIncomplete('This test has not been implemented yet.');
58+
$result = $this->object->timestampToFlexiDate(time());
59+
$this->assertInstanceOf(\AbraFlexi\Date::class, $result);
6160
}
6261
}

0 commit comments

Comments
 (0)