From a4e5a8a4d37575a230625a3ac2884d5d18d74a04 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 8 May 2024 10:46:27 +0900 Subject: [PATCH 1/7] docs: add namespace to sample code --- user_guide_src/source/libraries/files/014.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/user_guide_src/source/libraries/files/014.php b/user_guide_src/source/libraries/files/014.php index cbd6f90e5388..fb11f62d31e6 100644 --- a/user_guide_src/source/libraries/files/014.php +++ b/user_guide_src/source/libraries/files/014.php @@ -1,5 +1,7 @@ Date: Wed, 8 May 2024 10:46:54 +0900 Subject: [PATCH 2/7] docs: add empty line --- user_guide_src/source/libraries/file_collections.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/user_guide_src/source/libraries/file_collections.rst b/user_guide_src/source/libraries/file_collections.rst index 4b54f0ab07a8..15ff9dc048b5 100644 --- a/user_guide_src/source/libraries/file_collections.rst +++ b/user_guide_src/source/libraries/file_collections.rst @@ -44,7 +44,9 @@ define() ======== Allows child classes to define their own initial files. This method is called by the constructor and allows -predefined collections without having to use their methods. Example: +predefined collections without having to use their methods. + +Example: .. literalinclude:: files/014.php From a0a5c8eb1e1181b3bac120763db0a0c9981798b4 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 8 May 2024 10:47:56 +0900 Subject: [PATCH 3/7] docs: improve description --- user_guide_src/source/libraries/file_collections.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/libraries/file_collections.rst b/user_guide_src/source/libraries/file_collections.rst index 15ff9dc048b5..25ce4e4c0632 100644 --- a/user_guide_src/source/libraries/file_collections.rst +++ b/user_guide_src/source/libraries/file_collections.rst @@ -50,8 +50,9 @@ Example: .. literalinclude:: files/014.php -Now you may use the ``ConfigCollection`` anywhere in your project to access all App Config files without -having to re-call the collection methods every time. +Now you may use the ``ConfigCollection`` anywhere in your project to access all +PHP files in **app/Config/** without having to re-call the collection methods +every time. set(array $files) ================= From a56b5f38f9033f6e5bfb71aa67aafe05c5869c6e Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 8 May 2024 10:50:14 +0900 Subject: [PATCH 4/7] docs: break long lines --- .../source/libraries/file_collections.rst | 55 +++++++++++-------- 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/user_guide_src/source/libraries/file_collections.rst b/user_guide_src/source/libraries/file_collections.rst index 25ce4e4c0632..7ad0eea4cc92 100644 --- a/user_guide_src/source/libraries/file_collections.rst +++ b/user_guide_src/source/libraries/file_collections.rst @@ -2,8 +2,9 @@ File Collections ################ -Working with groups of files can be cumbersome, so the framework supplies the ``FileCollection`` class to facilitate -locating and working with groups of files across the filesystem. +Working with groups of files can be cumbersome, so the framework supplies the +``FileCollection`` class to facilitate locating and working with groups of files +across the filesystem. .. contents:: :local: @@ -18,13 +19,15 @@ of files you set or build: .. literalinclude:: files/011.php -After you have input the files you would like to work with you may remove files or use the filtering commands to remove -or retain files matching a certain regex or glob-style pattern: +After you have input the files you would like to work with you may remove files +or use the filtering commands to remove or retain files matching a certain regex +or glob-style pattern: .. literalinclude:: files/012.php -When your collection is complete, you can use ``get()`` to retrieve the final list of file paths, or take advantage of -``FileCollection`` being countable and iterable to work directly with each ``File``: +When your collection is complete, you can use ``get()`` to retrieve the final +list of file paths, or take advantage of ``FileCollection`` being countable and +iterable to work directly with each ``File``: .. literalinclude:: files/013.php @@ -37,14 +40,16 @@ Starting a Collection __construct(string[] $files = []) ================================= -The constructor accepts an optional array of file paths to use as the initial collection. These are passed to -``add()`` so any files supplied by child classes in the ``$files`` will remain. +The constructor accepts an optional array of file paths to use as the initial +collection. These are passed to ``add()`` so any files supplied by child classes +in the ``$files`` will remain. define() ======== -Allows child classes to define their own initial files. This method is called by the constructor and allows -predefined collections without having to use their methods. +Allows child classes to define their own initial files. This method is called by +the constructor and allows predefined collections without having to use their +methods. Example: @@ -57,8 +62,9 @@ every time. set(array $files) ================= -Sets the list of input files to the provided string array of file paths. This will remove any existing -files from the collection, so ``$collection->set([])`` is essentially a hard reset. +Sets the list of input files to the provided string array of file paths. This +will remove any existing files from the collection, so ``$collection->set([])`` +is essentially a hard reset. *************** Inputting Files @@ -67,13 +73,14 @@ Inputting Files add(string[]|string $paths, bool $recursive = true) =================================================== -Adds all files indicated by the path or array of paths. If the path resolves to a directory then ``$recursive`` -will include sub-directories. +Adds all files indicated by the path or array of paths. If the path resolves to +a directory then ``$recursive`` will include sub-directories. addFile(string $file) / addFiles(array $files) ============================================== -Adds the file or files to the current list of input files. Files are absolute paths to actual files. +Adds the file or files to the current list of input files. Files are absolute +paths to actual files. removeFile(string $file) / removeFiles(array $files) ==================================================== @@ -85,8 +92,8 @@ addDirectory(string $directory, bool $recursive = false) addDirectories(array $directories, bool $recursive = false) =========================================================== -Adds all files from the directory or directories, optionally recursing into sub-directories. Directories are -absolute paths to actual directories. +Adds all files from the directory or directories, optionally recursing into +sub-directories. Directories are absolute paths to actual directories. *************** Filtering Files @@ -97,11 +104,12 @@ removePattern(string $pattern, string $scope = null) retainPattern(string $pattern, string $scope = null) ==================================================== -Filters the current file list through the pattern (and optional scope), removing or retaining matched -files. ``$pattern`` may be a complete regex (like ``'#[A-Za-z]+\.php#'``) or a pseudo-regex similar -to ``glob()`` (like ``*.css``). -If a ``$scope`` is provided then only files in or under that directory will be considered (i.e. files -outside of ``$scope`` are always retained). When no scope is provided then all files are subject. +Filters the current file list through the pattern (and optional scope), removing +or retaining matched files. ``$pattern`` may be a complete regex (like ``'#[A-Za-z]+\.php#'``) +or a pseudo-regex similar to ``glob()`` (like ``*.css``). If a ``$scope`` is +provided then only files in or under that directory will be considered (i.e. files +outside of ``$scope`` are always retained). When no scope is provided then all +files are subject. Examples: @@ -116,4 +124,5 @@ get(): string[] Returns an array of all the loaded input files. -.. note:: ``FileCollection`` is an ``IteratorAggregate`` so you can work with it directly (e.g. ``foreach ($collection as $file)``). +.. note:: ``FileCollection`` is an ``IteratorAggregate`` so you can work with it + directly (e.g. ``foreach ($collection as $file)``). From 3dc1a097ef0662f86fe7379a09d9d5e5781ad786 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 8 May 2024 10:52:02 +0900 Subject: [PATCH 5/7] docs: add empty lines --- .../source/libraries/file_collections.rst | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/user_guide_src/source/libraries/file_collections.rst b/user_guide_src/source/libraries/file_collections.rst index 7ad0eea4cc92..a9871f259fa8 100644 --- a/user_guide_src/source/libraries/file_collections.rst +++ b/user_guide_src/source/libraries/file_collections.rst @@ -105,11 +105,14 @@ retainPattern(string $pattern, string $scope = null) ==================================================== Filters the current file list through the pattern (and optional scope), removing -or retaining matched files. ``$pattern`` may be a complete regex (like ``'#[A-Za-z]+\.php#'``) -or a pseudo-regex similar to ``glob()`` (like ``*.css``). If a ``$scope`` is -provided then only files in or under that directory will be considered (i.e. files -outside of ``$scope`` are always retained). When no scope is provided then all -files are subject. +or retaining matched files. + +``$pattern`` may be a complete regex (like ``'#[A-Za-z]+\.php#'``) or a pseudo-regex +similar to ``glob()`` (like ``*.css``). + +If a ``$scope`` is provided then only files in or under that directory will be +considered (i.e. files outside of ``$scope`` are always retained). When no scope +is provided then all files are subject. Examples: From 003a3ed2d555071275673184c0240d0cfccc4ef0 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 8 May 2024 10:53:08 +0900 Subject: [PATCH 6/7] docs: improve code samples --- user_guide_src/source/libraries/file_collections.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/libraries/file_collections.rst b/user_guide_src/source/libraries/file_collections.rst index a9871f259fa8..e0050b87e247 100644 --- a/user_guide_src/source/libraries/file_collections.rst +++ b/user_guide_src/source/libraries/file_collections.rst @@ -107,8 +107,8 @@ retainPattern(string $pattern, string $scope = null) Filters the current file list through the pattern (and optional scope), removing or retaining matched files. -``$pattern`` may be a complete regex (like ``'#[A-Za-z]+\.php#'``) or a pseudo-regex -similar to ``glob()`` (like ``*.css``). +``$pattern`` may be a complete regex (like ``'#\A[A-Za-z]+\.php\z#'``) or a +pseudo-regex similar to ``glob()`` (like ``'*.css'``). If a ``$scope`` is provided then only files in or under that directory will be considered (i.e. files outside of ``$scope`` are always retained). When no scope From 0125bc766ee690d6073182ee962708d78dc8fcf6 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 8 May 2024 10:56:47 +0900 Subject: [PATCH 7/7] docs: improve sample code --- user_guide_src/source/libraries/files/012.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/libraries/files/012.php b/user_guide_src/source/libraries/files/012.php index db0f881014c0..b87efe4a692a 100644 --- a/user_guide_src/source/libraries/files/012.php +++ b/user_guide_src/source/libraries/files/012.php @@ -1,6 +1,6 @@ removeFile(APPPATH . 'Filters/DevelopToolbar'); +$files->removeFile(APPPATH . 'Filters/DevelopToolbar.php'); $files->removePattern('#\.gitkeep#'); $files->retainPattern('*.php');