From 333323c9b308b4e4c48c312beb89919f053c10dc Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Sun, 7 Jan 2018 20:58:33 -0600 Subject: [PATCH 01/30] Bumped years --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 08533da..46c6d1c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2014, 2015, 2016 Josh Sherman +Copyright (c) 2014, 2015, 2016, 2017, 2018 Josh Sherman Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 8d0bd22b1b0cb9df6e24aa509c82ca0b462d0e99 Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Sun, 7 Jan 2018 21:02:24 -0600 Subject: [PATCH 02/30] Added PHP 7.2 and HHVM 7.2 is out and the README still says HHVM, figure should be testing against it. --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 11ab0f5..ab910a2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,8 @@ matrix: - php: 5.6 - php: 7.0 - php: 7.1 + - php: 7.2 + - php: hhvm install: - composer install From 30f193b036b5b7caedec1d9c8c4d141bc8cdf039 Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Sun, 7 Jan 2018 21:26:18 -0600 Subject: [PATCH 03/30] Install a different phpunit on HHVM --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index ab910a2..8652f5f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,11 +13,13 @@ matrix: - php: 7.1 - php: 7.2 - php: hhvm + env: HHVM=true install: - composer install before_script: + - if [[ $HHVM && ${HHVM-x} ]] && curl -sSf -o ~/.phpenv/versions/hhvm/bin/phpunit https://phar.phpunit.de/phpunit-5.7.phar - mkdir -p build/logs - cd tests From 5ed73226471715c7ab965fc788190eb7af593cbc Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Sun, 7 Jan 2018 21:35:12 -0600 Subject: [PATCH 04/30] Whoops, fixed syntax --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8652f5f..62e51a1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,7 @@ install: - composer install before_script: - - if [[ $HHVM && ${HHVM-x} ]] && curl -sSf -o ~/.phpenv/versions/hhvm/bin/phpunit https://phar.phpunit.de/phpunit-5.7.phar + - [[ $HHVM && ${HHVM-x} ]] && curl -sSf -o ~/.phpenv/versions/hhvm/bin/phpunit https://phar.phpunit.de/phpunit-5.7.phar - mkdir -p build/logs - cd tests From 1943a9b79f27a1f78ba4f495050d56c04a95f806 Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Sun, 7 Jan 2018 21:42:37 -0600 Subject: [PATCH 05/30] How about this? --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 62e51a1..31902b2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,7 @@ install: - composer install before_script: - - [[ $HHVM && ${HHVM-x} ]] && curl -sSf -o ~/.phpenv/versions/hhvm/bin/phpunit https://phar.phpunit.de/phpunit-5.7.phar + - if [[ $HHVM && ${HHVM-x} ]]; then curl -sSf -o ~/.phpenv/versions/hhvm/bin/phpunit https://phar.phpunit.de/phpunit-5.7.phar; fi - mkdir -p build/logs - cd tests From a7bf9d29c06d6a1925fc05aad2f51051a9ed0ee5 Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Sun, 7 Jan 2018 22:08:59 -0600 Subject: [PATCH 06/30] Simplified sanity check, report version for debugging --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 31902b2..6594d19 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,8 @@ install: - composer install before_script: - - if [[ $HHVM && ${HHVM-x} ]]; then curl -sSf -o ~/.phpenv/versions/hhvm/bin/phpunit https://phar.phpunit.de/phpunit-5.7.phar; fi + - if [[ $HHVM == true ]]; then curl -sSf -o ~/.phpenv/versions/hhvm/bin/phpunit https://phar.phpunit.de/phpunit-5.7.phar; fi + - phpunit --version - mkdir -p build/logs - cd tests From ffbdd892a3f8bf0234c0edc6255437e455d4db9d Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Sun, 7 Jan 2018 22:16:46 -0600 Subject: [PATCH 07/30] Tell curl to follow 302 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6594d19..dcaa4b3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,7 @@ install: - composer install before_script: - - if [[ $HHVM == true ]]; then curl -sSf -o ~/.phpenv/versions/hhvm/bin/phpunit https://phar.phpunit.de/phpunit-5.7.phar; fi + - if [[ $HHVM == true ]]; then curl -sSfL -o ~/.phpenv/versions/hhvm/bin/phpunit https://phar.phpunit.de/phpunit-5.7.phar; fi - phpunit --version - mkdir -p build/logs - cd tests From 9cbee4918f321393c5e0bac6a8677e12831cea7b Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Sun, 7 Jan 2018 22:36:27 -0600 Subject: [PATCH 08/30] Bumped years --- src/LoremIpsum.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LoremIpsum.php b/src/LoremIpsum.php index 95164be..df4424b 100644 --- a/src/LoremIpsum.php +++ b/src/LoremIpsum.php @@ -9,7 +9,7 @@ * Redistribution of these files must retain the above copyright notice. * * @author Josh Sherman - * @copyright Copyright 2014, 2015, 2016 Josh Sherman + * @copyright Copyright 2014, 2015, 2016, 2017, 2018 Josh Sherman * @license http://www.opensource.org/licenses/mit-license.html * @link https://github.com/joshtronic/php-loremipsum */ From c6b8669c2c676581921dd1ae1485b21895bc4e4c Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Sun, 7 Jan 2018 22:36:46 -0600 Subject: [PATCH 09/30] Trying to fix HHVM errors Also some code cleanup --- tests/LoremIpsumTest.php | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/tests/LoremIpsumTest.php b/tests/LoremIpsumTest.php index 7b794cd..6af55f9 100644 --- a/tests/LoremIpsumTest.php +++ b/tests/LoremIpsumTest.php @@ -2,7 +2,17 @@ require_once '../src/LoremIpsum.php'; -if (!class_exists('\PHPUnit_Framework_TestCase') && class_exists('\PHPUnit\Framework\TestCase')) { +if ( + !class_exists('\PHPUnit_Framework_Error') + && class_exists('\PHPUnit\Framework\Error') +) { + class_alias('\PHPUnit\Framework\Error', '\PHPUnit_Framework_Error'); +} + +if ( + !class_exists('\PHPUnit_Framework_TestCase') + && class_exists('\PHPUnit\Framework\TestCase') +) { class_alias('\PHPUnit\Framework\TestCase', '\PHPUnit_Framework_TestCase'); } @@ -34,8 +44,7 @@ class LoremIpsumTest extends PHPUnit_Framework_TestCase $this->assertTrue(is_array($words)); $this->assertCount(3, $words); - foreach ($words as $word) - { + foreach ($words as $word) { $this->assertRegExp('/^[a-z]+$/i', $word); } } @@ -61,8 +70,7 @@ class LoremIpsumTest extends PHPUnit_Framework_TestCase $this->assertTrue(is_array($sentences)); $this->assertCount(3, $sentences); - foreach ($sentences as $sentence) - { + foreach ($sentences as $sentence) { $this->assertRegExp('/^[a-z, ]+\.$/i', $sentence); } } @@ -86,8 +94,7 @@ class LoremIpsumTest extends PHPUnit_Framework_TestCase $this->assertTrue(is_array($paragraphs)); $this->assertCount(3, $paragraphs); - foreach ($paragraphs as $paragraph) - { + foreach ($paragraphs as $paragraph) { $this->assertRegExp('/^([a-z, ]+\.)+$/i', $paragraph); } } @@ -122,8 +129,7 @@ class LoremIpsumTest extends PHPUnit_Framework_TestCase $this->assertTrue(is_array($words)); $this->assertCount(3, $words); - foreach ($words as $word) - { + foreach ($words as $word) { $this->assertRegExp('/^
  • [a-z]+<\/li>$/i', $word); } } From 3d4ceeb6fd0da0563bc50c3021d14f7d8930e8e0 Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Sun, 7 Jan 2018 22:41:41 -0600 Subject: [PATCH 10/30] Do that didn't help --- tests/LoremIpsumTest.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/tests/LoremIpsumTest.php b/tests/LoremIpsumTest.php index 6af55f9..e568b4d 100644 --- a/tests/LoremIpsumTest.php +++ b/tests/LoremIpsumTest.php @@ -2,13 +2,6 @@ require_once '../src/LoremIpsum.php'; -if ( - !class_exists('\PHPUnit_Framework_Error') - && class_exists('\PHPUnit\Framework\Error') -) { - class_alias('\PHPUnit\Framework\Error', '\PHPUnit_Framework_Error'); -} - if ( !class_exists('\PHPUnit_Framework_TestCase') && class_exists('\PHPUnit\Framework\TestCase') From 1f016c6b4bfdafb1d5094053e32c177e95d4cbb9 Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Sun, 7 Jan 2018 23:13:00 -0600 Subject: [PATCH 11/30] Try composer install phpunit --- .travis.yml | 6 +++--- composer.json | 23 +++++++++++++---------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index dcaa4b3..e23ec39 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,13 +19,13 @@ install: - composer install before_script: - - if [[ $HHVM == true ]]; then curl -sSfL -o ~/.phpenv/versions/hhvm/bin/phpunit https://phar.phpunit.de/phpunit-5.7.phar; fi - - phpunit --version - mkdir -p build/logs - cd tests script: - - phpunit --colors --coverage-clover ../build/logs/clover.xml . + - if [[ $HHVM == true ]]; then ./vendor/bin/phpunit --colors --coverage-clover ../build/logs/clover.xml .; fi + - if [[ $HHVM != true ]]; then phpunit --colors --coverage-clover ../build/logs/clover.xml .; fi + after_success: - cd .. diff --git a/composer.json b/composer.json index 4d1073e..caba723 100644 --- a/composer.json +++ b/composer.json @@ -1,23 +1,26 @@ { - "name": "joshtronic/php-loremipsum", + "name": "joshtronic/php-loremipsum", "description": "Lorem ipsum generator in PHP without dependencies", - "version": "1.0.2", - "type": "library", - "keywords": ["lorem", "ipsum", "generator"], - "homepage": "https://github.com/joshtronic/php-loremipsum", - "license": "MIT", + "version": "1.0.2", + "type": "library", + "keywords": ["lorem", "ipsum", "generator"], + "homepage": "https://github.com/joshtronic/php-loremipsum", + "license": "MIT", "authors": [{ - "name": "Josh Sherman", - "email": "josh@gravityblvd.com", - "homepage": "http://joshtronic.com" + "name": "Josh Sherman", + "email": "josh@gravityblvd.com", + "homepage": "https://joshtronic.com" }], "require": { "php": ">=5.3.0" }, "require-dev": { + "phpunit/phpunit": "5.7.*", "satooshi/php-coveralls": "~1.0" }, "autoload": { - "psr-4": {"joshtronic\\": "src/"} + "psr-4": { + "joshtronic\\": "src/" + } } } From 551a2d790d0d897b43ca430718feaf61bba9669a Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Sun, 7 Jan 2018 23:31:46 -0600 Subject: [PATCH 12/30] Let's try to install it directly --- .travis.yml | 12 ++++++++---- composer.json | 1 - 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index e23ec39..104e3e0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,9 @@ language: php dist: trusty sudo: required +env: + - HHVM=false + - PHPUNIT=phpunit matrix: include: @@ -13,19 +16,20 @@ matrix: - php: 7.1 - php: 7.2 - php: hhvm - env: HHVM=true + env: + - HHVM=true + - PHPUNIT=./vendor/bin/phpunit install: - composer install + - if [[ $HHVM == true ]]; then composer require "phpunit/phpunit:5.7"; fi before_script: - mkdir -p build/logs - cd tests script: - - if [[ $HHVM == true ]]; then ./vendor/bin/phpunit --colors --coverage-clover ../build/logs/clover.xml .; fi - - if [[ $HHVM != true ]]; then phpunit --colors --coverage-clover ../build/logs/clover.xml .; fi - + - $PHPUNIT --colors --coverage-clover ../build/logs/clover.xml . after_success: - cd .. diff --git a/composer.json b/composer.json index caba723..9396289 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,6 @@ "php": ">=5.3.0" }, "require-dev": { - "phpunit/phpunit": "5.7.*", "satooshi/php-coveralls": "~1.0" }, "autoload": { From dd120b78320b36c162e357b0455f045527845c03 Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Sun, 7 Jan 2018 23:39:20 -0600 Subject: [PATCH 13/30] Cleaned up env stuff Was triggering a few extra builds and was kinda borked --- .travis.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 104e3e0..c5d5d43 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,6 @@ language: php dist: trusty sudo: required -env: - - HHVM=false - - PHPUNIT=phpunit matrix: include: @@ -16,9 +13,7 @@ matrix: - php: 7.1 - php: 7.2 - php: hhvm - env: - - HHVM=true - - PHPUNIT=./vendor/bin/phpunit + env: HHVM=true install: - composer install @@ -29,7 +24,9 @@ before_script: - cd tests script: - - $PHPUNIT --colors --coverage-clover ../build/logs/clover.xml . + - if [[ $HHVM == true ]]; then ./vendor/bin/phpunit --colors --coverage-clover ../build/logs/clover.xml .; fi + - if [[ $HHVM != true ]]; then phpunit --colors --coverage-clover ../build/logs/clover.xml .; fi + after_success: - cd .. From fc7ce83cbca8aeaa407543d9aa2c5b28f5566e4a Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Sun, 7 Jan 2018 23:46:32 -0600 Subject: [PATCH 14/30] Let's try to get that path right --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c5d5d43..24b1527 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ before_script: - cd tests script: - - if [[ $HHVM == true ]]; then ./vendor/bin/phpunit --colors --coverage-clover ../build/logs/clover.xml .; fi + - if [[ $HHVM == true ]]; then ../vendor/bin/phpunit --colors --coverage-clover ../build/logs/clover.xml .; fi - if [[ $HHVM != true ]]; then phpunit --colors --coverage-clover ../build/logs/clover.xml .; fi From a82b10394d23b28f3b1eeb8a23f3e3f08a4e652a Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Sun, 7 Jan 2018 23:53:45 -0600 Subject: [PATCH 15/30] Bumped version, small bit of cleanup --- composer.json | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 9396289..c5eaa62 100644 --- a/composer.json +++ b/composer.json @@ -1,16 +1,22 @@ { "name": "joshtronic/php-loremipsum", "description": "Lorem ipsum generator in PHP without dependencies", - "version": "1.0.2", + "version": "1.0.3", "type": "library", - "keywords": ["lorem", "ipsum", "generator"], + "keywords": [ + "lorem", + "ipsum", + "generator" + ], "homepage": "https://github.com/joshtronic/php-loremipsum", "license": "MIT", - "authors": [{ - "name": "Josh Sherman", - "email": "josh@gravityblvd.com", - "homepage": "https://joshtronic.com" - }], + "authors": [ + { + "name": "Josh Sherman", + "email": "josh@gravityblvd.com", + "homepage": "https://joshtronic.com" + } + ], "require": { "php": ">=5.3.0" }, From 5fa8d5b300fc9a9ff1fcf10cb64564fe31dc7669 Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Mon, 8 Jan 2018 23:38:06 -0600 Subject: [PATCH 16/30] Made some adjustments to the word list --- src/LoremIpsum.php | 80 +++++++++++++++++++--------------------------- 1 file changed, 32 insertions(+), 48 deletions(-) diff --git a/src/LoremIpsum.php b/src/LoremIpsum.php index df4424b..393c9b6 100644 --- a/src/LoremIpsum.php +++ b/src/LoremIpsum.php @@ -8,7 +8,7 @@ * Licensed under The MIT License. * Redistribution of these files must retain the above copyright notice. * - * @author Josh Sherman + * @author Josh Sherman * @copyright Copyright 2014, 2015, 2016, 2017, 2018 Josh Sherman * @license http://www.opensource.org/licenses/mit-license.html * @link https://github.com/joshtronic/php-loremipsum @@ -39,53 +39,37 @@ class LoremIpsum */ public $words = array( // Lorem ipsum... - 'lorem', 'ipsum', 'dolor', 'sit', - 'amet', 'consectetur', 'adipiscing', 'elit', - // The rest of the vocabulary - 'a', 'ac', 'accumsan', 'ad', - 'aenean', 'aliquam', 'aliquet', 'ante', - 'aptent', 'arcu', 'at', 'auctor', - 'augue', 'bibendum', 'blandit', 'class', - 'commodo', 'condimentum', 'congue', 'consequat', - 'conubia', 'convallis', 'cras', 'cubilia', - 'cum', 'curabitur', 'curae', 'cursus', - 'dapibus', 'diam', 'dictum', 'dictumst', - 'dignissim', 'dis', 'donec', 'dui', - 'duis', 'egestas', 'eget', 'eleifend', - 'elementum', 'enim', 'erat', 'eros', - 'est', 'et', 'etiam', 'eu', - 'euismod', 'facilisi', 'facilisis', 'fames', - 'faucibus', 'felis', 'fermentum', 'feugiat', - 'fringilla', 'fusce', 'gravida', 'habitant', - 'habitasse', 'hac', 'hendrerit', 'himenaeos', - 'iaculis', 'id', 'imperdiet', 'in', - 'inceptos', 'integer', 'interdum', 'justo', - 'lacinia', 'lacus', 'laoreet', 'lectus', - 'leo', 'libero', 'ligula', 'litora', - 'lobortis', 'luctus', 'maecenas', 'magna', - 'magnis', 'malesuada', 'massa', 'mattis', - 'mauris', 'metus', 'mi', 'molestie', - 'mollis', 'montes', 'morbi', 'mus', - 'nam', 'nascetur', 'natoque', 'nec', - 'neque', 'netus', 'nibh', 'nisi', - 'nisl', 'non', 'nostra', 'nulla', - 'nullam', 'nunc', 'odio', 'orci', - 'ornare', 'parturient', 'pellentesque', 'penatibus', - 'per', 'pharetra', 'phasellus', 'placerat', - 'platea', 'porta', 'porttitor', 'posuere', - 'potenti', 'praesent', 'pretium', 'primis', - 'proin', 'pulvinar', 'purus', 'quam', - 'quis', 'quisque', 'rhoncus', 'ridiculus', - 'risus', 'rutrum', 'sagittis', 'sapien', - 'scelerisque', 'sed', 'sem', 'semper', - 'senectus', 'sociis', 'sociosqu', 'sodales', - 'sollicitudin', 'suscipit', 'suspendisse', 'taciti', - 'tellus', 'tempor', 'tempus', 'tincidunt', - 'torquent', 'tortor', 'tristique', 'turpis', - 'ullamcorper', 'ultrices', 'ultricies', 'urna', - 'ut', 'varius', 'vehicula', 'vel', - 'velit', 'venenatis', 'vestibulum', 'vitae', - 'vivamus', 'viverra', 'volutpat', 'vulputate', + 'lorem', 'ipsum', 'dolor', 'sit', 'amet', 'consectetur', 'adipiscing', 'elit', + + // and the rest of the vocabulary + 'a', 'ac', 'accumsan', 'ad', 'aenean', 'aliquam', 'aliquet', 'ante', + 'aptent', 'arcu', 'at', 'auctor', 'augue', 'bibendum', 'blandit', + 'class', 'commodo', 'condimentum', 'congue', 'consequat', 'conubia', + 'convallis', 'cras', 'cubilia', 'curabitur', 'curae', 'cursus', + 'dapibus', 'diam', 'dictum', 'dictumst', 'dignissim', 'dis', 'donec', + 'dui', 'duis', 'efficitur', 'egestas', 'eget', 'eleifend', 'elementum', + 'enim', 'erat', 'eros', 'est', 'et', 'etiam', 'eu', 'euismod', 'ex', + 'facilisi', 'facilisis', 'fames', 'faucibus', 'felis', 'fermentum', + 'feugiat', 'finibus', 'fringilla', 'fusce', 'gravida', 'habitant', + 'habitasse', 'hac', 'hendrerit', 'himenaeos', 'iaculis', 'id', + 'imperdiet', 'in', 'inceptos', 'integer', 'interdum', 'justo', + 'lacinia', 'lacus', 'laoreet', 'lectus', 'leo', 'libero', 'ligula', + 'litora', 'lobortis', 'luctus', 'maecenas', 'magna', 'magnis', + 'malesuada', 'massa', 'mattis', 'mauris', 'maximus', 'metus', 'mi', + 'molestie', 'mollis', 'montes', 'morbi', 'mus', 'nam', 'nascetur', + 'natoque', 'nec', 'neque', 'netus', 'nibh', 'nisi', 'nisl', 'non', + 'nostra', 'nulla', 'nullam', 'nunc', 'odio', 'orci', 'ornare', + 'parturient', 'pellentesque', 'penatibus', 'per', 'pharetra', + 'phasellus', 'placerat', 'platea', 'porta', 'porttitor', 'posuere', + 'potenti', 'praesent', 'pretium', 'primis', 'proin', 'pulvinar', + 'purus', 'quam', 'quis', 'quisque', 'rhoncus', 'ridiculus', 'risus', + 'rutrum', 'sagittis', 'sapien', 'scelerisque', 'sed', 'sem', 'semper', + 'senectus', 'sociosqu', 'sodales', 'sollicitudin', 'suscipit', + 'suspendisse', 'taciti', 'tellus', 'tempor', 'tempus', 'tincidunt', + 'torquent', 'tortor', 'tristique', 'turpis', 'ullamcorper', 'ultrices', + 'ultricies', 'urna', 'ut', 'varius', 'vehicula', 'vel', 'velit', + 'venenatis', 'vestibulum', 'vitae', 'vivamus', 'viverra', 'volutpat', + 'vulputate', ); /** From e6668afb5afb6f212d0095c90a43c6f34f62a7dc Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Mon, 8 Jan 2018 23:43:09 -0600 Subject: [PATCH 17/30] Updated email address --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c5eaa62..9c35393 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "authors": [ { "name": "Josh Sherman", - "email": "josh@gravityblvd.com", + "email": "hello@joshtronic.com", "homepage": "https://joshtronic.com" } ], From e41f4f76303b09b66448100d45a1bfdf695192bd Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Thu, 3 Jan 2019 00:21:50 -0600 Subject: [PATCH 18/30] PHP 7.3 and more * Added CI for PHP 7.3 * Dropped CI for HHVM (was running into too many issues out of no where) * Reworked CI distros where I could * Bumped copyright year * Cleaned up the README, fixed spacing, dumped some of the wordiness --- .travis.yml | 21 +++++++++----- LICENSE | 2 +- README.md | 69 +++++++++++++++++++--------------------------- composer.json | 2 +- src/LoremIpsum.php | 2 +- 5 files changed, 45 insertions(+), 51 deletions(-) diff --git a/.travis.yml b/.travis.yml index 24b1527..b7be01f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: php -dist: trusty +dist: bionic sudo: required matrix: @@ -7,26 +7,33 @@ matrix: - php: 5.3 dist: precise - php: 5.4 + dist: trusty - php: 5.5 + dist: trusty - php: 5.6 + dist: trusty - php: 7.0 + dist: xenial + env: PHPUNIT=5.7 - php: 7.1 - php: 7.2 - - php: hhvm - env: HHVM=true + - php: 7.3 install: - composer install - - if [[ $HHVM == true ]]; then composer require "phpunit/phpunit:5.7"; fi + - if [[ $PHPUNIT == 5.7 ]]; then composer require "phpunit/phpunit:5.7"; fi before_script: - mkdir -p build/logs - cd tests script: - - if [[ $HHVM == true ]]; then ../vendor/bin/phpunit --colors --coverage-clover ../build/logs/clover.xml .; fi - - if [[ $HHVM != true ]]; then phpunit --colors --coverage-clover ../build/logs/clover.xml .; fi - + - | + if [[ $PHPUNIT == 5.7 ]]; then + ../vendor/bin/phpunit --colors --coverage-clover ../build/logs/clover.xml . + else + phpunit --colors --coverage-clover ../build/logs/clover.xml . + fi after_success: - cd .. diff --git a/LICENSE b/LICENSE index 46c6d1c..ea461be 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2014, 2015, 2016, 2017, 2018 Josh Sherman +Copyright (c) 2014, 2015, 2016, 2017, 2018, 2019 Josh Sherman Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 848057d..7ea594d 100644 --- a/README.md +++ b/README.md @@ -4,36 +4,14 @@ [![Coverage Status](https://coveralls.io/repos/github/joshtronic/php-loremipsum/badge.svg?branch=master)](https://coveralls.io/github/joshtronic/php-loremipsum?branch=master) [![Total Downloads](https://poser.pugx.org/joshtronic/php-loremipsum/downloads)](https://packagist.org/packages/joshtronic/php-loremipsum) -Lorem ipsum generator in PHP without dependencies. Compatible with PHP 5.3+ as -well as HHVM. +Lorem ipsum generator in PHP without dependencies. Compatible with PHP 5.3+. -## Origins - -Once upon a time, I was attempting to find a lorem ipsum generator over on -[Packagist](https://packagist.org/search/?q=lorem%20ipsum). I was presented -with many options, and some of those options were good. Unfortunately, the -bulk of those options depended on Symphony or the Zend Framework. This -wouldn’t have been a big deal but under the circumstances, I wanted something -that was not tightly coupled to these frameworks because I wanted to use the -generator in my _own_ framework. - -I had decided to use -[badcow/lorem-ipsum](https://packagist.org/packages/badcow/lorem-ipsum) -because it did not have any dependencies nor did it rely on any external APIs. -As I started to use the library, I found that I was going to have to fight -with it to get it to do what I wanted. After digging through the code, I -realized that I was going to end up gutting most of it to bend it to my will. -I know when you overhaul someone’s code the liklihood of them accepting a pull -request goes down dramatically, hence building this library while taking cues -from it’s predecessor. - -Also, the aforementioned package had a bunch of “setter” and “getter” methods -that were grossing me out :scream: +[![Become a Patron](https://joshtronic.com/images/become-patron.png)](https://www.patreon.com/joshtronic) ## Installation -The preferred installation method is via `composer`. First add the following -to your `composer.json` +The preferred installation method is via `composer`. First add the following to +your `composer.json`: ```json "require": { @@ -41,7 +19,7 @@ to your `composer.json` } ``` -Then run `composer update` +Then run `composer update`. ## Usage @@ -58,21 +36,21 @@ echo '1 word: ' . $lipsum->word(); echo '5 words: ' . $lipsum->words(5); ``` -### Generating sentences +### Generating Sentences ```php -echo '1 sentence: ' . $lipsum->sentence(); +echo '1 sentence: ' . $lipsum->sentence(); echo '5 sentences: ' . $lipsum->sentences(5); ``` -### Generating paragraphs +### Generating Paragraphs ```php -echo '1 paragraph: ' . $lipsum->paragraph(); +echo '1 paragraph: ' . $lipsum->paragraph(); echo '5 paragraphs: ' . $lipsum->paragraphs(5); ``` -### Wrapping text with HTML tags +### Wrapping Text with HTML Tags If you would like to wrap the generated text with a tag, pass it as the second parameter: @@ -99,7 +77,7 @@ echo $lipsum->words(3, '
  • $1
  • '); // Generates:
  • ...
  • ...
  • ...
  • ``` -### Return as an array +### Return as an Array Perhaps you want an array instead of a string: @@ -117,16 +95,25 @@ print_r($lipsum->wordsArray(5, 'li')); ## Assumptions -Instead of having an option as to whether or not a string should start the -generated output with “Lorem ipsum dolor sit amet, consectetur adipiscing -elit.” a few assumptions are baked in. The first string generated will always -start with the traditional “Lorem ipsum…”. Subsequent strings may contain +The first string generated will always start with the traditional "Lorem ipsum +dolor sit amet, consectetur adipiscing elit". Subsequent strings may contain those words but will not explicitly start with them. ## Contributing -Suggestions and bug reports are always welcome, but karma points are earned -for pull requests. +Suggestions and bug reports are always welcome, but karma points are earned for +pull requests. -Unit tests are required for all contributions. You can run the test suite -from the `tests` directory simply by running `phpunit .` +Unit tests are required for all contributions. You can run the test suite from +the `tests` directory simply by running `phpunit .` + +## Credits + +`php-loremipsum` was originally inspired by +[badcow/lorem-ipsum](https://packagist.org/packages/badcow/lorem-ipsum) with a +goal of being a dependency free lorem ipsum generator with flexible generation +options. + +## License + +MIT diff --git a/composer.json b/composer.json index 9c35393..8681045 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "joshtronic/php-loremipsum", "description": "Lorem ipsum generator in PHP without dependencies", - "version": "1.0.3", + "version": "1.0.4", "type": "library", "keywords": [ "lorem", diff --git a/src/LoremIpsum.php b/src/LoremIpsum.php index 393c9b6..6994156 100644 --- a/src/LoremIpsum.php +++ b/src/LoremIpsum.php @@ -9,7 +9,7 @@ * Redistribution of these files must retain the above copyright notice. * * @author Josh Sherman - * @copyright Copyright 2014, 2015, 2016, 2017, 2018 Josh Sherman + * @copyright Copyright 2014, 2015, 2016, 2017, 2018, 2019 Josh Sherman * @license http://www.opensource.org/licenses/mit-license.html * @link https://github.com/joshtronic/php-loremipsum */ From cdb2e05cf4f48822920e5fb85c0983a155109885 Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Thu, 9 Jan 2020 18:53:08 -0600 Subject: [PATCH 19/30] chore(ci): test against PHP 7.4 * Updated to test again PHP 7.4 and to use that for coverage reporting. * Added PHP nightly builds as an allowable failure. * Added a git ignore as well as a `phpunit` configuration. * Updated the tests and CI configuration to better handle the juggling of PHP and `phpunit` versions. * Updated the coveralls dependency to be the latest and greatest instead of the deprecated package. * Tweaked the README, updated the LICENSE years and bumped this package's version. * Dropped Patreon link in favor of using Github Sponsors. --- .gitignore | 4 +++ .travis.yml | 22 ++++++++-------- FUNDING.yml | 1 + LICENSE | 2 +- README.md | 12 ++++----- composer.json | 55 ++++++++++++++++++++-------------------- phpunit.xml | 23 +++++++++++++++++ src/LoremIpsum.php | 2 +- tests/LoremIpsumTest.php | 55 +++++++++++++++++++++++----------------- 9 files changed, 106 insertions(+), 70 deletions(-) create mode 100644 .gitignore create mode 100644 FUNDING.yml create mode 100644 phpunit.xml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a2144a3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +composer.lock +composer.phar +.phpunit.result.cache +/vendor/ diff --git a/.travis.yml b/.travis.yml index b7be01f..36d3649 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,27 +14,27 @@ matrix: dist: trusty - php: 7.0 dist: xenial - env: PHPUNIT=5.7 - php: 7.1 - php: 7.2 - php: 7.3 + - php: 7.4 + env: COVERAGE=true + - php: nightly + allow_failures: + - php: nightly install: + - php --version - composer install - - if [[ $PHPUNIT == 5.7 ]]; then composer require "phpunit/phpunit:5.7"; fi before_script: - mkdir -p build/logs - - cd tests script: - - | - if [[ $PHPUNIT == 5.7 ]]; then - ../vendor/bin/phpunit --colors --coverage-clover ../build/logs/clover.xml . - else - phpunit --colors --coverage-clover ../build/logs/clover.xml . - fi + - vendor/bin/phpunit --coverage-clover build/logs/clover.xml after_success: - - cd .. - - php vendor/bin/coveralls --config .coveralls.yml -v + - | + if [[ $COVERAGE ]]; then + travis_retry php vendor/bin/php-coveralls --config .coveralls.yml -v + fi diff --git a/FUNDING.yml b/FUNDING.yml new file mode 100644 index 0000000..8b5faa1 --- /dev/null +++ b/FUNDING.yml @@ -0,0 +1 @@ +patreon: joshtronic diff --git a/LICENSE b/LICENSE index ea461be..80b6dad 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2014, 2015, 2016, 2017, 2018, 2019 Josh Sherman +Copyright (c) 2014, 2015, 2016, 2017, 2018, 2019, 2020 Josh Sherman Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 7ea594d..fb7d1df 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ # php-loremipsum -[![Build Status](https://travis-ci.org/joshtronic/php-loremipsum.svg?branch=master)](https://travis-ci.org/joshtronic/php-loremipsum) -[![Coverage Status](https://coveralls.io/repos/github/joshtronic/php-loremipsum/badge.svg?branch=master)](https://coveralls.io/github/joshtronic/php-loremipsum?branch=master) -[![Total Downloads](https://poser.pugx.org/joshtronic/php-loremipsum/downloads)](https://packagist.org/packages/joshtronic/php-loremipsum) +[![License](https://img.shields.io/packagist/l/joshtronic/php-loremipsum?style=for-the-badge)](https://github.com/joshtronic/php-loremipsum/blob/master/LICENSE) +![PHP Version](https://img.shields.io/packagist/php-v/joshtronic/php-loremipsum?style=for-the-badge) +[![Build Status](https://img.shields.io/travis/joshtronic/php-loremipsum/master?style=for-the-badge)](https://travis-ci.org/joshtronic/php-loremipsum) +[![Coverage Status](https://img.shields.io/coveralls/github/joshtronic/php-loremipsum/master?style=for-the-badge)](https://coveralls.io/github/joshtronic/php-loremipsum?branch=master) +[![Monthly Downloads](https://img.shields.io/packagist/dm/joshtronic/php-loremipsum?style=for-the-badge)](https://packagist.org/packages/joshtronic/php-loremipsum) Lorem ipsum generator in PHP without dependencies. Compatible with PHP 5.3+. -[![Become a Patron](https://joshtronic.com/images/become-patron.png)](https://www.patreon.com/joshtronic) - ## Installation The preferred installation method is via `composer`. First add the following to @@ -105,7 +105,7 @@ Suggestions and bug reports are always welcome, but karma points are earned for pull requests. Unit tests are required for all contributions. You can run the test suite from -the `tests` directory simply by running `phpunit .` +the project's root directory simply by running `phpunit`. ## Credits diff --git a/composer.json b/composer.json index 8681045..52ed17d 100644 --- a/composer.json +++ b/composer.json @@ -1,31 +1,30 @@ { - "name": "joshtronic/php-loremipsum", - "description": "Lorem ipsum generator in PHP without dependencies", - "version": "1.0.4", - "type": "library", - "keywords": [ - "lorem", - "ipsum", - "generator" - ], - "homepage": "https://github.com/joshtronic/php-loremipsum", - "license": "MIT", - "authors": [ - { - "name": "Josh Sherman", - "email": "hello@joshtronic.com", - "homepage": "https://joshtronic.com" - } - ], - "require": { - "php": ">=5.3.0" - }, - "require-dev": { - "satooshi/php-coveralls": "~1.0" - }, - "autoload": { - "psr-4": { - "joshtronic\\": "src/" - } + "name": "joshtronic/php-loremipsum", + "description": "Lorem ipsum generator in PHP without dependencies", + "version": "1.0.5", + "type": "library", + "keywords": [ + "lorem", + "ipsum", + "generator" + ], + "homepage": "https://github.com/joshtronic/php-loremipsum", + "license": "MIT", + "authors": [{ + "name": "Josh Sherman", + "email": "hello@joshtronic.com", + "homepage": "https://joshtronic.com" + }], + "require": { + "php": ">=5.3" + }, + "require-dev": { + "php-coveralls/php-coveralls": ">=1", + "phpunit/phpunit": ">=4" + }, + "autoload": { + "psr-4": { + "joshtronic\\": "src/" } + } } diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..eea8f91 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,23 @@ + + + + + tests + + + + + ./src + + + diff --git a/src/LoremIpsum.php b/src/LoremIpsum.php index 6994156..6db3cb6 100644 --- a/src/LoremIpsum.php +++ b/src/LoremIpsum.php @@ -9,7 +9,7 @@ * Redistribution of these files must retain the above copyright notice. * * @author Josh Sherman - * @copyright Copyright 2014, 2015, 2016, 2017, 2018, 2019 Josh Sherman + * @copyright Copyright 2014, 2015, 2016, 2017, 2018, 2019, 2020 Josh Sherman * @license http://www.opensource.org/licenses/mit-license.html * @link https://github.com/joshtronic/php-loremipsum */ diff --git a/tests/LoremIpsumTest.php b/tests/LoremIpsumTest.php index e568b4d..e05ffbb 100644 --- a/tests/LoremIpsumTest.php +++ b/tests/LoremIpsumTest.php @@ -1,6 +1,5 @@ lipsum = new joshtronic\LoremIpsum(); - } - public function testWord() { - $this->assertRegExp('/^[a-z]+$/i', $this->lipsum->word()); + $lipsum = new joshtronic\LoremIpsum(); + $this->assertRegExp('/^[a-z]+$/i', $lipsum->word()); } public function testWords() { + $lipsum = new joshtronic\LoremIpsum(); $this->assertRegExp( '/^[a-z]+ [a-z]+ [a-z]+$/i', - $this->lipsum->words(3) + $lipsum->words(3) ); } public function testWordsArray() { - $words = $this->lipsum->wordsArray(3); + $lipsum = new joshtronic\LoremIpsum(); + $words = $lipsum->wordsArray(3); $this->assertTrue(is_array($words)); $this->assertCount(3, $words); @@ -44,22 +39,29 @@ class LoremIpsumTest extends PHPUnit_Framework_TestCase public function testWordsExceedingVocab() { - $this->assertCount(500, $this->lipsum->wordsArray(500)); + $lipsum = new joshtronic\LoremIpsum(); + $this->assertCount(500, $lipsum->wordsArray(500)); } public function testSentence() { - $this->assertRegExp('/^[a-z, ]+\.$/i', $this->lipsum->sentence()); + $lipsum = new joshtronic\LoremIpsum(); + $this->assertRegExp('/^[a-z, ]+\.$/i', $lipsum->sentence()); } public function testSentences() { - $this->assertRegExp('/^[a-z, ]+\. [a-z, ]+\. [a-z, ]+\.$/i', $this->lipsum->sentences(3)); + $lipsum = new joshtronic\LoremIpsum(); + $this->assertRegExp( + '/^[a-z, ]+\. [a-z, ]+\. [a-z, ]+\.$/i', + $lipsum->sentences(3) + ); } public function testSentencesArray() { - $sentences = $this->lipsum->sentencesArray(3); + $lipsum = new joshtronic\LoremIpsum(); + $sentences = $lipsum->sentencesArray(3); $this->assertTrue(is_array($sentences)); $this->assertCount(3, $sentences); @@ -70,20 +72,23 @@ class LoremIpsumTest extends PHPUnit_Framework_TestCase public function testParagraph() { - $this->assertRegExp('/^([a-z, ]+\.)+$/i', $this->lipsum->paragraph()); + $lipsum = new joshtronic\LoremIpsum(); + $this->assertRegExp('/^([a-z, ]+\.)+$/i', $lipsum->paragraph()); } public function testParagraphs() { + $lipsum = new joshtronic\LoremIpsum(); $this->assertRegExp( '/^([a-z, ]+\.)+\n\n([a-z, ]+\.)+\n\n([a-z, ]+\.)+$/i', - $this->lipsum->paragraphs(3) + $lipsum->paragraphs(3) ); } public function testParagraphsArray() { - $paragraphs = $this->lipsum->paragraphsArray(3); + $lipsum = new joshtronic\LoremIpsum(); + $paragraphs = $lipsum->paragraphsArray(3); $this->assertTrue(is_array($paragraphs)); $this->assertCount(3, $paragraphs); @@ -94,31 +99,35 @@ class LoremIpsumTest extends PHPUnit_Framework_TestCase public function testMarkupString() { + $lipsum = new joshtronic\LoremIpsum(); $this->assertRegExp( '/^
  • [a-z]+<\/li>$/i', - $this->lipsum->word('li') + $lipsum->word('li') ); } public function testMarkupArray() { + $lipsum = new joshtronic\LoremIpsum(); $this->assertRegExp( '/^

    [a-z]+<\/p><\/div>$/i', - $this->lipsum->word(array('div', 'p')) + $lipsum->word(array('div', 'p')) ); } public function testMarkupBackReference() { + $lipsum = new joshtronic\LoremIpsum(); $this->assertRegExp( '/^

  • [a-z]+<\/a><\/li>$/i', - $this->lipsum->word('
  • $1
  • ') + $lipsum->word('
  • $1
  • ') ); } public function testMarkupArrayReturn() { - $words = $this->lipsum->wordsArray(3, 'li'); + $lipsum = new joshtronic\LoremIpsum(); + $words = $lipsum->wordsArray(3, 'li'); $this->assertTrue(is_array($words)); $this->assertCount(3, $words); From 73e356956cb1192423727cdc642d79de6f1d58f3 Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Mon, 2 Mar 2020 20:53:03 -0600 Subject: [PATCH 20/30] docs: update funding --- FUNDING.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FUNDING.yml b/FUNDING.yml index 8b5faa1..9396c28 100644 --- a/FUNDING.yml +++ b/FUNDING.yml @@ -1 +1 @@ -patreon: joshtronic +github: joshtronic From f0ec43a045b9bfa5e68cac01805e6312a9e9c7e6 Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Mon, 1 Jun 2020 22:14:03 -0500 Subject: [PATCH 21/30] ci: switch to github actions Dropped Travis CI and Coveralls for GitHub Actions and CodeCov. --- .coveralls.yml | 1 - .github/workflows/test.yml | 29 +++++++++++++++++++++++++++ .travis.yml | 40 -------------------------------------- README.md | 4 ++-- codecov.yml | 20 +++++++++++++++++++ composer.json | 3 +-- 6 files changed, 52 insertions(+), 45 deletions(-) delete mode 100644 .coveralls.yml create mode 100644 .github/workflows/test.yml delete mode 100644 .travis.yml create mode 100644 codecov.yml diff --git a/.coveralls.yml b/.coveralls.yml deleted file mode 100644 index 9160059..0000000 --- a/.coveralls.yml +++ /dev/null @@ -1 +0,0 @@ -service_name: travis-ci diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..41cef6c --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,29 @@ +name: Test +on: [push, pull_request] +jobs: + test: + name: Test PHP ${{ matrix.php-version }} + runs-on: ubuntu-latest + strategy: + matrix: + php-version: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4'] + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + - name: PHP Version + run: php --version + - name: Composer Version + run: composer --version + - name: Install Dependencies + run: COMPOSER_MEMORY_LIMIT=-1 composer install + - name: Run Tests + run: vendor/bin/phpunit --coverage-clover ./coverage.xml + - name: Upload Coverage + if: ${{ matrix.php-version == '7.4' }} + uses: codecov/codecov-action@v1 + with: + file: ./coverage.xml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 36d3649..0000000 --- a/.travis.yml +++ /dev/null @@ -1,40 +0,0 @@ -language: php -dist: bionic -sudo: required - -matrix: - include: - - php: 5.3 - dist: precise - - php: 5.4 - dist: trusty - - php: 5.5 - dist: trusty - - php: 5.6 - dist: trusty - - php: 7.0 - dist: xenial - - php: 7.1 - - php: 7.2 - - php: 7.3 - - php: 7.4 - env: COVERAGE=true - - php: nightly - allow_failures: - - php: nightly - -install: - - php --version - - composer install - -before_script: - - mkdir -p build/logs - -script: - - vendor/bin/phpunit --coverage-clover build/logs/clover.xml - -after_success: - - | - if [[ $COVERAGE ]]; then - travis_retry php vendor/bin/php-coveralls --config .coveralls.yml -v - fi diff --git a/README.md b/README.md index fb7d1df..2b29143 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![License](https://img.shields.io/packagist/l/joshtronic/php-loremipsum?style=for-the-badge)](https://github.com/joshtronic/php-loremipsum/blob/master/LICENSE) ![PHP Version](https://img.shields.io/packagist/php-v/joshtronic/php-loremipsum?style=for-the-badge) -[![Build Status](https://img.shields.io/travis/joshtronic/php-loremipsum/master?style=for-the-badge)](https://travis-ci.org/joshtronic/php-loremipsum) -[![Coverage Status](https://img.shields.io/coveralls/github/joshtronic/php-loremipsum/master?style=for-the-badge)](https://coveralls.io/github/joshtronic/php-loremipsum?branch=master) +[![Test Status](https://img.shields.io/github/workflow/status/joshtronic/php-loremipsum/Test?style=for-the-badge)](https://github.com/joshtronic/php-loremipsum/actions) +[![Code Coverage](https://img.shields.io/codecov/c/github/joshtronic/php-loremipsum?style=for-the-badge)](https://codecov.io/gh/joshtronic/php-loremipsum) [![Monthly Downloads](https://img.shields.io/packagist/dm/joshtronic/php-loremipsum?style=for-the-badge)](https://packagist.org/packages/joshtronic/php-loremipsum) Lorem ipsum generator in PHP without dependencies. Compatible with PHP 5.3+. diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..657d8f7 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,20 @@ +codecov: + require_ci_to_pass: yes + +coverage: + precision: 2 + round: down + range: "70...100" + +parsers: + gcov: + branch_detection: + conditional: yes + loop: yes + method: no + macro: no + +comment: + layout: "reach,diff,flags,tree" + behavior: default + require_changes: no diff --git a/composer.json b/composer.json index 52ed17d..9300c87 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "joshtronic/php-loremipsum", "description": "Lorem ipsum generator in PHP without dependencies", - "version": "1.0.5", + "version": "1.0.6", "type": "library", "keywords": [ "lorem", @@ -19,7 +19,6 @@ "php": ">=5.3" }, "require-dev": { - "php-coveralls/php-coveralls": ">=1", "phpunit/phpunit": ">=4" }, "autoload": { From 007b7a211eb9411edc81586b2b09bb8aecccc82a Mon Sep 17 00:00:00 2001 From: Umair Khan Date: Thu, 1 Oct 2020 10:30:09 +0500 Subject: [PATCH 22/30] Fix #7 Change visibility of $words The PHPDoc block of `$words` say that the visibility / access of `$words` is private but its `public` in php code. https://github.com/joshtronic/php-loremipsum/blob/master/src/LoremIpsum.php#L37-L40 --- src/LoremIpsum.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LoremIpsum.php b/src/LoremIpsum.php index 6db3cb6..ebc9dda 100644 --- a/src/LoremIpsum.php +++ b/src/LoremIpsum.php @@ -37,7 +37,7 @@ class LoremIpsum * @access private * @var array */ - public $words = array( + private $words = array( // Lorem ipsum... 'lorem', 'ipsum', 'dolor', 'sit', 'amet', 'consectetur', 'adipiscing', 'elit', From 732be48504ab7de5d959b0a8a5502344d93f7e3b Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Mon, 12 Oct 2020 17:42:21 -0500 Subject: [PATCH 23/30] test: update assertion syntax Tweaked the assertion syntax based on some upcoming changes to PHPUnit. --- tests/LoremIpsumTest.php | 111 +++++++++++++++++++++++++++++---------- 1 file changed, 82 insertions(+), 29 deletions(-) diff --git a/tests/LoremIpsumTest.php b/tests/LoremIpsumTest.php index e05ffbb..02bd2f8 100644 --- a/tests/LoremIpsumTest.php +++ b/tests/LoremIpsumTest.php @@ -10,22 +10,42 @@ if ( class LoremIpsumTest extends PHPUnit_Framework_TestCase { - public function testWord() - { - $lipsum = new joshtronic\LoremIpsum(); - $this->assertRegExp('/^[a-z]+$/i', $lipsum->word()); + /** + * @doesNotPerformAssertions + */ + public function testAssertRegExp() { + if (version_compare(PHP_VERSION, '7.3.0', '>=')) { + return 'assertMatchesRegularExpression'; + } + + return 'assertRegExp'; } - public function testWords() + /** + * @depends testAssertRegExp + */ + public function testWord($assertRegExp) { $lipsum = new joshtronic\LoremIpsum(); - $this->assertRegExp( + $this->$assertRegExp('/^[a-z]+$/i', $lipsum->word()); + } + + /** + * @depends testAssertRegExp + */ + public function testWords($assertRegExp) + { + $lipsum = new joshtronic\LoremIpsum(); + $this->$assertRegExp( '/^[a-z]+ [a-z]+ [a-z]+$/i', $lipsum->words(3) ); } - public function testWordsArray() + /** + * @depends testAssertRegExp + */ + public function testWordsArray($assertRegExp) { $lipsum = new joshtronic\LoremIpsum(); $words = $lipsum->wordsArray(3); @@ -33,32 +53,44 @@ class LoremIpsumTest extends PHPUnit_Framework_TestCase $this->assertCount(3, $words); foreach ($words as $word) { - $this->assertRegExp('/^[a-z]+$/i', $word); + $this->$assertRegExp('/^[a-z]+$/i', $word); } } - public function testWordsExceedingVocab() + /** + * @depends testAssertRegExp + */ + public function testWordsExceedingVocab($assertRegExp) { $lipsum = new joshtronic\LoremIpsum(); $this->assertCount(500, $lipsum->wordsArray(500)); } - public function testSentence() + /** + * @depends testAssertRegExp + */ + public function testSentence($assertRegExp) { $lipsum = new joshtronic\LoremIpsum(); - $this->assertRegExp('/^[a-z, ]+\.$/i', $lipsum->sentence()); + $this->$assertRegExp('/^[a-z, ]+\.$/i', $lipsum->sentence()); } - public function testSentences() + /** + * @depends testAssertRegExp + */ + public function testSentences($assertRegExp) { $lipsum = new joshtronic\LoremIpsum(); - $this->assertRegExp( + $this->$assertRegExp( '/^[a-z, ]+\. [a-z, ]+\. [a-z, ]+\.$/i', $lipsum->sentences(3) ); } - public function testSentencesArray() + /** + * @depends testAssertRegExp + */ + public function testSentencesArray($assertRegExp) { $lipsum = new joshtronic\LoremIpsum(); $sentences = $lipsum->sentencesArray(3); @@ -66,26 +98,35 @@ class LoremIpsumTest extends PHPUnit_Framework_TestCase $this->assertCount(3, $sentences); foreach ($sentences as $sentence) { - $this->assertRegExp('/^[a-z, ]+\.$/i', $sentence); + $this->$assertRegExp('/^[a-z, ]+\.$/i', $sentence); } } - public function testParagraph() + /** + * @depends testAssertRegExp + */ + public function testParagraph($assertRegExp) { $lipsum = new joshtronic\LoremIpsum(); - $this->assertRegExp('/^([a-z, ]+\.)+$/i', $lipsum->paragraph()); + $this->$assertRegExp('/^([a-z, ]+\.)+$/i', $lipsum->paragraph()); } - public function testParagraphs() + /** + * @depends testAssertRegExp + */ + public function testParagraphs($assertRegExp) { $lipsum = new joshtronic\LoremIpsum(); - $this->assertRegExp( + $this->$assertRegExp( '/^([a-z, ]+\.)+\n\n([a-z, ]+\.)+\n\n([a-z, ]+\.)+$/i', $lipsum->paragraphs(3) ); } - public function testParagraphsArray() + /** + * @depends testAssertRegExp + */ + public function testParagraphsArray($assertRegExp) { $lipsum = new joshtronic\LoremIpsum(); $paragraphs = $lipsum->paragraphsArray(3); @@ -93,38 +134,50 @@ class LoremIpsumTest extends PHPUnit_Framework_TestCase $this->assertCount(3, $paragraphs); foreach ($paragraphs as $paragraph) { - $this->assertRegExp('/^([a-z, ]+\.)+$/i', $paragraph); + $this->$assertRegExp('/^([a-z, ]+\.)+$/i', $paragraph); } } - public function testMarkupString() + /** + * @depends testAssertRegExp + */ + public function testMarkupString($assertRegExp) { $lipsum = new joshtronic\LoremIpsum(); - $this->assertRegExp( + $this->$assertRegExp( '/^
  • [a-z]+<\/li>$/i', $lipsum->word('li') ); } - public function testMarkupArray() + /** + * @depends testAssertRegExp + */ + public function testMarkupArray($assertRegExp) { $lipsum = new joshtronic\LoremIpsum(); - $this->assertRegExp( + $this->$assertRegExp( '/^

    [a-z]+<\/p><\/div>$/i', $lipsum->word(array('div', 'p')) ); } - public function testMarkupBackReference() + /** + * @depends testAssertRegExp + */ + public function testMarkupBackReference($assertRegExp) { $lipsum = new joshtronic\LoremIpsum(); - $this->assertRegExp( + $this->$assertRegExp( '/^

  • [a-z]+<\/a><\/li>$/i', $lipsum->word('
  • $1
  • ') ); } - public function testMarkupArrayReturn() + /** + * @depends testAssertRegExp + */ + public function testMarkupArrayReturn($assertRegExp) { $lipsum = new joshtronic\LoremIpsum(); $words = $lipsum->wordsArray(3, 'li'); @@ -132,7 +185,7 @@ class LoremIpsumTest extends PHPUnit_Framework_TestCase $this->assertCount(3, $words); foreach ($words as $word) { - $this->assertRegExp('/^
  • [a-z]+<\/li>$/i', $word); + $this->$assertRegExp('/^
  • [a-z]+<\/li>$/i', $word); } } } From ae53465dad7552ccf6667836c7d449dba2f96fe5 Mon Sep 17 00:00:00 2001 From: peter279k Date: Fri, 25 Dec 2020 21:59:22 +0800 Subject: [PATCH 24/30] Improvements about namespace and PHPUnit version --- .github/workflows/test.yml | 2 +- composer.json | 7 ++++++- phpunit.xml | 1 + tests/LoremIpsumTest.php | 41 +++++++++++++++++--------------------- 4 files changed, 26 insertions(+), 25 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 41cef6c..ddf8b8d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,7 +6,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-version: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4'] + php-version: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0'] steps: - name: Checkout uses: actions/checkout@v2 diff --git a/composer.json b/composer.json index 9300c87..ebaf162 100644 --- a/composer.json +++ b/composer.json @@ -19,11 +19,16 @@ "php": ">=5.3" }, "require-dev": { - "phpunit/phpunit": ">=4" + "phpunit/phpunit": "^4.8.36 || ^9.0" }, "autoload": { "psr-4": { "joshtronic\\": "src/" } + }, + "autoload-dev": { + "psr-4": { + "joshtronic\\Tests\\": "tests/" + } } } diff --git a/phpunit.xml b/phpunit.xml index eea8f91..8fe6c98 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,5 +1,6 @@ $assertRegExp('/^[a-z]+$/i', $lipsum->word()); } @@ -35,7 +30,7 @@ class LoremIpsumTest extends PHPUnit_Framework_TestCase */ public function testWords($assertRegExp) { - $lipsum = new joshtronic\LoremIpsum(); + $lipsum = new LoremIpsum(); $this->$assertRegExp( '/^[a-z]+ [a-z]+ [a-z]+$/i', $lipsum->words(3) @@ -47,7 +42,7 @@ class LoremIpsumTest extends PHPUnit_Framework_TestCase */ public function testWordsArray($assertRegExp) { - $lipsum = new joshtronic\LoremIpsum(); + $lipsum = new LoremIpsum(); $words = $lipsum->wordsArray(3); $this->assertTrue(is_array($words)); $this->assertCount(3, $words); @@ -62,7 +57,7 @@ class LoremIpsumTest extends PHPUnit_Framework_TestCase */ public function testWordsExceedingVocab($assertRegExp) { - $lipsum = new joshtronic\LoremIpsum(); + $lipsum = new LoremIpsum(); $this->assertCount(500, $lipsum->wordsArray(500)); } @@ -71,7 +66,7 @@ class LoremIpsumTest extends PHPUnit_Framework_TestCase */ public function testSentence($assertRegExp) { - $lipsum = new joshtronic\LoremIpsum(); + $lipsum = new LoremIpsum(); $this->$assertRegExp('/^[a-z, ]+\.$/i', $lipsum->sentence()); } @@ -80,7 +75,7 @@ class LoremIpsumTest extends PHPUnit_Framework_TestCase */ public function testSentences($assertRegExp) { - $lipsum = new joshtronic\LoremIpsum(); + $lipsum = new LoremIpsum(); $this->$assertRegExp( '/^[a-z, ]+\. [a-z, ]+\. [a-z, ]+\.$/i', $lipsum->sentences(3) @@ -92,7 +87,7 @@ class LoremIpsumTest extends PHPUnit_Framework_TestCase */ public function testSentencesArray($assertRegExp) { - $lipsum = new joshtronic\LoremIpsum(); + $lipsum = new LoremIpsum(); $sentences = $lipsum->sentencesArray(3); $this->assertTrue(is_array($sentences)); $this->assertCount(3, $sentences); @@ -107,7 +102,7 @@ class LoremIpsumTest extends PHPUnit_Framework_TestCase */ public function testParagraph($assertRegExp) { - $lipsum = new joshtronic\LoremIpsum(); + $lipsum = new LoremIpsum(); $this->$assertRegExp('/^([a-z, ]+\.)+$/i', $lipsum->paragraph()); } @@ -116,7 +111,7 @@ class LoremIpsumTest extends PHPUnit_Framework_TestCase */ public function testParagraphs($assertRegExp) { - $lipsum = new joshtronic\LoremIpsum(); + $lipsum = new LoremIpsum(); $this->$assertRegExp( '/^([a-z, ]+\.)+\n\n([a-z, ]+\.)+\n\n([a-z, ]+\.)+$/i', $lipsum->paragraphs(3) @@ -128,7 +123,7 @@ class LoremIpsumTest extends PHPUnit_Framework_TestCase */ public function testParagraphsArray($assertRegExp) { - $lipsum = new joshtronic\LoremIpsum(); + $lipsum = new LoremIpsum(); $paragraphs = $lipsum->paragraphsArray(3); $this->assertTrue(is_array($paragraphs)); $this->assertCount(3, $paragraphs); @@ -143,7 +138,7 @@ class LoremIpsumTest extends PHPUnit_Framework_TestCase */ public function testMarkupString($assertRegExp) { - $lipsum = new joshtronic\LoremIpsum(); + $lipsum = new LoremIpsum(); $this->$assertRegExp( '/^
  • [a-z]+<\/li>$/i', $lipsum->word('li') @@ -155,7 +150,7 @@ class LoremIpsumTest extends PHPUnit_Framework_TestCase */ public function testMarkupArray($assertRegExp) { - $lipsum = new joshtronic\LoremIpsum(); + $lipsum = new LoremIpsum(); $this->$assertRegExp( '/^

    [a-z]+<\/p><\/div>$/i', $lipsum->word(array('div', 'p')) @@ -167,7 +162,7 @@ class LoremIpsumTest extends PHPUnit_Framework_TestCase */ public function testMarkupBackReference($assertRegExp) { - $lipsum = new joshtronic\LoremIpsum(); + $lipsum = new LoremIpsum(); $this->$assertRegExp( '/^

  • [a-z]+<\/a><\/li>$/i', $lipsum->word('
  • $1
  • ') @@ -179,7 +174,7 @@ class LoremIpsumTest extends PHPUnit_Framework_TestCase */ public function testMarkupArrayReturn($assertRegExp) { - $lipsum = new joshtronic\LoremIpsum(); + $lipsum = new LoremIpsum(); $words = $lipsum->wordsArray(3, 'li'); $this->assertTrue(is_array($words)); $this->assertCount(3, $words); From c9e2957c238710c3c3e48972cc5200bbccbec357 Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Tue, 4 Jan 2022 21:06:55 -0600 Subject: [PATCH 25/30] feat: ensure passed tags are strings Newer versions of PHP raise a warning if you attempt to use array syntax against non-strings / non-arrays. Added sanity check to ensure we're working with a string, otherwise skip it. Also added in PHP 8.1 to the testing suite and bumped the copyright. Bumped version to 2.0 since as the change in expected output is a breaking change. --- .github/workflows/test.yml | 4 ++-- LICENSE | 2 +- composer.json | 2 +- src/LoremIpsum.php | 14 ++++++++------ tests/LoremIpsumTest.php | 11 +++++++++++ 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ddf8b8d..c492e7a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,7 +6,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-version: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0'] + php-version: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1'] steps: - name: Checkout uses: actions/checkout@v2 @@ -23,7 +23,7 @@ jobs: - name: Run Tests run: vendor/bin/phpunit --coverage-clover ./coverage.xml - name: Upload Coverage - if: ${{ matrix.php-version == '7.4' }} + if: ${{ matrix.php-version == '8.1' }} uses: codecov/codecov-action@v1 with: file: ./coverage.xml diff --git a/LICENSE b/LICENSE index 80b6dad..cc7838a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2014, 2015, 2016, 2017, 2018, 2019, 2020 Josh Sherman +Copyright (c) 2014-2022 Josh Sherman Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/composer.json b/composer.json index ebaf162..da7781c 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "joshtronic/php-loremipsum", "description": "Lorem ipsum generator in PHP without dependencies", - "version": "1.0.6", + "version": "2.0.0", "type": "library", "keywords": [ "lorem", diff --git a/src/LoremIpsum.php b/src/LoremIpsum.php index ebc9dda..a48304b 100644 --- a/src/LoremIpsum.php +++ b/src/LoremIpsum.php @@ -9,7 +9,7 @@ * Redistribution of these files must retain the above copyright notice. * * @author Josh Sherman - * @copyright Copyright 2014, 2015, 2016, 2017, 2018, 2019, 2020 Josh Sherman + * @copyright Copyright 2014-2022 Josh Sherman * @license http://www.opensource.org/licenses/mit-license.html * @link https://github.com/joshtronic/php-loremipsum */ @@ -351,11 +351,13 @@ class LoremIpsum foreach ($strings as $key => $string) { foreach ($tags as $tag) { - // Detects / applies back reference - if ($tag[0] == '<') { - $string = str_replace('$1', $string, $tag); - } else { - $string = sprintf('<%1$s>%2$s', $tag, $string); + if (is_string($tag)) { + // Detects / applies back reference + if ($tag[0] == '<') { + $string = str_replace('$1', $string, $tag); + } else { + $string = sprintf('<%1$s>%2$s', $tag, $string); + } } $strings[$key] = $string; diff --git a/tests/LoremIpsumTest.php b/tests/LoremIpsumTest.php index 01d1fec..77c5906 100644 --- a/tests/LoremIpsumTest.php +++ b/tests/LoremIpsumTest.php @@ -183,5 +183,16 @@ class LoremIpsumTest extends TestCase $this->$assertRegExp('/^
  • [a-z]+<\/li>$/i', $word); } } + + /** + * @depends testAssertRegExp + */ + public function testSkipNonStringTag($assertRegExp) + { + $lipsum = new LoremIpsum(); + $this->$assertRegExp('/^[a-z]+$/i', $lipsum->word(123)); + $this->$assertRegExp('/^[a-z]+$/i', $lipsum->word(array(1, 2, 3))); + $this->$assertRegExp('/^[a-z]+$/i', $lipsum->word(true)); + } } From 63a52c853bff27d00e23d9506e25b6f1c3b21007 Mon Sep 17 00:00:00 2001 From: Roy Verrips Date: Wed, 5 Jan 2022 23:21:49 -0600 Subject: [PATCH 26/30] PHP 8.1: Implicit incompatible float to int conversion is deprecated In PHP 8.1 floats are not implicitly converted to integers as before. The array_slice on line 139 requires an integer as the third parameter (the $count variable) so added line 117 to do the conversion of $count. --- src/LoremIpsum.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/LoremIpsum.php b/src/LoremIpsum.php index a48304b..487610b 100644 --- a/src/LoremIpsum.php +++ b/src/LoremIpsum.php @@ -114,6 +114,7 @@ class LoremIpsum */ public function words($count = 1, $tags = false, $array = false) { + $count = (int) $count; $words = array(); $word_count = 0; From 6e973db52189f16c76d6ee9702fac526daadae5f Mon Sep 17 00:00:00 2001 From: Roy Verrips Date: Fri, 7 Jan 2022 11:52:46 -0600 Subject: [PATCH 27/30] Add phpstan with config set to max --- composer.json | 3 ++- phpstan.neon | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 phpstan.neon diff --git a/composer.json b/composer.json index da7781c..0ff53d6 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,8 @@ "php": ">=5.3" }, "require-dev": { - "phpunit/phpunit": "^4.8.36 || ^9.0" + "phpunit/phpunit": "^4.8.36 || ^9.0", + "phpstan/phpstan": "^1.3" }, "autoload": { "psr-4": { diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..0292a3b --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,14 @@ +parameters: + + paths: + - src + + # The level 8 is the highest level + level: max + + excludePaths: + - ./*/*/FileToBeExcluded.php + + checkMissingIterableValueType: true + + #editorUrl: 'vscode://file/%%file%%:%%line%%' From 7cebbfc06ae116993314f801bd10365321fa0596 Mon Sep 17 00:00:00 2001 From: Roy Verrips Date: Fri, 7 Jan 2022 15:00:48 -0600 Subject: [PATCH 28/30] Refactors to satisfy phpstan level 8 --- src/LoremIpsum.php | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/src/LoremIpsum.php b/src/LoremIpsum.php index 487610b..5085b4f 100644 --- a/src/LoremIpsum.php +++ b/src/LoremIpsum.php @@ -24,7 +24,7 @@ class LoremIpsum * Whether or not we should be starting the string with "Lorem ipsum..." * * @access private - * @var boolean + * @var mixed */ private $first = true; @@ -35,7 +35,7 @@ class LoremIpsum * a complete list exists and if so, where to get it. * * @access private - * @var array + * @var array */ private $words = array( // Lorem ipsum... @@ -83,7 +83,7 @@ class LoremIpsum */ public function word($tags = false) { - return $this->words(1, $tags); + return strval($this->words(1, $tags)); } /** @@ -94,7 +94,7 @@ class LoremIpsum * @access public * @param integer $count how many words to generate * @param mixed $tags string or array of HTML tags to wrap output with - * @return array generated lorem ipsum words + * @return mixed generated lorem ipsum words */ public function wordsArray($count = 1, $tags = false) { @@ -152,7 +152,7 @@ class LoremIpsum */ public function sentence($tags = false) { - return $this->sentences(1, $tags); + return strval($this->sentences(1, $tags)); } /** @@ -163,7 +163,7 @@ class LoremIpsum * @access public * @param integer $count how many sentences to generate * @param mixed $tags string or array of HTML tags to wrap output with - * @return array generated lorem ipsum sentences + * @return mixed generated lorem ipsum sentences */ public function sentencesArray($count = 1, $tags = false) { @@ -205,7 +205,7 @@ class LoremIpsum */ public function paragraph($tags = false) { - return $this->paragraphs(1, $tags); + return strval($this->paragraphs(1, $tags)); } /** @@ -216,15 +216,18 @@ class LoremIpsum * @access public * @param integer $count how many paragraphs to generate * @param mixed $tags string or array of HTML tags to wrap output with - * @return array generated lorem ipsum paragraphs + * @return array generated lorem ipsum paragraphs */ public function paragraphsArray($count = 1, $tags = false) { + // The $array parameter set to true means an array is returned. + // Return type is mixed, we should probably cast to array. + // @phpstan-ignore-next-line return $this->paragraphs($count, $tags, true); } /** - * Paragraphss + * Paragraphs * * Generates paragraphs of lorem ipsum. * @@ -239,10 +242,13 @@ class LoremIpsum $paragraphs = array(); for ($i = 0; $i < $count; $i++) { - $paragraphs[] = $this->sentences($this->gauss(5.8, 1.93)); + $paragraphs[] = strval($this->sentences($this->gauss(5.8, 1.93))); } - return $this->output($paragraphs, $tags, $array, "\n\n"); + if ($array) { + return $this->output($paragraphs, $tags, $array, "\n\n"); + } + return strval($this->output($paragraphs, $tags, false, "\n\n")); } /** @@ -256,7 +262,7 @@ class LoremIpsum * @access private * @param double $mean average value * @param double $std_dev stadnard deviation - * @return double calculated distribution + * @return int calculated distribution */ private function gauss($mean, $std_dev) { @@ -264,7 +270,7 @@ class LoremIpsum $y = mt_rand() / mt_getrandmax(); $z = sqrt(-2 * log($x)) * cos(2 * pi() * $y); - return $z * $std_dev + $mean; + return intval($z * $std_dev + $mean); } /** @@ -274,6 +280,7 @@ class LoremIpsum * the first time we are generating the text. * * @access private + * @return void */ private function shuffle() { @@ -299,18 +306,19 @@ class LoremIpsum * first word of the sentence. * * @access private - * @param array $sentences the sentences we would like to punctuate + * @param array $sentences the sentences we would like to punctuate + * @return void */ private function punctuate(&$sentences) { foreach ($sentences as $key => $sentence) { - $words = count($sentence); + $words = count($sentences); // Only worry about commas on sentences longer than 4 words if ($words > 4) { $mean = log($words, 6); $std_dev = $mean / 6; - $commas = round($this->gauss($mean, $std_dev)); + $commas = $this->gauss($mean, $std_dev); for ($i = 1; $i <= $commas; $i++) { $word = round($i * $words / ($commas + 1)); @@ -334,7 +342,7 @@ class LoremIpsum * into a string or not. * * @access private - * @param array $strings an array of generated strings + * @param array $strings an array of generated strings * @param mixed $tags string or array of HTML tags to wrap output with * @param boolean $array whether an array or a string should be returned * @param string $delimiter the string to use when calling implode() @@ -373,4 +381,3 @@ class LoremIpsum return $strings; } } - From a84cdd8917e90f096ed1978d4b760ca77d803aaf Mon Sep 17 00:00:00 2001 From: Roy Verrips Date: Fri, 7 Jan 2022 18:19:11 -0600 Subject: [PATCH 29/30] Remove phpstan from dependancies - want to keep this compatible with php 7.0 as per github build steps --- composer.json | 63 +++++++++++++++++++++++----------------------- src/LoremIpsum.php | 3 +-- 2 files changed, 32 insertions(+), 34 deletions(-) diff --git a/composer.json b/composer.json index 0ff53d6..8141871 100644 --- a/composer.json +++ b/composer.json @@ -1,35 +1,34 @@ { - "name": "joshtronic/php-loremipsum", - "description": "Lorem ipsum generator in PHP without dependencies", - "version": "2.0.0", - "type": "library", - "keywords": [ - "lorem", - "ipsum", - "generator" - ], - "homepage": "https://github.com/joshtronic/php-loremipsum", - "license": "MIT", - "authors": [{ - "name": "Josh Sherman", - "email": "hello@joshtronic.com", - "homepage": "https://joshtronic.com" - }], - "require": { - "php": ">=5.3" - }, - "require-dev": { - "phpunit/phpunit": "^4.8.36 || ^9.0", - "phpstan/phpstan": "^1.3" - }, - "autoload": { - "psr-4": { - "joshtronic\\": "src/" - } - }, - "autoload-dev": { - "psr-4": { - "joshtronic\\Tests\\": "tests/" + "name": "joshtronic/php-loremipsum", + "description": "Lorem ipsum generator in PHP without dependencies", + "version": "2.0.0", + "type": "library", + "keywords": [ + "lorem", + "ipsum", + "generator" + ], + "homepage": "https://github.com/joshtronic/php-loremipsum", + "license": "MIT", + "authors": [{ + "name": "Josh Sherman", + "email": "hello@joshtronic.com", + "homepage": "https://joshtronic.com" + }], + "require": { + "php": ">=5.3" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.36 || ^9.0" + }, + "autoload": { + "psr-4": { + "joshtronic\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "joshtronic\\Tests\\": "tests/" + } } } -} diff --git a/src/LoremIpsum.php b/src/LoremIpsum.php index 5085b4f..863b8d5 100644 --- a/src/LoremIpsum.php +++ b/src/LoremIpsum.php @@ -312,8 +312,7 @@ class LoremIpsum private function punctuate(&$sentences) { foreach ($sentences as $key => $sentence) { - $words = count($sentences); - + $words = count($sentence); // Only worry about commas on sentences longer than 4 words if ($words > 4) { $mean = log($words, 6); From 6d7f8cff6a092a53d66b5237edbe97d398b14f88 Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Sun, 23 Jan 2022 17:27:44 -0600 Subject: [PATCH 30/30] chore: bump version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 8141871..a28a4b3 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "joshtronic/php-loremipsum", "description": "Lorem ipsum generator in PHP without dependencies", - "version": "2.0.0", + "version": "2.1.0", "type": "library", "keywords": [ "lorem",