From 7fa1982281c59644cb2ff059e833e4e640437e26 Mon Sep 17 00:00:00 2001 From: lukareihl Date: Wed, 11 Oct 2023 16:26:31 +0200 Subject: [PATCH 1/2] Introduce PSR-4 autoloading --- composer.json | 36 ++++------ examples/CustomFlowElement.php | 68 +++++++++---------- examples/FlowElementsForExamples.php | 46 ++++++------- examples/Pipeline.php | 68 +++++++++---------- phpunit.xml | 2 +- .../AspectPropertyValue.php | 42 ++++++------ .../BasicListEvidenceKeyFilter.php | 44 ++++++------ Constants.php => src/Constants.php | 42 ++++++------ ElementData.php => src/ElementData.php | 42 ++++++------ .../ElementDataDictionary.php | 44 ++++++------ Evidence.php => src/Evidence.php | 2 - .../EvidenceKeyFilter.php | 42 ++++++------ FlowData.php => src/FlowData.php | 43 ++++++------ FlowElement.php => src/FlowElement.php | 42 ++++++------ .../JavaScriptResource.mustache | 0 .../JavascriptBuilderElement.php | 42 ++++++------ JsonBundler.php => src/JsonBundlerElement.php | 42 ++++++------ Logger.php => src/Logger.php | 46 ++++++------- Messages.php => src/Messages.php | 42 ++++++------ Pipeline.php => src/Pipeline.php | 42 ++++++------ .../PipelineBuilder.php | 42 ++++++------ .../SequenceElement.php | 42 ++++++------ .../SetHeaderElement.php | 52 +++++++------- Utils.php => src/Utils.php | 42 ++++++------ tests/CoreTests.php | 59 +++++++--------- tests/ExampleTests.php | 44 ++++++------ tests/FlowDataTests.php | 46 ++++++------- tests/JavaScriptBundlerTests.php | 45 ++++++------ tests/SetHeaderTests.php | 48 +++++++------ tests/classes/Constants.php | 30 ++++---- tests/classes/ErrorFlowData.php | 44 ++++++------ tests/classes/ExampleFlowElement1.php | 44 ++++++------ tests/classes/ExampleFlowElement2.php | 44 ++++++------ tests/classes/MemoryLogger.php | 36 +++++----- tests/classes/StopFlowData.php | 44 ++++++------ tests/classes/TestPipeline.php | 50 ++++++-------- 36 files changed, 726 insertions(+), 763 deletions(-) rename AspectPropertyValue.php => src/AspectPropertyValue.php (99%) rename BasicListEvidenceKeyFilter.php => src/BasicListEvidenceKeyFilter.php (96%) rename Constants.php => src/Constants.php (98%) rename ElementData.php => src/ElementData.php (99%) rename ElementDataDictionary.php => src/ElementDataDictionary.php (97%) rename Evidence.php => src/Evidence.php (99%) rename EvidenceKeyFilter.php => src/EvidenceKeyFilter.php (99%) rename FlowData.php => src/FlowData.php (99%) rename FlowElement.php => src/FlowElement.php (99%) rename JavaScriptResource.mustache => src/JavaScriptResource.mustache (100%) rename JavascriptBuilder.php => src/JavascriptBuilderElement.php (99%) rename JsonBundler.php => src/JsonBundlerElement.php (99%) rename Logger.php => src/Logger.php (97%) rename Messages.php => src/Messages.php (99%) rename Pipeline.php => src/Pipeline.php (99%) rename PipelineBuilder.php => src/PipelineBuilder.php (99%) rename SequenceElement.php => src/SequenceElement.php (99%) rename SetHeaderElement.php => src/SetHeaderElement.php (97%) rename Utils.php => src/Utils.php (99%) diff --git a/composer.json b/composer.json index 107c800..c113acb 100644 --- a/composer.json +++ b/composer.json @@ -23,32 +23,24 @@ "license": "EUPL-1.2", "type": "library", "require": { + "php": ">=7.4", + "ext-ctype": "*", + "ext-json": "*", "mustache/mustache": "^2.13", "tedivm/jshrink": "~1.0" }, + "require-dev": { + "kint-php/kint": "^3.3", + "phpunit/phpunit": "*" + }, "autoload": { - "classmap": [ - "ElementData.php", - "AspectPropertyValue.php", - "ElementDataDictionary.php", - "Evidence.php", - "EvidenceKeyFilter.php", - "BasicListEvidenceKeyFilter.php", - "FlowData.php", - "FlowElement.php", - "Logger.php", - "Messages.php", - "Pipeline.php", - "PipelineBuilder.php", - "JavascriptBuilder.php", - "JsonBundler.php", - "SequenceElement.php", - "SetHeaderElement.php", - "Constants.php", - "Utils.php" - ] + "psr-4": { + "fiftyone\\pipeline\\core\\": "src/" + } }, - "require-dev": { - "kint-php/kint": "^3.3" + "autoload-dev": { + "psr-4": { + "fiftyone\\pipeline\\core\\tests\\": "tests/" + } } } diff --git a/examples/CustomFlowElement.php b/examples/CustomFlowElement.php index 82b8645..d7e689a 100644 --- a/examples/CustomFlowElement.php +++ b/examples/CustomFlowElement.php @@ -1,38 +1,38 @@ -evidence->get("query.dateOfBirth"); - + if ($dateOfBirth) { $dateOfBirth = explode("-", $dateOfBirth); diff --git a/examples/FlowElementsForExamples.php b/examples/FlowElementsForExamples.php index fc44734..fd84317 100644 --- a/examples/FlowElementsForExamples.php +++ b/examples/FlowElementsForExamples.php @@ -1,24 +1,24 @@ -add($fe1) - ->add($feStop) - ->add($fe2) - ->addLogger(new ArrayLogger("info")) - ->build(); + ->add($fe1) + ->add($feStop) + ->add($fe2) + ->addLogger(new ArrayLogger("info")) + ->build(); // We create FlowData which we will add evidence to diff --git a/phpunit.xml b/phpunit.xml index e48f980..47eb87b 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,4 +1,4 @@ - + tests/CoreTests.php diff --git a/AspectPropertyValue.php b/src/AspectPropertyValue.php similarity index 99% rename from AspectPropertyValue.php rename to src/AspectPropertyValue.php index be27893..56fef46 100644 --- a/AspectPropertyValue.php +++ b/src/AspectPropertyValue.php @@ -1,24 +1,24 @@ -log[] = $log; - } - } + * ********************************************************************* */ + + + +namespace fiftyone\pipeline\core\tests\classes; + +use fiftyone\pipeline\core\Logger; + +class MemoryLogger extends Logger +{ + public $log = []; + + public function logInternal($log) + { + if ($log["message"] === "test") { + $this->log[] = $log; + } + } } \ No newline at end of file diff --git a/tests/classes/StopFlowData.php b/tests/classes/StopFlowData.php index d214848..69c9701 100644 --- a/tests/classes/StopFlowData.php +++ b/tests/classes/StopFlowData.php @@ -1,29 +1,29 @@ - Date: Wed, 11 Oct 2023 16:26:31 +0200 Subject: [PATCH 2/2] Introduce PSR-4 autoloading --- composer.json | 36 ++++------ examples/CustomFlowElement.php | 67 +++++++++--------- examples/FlowElementsForExamples.php | 46 ++++++------- examples/Pipeline.php | 68 +++++++++---------- phpunit.xml | 2 +- .../AspectPropertyValue.php | 42 ++++++------ .../BasicListEvidenceKeyFilter.php | 44 ++++++------ Constants.php => src/Constants.php | 42 ++++++------ ElementData.php => src/ElementData.php | 42 ++++++------ .../ElementDataDictionary.php | 44 ++++++------ Evidence.php => src/Evidence.php | 2 - .../EvidenceKeyFilter.php | 42 ++++++------ FlowData.php => src/FlowData.php | 43 ++++++------ FlowElement.php => src/FlowElement.php | 42 ++++++------ .../JavaScriptResource.mustache | 0 .../JavascriptBuilderElement.php | 42 ++++++------ JsonBundler.php => src/JsonBundlerElement.php | 42 ++++++------ Logger.php => src/Logger.php | 46 ++++++------- Messages.php => src/Messages.php | 42 ++++++------ Pipeline.php => src/Pipeline.php | 42 ++++++------ .../PipelineBuilder.php | 42 ++++++------ .../SequenceElement.php | 42 ++++++------ .../SetHeaderElement.php | 52 +++++++------- Utils.php => src/Utils.php | 42 ++++++------ tests/CoreTests.php | 59 +++++++--------- tests/ExampleTests.php | 44 ++++++------ tests/FlowDataTests.php | 46 ++++++------- tests/JavaScriptBundlerTests.php | 45 ++++++------ tests/SetHeaderTests.php | 48 +++++++------ tests/classes/Constants.php | 30 ++++---- tests/classes/ErrorFlowData.php | 44 ++++++------ tests/classes/ExampleFlowElement1.php | 44 ++++++------ tests/classes/ExampleFlowElement2.php | 44 ++++++------ tests/classes/MemoryLogger.php | 36 +++++----- tests/classes/StopFlowData.php | 44 ++++++------ tests/classes/TestPipeline.php | 50 ++++++-------- 36 files changed, 725 insertions(+), 763 deletions(-) rename AspectPropertyValue.php => src/AspectPropertyValue.php (99%) rename BasicListEvidenceKeyFilter.php => src/BasicListEvidenceKeyFilter.php (96%) rename Constants.php => src/Constants.php (98%) rename ElementData.php => src/ElementData.php (99%) rename ElementDataDictionary.php => src/ElementDataDictionary.php (97%) rename Evidence.php => src/Evidence.php (99%) rename EvidenceKeyFilter.php => src/EvidenceKeyFilter.php (99%) rename FlowData.php => src/FlowData.php (99%) rename FlowElement.php => src/FlowElement.php (99%) rename JavaScriptResource.mustache => src/JavaScriptResource.mustache (100%) rename JavascriptBuilder.php => src/JavascriptBuilderElement.php (99%) rename JsonBundler.php => src/JsonBundlerElement.php (99%) rename Logger.php => src/Logger.php (97%) rename Messages.php => src/Messages.php (99%) rename Pipeline.php => src/Pipeline.php (99%) rename PipelineBuilder.php => src/PipelineBuilder.php (99%) rename SequenceElement.php => src/SequenceElement.php (99%) rename SetHeaderElement.php => src/SetHeaderElement.php (97%) rename Utils.php => src/Utils.php (99%) diff --git a/composer.json b/composer.json index 107c800..c113acb 100644 --- a/composer.json +++ b/composer.json @@ -23,32 +23,24 @@ "license": "EUPL-1.2", "type": "library", "require": { + "php": ">=7.4", + "ext-ctype": "*", + "ext-json": "*", "mustache/mustache": "^2.13", "tedivm/jshrink": "~1.0" }, + "require-dev": { + "kint-php/kint": "^3.3", + "phpunit/phpunit": "*" + }, "autoload": { - "classmap": [ - "ElementData.php", - "AspectPropertyValue.php", - "ElementDataDictionary.php", - "Evidence.php", - "EvidenceKeyFilter.php", - "BasicListEvidenceKeyFilter.php", - "FlowData.php", - "FlowElement.php", - "Logger.php", - "Messages.php", - "Pipeline.php", - "PipelineBuilder.php", - "JavascriptBuilder.php", - "JsonBundler.php", - "SequenceElement.php", - "SetHeaderElement.php", - "Constants.php", - "Utils.php" - ] + "psr-4": { + "fiftyone\\pipeline\\core\\": "src/" + } }, - "require-dev": { - "kint-php/kint": "^3.3" + "autoload-dev": { + "psr-4": { + "fiftyone\\pipeline\\core\\tests\\": "tests/" + } } } diff --git a/examples/CustomFlowElement.php b/examples/CustomFlowElement.php index 82b8645..363a562 100644 --- a/examples/CustomFlowElement.php +++ b/examples/CustomFlowElement.php @@ -1,40 +1,39 @@ -evidence->get("query.dateOfBirth"); - + if ($dateOfBirth) { $dateOfBirth = explode("-", $dateOfBirth); diff --git a/examples/FlowElementsForExamples.php b/examples/FlowElementsForExamples.php index fc44734..fd84317 100644 --- a/examples/FlowElementsForExamples.php +++ b/examples/FlowElementsForExamples.php @@ -1,24 +1,24 @@ -add($fe1) - ->add($feStop) - ->add($fe2) - ->addLogger(new ArrayLogger("info")) - ->build(); + ->add($fe1) + ->add($feStop) + ->add($fe2) + ->addLogger(new ArrayLogger("info")) + ->build(); // We create FlowData which we will add evidence to diff --git a/phpunit.xml b/phpunit.xml index e48f980..47eb87b 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,4 +1,4 @@ - + tests/CoreTests.php diff --git a/AspectPropertyValue.php b/src/AspectPropertyValue.php similarity index 99% rename from AspectPropertyValue.php rename to src/AspectPropertyValue.php index be27893..56fef46 100644 --- a/AspectPropertyValue.php +++ b/src/AspectPropertyValue.php @@ -1,24 +1,24 @@ -log[] = $log; - } - } + * ********************************************************************* */ + + + +namespace fiftyone\pipeline\core\tests\classes; + +use fiftyone\pipeline\core\Logger; + +class MemoryLogger extends Logger +{ + public $log = []; + + public function logInternal($log) + { + if ($log["message"] === "test") { + $this->log[] = $log; + } + } } \ No newline at end of file diff --git a/tests/classes/StopFlowData.php b/tests/classes/StopFlowData.php index d214848..69c9701 100644 --- a/tests/classes/StopFlowData.php +++ b/tests/classes/StopFlowData.php @@ -1,29 +1,29 @@ -